1
我是使用aspose.slides
的新手,想知道是否可以創建此鏡頭描述中給出的條形圖。使用Aspose Slide繪製圖形
我試圖更新的圖表的y軸從-100到100,0軸上的x軸和條形圖應該位於正向上升或負向下降。
下圖顯示了代碼定期條形圖是波紋管
// Instantiate PresentationEx class that represents PPTX file
PresentationEx pres = new PresentationEx("D:\\AsposeChart.pptx");
// Access first slide
SlideEx sld = pres.Slides[0];
// Add chart with default data
ChartEx chart = (ChartEx)sld.Shapes[0];
// Setting the index of chart data sheet
int defaultWorksheetIndex = 0;
// Getting the chart data worksheet
ChartDataCellFactory fact = chart.ChartData.ChartDataCellFactory;
// Take first chart series
ChartSeriesEx series = chart.ChartData.Series[0];
// Now updating series data
fact.GetCell(defaultWorksheetIndex, 0, 1, "New_Series1");//modifying series name
series.Values[0].Value = 90;
series.Values[1].Value = 123;
series.Values[2].Value =44;
// Take Second chart series
series = chart.ChartData.Series[1];
// Now updating series data
fact.GetCell(defaultWorksheetIndex, 0, 2, "New_Series2");//modifying series name
series.Values[0].Value = 23;
series.Values[1].Value = 67;
series.Values[2].Value = 99;
// Now, Adding a new series
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 3, "Series 3"), chart.Type);
// Take 3rd chart series
series = chart.ChartData.Series[2];
// Now populating series data
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 1, 3, 20));
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 2, 3, 50));
series.Values.Add(fact.GetCell(defaultWorksheetIndex, 3, 3, 30));
chart.Type = ChartTypeEx.ClusteredCylinder;
// Save presentation with chart
pres.Write(@"D:\AsposeChartMoodified.pptx");