Applying data to chart

Hello.

There is exists some method for chart for applying chart data and category data in one step. Now i have this ability in Excel and trying to use method "series.add", but results are different.

@Test
public void calculationChainTest() {
try {
Workbook wb = new Workbook("D:\\chart.xlsx");
Chart chart = wb.getWorksheets().get(0).getCharts().get(0);
SeriesCollection series = chart.getNSeries();
series.add("Chart!B4:E8", true);
wb.save("D:\\out.xlsx");
} catch (Exception e) {
e.printStackTrace();
assertNull(e);
}
}

But excel (chart data source string) shows, that results are identical. If i will open out.xlsx and twice toggle button for source i will receive right result.

Also i have reveived right result by using following code

@Test
public void calculationChainTest() {
try {
Workbook wb = new Workbook("D:\\chart.xlsx");
Chart chart = wb.getWorksheets().get(0).getCharts().get(0);
SeriesCollection series = chart.getNSeries();
series.add("Chart!C4:E8", true);

series.setCategoryData("Chart!B4:B8");
wb.save("D:\\out.xlsx");
} catch (Exception e) {
e.printStackTrace();
assertNull(e);
}
}

But i want to use "one-line-code"

Hi,


I have evaluated your scenario/ issue a bit.

I am afraid, you have to use two lines of code to specify the Chart’s data source completely with current object model of Chart APIs. See the lines of code for your reference:
e.g
Sample code:
//…
series.add(“Chart!C4:E8”, true);
series.setCategoryData(“Chart!B4:B8”);


We will also check if we could enhance it more or provide one line of code (if possible) or workaround to specify the chart’s data for your scenario.

Thank you.