How to bind data in the chart using Aspose.Cells in .NET

Hi

While using chat tools of aspose, i am facing below problem

chart.NSeries.CategoryData = "Data!B1:B25";

I am using above code for binding data in Line as well as Stacked chart. And the data present in "B" columns are different State Name of India, but it is binding numerics in X-Axis.

How can i change this. ? or is there any property which needs to be used for setting this.I am attaching the excel sheet for your reference.

Below is code i am using.. ::

public static void CreateStaticLineReport(Workbook workbook)

{

//get next index for new worksheet

//Initalize worksheet for given index

Worksheet sheet = workbook.Worksheets[0];

Aspose.Cells.Cells cells = workbook.Worksheets[0].Cells;

//Set the name of worksheet

sheet.Name = "Data";

//Create Chart

int chartIndex = 0;

int sheetIndex = workbook.Worksheets.Add(SheetType.Chart);

Worksheet sheet1 = workbook.Worksheets[sheetIndex];

sheet1.Name = "Chart";

chartIndex = sheet1.Charts.Add(ChartType.LineWithDataMarkers, 1, 1, 25, 10);

Chart chart = sheet1.Charts[chartIndex];

//Set Chart's MajorGridLines invisib;e

chart.CategoryAxis.MajorGridLines.IsVisible = false;

chart.PlotArea.Area.ForegroundColor = System.Drawing.Color.AntiqueWhite;

chart.PlotArea.Border.IsVisible = false;

//Set Properties of chart title

chart.Title.Text = "Graphical Report";

chart.Title.TextFont.Color = Color.Red;

chart.Title.TextFont.IsBold = true;

chart.Title.TextFont.Size = 12;

//Set properies to nseries

chart.NSeries.CategoryData = "Data!B2:B25";

//Set NSeries Data

chart.NSeries.Add("Data!D2:D25", true);

//Set Nseries color varience to True

chart.NSeries.IsColorVaried = false;

for (int i = 1; i < chart.NSeries.Count; i++)

{

chart.NSeries[i].MarkerStyle = ChartMarkerType.Diamond;

//Set Nseriese Marker Background and ForeGround colors

chart.NSeries[i].MarkerBackgroundColor = Color.Red;

chart.NSeries[i].MarkerForegroundColor = Color.RosyBrown;

//Set NSeries Marker size

chart.NSeries[i].MarkerSize = 20;

}

chart.ShowLegend = false;

}

Hi,


Please first add NSeries values axis then add CategoryData, e.g, please update / interchange your lines of code:
//Set properies to nseries

chart.NSeries.CategoryData = “Data!B2:B25”;

//Set NSeries Data

chart.NSeries.Add(“Data!D2:D25”, true);

to:

//Set NSeries Data
chart.NSeries.Add(“Data!D2:D25”, true);

//Set properies to nseries

chart.NSeries.CategoryData = “Data!B2:B25”;

Thank you..!!

Its working...