Displaying 0 Values in Syncfusion Presentation Stacked 100 Bar Chart

Hello,

Is there a way to plot 0 values in stacked 100 bar charts, like the third bar in the following sample image?



I'm using the .Net Core Syncfusion Presentation package and the chart doesn't display a bar by default for 0 values, like the below image:



Thank you!

3 Replies 1 reply marked as answer

HC Hemalatha Chiranjeevulu Syncfusion Team March 16, 2021 06:14 PM UTC

Hi Yasmin,

Thank you for contacting Syncfusion support.

We suspect that the reported issue might be based on the file level information in the input Presentation document which used at your end. Could you please share us the below things at your end:
  1.Input Presentation document
  2.Complete code snippets which used at your end
  3.Syncfusion product version which used in your application
This will be more helpful to replicate the same problem at our end. Thereby we will analyze further on the reported problem using that details and update you with appropriate solution at the earliest.

Please let us know if you have any other questions.

Regards,
Hemalatha C



YE Yasmin Eldokany April 20, 2021 04:19 PM UTC

Hello,

The presentation is generated entirely from code, kindly check the below code snippet:

        //Creates a Presentation instance
        IPresentation pptxDoc = Presentation.Create();

        // Create an instance of Presentation Renderer for converting chart to image
        pptxDoc.PresentationRenderer = new PresentationRenderer();

        //Adds a blank slide to the Presentation
        ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank);

        //Adds chart to the slide with position and size
        IPresentationChart chart = slide.Charts.AddChart(100, 10, 700, 500);

        //Specifies the chart title
        chart.ChartTitle = "Sales Analysis";

        //Sets chart data - Row1
        chart.ChartData.SetValue(1, 2, "Jan");
        chart.ChartData.SetValue(1, 3, "Feb");
        chart.ChartData.SetValue(1, 4, "March");

        //Sets chart data - Row2
        chart.ChartData.SetValue(2, 1, 2010);
        chart.ChartData.SetValue(2, 2, 0);
        chart.ChartData.SetValue(2, 3, 0);
        chart.ChartData.SetValue(2, 4, 0);

        //Sets chart data - Row3
        chart.ChartData.SetValue(3, 1, 2011);
        chart.ChartData.SetValue(3, 2, 800);
        chart.ChartData.SetValue(3, 3, 700);
        chart.ChartData.SetValue(3, 4, 600);

        //Sets chart data - Row4
        chart.ChartData.SetValue(4, 1, 2012);
        chart.ChartData.SetValue(4, 2, 600);
        chart.ChartData.SetValue(4, 3, 700);
        chart.ChartData.SetValue(4, 4, 800);

        //Sets the data range of the category axis
        chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[2, 1, 4, 1];

        //Creates a new chart series with the name
        IOfficeChartSerie seriesJan = chart.Series.Add("Jan");

        //Sets the data range of chart series – start row, start column, end row, end column
        seriesJan.Values = chart.ChartData[2, 2, 4, 2];

        //Creates a new chart series with the name
        IOfficeChartSerie seriesFeb = chart.Series.Add("Feb");

        //Sets the data range of chart series – start row, start column, end row, end column
        seriesFeb.Values = chart.ChartData[2, 3, 4, 3];

        //Creates a new chart series with the name
        IOfficeChartSerie seriesMarch = chart.Series.Add("March");

        //Sets the data range of chart series – start row, start column, end row, end column
        seriesMarch.Values = chart.ChartData[2, 4, 4, 4];

        //Specifies the chart type
        chart.ChartType = OfficeChartType.Bar_Stacked_100;

        using (var stream = new MemoryStream())
        {
            pptxDoc.PresentationRenderer.ConvertToImage(chart, stream);

            slide.Shapes.AddPicture(stream, 100, 10, 700, 500);
        }

        //Save the PowerPoint file
        pptxDoc.Save("Output.pptx");

        //Close the PowerPoint instance
        pptxDoc.Close();


This generates the following chart image, how can I get the 0 bars to display like the above image:



I'm using the latest Syncfusion.Presentation.Net.Core and Syncfusion.PresentationRenderer.Net.Core nuget package versions (v19.1.0.57).


HC Hemalatha Chiranjeevulu Syncfusion Team April 21, 2021 03:24 PM UTC

Hi Yasmin,

Thank you for sharing us the details.

On further analyzing, we have found in Microsoft PowerPoint application, series of the chart not displayed when chart data value is zero. Essential Presentation does the same. It is not an issue which is behavior of chart in the Microsoft PowerPoint application.

Please let us know if you have any other questions.

Regards,
Hemalatha C


Marked as answer
Loader.
Up arrow icon