Sorry. its working. i was doing a mistake.
Hi,
As one of my requirements , I also require to have stackedChart as:
30% | |
35% | |
70% | |
60% |
Here we need to display % of area covered by series.
Hi,
However, there has been issue observed in adding custom label. Actually, custom labels are added but only last added custom label is displayed and for first category only. The rest of labels depicts the default chart series values. I have created an issue with ID SLIDESNET-33811 to further investigate and resolve the issue. But the above code will serve the purpose completely for your once the issue will be resolved. I have linked this thread with the issue so that you may be automatically notified once the issue will be fixed.public static void MangeStackedColumnChartProperties(){MemoryStream ms = new MemoryStream();ms.Position = 0;PresentationEx pres = new PresentationEx();SlideEx slide = pres.Slides[0];ChartEx chart = slide.Shapes.AddChart(ChartTypeEx.StackedColumn, 50, 50, 500, 400);//Setting Major and minor grid lines format for value axischart.ValueAxis.MajorGridLines.FillFormat.FillType = FillTypeEx.NoFill;chart.ValueAxis.MinorGridLines.FillFormat.FillType = FillTypeEx.NoFill;chart.CategoryAxis.MajorGridLines.FillFormat.FillType = FillTypeEx.NoFill;chart.CategoryAxis.MinorGridLines.FillFormat.FillType = FillTypeEx.NoFill;//working with chart seriesChartSeriesEx series = chart.ChartData.Series[0];ChartDataWorksheet work = chart.ChartData.Series[0].Values[0].ChartDataWorksheet;ChartDataCellFactory fact = chart.ChartData.ChartDataCellFactory;ChartDataCell cell = fact.GetCell(0, chart.ChartData.Series[0].Values[0].Row, chart.ChartData.Series[0].Values[0].Column);//Adding Series label and its properties//For Category 1double totalSeries = System.Convert.ToDouble(chart.ChartData.Series[0].Values[0].Value) + System.Convert.ToDouble(chart.ChartData.Series[1].Values[0].Value) + System.Convert.ToDouble(chart.ChartData.Series[2].Values[0].Value);double percent1 = (System.Convert.ToDouble(chart.ChartData.Series[0].Values[0].Value) / totalSeries) * 100;double percent2 = (System.Convert.ToDouble(chart.ChartData.Series[1].Values[0].Value) / totalSeries) * 100;double percent3 = (System.Convert.ToDouble(chart.ChartData.Series[2].Values[0].Value) / totalSeries) * 100;String per1 = string.Format("{0:0.##}", percent1);String per2 = string.Format("{0:0.##}", percent2);String per3 = string.Format("{0:0.##}", percent3);//For Category 2double totalSeries2 = System.Convert.ToDouble(chart.ChartData.Series[0].Values[1].Value) + System.Convert.ToDouble(chart.ChartData.Series[1].Values[1].Value) + System.Convert.ToDouble(chart.ChartData.Series[1].Values[0].Value);double percent12 = (System.Convert.ToDouble(chart.ChartData.Series[0].Values[1].Value) / totalSeries2) * 100;double percent22 = (System.Convert.ToDouble(chart.ChartData.Series[1].Values[1].Value) / totalSeries2) * 100;double percent32 = (System.Convert.ToDouble(chart.ChartData.Series[2].Values[1].Value) / totalSeries2) * 100;String per12 = string.Format("{0:0.##}", percent12);String per22 = string.Format("{0:0.##}", percent22);String per32 = string.Format("{0:0.##}", percent32);//For Category 3double totalSeries3 = System.Convert.ToDouble(chart.ChartData.Series[0].Values[2].Value) + System.Convert.ToDouble(chart.ChartData.Series[1].Values[2].Value) + System.Convert.ToDouble(chart.ChartData.Series[2].Values[2].Value);double percent13 = (System.Convert.ToDouble(chart.ChartData.Series[0].Values[2].Value) / totalSeries3) * 100;double percent23 = (System.Convert.ToDouble(chart.ChartData.Series[1].Values[2].Value) / totalSeries3) * 100;double percent33 = (System.Convert.ToDouble(chart.ChartData.Series[2].Values[2].Value) / totalSeries3) * 100;String per13 = string.Format("{0:0.##}", percent13);String per23 = string.Format("{0:0.##}", percent23);String per33= string.Format("{0:0.##}", percent33);//For Category 4double totalSeries4 = System.Convert.ToDouble(chart.ChartData.Series[0].Values[3].Value) + System.Convert.ToDouble(chart.ChartData.Series[1].Values[3].Value) + System.Convert.ToDouble(chart.ChartData.Series[2].Values[3].Value);double percent14 = (System.Convert.ToDouble(chart.ChartData.Series[0].Values[3].Value) / totalSeries4) * 100;double percent24 = (System.Convert.ToDouble(chart.ChartData.Series[1].Values[3].Value) / totalSeries4) * 100;double percent34 = (System.Convert.ToDouble(chart.ChartData.Series[2].Values[3].Value) / totalSeries4) * 100;String per14 = string.Format("{0:0.##}", percent14);String per24 = string.Format("{0:0.##}", percent24);String per34= string.Format("{0:0.##}", percent34);series.Labels.ShowValue = false;series.Labels.ShowSeriesName = false;series.Labels.ShowCategoryName = false;series.Labels.LinkedSource = false;series.Labels.ShowPercentage = false;DataLabelEx label = new DataLabelEx(series);TextFrameEx txt = label.TextFrame;txt.Text = “”;txt.Paragraphs[0].Portions[0].Text = per1+ “%”;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType=FillTypeEx.Solid;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.Red;txt.Paragraphs[0].Portions[0].PortionFormat.FontBold = NullableBool.True;series.Labels.Add(label);DataLabelEx label12 = new DataLabelEx(series);txt = label.TextFrame;txt.Text = “”;txt.Paragraphs[0].Portions[0].Text = per12 + “%”;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType = FillTypeEx.Solid;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.Red;txt.Paragraphs[0].Portions[0].PortionFormat.FontBold = NullableBool.True;series.Labels.Add(label12);DataLabelEx label13 = new DataLabelEx(series);txt = label.TextFrame;txt.Text = “”;txt.Paragraphs[0].Portions[0].Text = per13 + “%”;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType = FillTypeEx.Solid;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.Red;txt.Paragraphs[0].Portions[0].PortionFormat.FontBold = NullableBool.True;series.Labels.Add(label13);DataLabelEx label14 = new DataLabelEx(series);txt = label.TextFrame;txt.Text = “”;txt.Paragraphs[0].Portions[0].Text = per14 + “%”;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType = FillTypeEx.Solid;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.Red;txt.Paragraphs[0].Portions[0].PortionFormat.FontBold = NullableBool.True;series.Labels.Add(label14);series.Labels.Position = LegendDataLabelPositionEx.BestFit;/* series.Labels.TextProperties.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontHeight = 20;series.Labels.TextProperties.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontBold = NullableBool.True;series.Labels.TextProperties.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontItalic = NullableBool.True;series.Labels.TextProperties.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FillFormat.FillType = FillTypeEx.Solid;series.Labels.TextProperties.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FillFormat.SolidFillColor.Color = Color.DarkGreen;*/ChartSeriesEx series2 = chart.ChartData.Series[1];DataLabelEx label2 = new DataLabelEx(series2);txt = label2.TextFrame;txt.Text = “”;txt.Paragraphs[0].Portions[0].Text = per2 + “%”;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType = FillTypeEx.Solid;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.Red;txt.Paragraphs[0].Portions[0].PortionFormat.FontBold = NullableBool.True;series2.Labels.Add(label2);DataLabelEx label22 = new DataLabelEx(series2);txt = label22.TextFrame;txt.Text = “”;txt.Paragraphs[0].Portions[0].Text = per22 + “%”;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType = FillTypeEx.Solid;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.Red;txt.Paragraphs[0].Portions[0].PortionFormat.FontBold = NullableBool.True;series2.Labels.Add(label22);DataLabelEx label23 = new DataLabelEx(series2);txt = label23.TextFrame;txt.Text = “”;txt.Paragraphs[0].Portions[0].Text = per23 + “%”;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType = FillTypeEx.Solid;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.Red;txt.Paragraphs[0].Portions[0].PortionFormat.FontBold = NullableBool.True;series2.Labels.Add(label23);DataLabelEx label24 = new DataLabelEx(series2);txt = label24.TextFrame;txt.Text = “”;txt.Paragraphs[0].Portions[0].Text = per24 + “%”;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType = FillTypeEx.Solid;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.Red;txt.Paragraphs[0].Portions[0].PortionFormat.FontBold = NullableBool.True;series2.Labels.Add(label24);ChartSeriesEx series3 = chart.ChartData.Series[2];DataLabelEx label3 = new DataLabelEx(series3);txt = label3.TextFrame;txt.Text = “”;txt.Paragraphs[0].Portions[0].Text = per3 + “%”;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType = FillTypeEx.Solid;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.Red;txt.Paragraphs[0].Portions[0].PortionFormat.FontBold = NullableBool.True;series3.Labels.Add(label3);DataLabelEx label32 = new DataLabelEx(series3);txt = label32.TextFrame;txt.Text = “”;txt.Paragraphs[0].Portions[0].Text = per32 + “%”;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType = FillTypeEx.Solid;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.Red;txt.Paragraphs[0].Portions[0].PortionFormat.FontBold = NullableBool.True;series3.Labels.Add(label32);DataLabelEx label33 = new DataLabelEx(series3);txt = label33.TextFrame;txt.Text = “”;txt.Paragraphs[0].Portions[0].Text = per33 + “%”;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType = FillTypeEx.Solid;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.Red;txt.Paragraphs[0].Portions[0].PortionFormat.FontBold = NullableBool.True;series3.Labels.Add(label33);DataLabelEx label34 = new DataLabelEx(series3);txt = label34.TextFrame;txt.Text = “”;txt.Paragraphs[0].Portions[0].Text = per34 + “%”;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType = FillTypeEx.Solid;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.Red;txt.Paragraphs[0].Portions[0].PortionFormat.FontBold = NullableBool.True;series3.Labels.Add(label34);// series.Labels.NumberFormat = “0.0%”;chart.GapDepth = 0;//Values in percentagechart.GapWidth = 0;//Saving Presentationpres.Write(“D:\Aspose Data\AxisValue.pptx”);}
Hi,
AS suggested by you I am not able to do formating of numeric label values
Hi,
public static void MangeChartProperties(){PresentationEx pres = new PresentationEx();SlideEx slide = pres.Slides[0];ChartEx chart = slide.Shapes.AddChart(ChartTypeEx.LineWithMarkers, 50, 50, 500, 400);//Setting Major and minor grid lines format for value axischart.ValueAxis.MajorGridLines.FillFormat.FillType = FillTypeEx.Solid;chart.ValueAxis.MajorGridLines.FillFormat.SolidFillColor.Color = Color.Blue;chart.ValueAxis.MajorGridLines.Width = 5;chart.ValueAxis.MinorGridLines.FillFormat.FillType = FillTypeEx.Solid;chart.ValueAxis.MinorGridLines.FillFormat.SolidFillColor.Color = Color.Red;chart.ValueAxis.MinorGridLines.Width = 3;chart.ValueAxis.SourceLinked = false;// chart.ValueAxis.DisplayUnit = DisplayUnitType.Millions;chart.ValueAxis.DisplayUnit = DisplayUnitType.Thousands;chart.ValueAxis.NumberFormat = “0.0%”;//Setting chart maximum, minimum valueschart.ValueAxis.IsAutomaticMajorUnit = false;chart.ValueAxis.IsAutomaticMaxValue = false;chart.ValueAxis.IsAutomaticMinorUnit = false;chart.ValueAxis.IsAutomaticMinValue = false;chart.ValueAxis.MaxValue = 15f;chart.ValueAxis.MinValue = -2f;chart.ValueAxis.MinorUnit = 0.5f;chart.ValueAxis.MajorUnit = 2.0f;//Setting Major and minor grid lines format for Category axischart.CategoryAxis.MajorGridLines.FillFormat.FillType = FillTypeEx.Solid;chart.CategoryAxis.MajorGridLines.FillFormat.SolidFillColor.Color = Color.Green;chart.CategoryAxis.MajorGridLines.Width = 5;chart.CategoryAxis.MinorGridLines.FillFormat.FillType = FillTypeEx.Solid;chart.CategoryAxis.MinorGridLines.FillFormat.SolidFillColor.Color = Color.Yellow;chart.CategoryAxis.MinorGridLines.Width = 3;//Setting Category Axis Text PropertiesTextFrameEx txt = chart.CategoryAxis.TextProperties;txt.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontBold = NullableBool.True;txt.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontHeight = 20;txt.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontItalic = NullableBool.True;txt.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FillFormat.FillType = FillTypeEx.Solid; ;txt.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FillFormat.SolidFillColor.Color = Color.Blue;//Setting Value Axis Text PropertiesTextFrameEx txt2 = chart.ValueAxis.TextProperties;txt2.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontBold = NullableBool.True;txt2.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontHeight = 20;txt2.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontItalic = NullableBool.True;txt2.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FillFormat.FillType = FillTypeEx.Solid; ;txt2.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FillFormat.SolidFillColor.Color = Color.Blue;//Setting Legends Text PropertiesTextFrameEx txt3 = chart.Legend.TextProperties;txt3.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontBold = NullableBool.True;txt3.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontHeight = 20;txt3.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontItalic = NullableBool.True;txt3.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FillFormat.FillType = FillTypeEx.Solid; ;txt3.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FillFormat.SolidFillColor.Color = Color.Blue;chart.ValueAxis.AxisLine.Width = 10;chart.ValueAxis.AxisLine.FillFormat.FillType = FillTypeEx.Solid;chart.ValueAxis.AxisLine.FillFormat.SolidFillColor.Color = Color.Red;chart.SecondValueAxis.IsVisible = true;chart.SecondValueAxis.AxisLine.Style = LineStyleEx.ThickBetweenThin;chart.SecondValueAxis.AxisLine.Width = 20;// TextFrameEx tf=chart.SecondValueAxis.Title.Text;//Setting chart back wall colorchart.ChartFormat.Fill.FillType = FillTypeEx.Solid;chart.ChartFormat.Fill.SolidFillColor.Color = Color.Orange;//Setting Plot area colorchart.PlotArea.Format.Fill.FillType = FillTypeEx.Solid;chart.PlotArea.Format.Fill.SolidFillColor.Color = Color.LightCyan;//working with chart seriesChartSeriesEx series = chart.ChartData.Series[0];//Setting marker and its properties for chart seriesseries.MarkerSymbol = MarkerStyleTypeEx.Diamond;series.MarkerSize = 20;series.MarkerFill.Fill.FillType = FillTypeEx.Solid;series.MarkerFill.Fill.SolidFillColor.Color = Color.RosyBrown;series.MarkerFill.Line.Width = 2;series.MarkerFill.Line.FillFormat.FillType = FillTypeEx.Solid;series.MarkerFill.Line.FillFormat.SolidFillColor.Color = Color.Chocolate;//Setting Line format for chart seriesseries.Format.Line.DashStyle = LineDashStyleEx.Dot;series.Format.Line.Style = LineStyleEx.ThickThin;series.Format.Line.Width = 5d;series.Format.Fill.FillType = FillTypeEx.Solid;series.Format.Fill.SolidFillColor.Color = Color.Black;//Plotting series on secondary axisseries.PlotOnSecondAxis = true;//Adding Series label and its propertiesDataLabelEx label = new DataLabelEx(series);series.Labels.Add(label);series.Labels.ShowValue = true;series.Labels.ShowSeriesName = false;series.Labels.ShowCategoryName = false;series.Labels.LinkedSource = false;// series.Labels.NumberFormat = “0.0%”;series.Values[0].Value = 4.35657;series.Values[1].Value = 2.45325657;series.Values[2].Value = 6.565657;series.Values[3].Value = 3.675657;series.Labels.NumberFormat = “#,##0.00”;series.Labels.TextProperties.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontHeight = 20;series.Labels.TextProperties.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontBold = NullableBool.True;series.Labels.TextProperties.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontItalic = NullableBool.True;series.Labels.TextProperties.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FillFormat.FillType = FillTypeEx.Solid;series.Labels.TextProperties.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FillFormat.SolidFillColor.Color = Color.DarkGreen;//Saving Presentationpres.Write(“D:\Aspose Data\AxisValue.pptx”);}
Hi,
I am not able to set title for Y-Axis doing this:
chart.ValueAxis.Title.Text.Text = "Numbers in billion";
Please let me know the correct code.
Thanks
I was not setting this propert:
chart.ValueAxis.HasTitle = true;
Now its working
Hi,
Hi ,
Now I have a requirement of displaying data as follows:
40 | 40 | ||||||
30 | |||||||
25 | 25 | ||||||
20 | |||||||
2000 | 2001 | 2002 | 2003 | 2004-jan | 2004-feb |
Here first 4 column has the data for the whole year. But for the year 2004 we have data for the first two months and rest of the months data is awaited. Please help me accomplishing this requirement.
Thanks
I also want to display value as :
2.00E+07
This is not working
//shows values
series.Labels.ShowValue = true;
series.Labels.NumberFormat = "0.00E+00";
Hi,
Please let me know if there is any update on my last two queries. I am just trying to know the feasibilty to achieve, with the current version of aspose chart.
Thanks.
Hi,
PresentationEx pres = new PresentationEx();SlideEx slide = pres.Slides[0];// ChartEx chart = slide.Shapes.AddChart(ChartTypeEx.LineWithMarkers, 50, 50, 500, 400);ChartEx chart = slide.Shapes.AddChart(ChartTypeEx.ClusteredColumn, 50, 50, 500, 400);//Setting Major and minor grid lines format for value axischart.ValueAxis.MajorGridLines.FillFormat.FillType = FillTypeEx.Solid;chart.ValueAxis.MajorGridLines.FillFormat.SolidFillColor.Color = Color.Blue;chart.ValueAxis.MajorGridLines.Width = 5;chart.ValueAxis.MinorGridLines.FillFormat.FillType = FillTypeEx.Solid;chart.ValueAxis.MinorGridLines.FillFormat.SolidFillColor.Color = Color.Red;chart.ValueAxis.MinorGridLines.Width = 3;chart.ValueAxis.SourceLinked = false;// chart.ValueAxis.DisplayUnit = DisplayUnitType.Millions;chart.ValueAxis.DisplayUnit = Aspose.Slides.Pptx.Charts.DisplayUnitType.Thousands;chart.ValueAxis.NumberFormat = “0.0%”;//Setting chart maximum, minimum valueschart.ValueAxis.IsAutomaticMajorUnit = false;chart.ValueAxis.IsAutomaticMaxValue = false;chart.ValueAxis.IsAutomaticMinorUnit = false;chart.ValueAxis.IsAutomaticMinValue = false;chart.ValueAxis.MaxValue = 15f;chart.ValueAxis.MinValue = -2f;chart.ValueAxis.MinorUnit = 0.5f;chart.ValueAxis.MajorUnit = 2.0f;//Setting Major and minor grid lines format for Category axischart.CategoryAxis.MajorGridLines.FillFormat.FillType = FillTypeEx.Solid;chart.CategoryAxis.MajorGridLines.FillFormat.SolidFillColor.Color = Color.Green;chart.CategoryAxis.MajorGridLines.Width = 5;chart.CategoryAxis.MinorGridLines.FillFormat.FillType = FillTypeEx.Solid;chart.CategoryAxis.MinorGridLines.FillFormat.SolidFillColor.Color = Color.Yellow;chart.CategoryAxis.MinorGridLines.Width = 3;//Setting Category Axis Text PropertiesTextFrameEx txt = chart.CategoryAxis.TextProperties;txt.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontBold = NullableBool.True;txt.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontHeight = 20;txt.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontItalic = NullableBool.True;txt.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FillFormat.FillType = FillTypeEx.Solid; ;txt.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FillFormat.SolidFillColor.Color = Color.Blue;//Setting Value Axis Text PropertiesTextFrameEx txt2 = chart.ValueAxis.TextProperties;txt2.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontBold = NullableBool.True;txt2.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontHeight = 20;txt2.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontItalic = NullableBool.True;txt2.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FillFormat.FillType = FillTypeEx.Solid; ;txt2.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FillFormat.SolidFillColor.Color = Color.Blue;//Setting Legends Text PropertiesTextFrameEx txt3 = chart.Legend.TextProperties;txt3.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontBold = NullableBool.True;txt3.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontHeight = 20;txt3.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontItalic = NullableBool.True;txt3.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FillFormat.FillType = FillTypeEx.Solid; ;txt3.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FillFormat.SolidFillColor.Color = Color.Blue;chart.ValueAxis.AxisLine.Width = 10;chart.ValueAxis.AxisLine.FillFormat.FillType = FillTypeEx.Solid;chart.ValueAxis.AxisLine.FillFormat.SolidFillColor.Color = Color.Red;chart.SecondValueAxis.IsVisible = true;chart.SecondValueAxis.AxisLine.Style = LineStyleEx.ThickBetweenThin;chart.SecondValueAxis.AxisLine.Width = 20;// TextFrameEx tf=chart.SecondValueAxis.Title.Text;//Setting chart back wall colorchart.ChartFormat.Fill.FillType = FillTypeEx.Solid;chart.ChartFormat.Fill.SolidFillColor.Color = Color.Orange;//Setting Plot area colorchart.PlotArea.Format.Fill.FillType = FillTypeEx.Solid;chart.PlotArea.Format.Fill.SolidFillColor.Color = Color.LightCyan;//working with chart seriesChartSeriesEx series = chart.ChartData.Series[0];//Setting marker and its properties for chart seriesseries.MarkerSymbol = MarkerStyleTypeEx.Diamond;series.MarkerSize = 20;series.MarkerFill.Fill.FillType = FillTypeEx.Solid;series.MarkerFill.Fill.SolidFillColor.Color = Color.RosyBrown;series.MarkerFill.Line.Width = 2;series.MarkerFill.Line.FillFormat.FillType = FillTypeEx.Solid;series.MarkerFill.Line.FillFormat.SolidFillColor.Color = Color.Chocolate;//Setting Line format for chart seriesseries.Format.Line.DashStyle = LineDashStyleEx.Dot;series.Format.Line.Style = LineStyleEx.Single;series.Format.Line.Width = 5d;series.Format.Line.FillFormat.FillType = FillTypeEx.Solid;series.Format.Line.FillFormat.SolidFillColor.Color = Color.Red;series.Format.Fill.FillType = FillTypeEx.Solid;series.Format.Fill.SolidFillColor.Color = Color.Black;//Plotting series on secondary axisseries.PlotOnSecondAxis = true;//Adding Series label and its propertiesDataLabelEx label = new DataLabelEx(series);series.Labels.Add(label);series.Labels.ShowValue = true;series.Labels.ShowSeriesName = false;series.Labels.ShowCategoryName = false;series.Labels.LinkedSource = false;// series.Labels.NumberFormat = “0.0%”;series.Values[0].Value = 4.35657;series.Labels.NumberFormat = “0.00E+00”;series.Labels.TextProperties.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontHeight = 20;series.Labels.TextProperties.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontBold = NullableBool.True;series.Labels.TextProperties.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontItalic = NullableBool.True;series.Labels.TextProperties.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FillFormat.FillType = FillTypeEx.Solid;series.Labels.TextProperties.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FillFormat.SolidFillColor.Color = Color.DarkGreen;//Saving Presentationpres.Write(“D:\Aspose Data\AxisValue.pptx”);
Hi,
Please show how to set background color of a chart. Below is the code I found which set the background color for the whole slide:
//Set the background color of the Master Slide to Forest Green
//pres.Masters[0].Background.Type = BackgroundTypeEx.OwnBackground;
//pres.Masters[0].Background.FillFormat.FillType = FillTypeEx.Solid;
//pres.Masters[0].Background.FillFormat.SolidFillColor.Color = Color.LightGray;
I want to do for only chart area.
Here is the code to change background color of chart area:
chart.PlotArea.Format.Fill.FillType = FillTypeEx.Solid;
chart.PlotArea.Format.Fill.SolidFillColor.Color = Color.DarkGray;
I have another query. How can I change the font color of one of the legend. Say for example I have the name for 4 differernt legend and I want to set only one legend to 'Bold'
Hi,
//Setting chart back wall colorchart.ChartFormat.Fill.FillType = FillTypeEx.Solid;chart.ChartFormat.Fill.SolidFillColor.Color = Color.Orange;
Hi,
public static void addLabelsToChart(){PresentationEx pres = new PresentationEx();SlideEx slide = pres.Slides[0];ChartEx chart = slide.Shapes.AddChart(ChartTypeEx.StackedColumn, 50, 50, 500, 400);//Setting Major and minor grid lines format for value axischart.ValueAxis.MajorGridLines.FillFormat.FillType = FillTypeEx.NoFill;chart.ValueAxis.MinorGridLines.FillFormat.FillType = FillTypeEx.NoFill;chart.CategoryAxis.MajorGridLines.FillFormat.FillType = FillTypeEx.NoFill;chart.CategoryAxis.MinorGridLines.FillFormat.FillType = FillTypeEx.NoFill;//Adding Series label and its properties//For Category 1double totalSeries = System.Convert.ToDouble(chart.ChartData.Series[0].Values[0].Value) + System.Convert.ToDouble(chart.ChartData.Series[1].Values[0].Value) + System.Convert.ToDouble(chart.ChartData.Series[2].Values[0].Value);double percent1 = (System.Convert.ToDouble(chart.ChartData.Series[0].Values[0].Value) / totalSeries) * 100;double percent2 = (System.Convert.ToDouble(chart.ChartData.Series[1].Values[0].Value) / totalSeries) * 100;double percent3 = (System.Convert.ToDouble(chart.ChartData.Series[2].Values[0].Value) / totalSeries) * 100;String per1 = string.Format("{0:0.##}", percent1);String per2 = string.Format("{0:0.##}", percent2);String per3 = string.Format("{0:0.##}", percent3);//For Category 2double totalSeries2 = System.Convert.ToDouble(chart.ChartData.Series[0].Values[1].Value) + System.Convert.ToDouble(chart.ChartData.Series[1].Values[1].Value) + System.Convert.ToDouble(chart.ChartData.Series[1].Values[0].Value);double percent12 = (System.Convert.ToDouble(chart.ChartData.Series[0].Values[1].Value) / totalSeries2) * 100;double percent22 = (System.Convert.ToDouble(chart.ChartData.Series[1].Values[1].Value) / totalSeries2) * 100;double percent32 = (System.Convert.ToDouble(chart.ChartData.Series[2].Values[1].Value) / totalSeries2) * 100;String per12 = string.Format("{0:0.##}", percent12);String per22 = string.Format("{0:0.##}", percent22);String per32 = string.Format("{0:0.##}", percent32);//For Category 3double totalSeries3 = System.Convert.ToDouble(chart.ChartData.Series[0].Values[2].Value) + System.Convert.ToDouble(chart.ChartData.Series[1].Values[2].Value) + System.Convert.ToDouble(chart.ChartData.Series[2].Values[2].Value);double percent13 = (System.Convert.ToDouble(chart.ChartData.Series[0].Values[2].Value) / totalSeries3) * 100;double percent23 = (System.Convert.ToDouble(chart.ChartData.Series[1].Values[2].Value) / totalSeries3) * 100;double percent33 = (System.Convert.ToDouble(chart.ChartData.Series[2].Values[2].Value) / totalSeries3) * 100;String per13 = string.Format("{0:0.##}", percent13);String per23 = string.Format("{0:0.##}", percent23);String per33 = string.Format("{0:0.##}", percent33);//For Category 4double totalSeries4 = System.Convert.ToDouble(chart.ChartData.Series[0].Values[3].Value) + System.Convert.ToDouble(chart.ChartData.Series[1].Values[3].Value) + System.Convert.ToDouble(chart.ChartData.Series[2].Values[3].Value);double percent14 = (System.Convert.ToDouble(chart.ChartData.Series[0].Values[3].Value) / totalSeries4) * 100;double percent24 = (System.Convert.ToDouble(chart.ChartData.Series[1].Values[3].Value) / totalSeries4) * 100;double percent34 = (System.Convert.ToDouble(chart.ChartData.Series[2].Values[3].Value) / totalSeries4) * 100;String per14 = string.Format("{0:0.##}", percent14);String per24 = string.Format("{0:0.##}", percent24);String per34 = string.Format("{0:0.##}", percent34);ChartSeriesEx series = chart.ChartData.Series[0];DataLabelEx label = new DataLabelEx(series);TextFrameEx txt = label.TextFrame;txt.Text = “”;txt.Paragraphs[0].Portions[0].Text = per1 + “%”;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType = FillTypeEx.Solid;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.Red;txt.Paragraphs[0].Portions[0].PortionFormat.FontBold = NullableBool.True;label.Id = 0;series.Labels.Add(label);DataLabelEx label12 = new DataLabelEx(series);txt = label12.TextFrame;txt.Text = “”;txt.Paragraphs[0].Portions[0].Text = per12 + “%”;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType = FillTypeEx.Solid;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.Red;txt.Paragraphs[0].Portions[0].PortionFormat.FontBold = NullableBool.True;label12.Id = 1;series.Labels.Add(label12);DataLabelEx label13 = new DataLabelEx(series);txt = label13.TextFrame;txt.Text = “”;txt.Paragraphs[0].Portions[0].Text = per13 + “%”;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType = FillTypeEx.Solid;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.Red;txt.Paragraphs[0].Portions[0].PortionFormat.FontBold = NullableBool.True;label13.Id = 2;series.Labels.Add(label13);DataLabelEx label14 = new DataLabelEx(series);txt = label14.TextFrame;txt.Text = “”;txt.Paragraphs[0].Portions[0].Text = per14 + “%”;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType = FillTypeEx.Solid;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.Red;txt.Paragraphs[0].Portions[0].PortionFormat.FontBold = NullableBool.True;label14.Id = 3;series.Labels.Add(label14);ChartSeriesEx series2 = chart.ChartData.Series[1];DataLabelEx label2 = new DataLabelEx(series2);txt = label2.TextFrame;txt.Text = “”;txt.Paragraphs[0].Portions[0].Text = per2 + “%”;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType = FillTypeEx.Solid;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.Red;txt.Paragraphs[0].Portions[0].PortionFormat.FontBold = NullableBool.True;label2.Id = 0;series2.Labels.Add(label2);DataLabelEx label22 = new DataLabelEx(series2);txt = label22.TextFrame;txt.Text = “”;txt.Paragraphs[0].Portions[0].Text = per22 + “%”;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType = FillTypeEx.Solid;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.Red;txt.Paragraphs[0].Portions[0].PortionFormat.FontBold = NullableBool.True;label22.Id = 1;series2.Labels.Add(label22);DataLabelEx label23 = new DataLabelEx(series2);txt = label23.TextFrame;txt.Text = “”;txt.Paragraphs[0].Portions[0].Text = per23 + “%”;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType = FillTypeEx.Solid;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.Red;txt.Paragraphs[0].Portions[0].PortionFormat.FontBold = NullableBool.True;label23.Id = 2;series2.Labels.Add(label23);DataLabelEx label24 = new DataLabelEx(series2);txt = label24.TextFrame;txt.Text = “”;txt.Paragraphs[0].Portions[0].Text = per24 + “%”;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType = FillTypeEx.Solid;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.Red;txt.Paragraphs[0].Portions[0].PortionFormat.FontBold = NullableBool.True;label24.Id = 3;series2.Labels.Add(label24);ChartSeriesEx series3 = chart.ChartData.Series[2];DataLabelEx label3 = new DataLabelEx(series3);txt = label3.TextFrame;txt.Text = “”;txt.Paragraphs[0].Portions[0].Text = per3 + “%”;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType = FillTypeEx.Solid;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.Red;txt.Paragraphs[0].Portions[0].PortionFormat.FontBold = NullableBool.True;label3.Id = 0;series3.Labels.Add(label3);DataLabelEx label32 = new DataLabelEx(series3);txt = label32.TextFrame;txt.Text = “”;txt.Paragraphs[0].Portions[0].Text = per32 + “%”;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType = FillTypeEx.Solid;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.Red;txt.Paragraphs[0].Portions[0].PortionFormat.FontBold = NullableBool.True;label32.Id = 1;series3.Labels.Add(label32);DataLabelEx label33 = new DataLabelEx(series3);txt = label33.TextFrame;txt.Text = “”;txt.Paragraphs[0].Portions[0].Text = per33 + “%”;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType = FillTypeEx.Solid;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.Red;txt.Paragraphs[0].Portions[0].PortionFormat.FontBold = NullableBool.True;label33.Id = 2;series3.Labels.Add(label33);DataLabelEx label34 = new DataLabelEx(series3);txt = label34.TextFrame;txt.Text = “”;txt.Paragraphs[0].Portions[0].Text = per34 + “%”;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType = FillTypeEx.Solid;txt.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.Red;txt.Paragraphs[0].Portions[0].PortionFormat.FontBold = NullableBool.True;label34.Id = 3;series3.Labels.Add(label34);chart.GapDepth = 0;//Values in percentagechart.GapWidth = 0;//Saving Presentationpres.Write(@“D:\Aspose Data\AxisValue.pptx”);}
Im getting the same issue and there is a red line beneath the Color saying that in not in the current context.
Hi Jim,
The issues you have found earlier (filed as SLIDESNET-33811) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by aspose.notifier.