//ExStart:HistogramChart public static void Run() { string dataDir = RunExamples.GetDataDir_Charts(); using (Presentation pres = new Presentation(dataDir + "test.pptx")) { IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.Histogram, 50, 50, 500, 400); chart.ChartData.Categories.Clear(); chart.ChartData.Series.Clear(); IChartDataWorkbook wb = chart.ChartData.ChartDataWorkbook; wb.Clear(0); IChartSeries series = chart.ChartData.Series.Add(ChartType.Histogram); series.DataPoints.AddDataPointForHistogramSeries(wb.GetCell(0, "A1", 15)); series.DataPoints.AddDataPointForHistogramSeries(wb.GetCell(0, "A2", -41)); series.DataPoints.AddDataPointForHistogramSeries(wb.GetCell(0, "A3", 16)); series.DataPoints.AddDataPointForHistogramSeries(wb.GetCell(0, "A4", 10)); series.DataPoints.AddDataPointForHistogramSeries(wb.GetCell(0, "A5", -23)); series.DataPoints.AddDataPointForHistogramSeries(wb.GetCell(0, "A6", 16)); chart.Axes.HorizontalAxis.AggregationType = AxisAggregationType.Automatic; pres.Save(dataDir + "Histogram.pptx", SaveFormat.Pptx); } }
//ExStart:FunnelChart public static void Run() { string dataDir = RunExamples.GetDataDir_Charts(); using (Presentation pres = new Presentation(dataDir + "test.pptx")) { IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.Funnel, 50, 50, 500, 400); chart.ChartData.Categories.Clear(); chart.ChartData.Series.Clear(); IChartDataWorkbook wb = chart.ChartData.ChartDataWorkbook; wb.Clear(0); chart.ChartData.Categories.Add(wb.GetCell(0, "A1", "Category 1")); chart.ChartData.Categories.Add(wb.GetCell(0, "A2", "Category 2")); chart.ChartData.Categories.Add(wb.GetCell(0, "A3", "Category 3")); chart.ChartData.Categories.Add(wb.GetCell(0, "A4", "Category 4")); chart.ChartData.Categories.Add(wb.GetCell(0, "A5", "Category 5")); chart.ChartData.Categories.Add(wb.GetCell(0, "A6", "Category 6")); IChartSeries series = chart.ChartData.Series.Add(ChartType.Funnel); series.DataPoints.AddDataPointForFunnelSeries(wb.GetCell(0, "B1", 50)); series.DataPoints.AddDataPointForFunnelSeries(wb.GetCell(0, "B2", 100)); series.DataPoints.AddDataPointForFunnelSeries(wb.GetCell(0, "B3", 200)); series.DataPoints.AddDataPointForFunnelSeries(wb.GetCell(0, "B4", 300)); series.DataPoints.AddDataPointForFunnelSeries(wb.GetCell(0, "B5", 400)); series.DataPoints.AddDataPointForFunnelSeries(wb.GetCell(0, "B6", 500)); pres.Save(dataDir + "Funnel.pptx", SaveFormat.Pptx); } }
public static void Run() { //ExStart:SettingDateFormatForCategoryAxis // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Charts(); using (Presentation pres = new Presentation()) { IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.Area, 50, 50, 450, 300); IChartDataWorkbook wb = chart.ChartData.ChartDataWorkbook; wb.Clear(0); chart.ChartData.Categories.Clear(); chart.ChartData.Series.Clear(); chart.ChartData.Categories.Add(wb.GetCell(0, "A2", new DateTime(2015, 1, 1).ToOADate())); chart.ChartData.Categories.Add(wb.GetCell(0, "A3", new DateTime(2016, 1, 1).ToOADate())); chart.ChartData.Categories.Add(wb.GetCell(0, "A4", new DateTime(2017, 1, 1).ToOADate())); chart.ChartData.Categories.Add(wb.GetCell(0, "A5", new DateTime(2018, 1, 1).ToOADate())); IChartSeries series = chart.ChartData.Series.Add(ChartType.Line); series.DataPoints.AddDataPointForLineSeries(wb.GetCell(0, "B2", 1)); series.DataPoints.AddDataPointForLineSeries(wb.GetCell(0, "B3", 2)); series.DataPoints.AddDataPointForLineSeries(wb.GetCell(0, "B4", 3)); series.DataPoints.AddDataPointForLineSeries(wb.GetCell(0, "B5", 4)); chart.Axes.HorizontalAxis.CategoryAxisType = CategoryAxisType.Date; chart.Axes.HorizontalAxis.IsNumberFormatLinkedToSource = false; chart.Axes.HorizontalAxis.NumberFormat = "yyyy"; pres.Save(dataDir + "test.pptx", SaveFormat.Pptx); } //ExEnd:SettingDateFormatForCategoryAxis }
public void Index() { using (Presentation pres = new Presentation()) { IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.Histogram, 50, 50, 500, 400); chart.ChartData.Categories.Clear(); chart.ChartData.Series.Clear(); IChartDataWorkbook wb = chart.ChartData.ChartDataWorkbook; wb.Clear(0); IChartSeries series = chart.ChartData.Series.Add(ChartType.Histogram); series.DataPoints.AddDataPointForHistogramSeries(wb.GetCell(0, "A1", 15)); series.DataPoints.AddDataPointForHistogramSeries(wb.GetCell(0, "A2", -41)); series.DataPoints.AddDataPointForHistogramSeries(wb.GetCell(0, "A3", 16)); series.DataPoints.AddDataPointForHistogramSeries(wb.GetCell(0, "A4", 10)); series.DataPoints.AddDataPointForHistogramSeries(wb.GetCell(0, "A5", -23)); series.DataPoints.AddDataPointForHistogramSeries(wb.GetCell(0, "A6", 16)); chart.Axes.HorizontalAxis.AggregationType = AxisAggregationType.Automatic; pres.Save("C:/Users/esshreem/Histogram.pptx", SaveFormat.Pptx); } }
//ExStart:TreeMapChart public static void Run() { string dataDir = RunExamples.GetDataDir_Charts(); using (Presentation pres = new Presentation(dataDir + "test.pptx")) { IChart chart = pres.Slides[0].Shapes.AddChart(Aspose.Slides.Charts.ChartType.Treemap, 50, 50, 500, 400); chart.ChartData.Categories.Clear(); chart.ChartData.Series.Clear(); IChartDataWorkbook wb = chart.ChartData.ChartDataWorkbook; wb.Clear(0); //branch 1 IChartCategory leaf = chart.ChartData.Categories.Add(wb.GetCell(0, "C1", "Leaf1")); leaf.GroupingLevels.SetGroupingItem(1, "Stem1"); leaf.GroupingLevels.SetGroupingItem(2, "Branch1"); chart.ChartData.Categories.Add(wb.GetCell(0, "C2", "Leaf2")); leaf = chart.ChartData.Categories.Add(wb.GetCell(0, "C3", "Leaf3")); leaf.GroupingLevels.SetGroupingItem(1, "Stem2"); chart.ChartData.Categories.Add(wb.GetCell(0, "C4", "Leaf4")); //branch 2 leaf = chart.ChartData.Categories.Add(wb.GetCell(0, "C5", "Leaf5")); leaf.GroupingLevels.SetGroupingItem(1, "Stem3"); leaf.GroupingLevels.SetGroupingItem(2, "Branch2"); chart.ChartData.Categories.Add(wb.GetCell(0, "C6", "Leaf6")); leaf = chart.ChartData.Categories.Add(wb.GetCell(0, "C7", "Leaf7")); leaf.GroupingLevels.SetGroupingItem(1, "Stem4"); chart.ChartData.Categories.Add(wb.GetCell(0, "C8", "Leaf8")); IChartSeries series = chart.ChartData.Series.Add(Aspose.Slides.Charts.ChartType.Treemap); series.Labels.DefaultDataLabelFormat.ShowCategoryName = true; series.DataPoints.AddDataPointForTreemapSeries(wb.GetCell(0, "D1", 4)); series.DataPoints.AddDataPointForTreemapSeries(wb.GetCell(0, "D2", 5)); series.DataPoints.AddDataPointForTreemapSeries(wb.GetCell(0, "D3", 3)); series.DataPoints.AddDataPointForTreemapSeries(wb.GetCell(0, "D4", 6)); series.DataPoints.AddDataPointForTreemapSeries(wb.GetCell(0, "D5", 9)); series.DataPoints.AddDataPointForTreemapSeries(wb.GetCell(0, "D6", 9)); series.DataPoints.AddDataPointForTreemapSeries(wb.GetCell(0, "D7", 4)); series.DataPoints.AddDataPointForTreemapSeries(wb.GetCell(0, "D8", 3)); series.ParentLabelLayout = ParentLabelLayoutType.Overlapping; pres.Save("Treemap.pptx", SaveFormat.Pptx); } }
public static void Run() { //ExStart:MultiCategoryChart // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Charts(); 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(dataDir + "AsposeChart_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx); //ExEnd:MultiCategoryChart }
//ExStart:BoxChart public static void Run() { string dataDir = RunExamples.GetDataDir_Charts(); using (Presentation pres = new Presentation(dataDir + "test.pptx")) { IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.BoxAndWhisker, 50, 50, 500, 400); chart.ChartData.Categories.Clear(); chart.ChartData.Series.Clear(); IChartDataWorkbook wb = chart.ChartData.ChartDataWorkbook; wb.Clear(0); chart.ChartData.Categories.Add(wb.GetCell(0, "A1", "Category 1")); chart.ChartData.Categories.Add(wb.GetCell(0, "A2", "Category 1")); chart.ChartData.Categories.Add(wb.GetCell(0, "A3", "Category 1")); chart.ChartData.Categories.Add(wb.GetCell(0, "A4", "Category 1")); chart.ChartData.Categories.Add(wb.GetCell(0, "A5", "Category 1")); chart.ChartData.Categories.Add(wb.GetCell(0, "A6", "Category 1")); IChartSeries series = chart.ChartData.Series.Add(ChartType.BoxAndWhisker); series.QuartileMethod = QuartileMethodType.Exclusive; series.ShowMeanLine = true; series.ShowMeanMarkers = true; series.ShowInnerPoints = true; series.ShowOutlierPoints = true; series.DataPoints.AddDataPointForBoxAndWhiskerSeries(wb.GetCell(0, "B1", 15)); series.DataPoints.AddDataPointForBoxAndWhiskerSeries(wb.GetCell(0, "B2", 41)); series.DataPoints.AddDataPointForBoxAndWhiskerSeries(wb.GetCell(0, "B3", 16)); series.DataPoints.AddDataPointForBoxAndWhiskerSeries(wb.GetCell(0, "B4", 10)); series.DataPoints.AddDataPointForBoxAndWhiskerSeries(wb.GetCell(0, "B5", 23)); series.DataPoints.AddDataPointForBoxAndWhiskerSeries(wb.GetCell(0, "B6", 16)); pres.Save("BoxAndWhisker.pptx", SaveFormat.Pptx); } }