Hi
I want to draw a chart .
please find the uploaded chart type.please help me to draw the same chart which is attached in file.
Regards,
Anusha
//Create a PowerPoint document
Presentation presentation = new Presentation();
//Add a "BarClustered" chart to the first slide
presentation.SlideSize.Type = SlideSizeType.Screen16x9;
SizeF slidesize = presentation.SlideSize.Size;
var slide = presentation.Slides[0];
RectangleF rect = new RectangleF(20, 20, slidesize.Width - 40, slidesize.Height - 40);
IChart chart = slide.Shapes.AppendChart(Spire.Presentation.Charts.ChartType.BarClustered, rect);
//Create a datatable
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("Date", Type.GetType("System.String")));
dt.Columns.Add(new DataColumn("Sales", Type.GetType("System.Double")));
dt.Rows.Add("2020/1/1", 455.41);
dt.Rows.Add("2020/1/2", 777.19);
dt.Rows.Add("2020/1/3", 1249.61);
dt.Rows.Add("2020/1/4", 1327.58);
dt.Rows.Add("2020/1/5", 3245.48);
dt.Rows.Add("2020/1/6", 3416.16);
dt.Rows.Add("2020/1/7", 14224.41);
dt.Rows.Add("2020/1/8", 18227.57);
dt.Rows.Add("2020/1/9", 22998.39);
dt.Rows.Add("2020/1/10", 99186.24);
//Import data from datatable to chart data
for (int c = 0; c < dt.Columns.Count; c++)
{
chart.ChartData[0, c].Text = dt.Columns[c].Caption;
}
for (int r = 0; r < dt.Rows.Count; r++)
{
object[] datas = dt.Rows[r].ItemArray;
for (int c = 0; c < datas.Length; c++)
{
chart.ChartData[r + 1, c].Value = datas[c];
}
}
chart.Series.SeriesLabel = chart.ChartData[0, 1, 0, dt.Columns.Count - 1];
chart.Categories.CategoryLabels = chart.ChartData[1, 0, dt.Rows.Count, 0];
//Set the position of category axis
chart.PrimaryCategoryAxis.Position = AxisPositionType.Left;
chart.SecondaryCategoryAxis.Position = AxisPositionType.Left;
chart.PrimaryCategoryAxis.TickLabelPosition = TickLabelPositionType.TickLabelPositionLow;
//Set the data, font and format for the series of each column
for (int c = 0; c < dt.Columns.Count - 1; ++c)
{
chart.Series[c].Values = chart.ChartData[1, c + 1, dt.Rows.Count, c + 1];
chart.Series[c].Fill.FillType = FillFormatType.Solid;
chart.Series[c].InvertIfNegative = false;
for (int r = 0; r < dt.Rows.Count; ++r)
{
var label = chart.Series[c].DataLabels.Add();
label.LabelValueVisible = true;
chart.Series[c].DataLabels[r].HasDataSource = false;
chart.Series[c].DataLabels[r].NumberFormat = "[$$-en-US]#,##0.00";
chart.Series[c].DataLabels.TextProperties.Paragraphs[0].DefaultCharacterProperties.FontHeight = 12;
}
}
//Set the color of the Series
chart.Series[0].Fill.SolidColor.Color = Color.Red;
TextFont font = new TextFont("Arial");
//Set the font and size for chartlegend.
for (int k = 0; k < chart.ChartLegend.EntryTextProperties.Length; k++)
{
chart.ChartLegend.EntryTextProperties[k].LatinFont = font;
chart.ChartLegend.EntryTextProperties[k].FontHeight = 20;
}
String result = "BarChart.pptx";
//Save to file
presentation.SaveToFile(result, FileFormat.Pptx2013);
chart.PrimaryValueAxis.MajorGridTextLines.FillType = FillFormatType.None;