Pie chart Labels colors issue

Hi!
For Pie chart creation, if we have “0%” data points, the corresponding labels may come out of the pie body as following,
image.png (10.9 KB)
In such scenario, if I want to change the data Labels color to white (previously black) , we get following results
image.png (8.6 KB)
Here, 0% labels are present but we can’t see them as background is also white.
We want to see following results,
image.png (17.2 KB)
Please suggest any possible way by which we can achieve the same.
Thanks!

@jnachi1699,

Thanks for the screenshots.

Could you please share your sample (runnable) code (that you are using) to create your undesired results (Excel file) using Aspose.Cells. Also share a sample Excel file with your desired results, you may create the file with your desired chart in MS Excel manually. We will check your issue and may update to accomplish your task.

PS. please zip the Excel files prior attaching here.

@Amjad_Sahi
Thanks for the response!
Sharing sample code, and two excel files for your reference
Pie.zip (29.4 KB)
As you can see, WhiteColoredLabels file has manually created white labels in which 0% labels can’t be seen.
Please suggest a way in order to have white colored labels for inner labels(inside Pie body) and black colored labels for outside labels(0%).

Thanks!

@jnachi1699,

Thanks for the sample files.

See the following (updated) sample code for your requirements for your reference:
e.g.
Sample code:

        Workbook workbook = new Workbook();
        WorksheetCollection worksheets = workbook.getWorksheets();
        Worksheet sheet = worksheets.get(0);

        // Adding some sample value to cells
        Cells cells = sheet.getCells();
        Cell cell = cells.get("A1");
        cell.setValue("Component");
        cell = cells.get("A2");
        cell.setValue("A");
        cell = cells.get("A3");
        cell.setValue("B");
        cell = cells.get("A4");
        cell.setValue("C");
        cell = cells.get("A5");
        cell.setValue("D");
        cell = cells.get("A6");
        cell.setValue("E");
        cell = cells.get("A7");
        cell.setValue("F");
        cell = cells.get("A8");
        cell.setValue("G");

        cell = cells.get("B1");
        cell.setValue("Price");
        cell = cells.get("B2");
        cell.setValue(20000);
        cell = cells.get("B3");
        cell.setValue(45000);
        cell = cells.get("B4");
        cell.setValue(70000);
        cell = cells.get("B5");
        cell.setValue(19000);
        cell = cells.get("B6");
        cell.setValue(0);
        cell = cells.get("B7");
        cell.setValue(28000);
        cell = cells.get("B8");
        cell.setValue(0);

        ChartCollection charts = sheet.getCharts();
        int chartIndex = charts.add(ChartType.PIE, 15, 4, 40, 15);
        Chart chart = charts.get(chartIndex);

        SeriesCollection serieses = chart.getNSeries();
        serieses.add("B2:B8", true);
        serieses.setCategoryData("A2:B8");

        chart.getTitle().setText("Sales By Region");
        chart.getTitle().getFont().setColor(com.aspose.cells.Color.getBlue());
        chart.getTitle().getFont().setBold(true);
        chart.getTitle().getFont().setSize(12);

        chart.calculate();
        DataLabels datalabels;
        for (int i = 0; i < serieses.getCount(); i++) {
            Series series = serieses.get(i);
            datalabels = series.getDataLabels();
            datalabels.setNumberFormatLinked(true);
            datalabels.setPosition(LabelPositionType.BEST_FIT);
            datalabels.setShowPercentage(true);

            for(int j =0;j<series.getPoints().getCount();j++)
            {
                ChartPoint dataPoint = series.getPoints().get(j);


                if(dataPoint.getYValue().toString().equals("0.0"))
                {
                    dataPoint.getDataLabels().getFont().setColor(com.aspose.cells.Color.getBlack());
                    System.out.println(dataPoint.getYValue());
                }
                else
                {

                    dataPoint.getDataLabels().getFont().setColor(com.aspose.cells.Color.getWhite());
                }

            }

        }

        workbook.save("f:\\files\\Name.xls");

Hope, this helps a bit.