Spire.Presentation 7.7.5 supports creating new chart types in PowerPoint2016

2022-07-15 00:58:38

We are excited to announce the release of Spire.Presentation 7.7.5. This version supports the creation of new chart types defined in PowerPoint 2016, namely Waterfall, Treemap, Boxandwhisker, Histogram, Pareto, and SunBurst. This release provides the SlidePicture.Crop() method supporting cropping slide pictures and provides the InsertPicture(stream) mehtod to insert pictures to slide from file stream. More details are listed below.

Here is a list of changes made in this release

Category ID Description
New feature SPIREPPT-1965 Supports cropping slide picture.
SlidePicture slidePicture =    (SlidePicture)presentation.Slides[0].Shapes[0];
slidePicture.Crop(float x, float y, float   width, float height);
New feature SPIREPPT-1984 Provides InsertPicture(stream) to insert picture from file stream.
presentation.Slides[0].Shapes[0].InsertPicture(Stream stream)
New feature - Supports creating new chart types in PowerPoint2016 (Waterfall, Treemap, Boxandwhisker, Histogram, Pareto, SunBurst).
  public void CreateWaterFall(Presentation ppt)
  {
      IChart chart = ppt.Slides[0].Shapes.AppendChart(ChartType.WaterFall, new RectangleF(50, 50, 500, 400), false);
      chart.ChartData[0, 1].Text = "Series 1";
      string[] categories = { "Category 1", "Category 2", "Category 3", "Category 4", "Category 5", "Category 6", "Category 7" };
      for (int i = 0; i < categories.Length; i++)
      {
          chart.ChartData[i + 1, 0].Text = categories[i];
      }
      double[] values = { 100, 20, 50, -40, 130, -60, 70 };
      for (int i = 0; i < values.Length; i++)
      {
          chart.ChartData[i + 1, 1].NumberValue = values[i];
      }
      chart.Series.SeriesLabel = chart.ChartData[0, 1, 0, 1];
      chart.Categories.CategoryLabels = chart.ChartData[1, 0, categories.Length, 0];
      chart.Series[0].Values = chart.ChartData[1, 1, values.Length, 1];

      ChartDataPoint chartDataPoint = new ChartDataPoint(chart.Series[0]);
      chartDataPoint.Index = 2;
      chartDataPoint.SetAsTotal = true;
      chart.Series[0].DataPoints.Add(chartDataPoint);
      ChartDataPoint chartDataPoint2 = new ChartDataPoint(chart.Series[0]);
      chartDataPoint2.Index = 5;
      chartDataPoint2.SetAsTotal = true;
      chart.Series[0].DataPoints.Add(chartDataPoint2);
      chart.Series[0].ShowConnectorLines = true;
      chart.Series[0].DataLabels.LabelValueVisible = true;
      chart.ChartLegend.Position = ChartLegendPositionType.Right;
      chart.ChartTitle.TextProperties.Text = "WaterFall";
  }
  public void CreateTreeMap(Presentation ppt)
  {
      IChart chart = ppt.Slides[0].Shapes.AppendChart(ChartType.TreeMap, new RectangleF(50, 50, 500, 400), false);
      chart.ChartData[0, 3].Text = "Series 1";

      string[,] categories = {{"Branch 1","Stem 1","Leaf 1"},{"Branch 1","Stem 1","Leaf 2"},{"Branch 1","Stem 1", "Leaf 3"},
           {"Branch 1","Stem 2","Leaf 4"},{"Branch 1","Stem 2","Leaf 5"},{"Branch 1","Stem 2","Leaf 6"},{"Branch 1","Stem 2","Leaf 7"},
           {"Branch 2","Stem 3","Leaf 8"},{"Branch 2","Stem 3","Leaf 9"},{"Branch 2","Stem 4","Leaf 10"},{"Branch 2","Stem 4","Leaf 11"},
           {"Branch 2","Stem 5","Leaf 12"},{"Branch 3","Stem 5","Leaf 13"},{"Branch 3","Stem 6","Leaf 14"},{"Branch 3","Stem 6","Leaf 15"}};

      for (int i = 0; i < 15; i++)
      {
          for (int j = 0; j < 3; j++)
              chart.ChartData[i + 1, j].Text = categories[i, j];
      }
      double[] values = { 17, 23, 48, 22, 76, 54, 77, 26, 44, 63, 10, 15, 48, 15, 51 };
      for (int i = 0; i < values.Length; i++)
      {
          chart.ChartData[i + 1, 3].NumberValue = values[i];
      }
      chart.Series.SeriesLabel = chart.ChartData[0, 3, 0, 3];
      chart.Categories.CategoryLabels = chart.ChartData[1, 0, values.Length, 2];
      chart.Series[0].Values = chart.ChartData[1, 3, values.Length, 3];

      chart.Series[0].DataLabels.CategoryNameVisible = true;
      chart.Series[0].TreeMapLabelOption = TreeMapLabelOption.Banner;
      chart.ChartTitle.TextProperties.Text = "TreeMap";

      chart.HasLegend = true;
      chart.ChartLegend.Position = ChartLegendPositionType.Top;
  }
  public void CreateSunBurs(Presentation ppt)
  {
      IChart chart = ppt.Slides[0].Shapes.AppendChart(ChartType.SunBurst, new RectangleF(50, 50, 500, 400), false);
      chart.ChartData[0, 3].Text = "Series 1";

      string[,] categories = {{"Branch 1","Stem 1","Leaf 1"},{"Branch 1","Stem 1","Leaf 2"},{"Branch 1","Stem 1", "Leaf 3"},
           {"Branch 1","Stem 2","Leaf 4"},{"Branch 1","Stem 2","Leaf 5"},{"Branch 1","Leaf 6",null},{"Branch 1","Leaf 7", null},
           {"Branch 2","Stem 3","Leaf 8"},{"Branch 2","Leaf 9",null},{"Branch 2","Stem 4","Leaf 10"},{"Branch 2","Stem 4","Leaf 11"},
           {"Branch 2","Stem 5","Leaf 12"},{"Branch 3","Stem 5","Leaf 13"},{"Branch 3","Stem 6","Leaf 14"},{"Branch 3","Leaf 15",null}};

      for (int i = 0; i < 15; i++)
      {
          for (int j = 0; j < 3; j++)
              chart.ChartData[i + 1, j].Value = categories[i, j];
      }
      double[] values = { 17, 23, 48, 22, 76, 54, 77, 26, 44, 63, 10, 15, 48, 15, 51 };
      for (int i = 0; i < values.Length; i++)
      {
          chart.ChartData[i + 1, 3].NumberValue = values[i];
      }
      chart.Series.SeriesLabel = chart.ChartData[0, 3, 0, 3];
      chart.Categories.CategoryLabels = chart.ChartData[1, 0, values.Length, 2];
      chart.Series[0].Values = chart.ChartData[1, 3, values.Length, 3];

      chart.Series[0].DataLabels.CategoryNameVisible = true;

      chart.ChartTitle.TextProperties.Text = "SunBurst";

      chart.HasLegend = true;
      chart.ChartLegend.Position = ChartLegendPositionType.Top;
  }
  public void CreatePareto(Presentation ppt)
  {
      IChart chart = ppt.Slides[0].Shapes.AppendChart(ChartType.Pareto, new RectangleF(50, 50, 500, 400), false);

      chart.ChartData[0, 1].Text = "Series 1";

      string[] categories = { "Category 1", "Category 2", "Category 4", "Category 3", "Category 4", "Category 2", "Category 1",
          "Category 1", "Category 3", "Category 2", "Category 4", "Category 2", "Category 3",
          "Category 1", "Category 3", "Category 2", "Category 4", "Category 1", "Category 1",
          "Category 3", "Category 2", "Category 4", "Category 1", "Category 1", "Category 3",
          "Category 2", "Category 4", "Category 1"};
      for (int i = 0; i < categories.Length; i++)
      {
          chart.ChartData[i + 1, 0].Text = categories[i];
      }

      double[] values = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
      for (int i = 0; i < values.Length; i++)
      {
          chart.ChartData[i + 1, 1].NumberValue = values[i];
      }
      chart.Series.SeriesLabel = chart.ChartData[0, 1, 0, 1];
      chart.Categories.CategoryLabels = chart.ChartData[1, 0, categories.Length, 0];
      chart.Series[0].Values = chart.ChartData[1, 1, values.Length, 1];

      chart.PrimaryCategoryAxis.IsBinningByCategory = true;

      chart.Series[1].Line.FillFormat.FillType = FillFormatType.Solid;
      chart.Series[1].Line.FillFormat.SolidFillColor.Color = Color.Red;

      chart.ChartTitle.TextProperties.Text = "Pareto";

      chart.HasLegend = true;
      chart.ChartLegend.Position = ChartLegendPositionType.Bottom;
  }
  public void CreateHistogram(Presentation ppt)
  {
      IChart chart = ppt.Slides[0].Shapes.AppendChart(ChartType.Histogram, new RectangleF(50, 50, 500, 400), false);
      chart.ChartData[0, 0].Text = "Series 1";
      double[] values = { 1, 1, 1, 3, 3, 3, 3, 5, 5, 5, 8, 8, 8, 9, 9, 9, 12, 12, 13, 13, 17, 17, 17, 19,
          19, 19, 25, 25, 25, 25, 25, 25, 25, 25, 29, 29, 29, 29, 32, 32, 33, 33, 35, 35, 41, 41, 44, 45, 49, 49 };

      for (int i = 0; i < values.Length; i++)
      {
          chart.ChartData[i + 1, 1].NumberValue = values[i];
      }
      chart.Series.SeriesLabel = chart.ChartData[0, 0, 0, 0];
      chart.Series[0].Values = chart.ChartData[1, 0, values.Length, 0];

      chart.PrimaryCategoryAxis.NumberOfBins = 7;

      chart.PrimaryCategoryAxis.GapWidth = 20;

      chart.ChartTitle.TextProperties.Text = "Histogram";

      chart.ChartLegend.Position = ChartLegendPositionType.Bottom;
  }
  public void CreateBoxAndWhisker(Presentation ppt)
  {
      IChart chart = ppt.Slides[0].Shapes.AppendChart(ChartType.BoxAndWhisker, new RectangleF(50, 50, 500, 400), false);
      string[] seriesLabel = { "Series 1", "Series 2", "Series 3" };


      for (int i = 0; i < seriesLabel.Length; i++)
      {

          chart.ChartData[0, i + 1].Text = "Series 1";
      }
      string[] categories = {"Category 1", "Category 1", "Category 1", "Category 1", "Category 1", "Category 1", "Category 1",
           "Category 2", "Category 2", "Category 2", "Category 2", "Category 2", "Category 2",
           "Category 3", "Category 3", "Category 3", "Category 3", "Category 3"};
      for (int i = 0; i < categories.Length; i++)
      {
          chart.ChartData[i + 1, 0].Text = categories[i];
      }
      double[,] values = new double[18, 3]{{-7,-3,-24},{-10,1,11},{-28,-6,34},{47,2,-21},{35,17,22},{-22,15,19},{17,-11,25},
                       {-30,18,25},{49,22,56},{37,22,15},{-55,25,31},{14,18,22},{18,-22,36},{-45,25,-17},
                       {-33,18,22},{18,2,-23},{-33,-22,10},{10,19,22}};

      for (int i = 0; i < seriesLabel.Length; i++)
      {
          for (int j = 0; j < categories.Length; j++)
          {
              chart.ChartData[j + 1, i + 1].NumberValue = values[j, i];
          }
      }
      chart.Series.SeriesLabel = chart.ChartData[0, 1, 0, seriesLabel.Length];
      chart.Categories.CategoryLabels = chart.ChartData[1, 0, categories.Length, 0];

      chart.Series[0].Values = chart.ChartData[1, 1, categories.Length, 1];
      chart.Series[1].Values = chart.ChartData[1, 2, categories.Length, 2];
      chart.Series[2].Values = chart.ChartData[1, 3, categories.Length, 3];

      chart.Series[0].ShowInnerPoints = false;
      chart.Series[0].ShowOutlierPoints = true;
      chart.Series[0].ShowMeanMarkers = true;
      chart.Series[0].ShowMeanLine = true;
      chart.Series[0].QuartileCalculationType = QuartileCalculation.ExclusiveMedian;

      chart.Series[1].ShowInnerPoints = false;
      chart.Series[1].ShowOutlierPoints = true;
      chart.Series[1].ShowMeanMarkers = true;
      chart.Series[1].ShowMeanLine = true;
      chart.Series[1].QuartileCalculationType = QuartileCalculation.InclusiveMedian;

      chart.Series[2].ShowInnerPoints = false;
      chart.Series[2].ShowOutlierPoints = true;
      chart.Series[2].ShowMeanMarkers = true;
      chart.Series[2].ShowMeanLine = true;
      chart.Series[2].QuartileCalculationType = QuartileCalculation.ExclusiveMedian;

      chart.HasLegend = true;
      chart.ChartTitle.TextProperties.Text = "BoxAndWhisker";
      chart.ChartLegend.Position = ChartLegendPositionType.Top;
  }
Click the link to download Spire. Presentation 7.7.5
More information of Spire.Presentation new release or hotfix: