//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);
            }
        }
Example #2
0
        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
        }