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

Free Support Forum - aspose.com

How can I dynamically change range of data for an NSeries or Chart?

I use WorkbookDesigner to inject data into a template worksheet with a pre-built chart to cover a range of data area… For discussion, let say the chart display investment performance with y-axis showing investment returns and a-axis shows the investment year.

User wants to dynamically choose a range of years of investment returns to display. I see your NSeries class only has two add methods. There does not seem to be a way to to change the data range (the range of investment years) for the chart once the NSeries or chart has been added. Because my chart is pre-built in the template, I cannot even use the NSeries.Add() to set the data range.

Is there a way to dynamically choose or change the range of data for the graph for existing NSeries? This seems to be a reasonable thing many users will want to do.

Thanks.

Perhaps I can set up my chart in the designer worksheet to refer to a range and dynamically change the range like this:

Dim range As Aspose.Cells.Range =
designerWB.Workbook.Worksheets(workSheetName).Cells.CreateRange(0, 0, numRows, numCols)
range.Name = “range_chartData” ’ set the range name for the data

Hi,

I think, alternatively, you may directly try to change the nseries range in the designer chart:

e.g..,

Dim workbook As Workbook = New Workbook()
workbook.Open(tempfile)
'Get the first chart in the first worksheet.
Aspose.Cells.Chart chart = workbook.Worksheets(0).Charts(0)
...............
Dim labelStart As String= Aspose.Cells.CellsHelper.CellIndexToName(..,...)
Dim labelEnd As String = Aspose.Cells.CellsHelper.CellIndexToName(..., ...)
Dim rangeStart As String= Aspose.Cells.CellsHelper.CellIndexToName(...,....)
Dim rangeEnd As String = Aspose.Cells.CellsHelper.CellIndexToName(..,..)
Dim range As String = wks.Name & "!" & rangeStart & ":" & rangeEnd
Dim labels As String = wks.Name &"!" & labelStart & ":" & labelEnd

chart.NSeries(0).Values = range
chart.NSeries.CategoryData= labels
.............

For further reference, please check: http://www.aspose.com/documentation/file-format-components/aspose.cells-for-.net-and-java/manipulating-designer-charts.html

Thank you.