I’m trying to create a graph from some data I export to an .xls file. I create the graph just fine, but I’m going to have anywhere from 3 – 7 lines on the graph. I added the legend to make it easier to read, but the legend has no text on it. It just shows a line without a label. Is there anyway to label the legend key?
Here’s the code of the graph I’m making:
var lineChart = ws.Drawings.AddChart(item.TestHeader, eChartType.Line) as ExcelLineChart; lineChart.SetSize(800, 400); lineChart.Series.Add(Char.ConvertFromUtf32(65 + distanceCount + 1).ToString() + "1:" + Char.ConvertFromUtf32(65 + distanceCount + 1).ToString() + (testCount.ToString()), "A1:A" + (testCount.ToString())); lineChart.Title.Text = item.TestHeader; lineChart.DataLabel.ShowSeriesName = true; lineChart.DataLabel.ShowLegendKey = true; lineChart.DataLabel.ShowLeaderLines = true; lineChart.XAxis.Title.Text = "Inches from Decoder"; lineChart.YAxis.Title.Text = "Milliseconds to decode"; lineChart.YAxis.MaxValue = 1000;
Any help is better than none, thanks!
Your example generated a series name in the legend for me named “Series”. But you can set it explicitly using
lineChart.Series.Header = "Series 1 Name";