Hi All,
I want to draw a combo (Line+column) chart. when i draw a column chart on secondary y-axis then it draw from secondary x-axis for the same.
but i want to plot this chart on primary x-axis and secondary y-axis.
To get this i write this code-
chart.Axes.SecondaryVerticalAxis.IsPlotOrderReversed = true;
but when i write this code, the value of secondary y-axis starts from top to bottom.
my code to draw Line+column chart is-
Presentation pres = new Presentation();
ISlide sld = pres.Slides[0];
IChart chart = sld.Shapes.AddChart(ChartType.ClusteredColumn, 0, 0, 500, 500);
chart.ChartTitle.AddTextFrameForOverriding(“Sample Title”);
chart.ChartTitle.TextFrameForOverriding.TextFrameFormat.CenterText = NullableBool.True;
chart.ChartTitle.Height = 20;
chart.HasTitle = true;
chart.ChartData.Series[0].Labels.DefaultDataLabelFormat.ShowValue = true;
int defaultWorksheetIndex = 0;
IChartDataWorkbook fact = chart.ChartData.ChartDataWorkbook;
chart.ChartData.Series.Clear();
chart.ChartData.Categories.Clear();
int s = chart.ChartData.Series.Count;
s = chart.ChartData.Categories.Count;
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 1, “Series 1”), chart.Type);
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 2, “Series 2”), chart.Type);
IChartSeries series = chart.ChartData.Series[0];
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 1, 1, 20));
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 2, 1, 50));
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 3, 1, 30));
series.PlotOnSecondAxis = true;
chart.Axes.SecondaryVerticalAxis.IsPlotOrderReversed = true;
series = chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 5, “Series 4”), ChartType.ScatterWithStraightLinesAndMarkers);
series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 1, 5, 5), fact.GetCell(defaultWorksheetIndex, 1, 6, 1));
series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 2, 5,10), fact.GetCell(defaultWorksheetIndex, 2, 6, 7));
series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 3, 5, 15), fact.GetCell(defaultWorksheetIndex, 3, 6, 7));
series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 4, 5, 20), fact.GetCell(defaultWorksheetIndex, 4, 6,12));
series.Marker.Size = 10;
series.Marker.Symbol = MarkerStyleType.Circle;
pres.Save(@“D:\”+“Line+Column.pptx”, SaveFormat.Pptx);