Free Support Forum - aspose.com

Pie chart data labels getting rounded off

Hi Team,
Pie chart created using aspose slides is showing datalabels rounded off to whole value. Is it possible to show with decimal points as per original data? Below is my code.
Presentation presentation = new Presentation();
ISlide slides = pres.Slides[0];

        // Add chart with default data
        IChart chart = slides.Shapes.AddChart(ChartType.Pie, 247, 136, 375, 375);
        chart.ChartTitle.AddTextFrameForOverriding("Sample Title");
        chart.ChartTitle.TextFrameForOverriding.TextFrameFormat.CenterText = NullableBool.True;
        chart.ChartTitle.Height = 20;
        chart.HasTitle = true;

        // Set first series to Show Values
        chart.ChartData.Series[0].Labels.DefaultDataLabelFormat.ShowValue = true;

        // Setting the index of chart data sheet
        int defaultWorksheetIndex = 0;

        // Getting the chart data worksheet
        IChartDataWorkbook fact = chart.ChartData.ChartDataWorkbook;

        // Delete default generated series and categories
        chart.ChartData.Series.Clear();
        chart.ChartData.Categories.Clear();

        // Adding new categories
        chart.ChartData.Categories.Add(fact.GetCell(0, 1, 0, "Category1"));
        chart.ChartData.Categories.Add(fact.GetCell(0, 2, 0, "Category2"));
        chart.ChartData.Categories.Add(fact.GetCell(0, 3, 0, "Category3"));
        chart.ChartData.Categories.Add(fact.GetCell(0, 4, 0, "Category4"));
        chart.ChartData.Categories.Add(fact.GetCell(0, 5, 0, "Category5"));
        chart.ChartData.Categories.Add(fact.GetCell(0, 6, 0, "Category6"));


        IChartSeries series = chart.ChartData.Series.Add(fact.GetCell(0, 0, 1), chart.Type);

        // Now populating series data
        series.DataPoints.AddDataPointForPieSeries(fact.GetCell(defaultWorksheetIndex, 1, 1, 71.44));
        series.DataPoints.AddDataPointForPieSeries(fact.GetCell(defaultWorksheetIndex, 2, 1, 10.56));
        series.DataPoints.AddDataPointForPieSeries(fact.GetCell(defaultWorksheetIndex, 3, 1, 5));
        series.DataPoints.AddDataPointForPieSeries(fact.GetCell(defaultWorksheetIndex, 4, 1, 4.25));
        series.DataPoints.AddDataPointForPieSeries(fact.GetCell(defaultWorksheetIndex, 5, 1, 1.75));
        series.DataPoints.AddDataPointForPieSeries(fact.GetCell(defaultWorksheetIndex, 6, 1, 7));

series.Labels.DefaultDataLabelFormat.ShowLeaderLines = true;

        series.Labels.DefaultDataLabelFormat.ShowPercentage = true;
        series.Labels.DefaultDataLabelFormat.ShowCategoryName = true;
        series.Labels.DefaultDataLabelFormat.TextFormat.PortionFormat.FontHeight = 11;
        series.Labels.DefaultDataLabelFormat.Position = LegendDataLabelPosition.BestFit;
        series.Labels.DefaultDataLabelFormat.Separator = ": ";
        chart.HasLegend = false;
        chart.HasTitle = false;
        chart.Legend.TextFormat.PortionFormat.FontHeight = 11;

@kavipriyad,
Thank you for your query. Try to use the following properties to show data labels as original values:

//series.Labels.DefaultDataLabelFormat.ShowPercentage = true; <-- commented
series.Labels.DefaultDataLabelFormat.ShowValue = true;
series.Labels.DefaultDataLabelFormat.NumberFormat = "General\"%\"";
series.Labels.DefaultDataLabelFormat.IsNumberFormatLinkedToSource = false;

More examples: Chart Data Label
API Reference: IDataLabelFormat Interface