Hi,
Is it possible to create a chart with two Y-axes and one shared X-axis ?
Just like in this link : http://www.techonthenet.com/excel/charts/2_y_axes.php
If yes, can you please provide an example on how to do it?
Regards,
Moshe
Hi,
Is it possible to create a chart with two Y-axes and one shared X-axis ?
Just like in this link : http://www.techonthenet.com/excel/charts/2_y_axes.php
If yes, can you please provide an example on how to do it?
Regards,
Moshe
Hi Moshe,
PresentationEx ppt = new PresentationEx();SlideEx sld = ppt.Slides[0];// — add chart to slide —ChartEx ch = sld.Shapes.AddChart(ChartTypeEx.ClusteredColumn, 20, 20, 500, 300);// ChartEx ch = sld.Shapes.AddChart(ChartTypeEx.Line , 20, 20, 500, 300);// — Getting the chart data worksheet —ChartDataCellFactory fact = ch.ChartData.ChartDataCellFactory;// — Delete default generated series and categories —ch.ChartData.Series.Clear();ch.ChartData.Categories.Clear();// — ADD SERIES 1 VALUES —int[] values = new int[] { 0, 4, 3, 4, 2, 6 };ch.ChartData.Series.Add(fact.GetCell(0, 0, 1, “Values”), ch.Type);ChartSeriesEx series1 = ch.ChartData.Series[0];series1.Format.Line.FillFormat.FillType = FillTypeEx.Solid;series1.Format.Line.FillFormat.SolidFillColor.Color = Color.Red;series1.Format.Fill.FillType = FillTypeEx.Solid;series1.Format.Fill.SolidFillColor.Color = Color.Red;for (int i = 1; i < 6; i++)series1.Values.Add(fact.GetCell(0, i, 1, values[i]));// — ADD TARGET DATA SERIES —int[] targets = new int[] { 0, 5, 5, 5, 5, 5 };ch.ChartData.Series.Add(fact.GetCell(0, 0, 3, “Target”), ChartTypeEx.Line);ChartSeriesEx targetSeries = ch.ChartData.Series[1];targetSeries.Format.Line.FillFormat.FillType = FillTypeEx.Solid;targetSeries.Format.Line.FillFormat.SolidFillColor.Color = Color.Green;targetSeries.Format.Fill.FillType = FillTypeEx.Solid;targetSeries.Format.Fill.SolidFillColor.Color = Color.Green;for (int i = 1; i < 6; i++)targetSeries.Values.Add(fact.GetCell(0, i, 3, targets[i]));// — ADD LABELS —for (int i = 1; i < 6; i++)ch.ChartData.Categories.Add(fact.GetCell(0, i, 0, "point " + i));//If you want plain line without marker then use following code/targetSeries.MarkerFill.Fill.FillType = FillTypeEx.NoFill;targetSeries.MarkerSymbol = MarkerStyleTypeEx.None;targetSeries.MarkerFill.Line.FillFormat.FillType = FillTypeEx.NoFill;targetSeries.MarkerSize = 0;/targetSeries.MarkerFill.Fill.FillType = FillTypeEx.Solid;targetSeries.MarkerFill.Fill.SolidFillColor.Color = Color.Blue;targetSeries.MarkerSymbol = MarkerStyleTypeEx.Diamond;targetSeries.MarkerFill.Line.FillFormat.FillType = FillTypeEx.Solid;targetSeries.MarkerFill.Line.FillFormat.SolidFillColor.Color = Color.Green;targetSeries.MarkerSize = 15;// — SAVE FILE —ppt.Save(“D:\Aspose Data\myPPt.pptx”, Aspose.Slides.Export.SaveFormat.Pptx);//, null);
Thanks for the quick response.
But I need to have 2 Y-axes: one on the left and one on the right.
Lets say that for “Target” the Y values will be 100,200,300,400,500
(and for “Values” the Y values remain 4,3,4,2,6)
Just like the percent values in this :
http://www.techonthenet.com/excel/charts/images/2_y_axes009.png
Regards,
Moshe
Hi Moshe,
Attached please find the chart with 2 Y axes
Regards
Moshe
Hi Moshe,
Hi Moshe,
PresentationEx ppt = new PresentationEx();SlideEx sld = ppt.Slides[0];// — add chart to slide —ChartEx ch = sld.Shapes.AddChart(ChartTypeEx.ClusteredColumn, 20, 20, 500, 300);// ChartEx ch = sld.Shapes.AddChart(ChartTypeEx.Line , 20, 20, 500, 300);// — Getting the chart data worksheet —ChartDataCellFactory fact = ch.ChartData.ChartDataCellFactory;// — Delete default generated series and categories —ch.ChartData.Series.Clear();ch.ChartData.Categories.Clear();// — ADD SERIES 1 VALUES —int[] values = new int[] { 0, 4, 3, 4, 2, 6 };ch.ChartData.Series.Add(fact.GetCell(0, 0, 1, “Values”), ch.Type);ChartSeriesEx series1 = ch.ChartData.Series[0];series1.Format.Line.FillFormat.FillType = FillTypeEx.Solid;series1.Format.Line.FillFormat.SolidFillColor.Color = Color.Red;series1.Format.Fill.FillType = FillTypeEx.Solid;series1.Format.Fill.SolidFillColor.Color = Color.Red;for (int i = 1; i < 6; i++)series1.Values.Add(fact.GetCell(0, i, 1, values[i]));// — ADD TARGET DATA SERIES —int[] targets = new int[] { 0, 5, 5, 5, 5, 5 };ch.ChartData.Series.Add(fact.GetCell(0, 0, 3, “Target”), ChartTypeEx.Line);ChartSeriesEx targetSeries = ch.ChartData.Series[1];targetSeries.Format.Line.FillFormat.FillType = FillTypeEx.Solid;targetSeries.Format.Line.FillFormat.SolidFillColor.Color = Color.Green;targetSeries.Format.Fill.FillType = FillTypeEx.Solid;targetSeries.Format.Fill.SolidFillColor.Color = Color.Green;for (int i = 1; i < 6; i++)targetSeries.Values.Add(fact.GetCell(0, i, 3, targets[i]));// — ADD LABELS —for (int i = 1; i < 6; i++)ch.ChartData.Categories.Add(fact.GetCell(0, i, 0, "point " + i));//If you want plain line without marker then use following code/targetSeries.MarkerFill.Fill.FillType = FillTypeEx.NoFill;targetSeries.MarkerSymbol = MarkerStyleTypeEx.None;targetSeries.MarkerFill.Line.FillFormat.FillType = FillTypeEx.NoFill;targetSeries.MarkerSize = 0;/targetSeries.MarkerFill.Fill.FillType = FillTypeEx.Solid;targetSeries.MarkerFill.Fill.SolidFillColor.Color = Color.Blue;targetSeries.MarkerSymbol = MarkerStyleTypeEx.Diamond;targetSeries.MarkerFill.Line.FillFormat.FillType = FillTypeEx.Solid;targetSeries.MarkerFill.Line.FillFormat.SolidFillColor.Color = Color.Green;targetSeries.MarkerSize = 15;targetSeries.PlotOnSecondAxis = true;// — SAVE FILE —ppt.Save(“D:\Aspose Data\myPPt.pptx”, Aspose.Slides.Export.SaveFormat.Pptx);
The issues you have found earlier (filed as SLIDESNET-33490) have been fixed in this update .
This message was posted using Notification2Forum from Downloads module by aspose.notifier.