Chart with series

Nov 25, 2010 at 1:28 PM

Hello ,I am using EEPplus to report an excel  which have a chart with two series (linechart and barchart) like this

I have tried but not working

 var chart = (worksheet.Drawings.AddChart("Chart", eChartType.Line) as ExcelLineChart);
                ExcelAddress valueAddress = new ExcelAddress(2, 5, 6, 5);
                chart.Series.Add(valueAddress.Address, "B2:B6");

                chart.DataLabel.ShowCategory = true;
                chart.DataLabel.ShowPercent = true;
                ExcelAddress valueAddress1   = new ExcelAddress(2,6,6,6);
                var ser = chart.Series.Add(valueAddress1.Address, "B2:B6");
                ser.Chart.ChartType= eChartType.ColumnStacked;

Can you post sample code ?

Nov 25, 2010 at 5:08 PM


Check out sample 9, in the LoadFile2 method, it shows how to do it.

In your case something like this...

var chart = sheet.Drawings.AddChart("chart2", eChartType.Line);
ExcelAddress valueAddress = new ExcelAddress(2, 5, 6, 5);
var ser1=chart.Series.Add(valueAddress.Address, "B2:B6");

//Add a new charttype
var chartType2 = chart.PlotArea.ChartTypes.Add(eChartType.ColumnStacked);
var ser2 = chartType2.Series.Add(valueAddress1.Address, "B2:B6");

(The Chart.Chartype shows the first charttype when the chart is added. It's supposed to be readonly, so it's a bugg. I'll add a fix for that  later)