SeriesCollection
SeriesCollection class
Encapsulates a collection of Series objects.
class SeriesCollection;
Example
const { Workbook, ChartType } = require("aspose.cells.node");
//Instantiating a Workbook object
var workbook = new Workbook();
//Adding a new worksheet to the Excel object
var sheetIndex = workbook.getWorksheets().add();
//Obtaining the reference of the newly added worksheet by passing its sheet index
var worksheet = workbook.getWorksheets().get(sheetIndex);
//Adding a sample value to "A1" cell
worksheet.getCells().get("A1").putValue(50);
//Adding a sample value to "A2" cell
worksheet.getCells().get("A2").putValue(100);
//Adding a sample value to "A3" cell
worksheet.getCells().get("A3").putValue(150);
//Adding a sample value to "A4" cell
worksheet.getCells().get("A4").putValue(200);
//Adding a sample value to "B1" cell
worksheet.getCells().get("B1").putValue(60);
//Adding a sample value to "B2" cell
worksheet.getCells().get("B2").putValue(32);
//Adding a sample value to "B3" cell
worksheet.getCells().get("B3").putValue(50);
//Adding a sample value to "B4" cell
worksheet.getCells().get("B4").putValue(40);
//Adding a sample value to "C1" cell as category data
worksheet.getCells().get("C1").putValue("Q1");
//Adding a sample value to "C2" cell as category data
worksheet.getCells().get("C2").putValue("Q2");
//Adding a sample value to "C3" cell as category data
worksheet.getCells().get("C3").putValue("Y1");
//Adding a sample value to "C4" cell as category data
worksheet.getCells().get("C4").putValue("Y2");
//Adding a chart to the worksheet
var chartIndex = worksheet.getCharts().add(ChartType.Column, 5, 0, 15, 5);
//Accessing the instance of the newly added chart
var chart = worksheet.getCharts().get(chartIndex);
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B4"
chart.getNSeries().add("A1:B4", true);
//Setting the data source for the category data of NSeries
chart.getNSeries().setCategoryData("C1:C4");
//Saving the Excel file
workbook.save("output/ChartsSeriesCollection.xls");
Methods
Method | Description |
---|---|
get(number) | Gets the Series element at the specified index. |
getCategoryData() | Gets or sets the range of category Axis values. It can be a range of cells (such as, “d1:e10”), or a sequence of values (such as,"{2,6,8,10}"). |
setCategoryData(string) | Gets or sets the range of category Axis values. It can be a range of cells (such as, “d1:e10”), or a sequence of values (such as,"{2,6,8,10}"). |
getSecondCategoryData() | Gets or sets the range of second category Axis values. It can be a range of cells (such as, “d1:e10”), or a sequence of values (such as,"{2,6,8,10}"). Only effects when some ASerieses plot on the second axis. |
setSecondCategoryData(string) | Gets or sets the range of second category Axis values. It can be a range of cells (such as, “d1:e10”), or a sequence of values (such as,"{2,6,8,10}"). Only effects when some ASerieses plot on the second axis. |
isColorVaried() | Represents if the color of points is varied. |
setIsColorVaried(boolean) | Represents if the color of points is varied. |
getSeriesByOrder(number) | Gets the Series element by order. |
removeAt(number) | Remove at a series at the specific index. |
changeSeriesOrder(number, number) | Directly changes the orders of the two series. |
swapSeries(number, number) | Directly changes the orders of the two series. |
setSeriesNames(number, string, boolean) | Sets the name of all the serieses in the chart. |
addR1C1(string, boolean) | Adds the Series collection to a chart. |
add(string, boolean) | Adds the Series collection to a chart. |
add(string, boolean, boolean) | Adds the Series collection to a chart. |
clear() | Clears the collection |
getCount() | Gets the number of elements contained in. |
isNull() | Checks whether the implementation object is null. |
get(number)
Gets the Series element at the specified index.
get(index: number) : Series;
Parameters:
Parameter | Type | Description |
---|---|---|
index | number | The zero based index of the element. |
Returns
The element at the specified index.
getCategoryData()
Gets or sets the range of category Axis values. It can be a range of cells (such as, “d1:e10”), or a sequence of values (such as,"{2,6,8,10}").
getCategoryData() : string;
setCategoryData(string)
Gets or sets the range of category Axis values. It can be a range of cells (such as, “d1:e10”), or a sequence of values (such as,"{2,6,8,10}").
setCategoryData(value: string) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | string | The value to set. |
getSecondCategoryData()
Gets or sets the range of second category Axis values. It can be a range of cells (such as, “d1:e10”), or a sequence of values (such as,"{2,6,8,10}"). Only effects when some ASerieses plot on the second axis.
getSecondCategoryData() : string;
setSecondCategoryData(string)
Gets or sets the range of second category Axis values. It can be a range of cells (such as, “d1:e10”), or a sequence of values (such as,"{2,6,8,10}"). Only effects when some ASerieses plot on the second axis.
setSecondCategoryData(value: string) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | string | The value to set. |
isColorVaried()
Represents if the color of points is varied.
isColorVaried() : boolean;
setIsColorVaried(boolean)
Represents if the color of points is varied.
setIsColorVaried(value: boolean) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The value to set. |
getSeriesByOrder(number)
Gets the Series element by order.
getSeriesByOrder(order: number) : Series;
Parameters:
Parameter | Type | Description |
---|---|---|
order | number | The order of series |
Returns
The element series
removeAt(number)
Remove at a series at the specific index.
removeAt(index: number) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
index | number | The index. |
changeSeriesOrder(number, number)
Directly changes the orders of the two series.
changeSeriesOrder(sourceIndex: number, destIndex: number) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
sourceIndex | number | The current index |
destIndex | number | The dest index |
Remarks
NOTE: This method is now obsolete. Instead, please use SeriesCollection.SwapSeries method. This method will be removed 12 months later since June 2024. Aspose apologizes for any inconvenience you may have experienced.
swapSeries(number, number)
Directly changes the orders of the two series.
swapSeries(sourceIndex: number, destIndex: number) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
sourceIndex | number | The current index |
destIndex | number | The dest index |
setSeriesNames(number, string, boolean)
Sets the name of all the serieses in the chart.
setSeriesNames(startIndex: number, area: string, isVertical: boolean) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
startIndex | number | The index of the first series which you want to set the name. |
area | string | Specifies the area for the series name. |
isVertical | boolean | >Specifies whether to plot the series from a range of cell values by row or by column. |
Remarks
br>If the start index is larger than the count of the serieses, it will return and do nothing.
If set data on contiguous cells, use colon to seperate them.For example, $C$2:$C$5.
If set data on contiguous cells, use comma to seperate them.For example, ($C$2,$D$5).</br
addR1C1(string, boolean)
Adds the Series collection to a chart.
addR1C1(area: string, isVertical: boolean) : number;
Parameters:
Parameter | Type | Description |
---|---|---|
area | string | Specifies values from which to plot the data series |
isVertical | boolean | Specifies whether to plot the series from a range of cell values by row or by column. |
Returns
Return the first index of the added ASeries in the NSeries.
Remarks
br>If set data on contiguous cells, use colon to seperate them.For example, R[1]C[1]:R[3]C[2].
If set data on contiguous cells, use comma to seperate them.For example,(R[1]C[1],R[3]C[2]).</br
add(string, boolean)
Adds the Series collection to a chart.
add(area: string, isVertical: boolean) : number;
Parameters:
Parameter | Type | Description |
---|---|---|
area | string | Specifies values from which to plot the data series |
isVertical | boolean | Specifies whether to plot the series from a range of cell values by row or by column. |
Returns
Return the first index of the added ASeries in the NSeries.
Remarks
br>If set data on contiguous cells, use colon to seperate them.For example, $C$2:$C$5.
If set data on non contiguous cells, use comma to seperate them.For example: ($C$2,$D$5).</br
add(string, boolean, boolean)
Adds the Series collection to a chart.
add(area: string, isVertical: boolean, checkLabels: boolean) : number;
Parameters:
Parameter | Type | Description |
---|---|---|
area | string | Specifies values from which to plot the data series |
isVertical | boolean | Specifies whether to plot the series from a range of cell values by row or by column. |
checkLabels | boolean | Indicates whether the range contains series’s name |
Returns
Return the first index of the added ASeries in the NSeries.
Remarks
br>If set data on contiguous cells, use colon to seperate them.For example, $C$2:$C$5.
If set data on non contiguous cells, use comma to seperate them.For example, ($C$2,$D$5).</br
clear()
Clears the collection
clear() : void;
getCount()
Gets the number of elements contained in.
getCount() : number;
isNull()
Checks whether the implementation object is null.
isNull() : boolean;