StackedBar ignoring and confusing categories until data is reselected


#1

Hi,

I’m creating a StackedBar with a number of series and categories. After adding each category I add some data points for some category/series combinations but not all. However in the graph some categories are missing and data is incorrectly shown in the wrong categories. I have inspected the data in the PPT embedded Excel and it is correct. If you add the data table to the graph the data shown there is wrong. If I chose to “Select Data” and then manually select all the data in the embedded table it refreshes and is correct.

Here is example code that creates the issue

  IChart chart = slide.getShapes().addChart(ChartType.StackedBar, 	
  		Utils.getPixelValue(16.82f),
  		Utils.getPixelValue(10.27f),
  		Utils.getPixelValue(12.42f),
  		Utils.getPixelValue(8.71f), false);		
  
  chart.setLegend(false);
  IChartDataWorkbook workBook = chart.getChartData().getChartDataWorkbook();
  chart.getChartData().getSeries().clear();
  chart.getChartData().getCategories().clear();		

  IChartSeries series1 = chart.getChartData().getSeries().add(workBook.getCell(0, 0, 0, "Series 0"),chart.getType());
  IChartSeries series2 = chart.getChartData().getSeries().add(workBook.getCell(0, 0, 1, "Series 1"),chart.getType());
  IChartSeries series3 = chart.getChartData().getSeries().add(workBook.getCell(0, 0, 2, "Series 2"),chart.getType());
  IChartSeries series4 = chart.getChartData().getSeries().add(workBook.getCell(0, 0, 3, "Series 3"),chart.getType());
  IChartSeries series5 = chart.getChartData().getSeries().add(workBook.getCell(0, 0, 4, "Series 4"),chart.getType());
  IChartSeries series6 = chart.getChartData().getSeries().add(workBook.getCell(0, 0, 5, "Series 5"),chart.getType());
  IChartSeries series7 = chart.getChartData().getSeries().add(workBook.getCell(0, 0, 6, "Series 6"),chart.getType());
  IChartSeries series8 = chart.getChartData().getSeries().add(workBook.getCell(0, 0, 7, "Series 7"),chart.getType());
  IChartSeries series9 = chart.getChartData().getSeries().add(workBook.getCell(0, 0, 8, "Series 8"),chart.getType());
  IChartSeries series10 = chart.getChartData().getSeries().add(workBook.getCell(0, 0, 9, "Series 9"),chart.getType());
  IChartSeries series11 = chart.getChartData().getSeries().add(workBook.getCell(0, 0, 10, "Series 10"),chart.getType());
  IChartSeries series12 = chart.getChartData().getSeries().add(workBook.getCell(0, 0, 11, "Series 11"),chart.getType());
  IChartSeries series13 = chart.getChartData().getSeries().add(workBook.getCell(0, 0, 12, "Series 12"),chart.getType());
  IChartSeries series14 = chart.getChartData().getSeries().add(workBook.getCell(0, 0, 13, "Series 13"),chart.getType());
  IChartSeries series15 = chart.getChartData().getSeries().add(workBook.getCell(0, 0, 14, "Series 14"),chart.getType());
  IChartSeries series16 = chart.getChartData().getSeries().add(workBook.getCell(0, 0, 15, "Series 15"),chart.getType());
  IChartSeries series17 = chart.getChartData().getSeries().add(workBook.getCell(0, 0, 16, "Series 16"),chart.getType());
  IChartSeries series18 = chart.getChartData().getSeries().add(workBook.getCell(0, 0, 17, "Series 17"),chart.getType());
  IChartSeries series19 = chart.getChartData().getSeries().add(workBook.getCell(0, 0, 18, "Series 18"),chart.getType());
  IChartSeries series20 = chart.getChartData().getSeries().add(workBook.getCell(0, 0, 19, "Series 19"),chart.getType());
  chart.getChartData().getCategories().add(workBook.getCell(0,1, 0, "Category 0"));
  series16.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,1,16, 166));
  chart.getChartData().getCategories().add(workBook.getCell(0,2, 0, "Category 1"));
  series18.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,2,18, 40));
  chart.getChartData().getCategories().add(workBook.getCell(0,3, 0, "Category 2"));
  series6.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,3,6, 7));
  series13.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,3,13, 98));
  series1.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,3,1, 0));
  series15.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,3,15, 21));
  series16.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,3,16, 93));
  series19.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,3,19, 34));
  series5.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,3,5, 103));
  series20.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,3,20, 5));
  series11.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,3,11, 0));
  series9.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,3,9, 2));
  series14.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,3,14, 16));
  series4.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,3,4, 0));
  series3.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,3,3, 24));
  series18.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,3,18, 19));
  chart.getChartData().getCategories().add(workBook.getCell(0,4, 0, "Category 3"));
  series7.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,4,7, 42));
  series6.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,4,6, 34));
  series13.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,4,13, 4));
  series1.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,4,1, 15));
  series15.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,4,15, 60));
  series16.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,4,16, 7));
  series19.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,4,19, 6));
  series5.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,4,5, 20));
  series20.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,4,20, 4));
  series11.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,4,11, 29));
  series9.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,4,9, 4));
  series14.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,4,14, 48));
  series4.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,4,4, 15));
  series3.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,4,3, 2));
  series18.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,4,18, 101));
  chart.getChartData().getCategories().add(workBook.getCell(0,5, 0, "Category 4"));
  series7.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,5,7, 6));
  series6.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,5,6, 0));
  series13.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,5,13, 0));
  series1.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,5,1, 37));
  series15.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,5,15, 0));
  series16.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,5,16, 22));
  series19.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,5,19, 32));
  series5.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,5,5, 5));
  series20.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,5,20, 71));
  series11.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,5,11, 36));
  series12.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,5,12, 4));
  series9.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,5,9, 41));
  series14.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,5,14, 41));
  series4.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,5,4, 3));
  chart.getChartData().getCategories().add(workBook.getCell(0,6, 0, "Category 5"));
  series1.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,6,1, 13));
  series15.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,6,15, 20));
  series5.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,6,5, 1));
  series3.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,6,3, 45));
  chart.getChartData().getCategories().add(workBook.getCell(0,7, 0, "Category 6"));
  series7.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,7,7, 0));
  series6.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,7,6, 0));
  series1.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,7,1, 17));
  series15.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,7,15, 27));
  series19.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,7,19, 18));
  series5.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,7,5, 39));
  series20.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,7,20, 20));
  series11.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,7,11, 9));
  series9.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,7,9, 1));
  series4.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,7,4, 24));
  series3.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,7,3, 25));
  series18.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,7,18, 10));
  chart.getChartData().getCategories().add(workBook.getCell(0,8, 0, "Category 7"));
  series6.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,8,6, 15));
  chart.getChartData().getCategories().add(workBook.getCell(0,9, 0, "Category 8"));
  series13.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,9,13, 24));
  series1.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,9,1, 21));
  series16.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,9,16, 2));
  series5.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,9,5, 4));
  series20.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,9,20, 23));
  series11.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,9,11, 31));
  series12.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,9,12, 28));
  series9.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,9,9, 1));
  series14.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,9,14, 2));
  series3.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,9,3, 9));
  series18.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,9,18, 3));
  chart.getChartData().getCategories().add(workBook.getCell(0,10, 0, "Category 9"));
  series7.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,10,7, 5));
  series6.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,10,6, 21));
  series13.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,10,13, 0));
  series1.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,10,1, 0));
  series19.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,10,19, 35));
  series20.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,10,20, 4));
  series12.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,10,12, 3));
  series9.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,10,9, 15));
  series14.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,10,14, 28));
  series4.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,10,4, 0));
  series18.getDataPoints().addDataPointForBarSeries(workBook.getCell(0,10,18, 18));

  chart.getChartData().getSeries().get_Item(0).getParentSeriesGroup().setOverlap((byte) 100);
  chart.getChartData().getSeries().get_Item(0).getParentSeriesGroup().setGapWidth(47);

