EvotecIT / OfficeIMO

Fast and easy to use cross-platform .NET library that creates or modifies Microsoft Word (DocX) and later also Excel (XLSX) files without installing any software. Library is based on Open XML SDK
MIT License
289 stars 50 forks source link

Improve Charts **Breaking Changes** #223

Closed PrzemyslawKlys closed 6 months ago

PrzemyslawKlys commented 6 months ago

This PR tries to deliver a few things:

This no longer works:

List<string> categories = new List<string>() { "Food", "Housing", "Mix" };
var pieChart = document.AddPieChart();
pieChart.AddCategories(categories);
pieChart.AddChartPie("Poland", new List<int> { 15, 20, 30 });

Instead, you need to use a more generic approach. There's AddChart() method, which then depending on what you want to add works with AddPie, AddLine, AddArea,AddBar methods. The methods do not mix together.

var pieChart2 = document.AddChart("Test");
pieChart2.AddPie("Poland", 15);
pieChart2.AddPie("USA", 30);
pieChart2.AddPie("Brazil", 20.2);

// or using

document.AddChart("Test")
    .AddPie("Poland", 15)
    .AddPie("USA", 30)
    .AddPie("Brazil", 20.2);