Specifying the data that appears in the graph legend

We’re still evaluating the product and are pretty set to buy a licence for our website however we are attempting to create a graph at the moment and are having problems specifying the data that appears in the graph legend. It appears to be taking data from a non-specified column. Is there a way of specifying the column that the legend should take its data from?

[C#]
Excel excel = new Excel();
Worksheet sheet = excel.Worksheets.GetAt(0);

Cells cells = sheet.Cells;
cells.GetAt(0,1).PutValue(“Income”);
cells.GetAt(1,0).PutValue(“Company A”);
cells.GetAt(2,0).PutValue(“Company B”);
cells.GetAt(3,0).PutValue(“Company C”);
cells.GetAt(1,1).PutValue(10000);
cells.GetAt(2,1).PutValue(20000);
cells.GetAt(3,1).PutValue(30000);

int chartIndex = sheet.Charts.Add(ChartType.Column, 9, 9, 21, 15);

Chart chart = sheet.Charts.GetAt(chartIndex);
chart.NSeries.Add(“B2:B4”, true);
chart.NSeries.CategoryData = “A2:A4”;

ASeries aSeries = chart.NSeries.GetAt(0);
aSeries.Name = “=B1”;
chart.IsLegendShown = true;
chart.Title.Text = “Income Analysis”;

[Visual Basic]
Dim excel As Excel = New Excel()
Dim sheet As Worksheet = excel.Worksheets.GetAt(0)

Dim cells As Cells = sheet.Cells
cells.GetAt(0,1).PutValue(“Income”)
cells.GetAt(1,0).PutValue(“Company A”)
cells.GetAt(2,0).PutValue(“Company B”)
cells.GetAt(3,0).PutValue(“Company C”)
cells.GetAt(1,1).PutValue(10000)
cells.GetAt(2,1).PutValue(20000)
cells.GetAt(3,1).PutValue(30000)

Dim chartIndex As Integer = sheet.Charts.Add(ChartType.Column,9,9,21,15)

Dim chart As Chart = sheet.Charts.GetAt(chartIndex)
chart.NSeries.Add(“B2:B4”, True)
chart.NSeries.CategoryData = “A2:A4”

Dim aSeries As ASeries = chart.NSeries.GetAt(0)
aSeries.Name = “=B1”
chart.IsLegendShown = True
chart.Title.Text = “Income Analysis”


excel.Save(“chart.xls”, SaveType.OpenInBrowser, FileFormatType.Default, Me.Response)