We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Charts: negative value in datapoint set by Aspose will result corructed format for datapoint

When adding a datapoint with a negative value to chart the formatting of the negative value will differ from the rest ot the series.
I would expect when I add a value that I won’t have any special cases where Aspose corrupts my formatting

I used Aspose.Slide 18.9 in netcore2.1

Full sample to reproduce the error:

using System;
using System.Diagnostics;
using System.IO;
using Aspose.Slides;
using Aspose.Slides.Charts;
using Aspose.Slides.Export;

namespace ErrorSample2
{
    class Program
    {
        static void Main(string[] args)
        {
            // set your license Pathhere
            var licensePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Aspose.Total.lic");
            var license = new License();
            using (var file = new FileStream(licensePath, FileMode.Open))
            {
                license.SetLicense(file);
            }

            var pres = new Presentation();
            using (pres)
            {
                var slide = pres.Slides[0];
                var chart = slide.Shapes.AddChart(ChartType.ClusteredBar, 10, 10, 700, 400);


                var fact = chart.ChartData.ChartDataWorkbook;
                var worksheetIndex = 1;

                var column = 0;
                var row = 1;
                var series = chart.ChartData.Series.Add(fact.GetCell(worksheetIndex, row++, column, "Series4"), chart.Type);

                series.DataPoints.AddDataPointForBarSeries(fact.GetCell(worksheetIndex, row++, column, 1.5));
                series.DataPoints.AddDataPointForBarSeries(fact.GetCell(worksheetIndex, row++, column, 2.5));
                series.DataPoints.AddDataPointForBarSeries(fact.GetCell(worksheetIndex, row++, column, -3.5)); // this one will look kinda wierd
                series.DataPoints.AddDataPointForBarSeries(fact.GetCell(worksheetIndex, row, column, 4.5));

                var filePath = Path.GetTempFileName();
                var fileName = filePath + ".pptx";

                //Write the output to disk
                using (Stream os = new FileStream(fileName, FileMode.OpenOrCreate))
                {
                    pres.Save(os, SaveFormat.Pptx);
                }

                Process.Start(@"cmd.exe", $"/c {fileName}");
            }
        }
    }
}

The result of the code above will look like this:

I would expect the top value of ‘Category3’ to have the same format as the rest of ‘Series4’

@jvoigtsolyp,

I have observed your requirements and like to share that it is not formatting issue. When you set the negative value for cahrt series data point there is a property InvertIfNegative that is by default true. It removes the filling of chart data point. You need to set the property to false.

series.InvertIfNegative = false;

I hope the shared information will be useful.