Chart data area does not expand automatically

Hello.

I have found, that data row expanding does not work correctly. in.zip (12.2 KB)
I have 2 charts. First has data for it on the same sheet (Chart1). Second chart has data for it on different worksheet (Data2). When I insert columns into data row for the first chart I have correct behavior - data charts are expanding (as like Excel) (1st part of test). When I insert columns into data row for the second chart I have wrong behavior - data charts are not expanding (not like Excel) (2nd part of test).

@Test
public void chart_data_one_worksheet() throws Exception {
    Workbook workbook = new Workbook("E://in.xlsx");
    Worksheet dataSheet = workbook.getWorksheets().get("Chart1");
    Cells cells = dataSheet.getCells();
    Chart chart = dataSheet.getCharts().get(0);
    String chartValuesBefore = chart.getNSeries().get(0).getValues();
    cells.insertColumns(2,5);
    String chartValuesAfter = chart.getNSeries().get(0).getValues();
    assertNotEquals(chartValuesBefore, chartValuesAfter);

    dataSheet = workbook.getWorksheets().get("Data2");
    cells = dataSheet.getCells();
    chart = workbook.getWorksheets().get("Chart2").getCharts().get(0);
    chartValuesBefore = chart.getNSeries().get(0).getValues();
    cells.insertColumns(2,5);
    chartValuesAfter = chart.getNSeries().get(0).getValues();
    assertNotEquals(chartValuesBefore, chartValuesAfter);
}

Best regards. Alexey

@makarovalv,

Could you please share a sample application which includes saving of output file. Also share the output file and screenshots. I have updated one line of code in your method and getting the error with latest version of API.

java.lang.AssertionError: Values should be different. Actual: =Data2!$B$1:$C$1

where the updated code is:

org.junit.Assert.assertNotEquals(chartValuesBefore, chartValuesAfter);

So please share runnable application for our testing. We will reproduce the problem and provide our feedback after analysis.

aspose-cells-19.3.4.zip (6.5 MB)

Hi. Ofcourse this test is not successful because the library works in wrong way.

Please, insert following line before the last assertion line
workbook.save(“E://out.xlsx”);

And you will see, that chart on worksheet Chart1 had changed the data range, whereas chart on worksheet Chart2 had not.

Data2.jpg (21.3 KB)
Chart1.jpg (59.6 KB)
Chart2.jpg (15.5 KB)

@makarovalv

I have added a value manually at Column H of Data2 worksheet in the input file “in.xlsx” but MS Excel 2016 does not update the data range automatically. Excel.PNG (23.5 KB)

However, I have logged it in our database for investigations. Once, we will have some news for you, we will update you in this topic.

This has been logged as

CELLSJAVA-42880 - Chart data area does not expand automatically

Hi.

Idea, that we set a data range for chart at start, then we insert columns between initial columns and range of chart is expanded too.
It works, when data range located on the same sheet. But it does not work for data range located on another worksheet

Best regards. Alexey

@makarovalv,

We have recorded your comments with the ticket and will share our feedback with you soon.

@makarovalv,

Please use the following line of code to fix your issue:
e.g
Sample code:

cells.insertColumns(2,5,true);

Please note, only when the parameter “updateReference” is true, the reference of other worksheets are updated.