Presentation stacked column chart

Hi, I need to create a stacked column chart in a pptx slide, but I’m unsure how.

Looking at the documentation it seems I need to use ‘ChartGrouping’ but the only examples I can find are for Spreadsheet not for Presentation.

Is this achievable in Presentation or do I need to figure a way to create a stacked column in excel then take the chart and insert it into the slide?

This is how I currently create graphs
var chart = slide.Content.AddChart(GemBox.Presentation.ChartType.Column, 3, 7, 24, 10, GemBox.Presentation.LengthUnit.Centimeter); but stacked columns aren’t an option.

If its not possible to create a stacked graph in presentation can you give me an example on how to create the graph in excel and the place it onto the slide?

Joseph, you need to use both GemBox.Presentation and GemBox.Spreadsheet to create a chart in a PPTX file. Please check our ‘Charts’ example for more information.

Hi Marko,

Its specifically a “Stacked Column” chart that I need, and the examples you linked don’t have that as an option.

It does seem to be an option in the GemBox.Spreadsheet so I’m not sure why its not available in both.

You can change the chart to stacked by casting the ExcelChart property to GemBox.Spreadsheet.Charts.BarChart and setting it’s Grouping property to ‘Stacked’. E.g.

// Create PowerPoint chart and add it to slide.
var chart = slide.Content.AddChart(GemBox.Presentation.ChartType.Bar,
   49.3, 40, 240, 120, GemBox.Presentation.LengthUnit.Millimeter);
            
// Get underlying Excel chart.
BarChart excelChart = (BarChart)chart.ExcelChart;
excelChart.Grouping = Spreadsheet.Charts.ChartGrouping.Stacked;
1 Like

Hi Joseph,

I just wanted to let you know that this option is also available in GemBox.Presentation, there are AddChart overload methods that accept ChartGrouping parameter.

For example:

var chart = slide.Content.AddChart(
    GemBox.Presentation.ChartType.Column,
    GemBox.Presentation.ChartGrouping.Stacked,
    49.3, 40, 240, 120, GemBox.Presentation.LengthUnit.Millimeter);

Regards,
Mario