Chart parentSeriesGroup.setOverlap does not overlap the series (Java)

parentSeriesGroup.setOverlap does not work as expected in Aspose Slide v19.12

I tried to create StackedColumn as stacked.
Creating chart with sample slide.shapes.addChart(ChartType.StackedColumn, 0, 0, 500, 500, true) was okay as I expected.https://purchase.aspose.com/

But it was not stacked with my sample data.
As you can see, series overlap is zero in powerpoint.
series-overlap-is-zero.PNG (322.6 KB)

I coded s1.parentSeriesGroup.setOverlap(100 as byte) and double check it was 100 using assert s1.parentSeriesGroup.getOverlap() == 100 as byte.
Here’s my sample code. (Code is groovy but it works well)

    def chart = slide.shapes.addChart(ChartType.StackedColumn, 0, 0, 500, 500, false)
    chart.chartTitle.addTextFrameForOverriding("PoC [1-5]")

    def wb = chart.chartData.getChartDataWorkbook()

    def s1 = chart.chartData.series.add(wb.getCell(dataSheetNo, 0, 1, "test"), chart.type)
    s1.parentSeriesGroup.setOverlap(100 as byte)
    assert s1.parentSeriesGroup.getOverlap() == 100 as byte

    chart.chartData.categories.add(wb.getCell(dataSheetNo, 1, 0, "[5]"))
    chart.chartData.categories.add(wb.getCell(dataSheetNo, 2, 0, "[4]"))
    chart.chartData.categories.add(wb.getCell(dataSheetNo, 3, 0, "[3]"))
    chart.chartData.categories.add(wb.getCell(dataSheetNo, 4, 0, "[2]"))
    chart.chartData.categories.add(wb.getCell(dataSheetNo, 5, 0, "[1]"))
    chart.legend.position = LegendPositionType.Left

    s1.dataPoints.addDataPointForBarSeries(wb.getCell(dataSheetNo, 1, 1, 18.7))
    s1.dataPoints.addDataPointForBarSeries(wb.getCell(dataSheetNo, 2, 1, 61.7))
    s1.dataPoints.addDataPointForBarSeries(wb.getCell(dataSheetNo, 3, 1, -27.7))
    s1.dataPoints.addDataPointForBarSeries(wb.getCell(dataSheetNo, 4, 1, -12.9)
    s1.dataPoints.addDataPointForBarSeries(wb.getCell(dataSheetNo, 5, 1, -0.6))

    chart.chartData.switchRowColumn()

@greg.lee,

I have observed the image shared by you and part of sample code. Can you please provide the working sample project along with source and output files so that we may log issue in our issue tracking system.

Hi @mudassir.fayyaz

Thank you for your prompt reply.
I attach an sample project to reproduce problem.

aspose-benchmark.zip (1.0 MB)

Please let me know if you need something else.

@greg.lee,

I suggest you to please try using following sample code on your end. I hope this will be helpful.

public static void TestOverlap()
{

    Presentation presentation = new Presentation();
     
    String dataDir =  "//Users//mudassir//Downloads//";
    // Adding chart
    IChart chart = presentation.getSlides().get_Item (0).getShapes().addChart(ChartType.ClusteredColumn, 50, 50, 600, 400, true);
    IChartSeriesCollection series = chart.getChartData().getSeries();

    chart. getChartData(). getSeries() .clear();
    chart. getChartData() . getCategories() .clear();;
    IChartDataWorkbook wb = chart. getChartData() .getChartDataWorkbook() ;

    IChartSeries s1 = chart. getChartData() . getSeries() .add(wb.getCell(0, 0, 1, "test"), chart.getType() );

    chart. getChartData().getCategories().add(wb.getCell(0, 1, 0, "[5]"));
    chart. getChartData().getCategories().add(wb.getCell(0, 2, 0, "[4]"));
    chart. getChartData().getCategories().add(wb.getCell(0, 3, 0, "[3]"));
    chart. getChartData().getCategories().add(wb.getCell(0, 4, 0, "[2]"));
    chart. getChartData().getCategories().add(wb.getCell(0, 5, 0, "[1]"));
    chart.getLegend().setPosition(LegendPositionType.Left);

    s1.getDataPoints() .addDataPointForBarSeries(wb.getCell(0, 1, 1, 18.7));
    s1.getDataPoints() .addDataPointForBarSeries(wb.getCell(0, 2, 1, 61.7));
    s1.getDataPoints() .addDataPointForBarSeries(wb.getCell(0, 3, 1, -27.7));
    s1.getDataPoints() .addDataPointForBarSeries(wb.getCell(0, 4, 1, -12.9));
    s1.getDataPoints() .addDataPointForBarSeries(wb.getCell(0, 5, 1, -0.6));


    chart. getChartData() .switchRowColumn();

    // Setting series overlap
     series.get_Item(0).getParentSeriesGroup().setOverlap((byte)100);

     // Write the presentation file to disk
    presentation.save(dataDir + "SetChartSeriesOverlap_out2.pptx", SaveFormat.Pptx);
 }

SetChartSeriesOverlap_out2.pptx.zip (29.8 KB)

@mudassir.fayyaz

once again, thank you for your prompt reply.
There is tiny syntax mistake in your code but I see your point - setOverlap() should be called after addDataPoint().

So I changed some code as followings:

chart.getChartData().switchRowColumn();

// (1) series was not declared
// series.get_Item(0).getParentSeriesGroup().setOverlap((byte)100);

// (2) use s1 which is already used in `addDataPoint()`, but It throws NPE
// s1.getParentSeriesGroup().setOverlap((byte) 100);

// (3) use `chart.getChartData().getSeries()`, it works well
chart.getChartData().getSeries().get_Item(0).getParentSeriesGroup().setOverlap((byte) 100);

In case of (2) looks little bit wired, it may be a bug? or my misunderstanding?

@greg.lee,

Yes, you are right. When you switched rows and columns, you need to call the overlap method after that.

Secondly, if you may please use my code as it is, you will not observe the issue. I shared the working code sample with you along with generated output.

Understood, Your help may help to purchase Aspose.Slide.

Thank you so much!

@greg.lee,

Thank you for sharing your feedback.