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

Free Support Forum - aspose.com

Aspose Slides - Charts

Aspose seems to be a suitable solution for our upcoming projects. We are looking to generate powerpoint charts using aspose slides. So far we were successful. We are facing challenges with the following 3 charts as there is no proper documentation available. Appreciate your response on this.

  1. Multi category chart.
  2. Bubble chart with category labels.
  3. Chart with reference line / Plotline / Benchmark line.

multicategory.PNG (21.9 KB)
bubble.PNG (23.0 KB)

@PRNG,

Thank you for showing interest in Aspose.Slides. For multi category charts, I suggest you to please try using following sample code.

public static void TestChartCategory()
{
    Presentation pres = new Presentation();
    ISlide slide = pres.Slides[0];

    IChart ch = pres.Slides[0].Shapes.AddChart(ChartType.ClusteredColumn, 100, 100, 600, 450);
    ch.ChartData.Series.Clear();
    ch.ChartData.Categories.Clear();


    IChartDataWorkbook fact = ch.ChartData.ChartDataWorkbook;
    fact.Clear(0);
    int defaultWorksheetIndex = 0;

    IChartCategory category = ch.ChartData.Categories.Add(fact.GetCell(0, "c2", "A"));
    category.GroupingLevels.SetGroupingItem(1, "Group1");
    category = ch.ChartData.Categories.Add(fact.GetCell(0, "c3", "B"));

    category = ch.ChartData.Categories.Add(fact.GetCell(0, "c4", "C"));
    category.GroupingLevels.SetGroupingItem(1, "Group2");
    category = ch.ChartData.Categories.Add(fact.GetCell(0, "c5", "D"));

    category = ch.ChartData.Categories.Add(fact.GetCell(0, "c6", "E"));
    category.GroupingLevels.SetGroupingItem(1, "Group3");
    category = ch.ChartData.Categories.Add(fact.GetCell(0, "c7", "F"));

    category = ch.ChartData.Categories.Add(fact.GetCell(0, "c8", "G"));
    category.GroupingLevels.SetGroupingItem(1, "Group4");
    category = ch.ChartData.Categories.Add(fact.GetCell(0, "c9", "H"));

    //            Adding Series
    IChartSeries series = ch.ChartData.Series.Add(fact.GetCell(0, "D1", "Series 1"),
        ChartType.ClusteredColumn);

    series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, "D2", 10));
    series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, "D3", 20));
    series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, "D4", 30));
    series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, "D5", 40));
    series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, "D6", 50));
    series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, "D7", 60));
    series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, "D8", 70));
    series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, "D9", 80));
    // Save presentation with chart
    pres.Save( "C:\\Aspose Data\\AsposeChart_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx);

For, bubble charts, I suggest you to please try using following sample code.

public static void TestBubble()
{
    // The path to the documents directory.
    string dataDir = "c:\\Aspose Data\\";// RunExamples.GetDataDir_Charts();

    // Creating empty presentation
    using (Presentation presentation = new Presentation())
    {
        // Creating a bubble chart
        IChart chart = presentation.Slides[0].Shapes.AddChart(ChartType.Bubble, 50, 50, 400, 300, true);

        // Adding custom Error bars and setting its format
        IChartSeries series = chart.ChartData.Series[0];
        IErrorBarsFormat errBarX = series.ErrorBarsXFormat;
        IErrorBarsFormat errBarY = series.ErrorBarsYFormat;
        errBarX.IsVisible = true;
        errBarY.IsVisible = true;
        errBarX.ValueType = ErrorBarValueType.Custom;
        errBarY.ValueType = ErrorBarValueType.Custom;

        // Accessing chart series data point and setting error bars values for individual point
        IChartDataPointCollection points = series.DataPoints;
        points.DataSourceTypeForErrorBarsCustomValues.DataSourceTypeForXPlusValues = DataSourceType.DoubleLiterals;
        points.DataSourceTypeForErrorBarsCustomValues.DataSourceTypeForXMinusValues = DataSourceType.DoubleLiterals;
        points.DataSourceTypeForErrorBarsCustomValues.DataSourceTypeForYPlusValues = DataSourceType.DoubleLiterals;
        points.DataSourceTypeForErrorBarsCustomValues.DataSourceTypeForYMinusValues = DataSourceType.DoubleLiterals;

        // Setting error bars for chart series points
        for (int i = 0; i < points.Count; i++)
        {
            points[i].ErrorBarsCustomValues.XMinus.AsLiteralDouble = i + 1;
            points[i].ErrorBarsCustomValues.XPlus.AsLiteralDouble = i + 1;
            points[i].ErrorBarsCustomValues.YMinus.AsLiteralDouble = i + 1;
            points[i].ErrorBarsCustomValues.YPlus.AsLiteralDouble = i + 1;
        }

        // Saving presentation
        presentation.Save(dataDir + "ErrorBarsCustomValues_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
     
    }
}

Please share, if I may help you further in this regard.