Spire.Presentation is a professional PowerPoint® compatible library that enables developers to create, read, write, modify, convert and Print PowerPoint documents. Get free and professional technical support for Spire.Presentation for .NET, Java, Android, C++, Python.

Wed Oct 03, 2018 7:15 am

Hi,

I need to create a thermometer chart. By default I am getting 3 Series and 4 categories but i need only 1 Series and 1 Catgeories. I am unable to create the chart. I am trying to achieve this using a column clustered chart. Thanks.
Here's my code:
RectangleF rect3 = new RectangleF(1095, 105, 146, 437);
IChart clusteredChart = presentation.Slides[1].Shapes.AppendChart(Spire.Presentation.Charts.ChartType.ColumnClustered, rect3);
clusteredChart.ChartTitle.TextProperties.Text = " ";
clusteredChart.ChartTitle.TextProperties.IsCentered = true;
clusteredChart.ChartTitle.Height = 1;
clusteredChart.HasTitle = true;
clusteredChart.HasLegend = false;
clusteredChart.PlotArea.Height = 350;
//remove grid lines
clusteredChart.PrimaryValueAxis.MajorGridTextLines.FillType = FillFormatType.Solid;
clusteredChart.PrimaryValueAxis.MajorGridTextLines.FillFormat.SolidFillColor.Color = Color.White;
clusteredChart.PrimaryCategoryAxis.MajorGridTextLines.FillType = FillFormatType.None;
clusteredChart.PrimaryValueAxis.IsAutoMax = false;
clusteredChart.PrimaryValueAxis.IsAutoMin = false;
clusteredChart.PrimaryValueAxis.MinValue = 0;
clusteredChart.PrimaryValueAxis.MaxValue = 10;
//remove horinzotal and vertical axis.
clusteredChart.PrimaryCategoryAxis.IsVisible = false;
clusteredChart.PrimaryValueAxis.IsVisible = false;
// remove series
clusteredChart.Series.RemoveAt(2);
clusteredChart.Series.RemoveAt(1);
clusteredChart.Series.Capacity = 1;
clusteredChart.Categories.Capacity = 1;
clusteredChart.Categories.RemoveAt(2);
clusteredChart.Categories.RemoveAt(1);
clusteredChart.Categories.RemoveAt(0);
for (int j = 0; j < 4; j++)
{
clusteredChart.ChartData[j + 1, 1].Value = 8.1;
clusteredChart.Series[0].Values[j].Value = 8.1;

}

//set border
clusteredChart.Series[0].Line.FillType = FillFormatType.Solid;
clusteredChart.Series[0].Line.SolidFillColor.Color = Color.White;
clusteredChart.Series[0].Fill.SolidColor.KnownColor = KnownColors.Gray;
clusteredChart.GapWidth = 25;
clusteredChart.OverLap = 100;
RectangleF rectEllipse = new RectangleF(1102, 461, 127, 127);
IAutoShape ellipse = presentation.Slides[1].Shapes.AppendShape(ShapeType.Ellipse, rectEllipse);
ellipse.Fill.FillType = FillFormatType.Solid;
ellipse.Fill.SolidColor.Color = Color.FromArgb(216, 59, 1);
ellipse.Line.FillType = FillFormatType.None;

Mudz7
 
Posts: 1
Joined: Mon Sep 10, 2018 10:35 am

Wed Oct 03, 2018 12:41 pm

Hello,

Thanks for your inquiry.
Please refer to below code to have a try. If it doesn't meet your need,please provide your expected output for our reference.
Code: Select all
Presentation presentation = new Presentation();
presentation.LoadFromFile("test.pptx");
RectangleF rect3 = new RectangleF(1095, 105, 146, 437);
IChart clusteredChart = presentation.Slides[1].Shapes.AppendChart(Spire.Presentation.Charts.ChartType.ColumnClustered, rect3);
clusteredChart.ChartTitle.TextProperties.Text = " ";
clusteredChart.ChartTitle.TextProperties.IsCentered = true;
clusteredChart.ChartTitle.Height = 1;
clusteredChart.HasTitle = true;
clusteredChart.HasLegend = false;
clusteredChart.PlotArea.Height = 350;

//remove grid lines
clusteredChart.PrimaryValueAxis.MajorGridTextLines.FillType = FillFormatType.Solid;
clusteredChart.PrimaryValueAxis.MajorGridTextLines.FillFormat.SolidFillColor.Color = Color.White;
clusteredChart.PrimaryCategoryAxis.MajorGridTextLines.FillType = FillFormatType.None;
clusteredChart.PrimaryValueAxis.IsAutoMax = false;
clusteredChart.PrimaryValueAxis.IsAutoMin = false;
clusteredChart.PrimaryValueAxis.MinValue = 0;
clusteredChart.PrimaryValueAxis.MaxValue = 10;
//remove horinzotal and vertical axis.
clusteredChart.PrimaryCategoryAxis.IsVisible = false;
clusteredChart.PrimaryValueAxis.IsVisible = false;

//Change data
clusteredChart.ChartData[1, 1].Value = 8.1;

//Set Series Label
clusteredChart.Series.SeriesLabel = clusteredChart.ChartData["B1", "B1"];
//Set Category Labels
clusteredChart.Categories.CategoryLabels = clusteredChart.ChartData["A2", "A2"];
//Set series value
clusteredChart.Series[0].Values = clusteredChart.ChartData["B2", "B2"];

//set border
clusteredChart.Series[0].Line.FillType = FillFormatType.Solid;
clusteredChart.Series[0].Line.SolidFillColor.Color = Color.White;
clusteredChart.Series[0].Fill.SolidColor.KnownColor = KnownColors.Gray;
clusteredChart.GapWidth = 25;
clusteredChart.OverLap = 100;
RectangleF rectEllipse = new RectangleF(1102, 461, 127, 127);
IAutoShape ellipse = presentation.Slides[1].Shapes.AppendShape(ShapeType.Ellipse, rectEllipse);
ellipse.Fill.FillType = FillFormatType.Solid;
ellipse.Fill.SolidColor.Color = Color.FromArgb(216, 59, 1);
ellipse.Line.FillType = FillFormatType.None;

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Mon Oct 08, 2018 10:27 am

Hello,

Greetings from E-iceblue.
Did my code help you? Thanks in advance for your valuable feedback and time.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.Presentation