Chart Styles Are Not Applied Using Aspose.Slides for .NET

I am trying to change a Chart’s default style using this code:

Presentation pres = new Presentation();

// Access first slide
ISlide slide = pres.Slides[0];

IChart chart = slide.Shapes.AddChart(ChartType.ClusteredBar, 0, 0, 500, 500);
chart.Style = StyleType.Style12;
…

But cannot see any difference if Style12 or any other style is applied.
Is there anything else that needs to be done in order to use a Style for a chart?

Thanks.

Hi Scott,

I have observed your comments. Can you please share source presentation, generated presentation and also please share which Aspose.Slides version you are using on your end so that we can further investigate to help you out.

Best Regards,

Here’s the code I am using…taken from your examples online. I am using v17.2

Presentation pres = new Presentation();
ISlide slide = pres.Slides[0];
IChart chart = slide.Shapes.AddChart(ChartType.ClusteredBar, 80, 100, 600, 300);

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();
int s = chart.ChartData.Series.Count;
s = chart.ChartData.Categories.Count;

// Adding new series
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 1, “Series 1”), chart.Type);
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 2, “Series 2”), chart.Type);

// Adding new categories
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 1, 0, “Category 1”));
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 2, 0, “Category 2”));
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 3, 0, “Category 3”));

// Take first chart series
IChartSeries series = chart.ChartData.Series[0];

// Now populating series data

series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 1, 1, 20));
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 2, 1, 50));
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 3, 1, 30));

// Setting fill color for series
series.Format.Fill.FillType = FillType.Solid;
series.Format.Fill.SolidFillColor.Color = Color.Red;

// Take second chart series
series = chart.ChartData.Series[1];

// Now populating series data
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 1, 2, 30));
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 2, 2, 10));
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 3, 2, 60));

// Setting fill color for series
series.Format.Fill.FillType = FillType.Solid;
series.Format.Fill.SolidFillColor.Color = Color.Green;

// First label will be show Category name
IDataLabel lbl = series.DataPoints[0].Label;
lbl.DataLabelFormat.ShowCategoryName = true;

lbl = series.DataPoints[1].Label;
lbl.DataLabelFormat.ShowSeriesName = true;

// Show value for third label
lbl = series.DataPoints[2].Label;
lbl.DataLabelFormat.ShowValue = true;
lbl.DataLabelFormat.ShowSeriesName = true;
lbl.DataLabelFormat.Separator = “/”;

chart.Style = StyleType.Style12;

Attached are 2 outputs. One for Style7 and one for Style12. Both are exactly the same.

Thanks for the help.

Hi Scott,

I have worked with the sample code shared by you and have been able to reproduce the issue on my end. An issue with ID SLIDESNET-38944 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be automatically notified once the issue will be fixed.

We are sorry for your inconvenience,

Hi Scott,

I suggest you to please try using following sample code on your end using Aspose.Slides for .NET 17.5. Actually, when you apply chart color scheme then you don’t really need to set the color for chart series. When you do so, it will overwrite the automatic chart color scheme.

public static void ChartWithTheme()
{
    using (Presentation pres = new Presentation())
    {
        pres.Slides.AddClone(pres.Slides[0]);
        ISlide slide = pres.Slides[0];
        pres.Slides.AddClone(pres.Slides[0]);
        IChart chart = slide.Shapes.AddChart(ChartType.ClusteredColumn, 80, 100, 600, 300);

        slide = pres.Slides[1];
        chart = slide.Shapes.AddChart(ChartType.ClusteredBar, 80, 100, 600, 300);
        chart.Style = StyleType.Style6;

        ///
        slide = pres.Slides[2];
        chart = slide.Shapes.AddChart(ChartType.ClusteredBar, 80, 100, 600, 300);
        chart.Style = StyleType.Style6;

        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();
        int s = chart.ChartData.Series.Count;
        s = chart.ChartData.Categories.Count;

        chart.Style = StyleType.Style12;
        // chart.Style = StyleType.Style6;

        // Adding new series
        chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 1, “Series 1”), chart.Type);
        chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 2, “Series 2”), chart.Type);

        // Adding new categories
        chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 1, 0, “Category 1”));
        chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 2, 0, “Category 2”));
        chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 3, 0, “Category 3”));

        // Take first chart series
        IChartSeries series = chart.ChartData.Series[0];

        // Now populating series data

        series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 1, 1, 20));
        series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 2, 1, 50));
        series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 3, 1, 30));

        // Setting fill color for series
        // series.Format.Fill.FillType = FillType.Solid;
        // series.Format.Fill.SolidFillColor.Color = Color.Red;

        // Take second chart series
        series = chart.ChartData.Series[1];

        // Now populating series data
        series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 1, 2, 30));
        series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 2, 2, 10));
        series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 3, 2, 60));

        // Setting fill color for series
        // series.Format.Fill.FillType = FillType.Solid;
        // series.Format.Fill.SolidFillColor.Color = Color.Green;

        // First label will be show Category name
        IDataLabel lbl = series.DataPoints[0].Label;
        lbl.DataLabelFormat.ShowCategoryName = true;

        lbl = series.DataPoints[1].Label;
        lbl.DataLabelFormat.ShowSeriesName = true;

        // Show value for third label
        lbl = series.DataPoints[2].Label;
        lbl.DataLabelFormat.ShowValue = true;
        lbl.DataLabelFormat.ShowSeriesName = true;
        lbl.DataLabelFormat.Separator = “/”;
        chart.Style = StyleType.Style6;

        pres.Save(“C:\Aspose Data\ThemeChart.pptx”, SaveFormat.Pptx);
    }
}

Many Thanks,

Sorry…still not working. I am using your code example above, along with the new 17.5 version. The resulting generated styles are attached:

Style12 is EXACTLY the same as Style8. Neither look anything like the Powerpoint Styles.

Style6 only changes the colors a wee bit…and doesn’t look anything like the Powerpoint Style6

See attached.

Again, I am using your exact code example above.

Hi Scott,

I have opened the attached presentations in PowerPoint 2010 on my end. Please observe the following images:

You can see from the chart layout styles in PowerPoint that they are identical to created chart with defined style. Can you please verify the same fact on your end.

Many Thanks,

I am using PowerPoint 2013…and the styles do not match.

Maybe that’s the issue?

If so, are there any plans to support later versions of Powerpoint?

Hi Scott,

Can you please share the snapshots of presentations getting opened in PowerPoint 2013 as I have shared with you in case of PowerPoint 2010. Please also share the complete PowerPoint 2013 version used on your end so that we may investigate it further.

Many Thanks,

It is MicrosoftOffice 2013. Powerpoint version: 15.0.4765.1000

Screenshots attached.

Hi Scott,

I have got your point. You are actually pointing to Overall Chart Visual Styles in generated chart that is not getting displayed. I regret to share that at present, Aspose.Slides only support applying Chart Quick Colors when you use Chart.Style property. An issue with ID SLIDESNET-38961 has been added as new feature request to provide the support for Overall Chart Visual Styles in Aspose.Slides. This thread has been linked with the issue so that you may be automatically notified once the support will be available.

We are sorry for your inconvenience,