4
votes

I am writing an excel file from my c# applicaiton that contains data and a chart. There are two data series (lines) displayed in the chart. One containing values from 10-300, the other one 1-10. Now I want tu use a secondary axis (usually drawn on the left side). How can I achieve this?

If I just set the chart.UseSecondaryAxis I get an excepetion telling me that '"Can's set to secondary axis when no serie uses the primary axis"'.

I am using C# (4.0) and the EPPlus library.

Thanks for any help

Mario

1

1 Answers

4
votes

I hava bad habit of answering my own questions:

Example #9 Sample9.cs shows the answer:

  var chart2 = firstChart.PlotArea.ChartTypes.Add( eChartType.LineMarkers );

  ser = ( chart2.Series.Add( "O3:O10","D3:D10", dataRowIdx ) ) as ExcelChartSerie );
  ser.Header = "OtherLine";
  chart2.UseSecondaryAxis = true;

The first line does the trick. You have to create a second charttype, although it can be of the same type as firstChart.

Mario