This project has moved. For the latest updates, please go here.

Having problems making linechart

Jun 15, 2011 at 2:18 PM

Hi all,

First, thanks for making this terrific library.

Now, my problem is that I'm trying to make a line chart but I'm not really clear on what I need to be doing. I can make a chart appear but it certainly isn't plotting my data.

Any hints appreciated !!

This is my code -

                    worksheet.Cells[RowNumber++, 3].Value = "Historical";
                    int GraphRow = RowNumber;

                    for (int i = Month - 6; i <= Month; i++)
                    {
                        int AdjustedYear = Year;
                        int AdjustedMonth = i;

                        if (i < 1)
                        {
                            AdjustedYear--;
                            AdjustedMonth = 12 + i;
                        }

                        worksheet.Cells[GraphRow, 3 + i].Value = AdjustedMonth.ToString() + "/" + AdjustedYear.ToString();
                        worksheet.Cells[GraphRow + 1, 3 + i].Value = SQL query here to return a value .....;
                    }
                    RowNumber++;
                    RowNumber++;

                    // Insert graph
                    // TODO: Fix graph - it is crap
                    var absenceChart = worksheet.Drawings.AddChart("Absences"+RosterID, eChartType.Line3D);
                    absenceChart.From.Row = RowNumber;
                    absenceChart.From.Column = 1;
                    absenceChart.To.Row = RowNumber + 4;
                    absenceChart.To.Column = 7;
                    string LabelRange = "D" + GraphRow.ToString() + ":I" + GraphRow.ToString();
                    string DataRange = "D" + (GraphRow + 1).ToString() + ":I" + (GraphRow + 1).ToString();
                    absenceChart.Series.Add(worksheet.Cells[LabelRange], worksheet.Cells[DataRange]);

                    RowNumber += 6;

Coordinator
Jun 16, 2011 at 7:10 AM

Can't see anything obviously wrong. Look at the series in Excel and see if the point to the correct range.