Aspose.Slides for Java Returns Incorrect Legend Entry Count from a Chart

When we are trying to fetch the legend entry count in case of PPT, we see that it is coming as 1 even though we have turned the show legend flag as false. In case of PPT it is coming as 1 and in case of excel it is coming as 0

This is a snippet of the code for your reference. Can you please check and update

import com.aspose.slides.*;
import com.aspose.slides.ChartType;

import java.awt.Color;

public class WaterfallChartExample {
    public static void main(String[] args) {
        // Create a presentation
        Presentation presentation = new Presentation();

        try {
            // Add a slide
            ISlide slide = presentation.getSlides().get_Item(0);

            // Add a Waterfall chart
            IChart chart = slide.getShapes().addChart(ChartType.Waterfall, 50, 50, 600, 400);

            // Access the chart data workbook
            IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();

            // Clear default data
            chart.getChartData().getSeries().clear();
            chart.getChartData().getCategories().clear();

            // Add categories
            chart.getChartData().getCategories().add(workbook.getCell(0, 1, 0, "Start"));
            chart.getChartData().getCategories().add(workbook.getCell(0, 2, 0, "Increase"));
            chart.getChartData().getCategories().add(workbook.getCell(0, 3, 0, "Decrease"));
            chart.getChartData().getCategories().add(workbook.getCell(0, 4, 0, "End"));

            // Add a series
            IChartSeries series = chart.getChartData().getSeries().add(workbook.getCell(0, 0, 1, "Series 1"), chart.getType());

            // Add data points
            series.getDataPoints().addDataPointForWaterfallSeries(workbook.getCell(0, 1, 1, 1200000));
            series.getDataPoints().addDataPointForWaterfallSeries(workbook.getCell(0, 2, 1, 800000));
            series.getDataPoints().addDataPointForWaterfallSeries(workbook.getCell(0, 3, 1, -500000));
            series.getDataPoints().addDataPointForWaterfallSeries(workbook.getCell(0, 4, 1, 1500000));

            // Set the first and last data points as totals
            series.getDataPoints().get_Item(0).setSetAsTotal(true);
            series.getDataPoints().get_Item(3).setSetAsTotal(true);

            // Enable connector lines
            series.setShowConnectorLines(true);

            // Customize chart appearance
            chart.getChartTitle().addTextFrameForOverriding("Waterfall Chart Example");
            chart.setLegend(false);
         chart.getChartTitle().getTextFrameForOverriding().getTextFrameFormat().setCenterText((byte)    TextAlignment.Center);
            chart.getChartTitle().setHeight(20);
            chart.hasTitle();
            System.out.println("Number of legend entries: " + chart.getLegend().getEntries().getCount());

            // Customize series colors
            series.getFormat().getFill().setFillType(FillType.Solid);
            series.getFormat().getFill().getSolidFillColor().setColor(Color.BLUE);

            // Save the presentation
            presentation.save("WaterfallChartExample.pptx", SaveFormat.Pptx);

            System.out.println("Waterfall chart created successfully.");
        } finally {
            // Dispose of the presentation
            presentation.dispose();
        }
    }
}

@VaradS,
Thank you for contacting free support. The ILegendEntryCollection.getCount method returns the entry count regardless of the legend visibility.