We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Line Chart Issue

Hi,

We have Column values in Grid in descending order(A1,A2,A3,A4). As of now we are able to Plot Line Chart for Range(A1:A4), But our requirement is to plot Chart series in range of (A4:A1)(Reverse order).We were able to acheive this by copying cell values to hidden field. But we are in need of fetching values directly from its Cells.(A4:A1). Can you please provide sample for the same.

Hi,


I have written a sample code to accomplish the task where you may specify non contiguous cells range/area while setting the data series and category data for the chart, you may refer to it and write your own codes accordingly for your needs:
e.g
Sample code:

//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Get First Worksheet of the Workbook
Worksheet ws = workbook.Worksheets[0];
string sname = “Data”;
//Add new Data Sheet
ws.Name = sname;
Cells cells = ws.Cells;
cells[“A1”].PutValue(“Aspose.Slides”);
cells[“A2”].PutValue(“Aspose.PDF”);
cells[“A3”].PutValue(“Aspose.Cells”);
cells[“A4”].PutValue(“Aspose.Words”);
cells[“B1”].PutValue(35);
cells[“B2”].PutValue(50);
cells[“B3”].PutValue(65);
cells[“B4”].PutValue(75);

Worksheet ws2 = workbook.Worksheets[workbook.Worksheets.Add()];
ChartCollection charts = ws2.Charts;

int index = charts.Add(ChartType.Line, 5, 0, 15, 5);
Chart chart = charts[index];
chart.NSeries.Add("=Data!B4,Data!B3,Data!B2,Data!B1", false);
chart.NSeries.CategoryData = “Data!A4,Data!A3,Data!A2,Data!A1”;



workbook.Save(“e:\test2\out1.xlsx”);

Hope, this helps a bit.

Thank you.