Hello,
Thank you for your inquiry.
Yes, our Spire.Presentation does support the creation of combination charts. Please refer to the example code snippet provided below:
- Code: Select all
Presentation presentation = new Presentation();
//Insert a bar clustered chart
RectangleF rect = new RectangleF(100, 100, 550, 320);
IChart chart = presentation.Slides[0].Shapes.AppendChart(ChartType.BarClustered, rect);
//Set chart title
chart.ChartTitle.TextProperties.Text = "Monthly Sales Report";
chart.ChartTitle.TextProperties.IsCentered = true;
chart.ChartTitle.Height = 30;
chart.HasTitle = true;
//Create a datatable
DataTable dataTable = new DataTable();
dataTable.Columns.Add(new DataColumn("Month", Type.GetType("System.String")));
dataTable.Columns.Add(new DataColumn("Sales", Type.GetType("System.Int32")));
dataTable.Columns.Add(new DataColumn("Growth rate", Type.GetType("System.Decimal")));
dataTable.Rows.Add("January", 200, 0.6);
dataTable.Rows.Add("February", 250, 0.8);
dataTable.Rows.Add("March", 300, 0.6);
dataTable.Rows.Add("April", 150, 0.2);
dataTable.Rows.Add("May", 200, 0.5);
dataTable.Rows.Add("June", 400, 0.9);
//Import data from datatable to chart data
for (int c = 0; c < dataTable.Columns.Count; c++)
{
chart.ChartData[0, c].Text = dataTable.Columns[c].Caption;
}
for (int r = 0; r < dataTable.Rows.Count; r++)
{
object[] datas = dataTable.Rows[r].ItemArray;
for (int c = 0; c < datas.Length; c++)
{
chart.ChartData[r + 1, c].Value = datas[c];
}
}
//Set series labels
chart.Series.SeriesLabel = chart.ChartData["B1", "C1"];
//Set categories labels
chart.Categories.CategoryLabels = chart.ChartData["A2", "A7"];
//Assign data to series values
chart.Series[0].Values = chart.ChartData["B2", "B7"];
chart.Series[1].Values = chart.ChartData["C2", "C7"];
//Change the chart type of serie 2 to line with Pie
chart.Series[1].Type = ChartType.Pie;
//Plot data of series 2 on the secondary axis
chart.Series[1].UseSecondAxis = true;
//Set the number format as percentage
chart.SecondaryValueAxis.NumberFormat = "0%";
//Hide gridlinkes of secondary axis
chart.SecondaryValueAxis.MajorGridTextLines.FillType = FillFormatType.None;
//Set overlap
chart.OverLap = -50;
//Set gapwidth
chart.GapWidth = 200;
//Save to file
presentation.SaveToFile("result.pptx", FileFormat.Pptx2010);
If you have any further questions or need assistance with implementing this feature, please feel free to reach out.
Thank you for considering our product.
Sincerely,
Annika
E-iceblue support team