Here is how it looks to start with with a data table to help understand:

image.png (10.8 KB)

First issue - only Category 1-7 shown when I added more categories than that
Second issue - Category 1 only has one value added in the code - the 166 value - see the first call to addDataPointForBarSeries is the only one where the category passed is value 1 BUT in the data table you can see many value sfor category 1

If you look at the data in the embedded excel it is correct:

image.png (23.6 KB)

If I chose “Select Data” from the powerpoint menu it says the data range is too complex to display which gives a hint that the data is messed up somehow. The category scrolling list only shows 7 categories.

image.png (14.4 KB)

If I manually select all the data in the embedded excel and press OK it renders the graph perfectly with no other action taken!

image.png (11.5 KB)

Please can you assist?

Kind regards,
Andy


#2

@andysteady,

I have worked with source code shared by you. For further investigation, can you please share environment details along with version you are using on your end and generated result so that we may help you out.


#3

Hi,

Sure - thank you. I am using aspose slides for java v18.5 jdk 16

Here is generated result

179543 stackedbar-ignoring-and-confusing-categories-until-data-is-reselected.zip (51.6 KB)

I have PowerPoint 2016 on Windows 10 with June Updates for Office Version 1806 (Build 10228.20080).

Many thanks,

Andy


#4

@andysteady,

I have worked with source files and sample shared by you and have been able to observe the issue. A ticket with ID SLIDESJAVA-37150 has been created in our issue tracking system to further investigate issue in detail. This thread has been linked with issue so that you may be automatically notified once issue will be fixed.


#5

Hi,

OK thanks.

Is there any work-around - some way I can refresh the chart / re-select the data programmatically or do something else differently?

Thanks,
Andy


#6

@andysteady,

I have observed your comments. I like to inform that we will investigate issue in details and share details regarding workaround after that. I request for your patience.


#7

No problem at all, thanks!