Chart

Chart class

Encapsulates the object that represents a single Excel chart.

class Chart;

Example

const { Workbook, ChartType } = require("aspose.cells.node");

var workbook = new Workbook();
var sheet = workbook.worksheets.get(0);
var cells = sheet.cells;
cells.get(0, 1).putValue("Income");
cells.get(1, 0).putValue("Company A");
cells.get(2, 0).putValue("Company B");
cells.get(3, 0).putValue("Company C");
cells.get(1, 1).putValue(10000);
cells.get(2, 1).putValue(20000);
cells.get(3, 1).putValue(30000);
var chartIndex = sheet.charts.add(ChartType.Column, 9, 9, 21, 15);
var chart = sheet.charts.get(chartIndex);
chart.nSeries.add("B2:B4", true);
chart.nSeries.categoryData = "A2:A4";
var aSeries = chart.nSeries.get(0);
aSeries.name = "=B1";
chart.showLegend = true;
chart.title.text = "Income Analysis";

Properties

PropertyTypeDescription
stylenumberGets and sets the builtin style.
chartObjectChartShapeReadonly. Represents the chartShape;
hidePivotFieldButtonsbooleanIndicates whether hide the pivot chart field buttons only when the chart is PivotChart.
pivotOptionsPivotOptionsReadonly. Specifies the pivot controls that appear on the chart
pivotSourcestringThe source is the data of the pivotTable. If PivotSource is not empty ,the chart is PivotChart.
plotByPlotDataByTypeReadonly. Gets and sets whether plot by row or column.
plotEmptyCellsTypePlotEmptyCellsTypeGets and sets how to plot the empty cells.
plotVisibleCellsOnlybooleanIndicates whether plot visible cells only.
displayNaAsBlankbooleanIndicates whether displaying #N/A as blank value.
namestringGets and sets the name of the chart.
sizeWithWindowbooleanTrue if Microsoft Excel resizes the chart to match the size of the chart sheet window.
worksheetWorksheetReadonly. Gets the worksheet which contains this chart.
shapesShapeCollectionReadonly. Returns all drawing shapes in this chart.
printSizePrintSizeTypeGets and sets the printed chart size.
typeChartTypeGets or sets a chart’s type.
nSeriesSeriesCollectionReadonly. Gets a SeriesCollection collection representing the data series in the chart.
filteredNSeriesSeriesCollectionReadonly. Gets a SeriesCollection collection representing the data series that are filtered in the chart.
titleTitleReadonly. Gets the chart’s title.
subTitleTitleReadonly. Gets the chart’s sub-title. Only for ODS format file.
plotAreaPlotAreaReadonly. Gets the chart’s plot area which includes axis tick labels.
chartAreaChartAreaReadonly. Gets the chart area in the worksheet.
categoryAxisAxisReadonly. Gets the chart’s X axis.
valueAxisAxisReadonly. Gets the chart’s Y axis.
secondValueAxisAxisReadonly. Gets the chart’s second Y axis.
secondCategoryAxisAxisReadonly. Gets the chart’s second X axis.
seriesAxisAxisReadonly. Gets the chart’s series axis.
legendLegendReadonly. Gets the chart legend.
chartDataTableChartDataTableReadonly. Represents the chart data table.
showLegendbooleanGets or sets a value indicating whether the chart legend will be displayed. Default is true.
isRectangularCorneredbooleanGets or sets a value indicating whether the chart area is rectangular cornered. Default is true.
showDataTablebooleanGets or sets a value indicating whether the chart displays a data table.
firstSliceAnglenumberGets or sets the angle of the first pie-chart or doughnut-chart slice, in degrees (clockwise from vertical). Applies only to pie, 3-D pie, and doughnut charts, 0 to 360.
gapWidthnumberReturns or sets the space between bar or column clusters, as a percentage of the bar or column width. The value of this property must be between 0 and 500.
gapDepthnumberGets or sets the distance between the data series in a 3-D chart, as a percentage of the marker width. The value of this property must be between 0 and 500.
floorFloorReadonly. Returns a Floor object that represents the walls of a 3-D chart.
wallsWallsReadonly. Returns a Walls object that represents the walls of a 3-D chart.
backWallWallsReadonly. Returns a Walls object that represents the back wall of a 3-D chart.
sideWallWallsReadonly. Returns a Walls object that represents the side wall of a 3-D chart.
wallsAndGridlines2DbooleanTrue if gridlines are drawn two-dimensionally on a 3-D chart.
rotationAnglenumberRepresents the rotation of the 3-D chart view (the rotation of the plot area around the z-axis, in degrees).
elevationnumberRepresents the elevation of the 3-D chart view, in degrees.
rightAngleAxesbooleanTrue if the chart axes are at right angles. Applies only for 3-D charts(except Column3D and 3-D Pie Charts).
autoScalingbooleanTrue if Microsoft Excel scales a 3-D chart so that it’s closer in size to the equivalent 2-D chart. The RightAngleAxes property must be True.
heightPercentnumberReturns or sets the height of a 3-D chart as a percentage of the chart width (between 5 and 500 percent).
perspectivenumberReturns or sets the perspective for the 3-D chart view. Must be between 0 and 100. This property is ignored if the RightAngleAxes property is True.
is3DbooleanReadonly. Indicates whether the chart is a 3d chart.
depthPercentnumberRepresents the depth of a 3-D chart as a percentage of the chart width (between 20 and 2000 percent).
placementPlacementTypeRepresents the way the chart is attached to the cells below it.
pageSetupPageSetupReadonly. Represents the page setup description in this chart.
lineLineReadonly. Gets the line.

Methods

MethodDescription
getStyle()@deprecated. Please use the ‘style’ property instead. Gets and sets the builtin style.
setStyle(number)@deprecated. Please use the ‘style’ property instead. Gets and sets the builtin style.
getChartObject()@deprecated. Please use the ‘chartObject’ property instead. Represents the chartShape;
getHidePivotFieldButtons()@deprecated. Please use the ‘hidePivotFieldButtons’ property instead. Indicates whether hide the pivot chart field buttons only when the chart is PivotChart.
setHidePivotFieldButtons(boolean)@deprecated. Please use the ‘hidePivotFieldButtons’ property instead. Indicates whether hide the pivot chart field buttons only when the chart is PivotChart.
getPivotOptions()@deprecated. Please use the ‘pivotOptions’ property instead. Specifies the pivot controls that appear on the chart
getPivotSource()@deprecated. Please use the ‘pivotSource’ property instead. The source is the data of the pivotTable. If PivotSource is not empty ,the chart is PivotChart.
setPivotSource(string)@deprecated. Please use the ‘pivotSource’ property instead. The source is the data of the pivotTable. If PivotSource is not empty ,the chart is PivotChart.
getPlotBy()@deprecated. Please use the ‘plotBy’ property instead. Gets and sets whether plot by row or column.
getPlotEmptyCellsType()@deprecated. Please use the ‘plotEmptyCellsType’ property instead. Gets and sets how to plot the empty cells.
setPlotEmptyCellsType(PlotEmptyCellsType)@deprecated. Please use the ‘plotEmptyCellsType’ property instead. Gets and sets how to plot the empty cells.
getPlotVisibleCellsOnly()@deprecated. Please use the ‘plotVisibleCellsOnly’ property instead. Indicates whether plot visible cells only.
setPlotVisibleCellsOnly(boolean)@deprecated. Please use the ‘plotVisibleCellsOnly’ property instead. Indicates whether plot visible cells only.
getDisplayNaAsBlank()@deprecated. Please use the ‘displayNaAsBlank’ property instead. Indicates whether displaying #N/A as blank value.
setDisplayNaAsBlank(boolean)@deprecated. Please use the ‘displayNaAsBlank’ property instead. Indicates whether displaying #N/A as blank value.
getName()@deprecated. Please use the ’name’ property instead. Gets and sets the name of the chart.
setName(string)@deprecated. Please use the ’name’ property instead. Gets and sets the name of the chart.
getSizeWithWindow()@deprecated. Please use the ‘sizeWithWindow’ property instead. True if Microsoft Excel resizes the chart to match the size of the chart sheet window.
setSizeWithWindow(boolean)@deprecated. Please use the ‘sizeWithWindow’ property instead. True if Microsoft Excel resizes the chart to match the size of the chart sheet window.
getWorksheet()@deprecated. Please use the ‘worksheet’ property instead. Gets the worksheet which contains this chart.
getShapes()@deprecated. Please use the ‘shapes’ property instead. Returns all drawing shapes in this chart.
getPrintSize()@deprecated. Please use the ‘printSize’ property instead. Gets and sets the printed chart size.
setPrintSize(PrintSizeType)@deprecated. Please use the ‘printSize’ property instead. Gets and sets the printed chart size.
getType()@deprecated. Please use the ’type’ property instead. Gets or sets a chart’s type.
setType(ChartType)@deprecated. Please use the ’type’ property instead. Gets or sets a chart’s type.
getNSeries()@deprecated. Please use the ’nSeries’ property instead. Gets a SeriesCollection collection representing the data series in the chart.
getFilteredNSeries()@deprecated. Please use the ‘filteredNSeries’ property instead. Gets a SeriesCollection collection representing the data series that are filtered in the chart.
getTitle()@deprecated. Please use the ’title’ property instead. Gets the chart’s title.
getSubTitle()@deprecated. Please use the ‘subTitle’ property instead. Gets the chart’s sub-title. Only for ODS format file.
getPlotArea()@deprecated. Please use the ‘plotArea’ property instead. Gets the chart’s plot area which includes axis tick labels.
getChartArea()@deprecated. Please use the ‘chartArea’ property instead. Gets the chart area in the worksheet.
getCategoryAxis()@deprecated. Please use the ‘categoryAxis’ property instead. Gets the chart’s X axis.
getValueAxis()@deprecated. Please use the ‘valueAxis’ property instead. Gets the chart’s Y axis.
getSecondValueAxis()@deprecated. Please use the ‘secondValueAxis’ property instead. Gets the chart’s second Y axis.
getSecondCategoryAxis()@deprecated. Please use the ‘secondCategoryAxis’ property instead. Gets the chart’s second X axis.
getSeriesAxis()@deprecated. Please use the ‘seriesAxis’ property instead. Gets the chart’s series axis.
getLegend()@deprecated. Please use the ’legend’ property instead. Gets the chart legend.
getChartDataTable()@deprecated. Please use the ‘chartDataTable’ property instead. Represents the chart data table.
getShowLegend()@deprecated. Please use the ‘showLegend’ property instead. Gets or sets a value indicating whether the chart legend will be displayed. Default is true.
setShowLegend(boolean)@deprecated. Please use the ‘showLegend’ property instead. Gets or sets a value indicating whether the chart legend will be displayed. Default is true.
isRectangularCornered()@deprecated. Please use the ‘isRectangularCornered’ property instead. Gets or sets a value indicating whether the chart area is rectangular cornered. Default is true.
setIsRectangularCornered(boolean)@deprecated. Please use the ‘isRectangularCornered’ property instead. Gets or sets a value indicating whether the chart area is rectangular cornered. Default is true.
getShowDataTable()@deprecated. Please use the ‘showDataTable’ property instead. Gets or sets a value indicating whether the chart displays a data table.
setShowDataTable(boolean)@deprecated. Please use the ‘showDataTable’ property instead. Gets or sets a value indicating whether the chart displays a data table.
getFirstSliceAngle()@deprecated. Please use the ‘firstSliceAngle’ property instead. Gets or sets the angle of the first pie-chart or doughnut-chart slice, in degrees (clockwise from vertical). Applies only to pie, 3-D pie, and doughnut charts, 0 to 360.
setFirstSliceAngle(number)@deprecated. Please use the ‘firstSliceAngle’ property instead. Gets or sets the angle of the first pie-chart or doughnut-chart slice, in degrees (clockwise from vertical). Applies only to pie, 3-D pie, and doughnut charts, 0 to 360.
getGapWidth()@deprecated. Please use the ‘gapWidth’ property instead. Returns or sets the space between bar or column clusters, as a percentage of the bar or column width. The value of this property must be between 0 and 500.
setGapWidth(number)@deprecated. Please use the ‘gapWidth’ property instead. Returns or sets the space between bar or column clusters, as a percentage of the bar or column width. The value of this property must be between 0 and 500.
getGapDepth()@deprecated. Please use the ‘gapDepth’ property instead. Gets or sets the distance between the data series in a 3-D chart, as a percentage of the marker width. The value of this property must be between 0 and 500.
setGapDepth(number)@deprecated. Please use the ‘gapDepth’ property instead. Gets or sets the distance between the data series in a 3-D chart, as a percentage of the marker width. The value of this property must be between 0 and 500.
getFloor()@deprecated. Please use the ‘floor’ property instead. Returns a Floor object that represents the walls of a 3-D chart.
getWalls()@deprecated. Please use the ‘walls’ property instead. Returns a Walls object that represents the walls of a 3-D chart.
getBackWall()@deprecated. Please use the ‘backWall’ property instead. Returns a Walls object that represents the back wall of a 3-D chart.
getSideWall()@deprecated. Please use the ‘sideWall’ property instead. Returns a Walls object that represents the side wall of a 3-D chart.
getWallsAndGridlines2D()@deprecated. Please use the ‘wallsAndGridlines2D’ property instead. True if gridlines are drawn two-dimensionally on a 3-D chart.
setWallsAndGridlines2D(boolean)@deprecated. Please use the ‘wallsAndGridlines2D’ property instead. True if gridlines are drawn two-dimensionally on a 3-D chart.
getRotationAngle()@deprecated. Please use the ‘rotationAngle’ property instead. Represents the rotation of the 3-D chart view (the rotation of the plot area around the z-axis, in degrees).
setRotationAngle(number)@deprecated. Please use the ‘rotationAngle’ property instead. Represents the rotation of the 3-D chart view (the rotation of the plot area around the z-axis, in degrees).
getElevation()@deprecated. Please use the ’elevation’ property instead. Represents the elevation of the 3-D chart view, in degrees.
setElevation(number)@deprecated. Please use the ’elevation’ property instead. Represents the elevation of the 3-D chart view, in degrees.
getRightAngleAxes()@deprecated. Please use the ‘rightAngleAxes’ property instead. True if the chart axes are at right angles. Applies only for 3-D charts(except Column3D and 3-D Pie Charts).
setRightAngleAxes(boolean)@deprecated. Please use the ‘rightAngleAxes’ property instead. True if the chart axes are at right angles. Applies only for 3-D charts(except Column3D and 3-D Pie Charts).
getAutoScaling()@deprecated. Please use the ‘autoScaling’ property instead. True if Microsoft Excel scales a 3-D chart so that it’s closer in size to the equivalent 2-D chart. The RightAngleAxes property must be True.
setAutoScaling(boolean)@deprecated. Please use the ‘autoScaling’ property instead. True if Microsoft Excel scales a 3-D chart so that it’s closer in size to the equivalent 2-D chart. The RightAngleAxes property must be True.
getHeightPercent()@deprecated. Please use the ‘heightPercent’ property instead. Returns or sets the height of a 3-D chart as a percentage of the chart width (between 5 and 500 percent).
setHeightPercent(number)@deprecated. Please use the ‘heightPercent’ property instead. Returns or sets the height of a 3-D chart as a percentage of the chart width (between 5 and 500 percent).
getPerspective()@deprecated. Please use the ‘perspective’ property instead. Returns or sets the perspective for the 3-D chart view. Must be between 0 and 100. This property is ignored if the RightAngleAxes property is True.
setPerspective(number)@deprecated. Please use the ‘perspective’ property instead. Returns or sets the perspective for the 3-D chart view. Must be between 0 and 100. This property is ignored if the RightAngleAxes property is True.
getIs3D()@deprecated. Please use the ‘is3D’ property instead. Indicates whether the chart is a 3d chart.
getDepthPercent()@deprecated. Please use the ‘depthPercent’ property instead. Represents the depth of a 3-D chart as a percentage of the chart width (between 20 and 2000 percent).
setDepthPercent(number)@deprecated. Please use the ‘depthPercent’ property instead. Represents the depth of a 3-D chart as a percentage of the chart width (between 20 and 2000 percent).
getPlacement()@deprecated. Please use the ‘placement’ property instead. Represents the way the chart is attached to the cells below it.
setPlacement(PlacementType)@deprecated. Please use the ‘placement’ property instead. Represents the way the chart is attached to the cells below it.
getPageSetup()@deprecated. Please use the ‘pageSetup’ property instead. Represents the page setup description in this chart.
getLine()@deprecated. Please use the ’line’ property instead. Gets the line.
isCellReferedByChart(number, number, number)Returns whether the cell refered by the chart.
isChartDataChanged()Detects if a chart’s data source has changed.
refreshPivotData()Refreshes chart’s data from pivot table.
changeTemplate(Uint8Array)Change chart type with preset template.
move(number, number, number, number)Moves the chart to a specified location.
calculate()Calculates the custom position of plot area, axes if the position of them are auto assigned.
calculate(ChartCalculateOptions)Calculates the custom position of plot area, axes if the position of them are auto assigned, with Chart Calculate Options.
toImage(string)Creates the chart image and saves it to a file. The extension of the file name determines the format of the image.
toImage(string, ImageType)Creates the chart image and saves it to a file in the specified image type.
toImage(string, number)Creates the chart image and saves it to a file in the Jpeg format.
toImage(number)Creates the chart image and saves it to a stream in the Jpeg format.
toImage(ImageType)Creates the chart image and saves it to a stream in the specified format.
toImage(string, ImageOrPrintOptions)Creates the chart image and saves it to a file. The extension of the file name determines the format of the image.
toImage(ImageOrPrintOptions)Creates the chart image and saves it to a stream in the specified format.
toImageAsync(string)Creates the chart image and saves it to a file. The extension of the file name determines the format of the image.
toImageAsync(string, ImageType)Creates the chart image and saves it to a file in the specified image type.
toImageAsync(string, number)Creates the chart image and saves it to a file in the Jpeg format.
toImageAsync(number)Creates the chart image and saves it to a stream in the Jpeg format.
toImageAsync(ImageType)Creates the chart image and saves it to a stream in the specified format.
toImageAsync(string, ImageOrPrintOptions)Creates the chart image and saves it to a file. The extension of the file name determines the format of the image.
toImageAsync(ImageOrPrintOptions)Creates the chart image and saves it to a stream in the specified format.
toPdf(string)Saves the chart to a pdf file.
toPdf(string, number, number, PageLayoutAlignmentType, PageLayoutAlignmentType)Saves the chart to a pdf file.
toPdf()Creates the chart pdf and saves it to a stream.
toPdf(number, number, PageLayoutAlignmentType, PageLayoutAlignmentType)Creates the chart pdf and saves it to a stream.
toPdfAsync(string)Saves the chart to a pdf file.
toPdfAsync(string, number, number, PageLayoutAlignmentType, PageLayoutAlignmentType)Saves the chart to a pdf file.
toPdfAsync()Creates the chart pdf and saves it to a stream.
toPdfAsync(number, number, PageLayoutAlignmentType, PageLayoutAlignmentType)Creates the chart pdf and saves it to a stream.
getActualSize()Gets actual size of chart in unit of pixels.
hasAxis(AxisType, boolean)Returns which axes exist on the chart.
switchRowColumn()Switches row/column.
getChartDataRange()Gets the data source range of the chart.
setChartDataRange(string, boolean)Specifies data range for a chart.
isNull()Checks whether the implementation object is null.

style

Gets and sets the builtin style.

style : number;

Remarks

It should be between 1 and 48. Return -1 if it’s not be set.

chartObject

Readonly. Represents the chartShape;

chartObject : ChartShape;

hidePivotFieldButtons

Indicates whether hide the pivot chart field buttons only when the chart is PivotChart.

hidePivotFieldButtons : boolean;

pivotOptions

Readonly. Specifies the pivot controls that appear on the chart

pivotOptions : PivotOptions;

pivotSource

The source is the data of the pivotTable. If PivotSource is not empty ,the chart is PivotChart.

pivotSource : string;

Remarks

If the pivot table “PivotTable1” in the Worksheet “Sheet1” in the file “Book1.xls”. The pivotSource could be “[Book1.xls]Sheet1!PivotTable1” if the chart and the PivotTable is not in the same workbook. If you set this property ,the previous data source setting will be lost.

plotBy

Readonly. Gets and sets whether plot by row or column.

plotBy : PlotDataByType;

plotEmptyCellsType

Gets and sets how to plot the empty cells.

plotEmptyCellsType : PlotEmptyCellsType;

plotVisibleCellsOnly

Indicates whether plot visible cells only.

plotVisibleCellsOnly : boolean;

displayNaAsBlank

Indicates whether displaying #N/A as blank value.

displayNaAsBlank : boolean;

name

Gets and sets the name of the chart.

name : string;

sizeWithWindow

True if Microsoft Excel resizes the chart to match the size of the chart sheet window.

sizeWithWindow : boolean;

worksheet

Readonly. Gets the worksheet which contains this chart.

worksheet : Worksheet;

shapes

Readonly. Returns all drawing shapes in this chart.

shapes : ShapeCollection;

printSize

Gets and sets the printed chart size.

printSize : PrintSizeType;

type

Gets or sets a chart’s type.

type : ChartType;

nSeries

Readonly. Gets a SeriesCollection collection representing the data series in the chart.

nSeries : SeriesCollection;

filteredNSeries

Readonly. Gets a SeriesCollection collection representing the data series that are filtered in the chart.

filteredNSeries : SeriesCollection;

title

Readonly. Gets the chart’s title.

title : Title;

subTitle

Readonly. Gets the chart’s sub-title. Only for ODS format file.

subTitle : Title;

plotArea

Readonly. Gets the chart’s plot area which includes axis tick labels.

plotArea : PlotArea;

chartArea

Readonly. Gets the chart area in the worksheet.

chartArea : ChartArea;

categoryAxis

Readonly. Gets the chart’s X axis.

categoryAxis : Axis;

valueAxis

Readonly. Gets the chart’s Y axis.

valueAxis : Axis;

secondValueAxis

Readonly. Gets the chart’s second Y axis.

secondValueAxis : Axis;

secondCategoryAxis

Readonly. Gets the chart’s second X axis.

secondCategoryAxis : Axis;

seriesAxis

Readonly. Gets the chart’s series axis.

seriesAxis : Axis;

legend

Readonly. Gets the chart legend.

legend : Legend;

chartDataTable

Readonly. Represents the chart data table.

chartDataTable : ChartDataTable;

showLegend

Gets or sets a value indicating whether the chart legend will be displayed. Default is true.

showLegend : boolean;

isRectangularCornered

Gets or sets a value indicating whether the chart area is rectangular cornered. Default is true.

isRectangularCornered : boolean;

showDataTable

Gets or sets a value indicating whether the chart displays a data table.

showDataTable : boolean;

firstSliceAngle

Gets or sets the angle of the first pie-chart or doughnut-chart slice, in degrees (clockwise from vertical). Applies only to pie, 3-D pie, and doughnut charts, 0 to 360.

firstSliceAngle : number;

gapWidth

Returns or sets the space between bar or column clusters, as a percentage of the bar or column width. The value of this property must be between 0 and 500.

gapWidth : number;

gapDepth

Gets or sets the distance between the data series in a 3-D chart, as a percentage of the marker width. The value of this property must be between 0 and 500.

gapDepth : number;

floor

Readonly. Returns a Floor object that represents the walls of a 3-D chart.

floor : Floor;

Remarks

This property doesn’t apply to 3-D pie charts.

walls

Readonly. Returns a Walls object that represents the walls of a 3-D chart.

walls : Walls;

Remarks

This property doesn’t apply to 3-D pie charts.

backWall

Readonly. Returns a Walls object that represents the back wall of a 3-D chart.

backWall : Walls;

sideWall

Readonly. Returns a Walls object that represents the side wall of a 3-D chart.

sideWall : Walls;

wallsAndGridlines2D

True if gridlines are drawn two-dimensionally on a 3-D chart.

wallsAndGridlines2D : boolean;

rotationAngle

Represents the rotation of the 3-D chart view (the rotation of the plot area around the z-axis, in degrees).

rotationAngle : number;

Remarks

The value of this property must be from 0 to 360, except for 3-D bar charts, where the value must be from 0 to 44. The default value is 20. Applies only to 3-D charts.

elevation

Represents the elevation of the 3-D chart view, in degrees.

elevation : number;

Remarks

The chart elevation is the height at which you view the chart, in degrees. The default is 15 for most chart types. The value of this property must be between -90 and 90, except for 3-D bar charts, where it must be between 0 and 44.

rightAngleAxes

True if the chart axes are at right angles. Applies only for 3-D charts(except Column3D and 3-D Pie Charts).

rightAngleAxes : boolean;

Remarks

If this property is True, the Perspective property is ignored.

autoScaling

True if Microsoft Excel scales a 3-D chart so that it’s closer in size to the equivalent 2-D chart. The RightAngleAxes property must be True.

autoScaling : boolean;

heightPercent

Returns or sets the height of a 3-D chart as a percentage of the chart width (between 5 and 500 percent).

heightPercent : number;

perspective

Returns or sets the perspective for the 3-D chart view. Must be between 0 and 100. This property is ignored if the RightAngleAxes property is True.

perspective : number;

is3D

Readonly. Indicates whether the chart is a 3d chart.

is3D : boolean;

depthPercent

Represents the depth of a 3-D chart as a percentage of the chart width (between 20 and 2000 percent).

depthPercent : number;

placement

Represents the way the chart is attached to the cells below it.

placement : PlacementType;

pageSetup

Readonly. Represents the page setup description in this chart.

pageSetup : PageSetup;

line

Readonly. Gets the line.

line : Line;

getStyle()

@deprecated. Please use the ‘style’ property instead. Gets and sets the builtin style.

getStyle() : number;

Remarks

It should be between 1 and 48. Return -1 if it’s not be set.

setStyle(number)

@deprecated. Please use the ‘style’ property instead. Gets and sets the builtin style.

setStyle(value: number) : void;

Parameters:

ParameterTypeDescription
valuenumberThe value to set.

Remarks

It should be between 1 and 48. Return -1 if it’s not be set.

getChartObject()

@deprecated. Please use the ‘chartObject’ property instead. Represents the chartShape;

getChartObject() : ChartShape;

Returns

ChartShape

getHidePivotFieldButtons()

@deprecated. Please use the ‘hidePivotFieldButtons’ property instead. Indicates whether hide the pivot chart field buttons only when the chart is PivotChart.

getHidePivotFieldButtons() : boolean;

setHidePivotFieldButtons(boolean)

@deprecated. Please use the ‘hidePivotFieldButtons’ property instead. Indicates whether hide the pivot chart field buttons only when the chart is PivotChart.

setHidePivotFieldButtons(value: boolean) : void;

Parameters:

ParameterTypeDescription
valuebooleanThe value to set.

getPivotOptions()

@deprecated. Please use the ‘pivotOptions’ property instead. Specifies the pivot controls that appear on the chart

getPivotOptions() : PivotOptions;

Returns

PivotOptions

getPivotSource()

@deprecated. Please use the ‘pivotSource’ property instead. The source is the data of the pivotTable. If PivotSource is not empty ,the chart is PivotChart.

getPivotSource() : string;

Remarks

If the pivot table “PivotTable1” in the Worksheet “Sheet1” in the file “Book1.xls”. The pivotSource could be “[Book1.xls]Sheet1!PivotTable1” if the chart and the PivotTable is not in the same workbook. If you set this property ,the previous data source setting will be lost.

setPivotSource(string)

@deprecated. Please use the ‘pivotSource’ property instead. The source is the data of the pivotTable. If PivotSource is not empty ,the chart is PivotChart.

setPivotSource(value: string) : void;

Parameters:

ParameterTypeDescription
valuestringThe value to set.

Remarks

If the pivot table “PivotTable1” in the Worksheet “Sheet1” in the file “Book1.xls”. The pivotSource could be “[Book1.xls]Sheet1!PivotTable1” if the chart and the PivotTable is not in the same workbook. If you set this property ,the previous data source setting will be lost.

getPlotBy()

@deprecated. Please use the ‘plotBy’ property instead. Gets and sets whether plot by row or column.

getPlotBy() : PlotDataByType;

Returns

PlotDataByType

getPlotEmptyCellsType()

@deprecated. Please use the ‘plotEmptyCellsType’ property instead. Gets and sets how to plot the empty cells.

getPlotEmptyCellsType() : PlotEmptyCellsType;

Returns

PlotEmptyCellsType

setPlotEmptyCellsType(PlotEmptyCellsType)

@deprecated. Please use the ‘plotEmptyCellsType’ property instead. Gets and sets how to plot the empty cells.

setPlotEmptyCellsType(value: PlotEmptyCellsType) : void;

Parameters:

ParameterTypeDescription
valuePlotEmptyCellsTypeThe value to set.

getPlotVisibleCellsOnly()

@deprecated. Please use the ‘plotVisibleCellsOnly’ property instead. Indicates whether plot visible cells only.

getPlotVisibleCellsOnly() : boolean;

setPlotVisibleCellsOnly(boolean)

@deprecated. Please use the ‘plotVisibleCellsOnly’ property instead. Indicates whether plot visible cells only.

setPlotVisibleCellsOnly(value: boolean) : void;

Parameters:

ParameterTypeDescription
valuebooleanThe value to set.

getDisplayNaAsBlank()

@deprecated. Please use the ‘displayNaAsBlank’ property instead. Indicates whether displaying #N/A as blank value.

getDisplayNaAsBlank() : boolean;

setDisplayNaAsBlank(boolean)

@deprecated. Please use the ‘displayNaAsBlank’ property instead. Indicates whether displaying #N/A as blank value.

setDisplayNaAsBlank(value: boolean) : void;

Parameters:

ParameterTypeDescription
valuebooleanThe value to set.

getName()

@deprecated. Please use the ’name’ property instead. Gets and sets the name of the chart.

getName() : string;

setName(string)

@deprecated. Please use the ’name’ property instead. Gets and sets the name of the chart.

setName(value: string) : void;

Parameters:

ParameterTypeDescription
valuestringThe value to set.

getSizeWithWindow()

@deprecated. Please use the ‘sizeWithWindow’ property instead. True if Microsoft Excel resizes the chart to match the size of the chart sheet window.

getSizeWithWindow() : boolean;

setSizeWithWindow(boolean)

@deprecated. Please use the ‘sizeWithWindow’ property instead. True if Microsoft Excel resizes the chart to match the size of the chart sheet window.

setSizeWithWindow(value: boolean) : void;

Parameters:

ParameterTypeDescription
valuebooleanThe value to set.

getWorksheet()

@deprecated. Please use the ‘worksheet’ property instead. Gets the worksheet which contains this chart.

getWorksheet() : Worksheet;

Returns

Worksheet

getShapes()

@deprecated. Please use the ‘shapes’ property instead. Returns all drawing shapes in this chart.

getShapes() : ShapeCollection;

Returns

ShapeCollection

getPrintSize()

@deprecated. Please use the ‘printSize’ property instead. Gets and sets the printed chart size.

getPrintSize() : PrintSizeType;

Returns

PrintSizeType

setPrintSize(PrintSizeType)

@deprecated. Please use the ‘printSize’ property instead. Gets and sets the printed chart size.

setPrintSize(value: PrintSizeType) : void;

Parameters:

ParameterTypeDescription
valuePrintSizeTypeThe value to set.

getType()

@deprecated. Please use the ’type’ property instead. Gets or sets a chart’s type.

getType() : ChartType;

Returns

ChartType

setType(ChartType)

@deprecated. Please use the ’type’ property instead. Gets or sets a chart’s type.

setType(value: ChartType) : void;

Parameters:

ParameterTypeDescription
valueChartTypeThe value to set.

getNSeries()

@deprecated. Please use the ’nSeries’ property instead. Gets a SeriesCollection collection representing the data series in the chart.

getNSeries() : SeriesCollection;

Returns

SeriesCollection

getFilteredNSeries()

@deprecated. Please use the ‘filteredNSeries’ property instead. Gets a SeriesCollection collection representing the data series that are filtered in the chart.

getFilteredNSeries() : SeriesCollection;

Returns

SeriesCollection

getTitle()

@deprecated. Please use the ’title’ property instead. Gets the chart’s title.

getTitle() : Title;

Returns

Title

getSubTitle()

@deprecated. Please use the ‘subTitle’ property instead. Gets the chart’s sub-title. Only for ODS format file.

getSubTitle() : Title;

Returns

Title

getPlotArea()

@deprecated. Please use the ‘plotArea’ property instead. Gets the chart’s plot area which includes axis tick labels.

getPlotArea() : PlotArea;

Returns

PlotArea

getChartArea()

@deprecated. Please use the ‘chartArea’ property instead. Gets the chart area in the worksheet.

getChartArea() : ChartArea;

Returns

ChartArea

getCategoryAxis()

@deprecated. Please use the ‘categoryAxis’ property instead. Gets the chart’s X axis.

getCategoryAxis() : Axis;

Returns

Axis

getValueAxis()

@deprecated. Please use the ‘valueAxis’ property instead. Gets the chart’s Y axis.

getValueAxis() : Axis;

Returns

Axis

getSecondValueAxis()

@deprecated. Please use the ‘secondValueAxis’ property instead. Gets the chart’s second Y axis.

getSecondValueAxis() : Axis;

Returns

Axis

getSecondCategoryAxis()

@deprecated. Please use the ‘secondCategoryAxis’ property instead. Gets the chart’s second X axis.

getSecondCategoryAxis() : Axis;

Returns

Axis

getSeriesAxis()

@deprecated. Please use the ‘seriesAxis’ property instead. Gets the chart’s series axis.

getSeriesAxis() : Axis;

Returns

Axis

getLegend()

@deprecated. Please use the ’legend’ property instead. Gets the chart legend.

getLegend() : Legend;

Returns

Legend

getChartDataTable()

@deprecated. Please use the ‘chartDataTable’ property instead. Represents the chart data table.

getChartDataTable() : ChartDataTable;

Returns

ChartDataTable

getShowLegend()

@deprecated. Please use the ‘showLegend’ property instead. Gets or sets a value indicating whether the chart legend will be displayed. Default is true.

getShowLegend() : boolean;

setShowLegend(boolean)

@deprecated. Please use the ‘showLegend’ property instead. Gets or sets a value indicating whether the chart legend will be displayed. Default is true.

setShowLegend(value: boolean) : void;

Parameters:

ParameterTypeDescription
valuebooleanThe value to set.

isRectangularCornered()

@deprecated. Please use the ‘isRectangularCornered’ property instead. Gets or sets a value indicating whether the chart area is rectangular cornered. Default is true.

isRectangularCornered() : boolean;

setIsRectangularCornered(boolean)

@deprecated. Please use the ‘isRectangularCornered’ property instead. Gets or sets a value indicating whether the chart area is rectangular cornered. Default is true.

setIsRectangularCornered(value: boolean) : void;

Parameters:

ParameterTypeDescription
valuebooleanThe value to set.

getShowDataTable()

@deprecated. Please use the ‘showDataTable’ property instead. Gets or sets a value indicating whether the chart displays a data table.

getShowDataTable() : boolean;

setShowDataTable(boolean)

@deprecated. Please use the ‘showDataTable’ property instead. Gets or sets a value indicating whether the chart displays a data table.

setShowDataTable(value: boolean) : void;

Parameters:

ParameterTypeDescription
valuebooleanThe value to set.

getFirstSliceAngle()

@deprecated. Please use the ‘firstSliceAngle’ property instead. Gets or sets the angle of the first pie-chart or doughnut-chart slice, in degrees (clockwise from vertical). Applies only to pie, 3-D pie, and doughnut charts, 0 to 360.

getFirstSliceAngle() : number;

setFirstSliceAngle(number)

@deprecated. Please use the ‘firstSliceAngle’ property instead. Gets or sets the angle of the first pie-chart or doughnut-chart slice, in degrees (clockwise from vertical). Applies only to pie, 3-D pie, and doughnut charts, 0 to 360.

setFirstSliceAngle(value: number) : void;

Parameters:

ParameterTypeDescription
valuenumberThe value to set.

getGapWidth()

@deprecated. Please use the ‘gapWidth’ property instead. Returns or sets the space between bar or column clusters, as a percentage of the bar or column width. The value of this property must be between 0 and 500.

getGapWidth() : number;

setGapWidth(number)

@deprecated. Please use the ‘gapWidth’ property instead. Returns or sets the space between bar or column clusters, as a percentage of the bar or column width. The value of this property must be between 0 and 500.

setGapWidth(value: number) : void;

Parameters:

ParameterTypeDescription
valuenumberThe value to set.

getGapDepth()

@deprecated. Please use the ‘gapDepth’ property instead. Gets or sets the distance between the data series in a 3-D chart, as a percentage of the marker width. The value of this property must be between 0 and 500.

getGapDepth() : number;

setGapDepth(number)

@deprecated. Please use the ‘gapDepth’ property instead. Gets or sets the distance between the data series in a 3-D chart, as a percentage of the marker width. The value of this property must be between 0 and 500.

setGapDepth(value: number) : void;

Parameters:

ParameterTypeDescription
valuenumberThe value to set.

getFloor()

@deprecated. Please use the ‘floor’ property instead. Returns a Floor object that represents the walls of a 3-D chart.

getFloor() : Floor;

Returns

Floor

Remarks

This property doesn’t apply to 3-D pie charts.

getWalls()

@deprecated. Please use the ‘walls’ property instead. Returns a Walls object that represents the walls of a 3-D chart.

getWalls() : Walls;

Returns

Walls

Remarks

This property doesn’t apply to 3-D pie charts.

getBackWall()

@deprecated. Please use the ‘backWall’ property instead. Returns a Walls object that represents the back wall of a 3-D chart.

getBackWall() : Walls;

Returns

Walls

getSideWall()

@deprecated. Please use the ‘sideWall’ property instead. Returns a Walls object that represents the side wall of a 3-D chart.

getSideWall() : Walls;

Returns

Walls

getWallsAndGridlines2D()

@deprecated. Please use the ‘wallsAndGridlines2D’ property instead. True if gridlines are drawn two-dimensionally on a 3-D chart.

getWallsAndGridlines2D() : boolean;

setWallsAndGridlines2D(boolean)

@deprecated. Please use the ‘wallsAndGridlines2D’ property instead. True if gridlines are drawn two-dimensionally on a 3-D chart.

setWallsAndGridlines2D(value: boolean) : void;

Parameters:

ParameterTypeDescription
valuebooleanThe value to set.

getRotationAngle()

@deprecated. Please use the ‘rotationAngle’ property instead. Represents the rotation of the 3-D chart view (the rotation of the plot area around the z-axis, in degrees).

getRotationAngle() : number;

Remarks

The value of this property must be from 0 to 360, except for 3-D bar charts, where the value must be from 0 to 44. The default value is 20. Applies only to 3-D charts.

setRotationAngle(number)

@deprecated. Please use the ‘rotationAngle’ property instead. Represents the rotation of the 3-D chart view (the rotation of the plot area around the z-axis, in degrees).

setRotationAngle(value: number) : void;

Parameters:

ParameterTypeDescription
valuenumberThe value to set.

Remarks

The value of this property must be from 0 to 360, except for 3-D bar charts, where the value must be from 0 to 44. The default value is 20. Applies only to 3-D charts.

getElevation()

@deprecated. Please use the ’elevation’ property instead. Represents the elevation of the 3-D chart view, in degrees.

getElevation() : number;

Remarks

The chart elevation is the height at which you view the chart, in degrees. The default is 15 for most chart types. The value of this property must be between -90 and 90, except for 3-D bar charts, where it must be between 0 and 44.

setElevation(number)

@deprecated. Please use the ’elevation’ property instead. Represents the elevation of the 3-D chart view, in degrees.

setElevation(value: number) : void;

Parameters:

ParameterTypeDescription
valuenumberThe value to set.

Remarks

The chart elevation is the height at which you view the chart, in degrees. The default is 15 for most chart types. The value of this property must be between -90 and 90, except for 3-D bar charts, where it must be between 0 and 44.

getRightAngleAxes()

@deprecated. Please use the ‘rightAngleAxes’ property instead. True if the chart axes are at right angles. Applies only for 3-D charts(except Column3D and 3-D Pie Charts).

getRightAngleAxes() : boolean;

Remarks

If this property is True, the Perspective property is ignored.

setRightAngleAxes(boolean)

@deprecated. Please use the ‘rightAngleAxes’ property instead. True if the chart axes are at right angles. Applies only for 3-D charts(except Column3D and 3-D Pie Charts).

setRightAngleAxes(value: boolean) : void;

Parameters:

ParameterTypeDescription
valuebooleanThe value to set.

Remarks

If this property is True, the Perspective property is ignored.

getAutoScaling()

@deprecated. Please use the ‘autoScaling’ property instead. True if Microsoft Excel scales a 3-D chart so that it’s closer in size to the equivalent 2-D chart. The RightAngleAxes property must be True.

getAutoScaling() : boolean;

setAutoScaling(boolean)

@deprecated. Please use the ‘autoScaling’ property instead. True if Microsoft Excel scales a 3-D chart so that it’s closer in size to the equivalent 2-D chart. The RightAngleAxes property must be True.

setAutoScaling(value: boolean) : void;

Parameters:

ParameterTypeDescription
valuebooleanThe value to set.

getHeightPercent()

@deprecated. Please use the ‘heightPercent’ property instead. Returns or sets the height of a 3-D chart as a percentage of the chart width (between 5 and 500 percent).

getHeightPercent() : number;

setHeightPercent(number)

@deprecated. Please use the ‘heightPercent’ property instead. Returns or sets the height of a 3-D chart as a percentage of the chart width (between 5 and 500 percent).

setHeightPercent(value: number) : void;

Parameters:

ParameterTypeDescription
valuenumberThe value to set.

getPerspective()

@deprecated. Please use the ‘perspective’ property instead. Returns or sets the perspective for the 3-D chart view. Must be between 0 and 100. This property is ignored if the RightAngleAxes property is True.

getPerspective() : number;

setPerspective(number)

@deprecated. Please use the ‘perspective’ property instead. Returns or sets the perspective for the 3-D chart view. Must be between 0 and 100. This property is ignored if the RightAngleAxes property is True.

setPerspective(value: number) : void;

Parameters:

ParameterTypeDescription
valuenumberThe value to set.

getIs3D()

@deprecated. Please use the ‘is3D’ property instead. Indicates whether the chart is a 3d chart.

getIs3D() : boolean;

getDepthPercent()

@deprecated. Please use the ‘depthPercent’ property instead. Represents the depth of a 3-D chart as a percentage of the chart width (between 20 and 2000 percent).

getDepthPercent() : number;

setDepthPercent(number)

@deprecated. Please use the ‘depthPercent’ property instead. Represents the depth of a 3-D chart as a percentage of the chart width (between 20 and 2000 percent).

setDepthPercent(value: number) : void;

Parameters:

ParameterTypeDescription
valuenumberThe value to set.

getPlacement()

@deprecated. Please use the ‘placement’ property instead. Represents the way the chart is attached to the cells below it.

getPlacement() : PlacementType;

Returns

PlacementType

setPlacement(PlacementType)

@deprecated. Please use the ‘placement’ property instead. Represents the way the chart is attached to the cells below it.

setPlacement(value: PlacementType) : void;

Parameters:

ParameterTypeDescription
valuePlacementTypeThe value to set.

getPageSetup()

@deprecated. Please use the ‘pageSetup’ property instead. Represents the page setup description in this chart.

getPageSetup() : PageSetup;

Returns

PageSetup

getLine()

@deprecated. Please use the ’line’ property instead. Gets the line.

getLine() : Line;

Returns

Line

isCellReferedByChart(number, number, number)

Returns whether the cell refered by the chart.

isCellReferedByChart(sheetIndex: number, rowIndex: number, columnIndex: number) : boolean;

Parameters:

ParameterTypeDescription
sheetIndexnumberThe sheet Index.-1 means the worksheet which contains current chart.
rowIndexnumberThe row index
columnIndexnumberThe column index

isChartDataChanged()

Detects if a chart’s data source has changed.

isChartDataChanged() : boolean;

Returns

Returns true if the chart has changed otherwise returns false

Remarks

The method detects the changes in the chart’s data source before rendering the chart to image format. At first Chart.toImage call, the chart source data (e.g. XValuesParseData, ValuesParseData) will be recorded. Before calling the Chart.toImage method again, call IsChartDataChanged method to check if Chart needs re-rendering.

refreshPivotData()

Refreshes chart’s data from pivot table.

refreshPivotData() : void;

Remarks

We will gather data from pivot data source to the pivot table report. This method is only used to gather all data to a pivot chart.

changeTemplate(Uint8Array)

Change chart type with preset template.

changeTemplate(data: Uint8Array) : void;

Parameters:

ParameterTypeDescription
datanumber[]The data of chart template file(.crtx).

move(number, number, number, number)

Moves the chart to a specified location.

move(upperLeftRow: number, upperLeftColumn: number, lowerRightRow: number, lowerRightColumn: number) : void;

Parameters:

ParameterTypeDescription
upperLeftRownumberUpper left row index.
upperLeftColumnnumberUpper left column index.
lowerRightRownumberLower right row index
lowerRightColumnnumberLower right column index

calculate()

Calculates the custom position of plot area, axes if the position of them are auto assigned.

calculate() : void;

calculate(ChartCalculateOptions)

Calculates the custom position of plot area, axes if the position of them are auto assigned, with Chart Calculate Options.

calculate(calculateOptions: ChartCalculateOptions) : void;

Parameters:

ParameterTypeDescription
calculateOptionsChartCalculateOptions

toImage(string)

Creates the chart image and saves it to a file. The extension of the file name determines the format of the image.

toImage(imageFile: string) : void;

Parameters:

ParameterTypeDescription
imageFilestringThe image file name with full path.

Remarks

The format of the image is specified by using the extension of the file name. For example, if you specify “myfile.png”, then the image will be saved in the PNG format. The following file extensions are recognized: .bmp, .gif, .png, .jpg, .jpeg, .tiff, .tif, .emf.

If the width or height is zero or the chart is not supported according to Supported Charts List, this method will do nothing.

toImage(string, ImageType)

Creates the chart image and saves it to a file in the specified image type.

toImage(imageFile: string, imageType: ImageType) : void;

Parameters:

ParameterTypeDescription
imageFilestringThe image file name with full path.
imageTypeImageTypeThe image type in which to save the image.

Remarks

The type of the image is specified by using imageType. The following types are supported: ImageType.Bmp, ImageType.Gif, ImageType.Png, ImageType.Jpeg, ImageType.Tiff, ImageType.Emf.

If the width or height is zero or the chart is not supported according to Supported Charts List, this method will do nothing.

toImage(string, number)

Creates the chart image and saves it to a file in the Jpeg format.

toImage(imageFile: string, jpegQuality: number) : void;

Parameters:

ParameterTypeDescription
imageFilestringThe image file name with full path.
jpegQualitynumberJpeg quality.

Remarks

If the width or height is zero or the chart is not supported according to Supported Charts List, this method will do nothing. NOTE: This method is now obsolete. Instead, please use ToImage(string,ImageOrPrintOptions) method with specified quality. This method will be removed 12 months later since March 2025. Aspose apologizes for any inconvenience you may have experienced.

toImage(number)

Creates the chart image and saves it to a stream in the Jpeg format.

toImage(jpegQuality: number) : Uint8Array;

Parameters:

ParameterTypeDescription
jpegQualitynumberJpeg quality.

Returns

The result stream

Remarks

If the width or height is zero or the chart is not supported according to Supported Charts List, this method will do nothing.

toImage(ImageType)

Creates the chart image and saves it to a stream in the specified format.

toImage(imageType: ImageType) : Uint8Array;

Parameters:

ParameterTypeDescription
imageTypeImageTypeThe image type in which to save the image.

Returns

The result stream

Remarks

The type of the image is specified by using imageType. The following types are supported: ImageType.Bmp, ImageType.Gif, ImageType.Png, ImageType.Jpeg, ImageType.Tiff, ImageType.Emf.

If the width or height is zero or the chart is not supported according to Supported Charts List, this method will do nothing.

toImage(string, ImageOrPrintOptions)

Creates the chart image and saves it to a file. The extension of the file name determines the format of the image.

toImage(imageFile: string, options: ImageOrPrintOptions) : void;

Parameters:

ParameterTypeDescription
imageFilestringThe image file name with full path.
optionsImageOrPrintOptionsAdditional image creation options

Remarks

The format of the image is specified by using the extension of the file name. For example, if you specify “myfile.png”, then the image will be saved in the PNG format. The following file extensions are recognized: .bmp, .gif, .png, .jpg, .jpeg, .tiff, .tif, .emf.

If the width or height is zero or the chart is not supported according to Supported Charts List, this method will do nothing. Please refer to Supported Charts List for more details.

Example

Saves a chart to a png file with 400 x dpi and 300 y dpi.

const { Workbook, ImageOrPrintOptions } = require("aspose.cells.node");

var options = new ImageOrPrintOptions();
options.horizontalResolution = 400;
options.verticalResolution = 300;
options.quality = 80;

var book = new Workbook("input/Chart.xls");
book.worksheets.get(0).charts.get(0).toImage("output/chart-r-400x300.png", options);

toImage(ImageOrPrintOptions)

Creates the chart image and saves it to a stream in the specified format.

toImage(options: ImageOrPrintOptions) : Uint8Array;

Parameters:

ParameterTypeDescription
optionsImageOrPrintOptionsAdditional image creation options

Returns

The result stream

Remarks

The type of the image is specified by using options.ImageType. The following formats are supported: ImageType.Bmp, ImageType.Gif, ImageType.Png, ImageType.Jpeg, ImageType.Tiff, ImageType.Emf.

If the width or height is zero or the chart is not supported according to Supported Charts List, this method will do nothing. Please refer to Supported Charts List for more details.

Example

Saves a chart to an Uint8Array in jpeg file format with 400 x dpi and 300 y dpi.

const fs = require("fs");
const { Workbook, ImageOrPrintOptions, ImageType } = require("aspose.cells.node");

var options = new ImageOrPrintOptions();
options.setImageType(ImageType.Jpeg);
options.horizontalResolution = 400;
options.verticalResolution = 300;

var book = new Workbook("input/Chart.xls");
var uint8Array = book.worksheets.get(0).charts.get(0).toImage(options);
const buffer = Buffer.from(uint8Array);
fs.writeFileSync("output/chart-stream.jpg", buffer);

toImageAsync(string)

Creates the chart image and saves it to a file. The extension of the file name determines the format of the image.

toImageAsync(imageFile: string) : Promise<void>;

Parameters:

ParameterTypeDescription
imageFilestringThe image file name with full path.

Returns

Promise

Remarks

The format of the image is specified by using the extension of the file name. For example, if you specify “myfile.png”, then the image will be saved in the PNG format. The following file extensions are recognized: .bmp, .gif, .png, .jpg, .jpeg, .tiff, .tif, .emf.

If the width or height is zero or the chart is not supported according to Supported Charts List, this method will do nothing.

toImageAsync(string, ImageType)

Creates the chart image and saves it to a file in the specified image type.

toImageAsync(imageFile: string, imageType: ImageType) : Promise<void>;

Parameters:

ParameterTypeDescription
imageFilestringThe image file name with full path.
imageTypeImageTypeThe image type in which to save the image.

Returns

Promise

Remarks

The type of the image is specified by using imageType. The following types are supported: ImageType.Bmp, ImageType.Gif, ImageType.Png, ImageType.Jpeg, ImageType.Tiff, ImageType.Emf.

If the width or height is zero or the chart is not supported according to Supported Charts List, this method will do nothing.

toImageAsync(string, number)

Creates the chart image and saves it to a file in the Jpeg format.

toImageAsync(imageFile: string, jpegQuality: number) : Promise<void>;

Parameters:

ParameterTypeDescription
imageFilestringThe image file name with full path.
jpegQualitynumberJpeg quality.

Returns

Promise

Remarks

If the width or height is zero or the chart is not supported according to Supported Charts List, this method will do nothing. NOTE: This method is now obsolete. Instead, please use ToImage(string,ImageOrPrintOptions) method with specified quality. This method will be removed 12 months later since March 2025. Aspose apologizes for any inconvenience you may have experienced.

toImageAsync(number)

Creates the chart image and saves it to a stream in the Jpeg format.

toImageAsync(jpegQuality: number) : Promise<Uint8Array>;

Parameters:

ParameterTypeDescription
jpegQualitynumberJpeg quality.

Returns

The result stream

Remarks

If the width or height is zero or the chart is not supported according to Supported Charts List, this method will do nothing.

toImageAsync(ImageType)

Creates the chart image and saves it to a stream in the specified format.

toImageAsync(imageType: ImageType) : Promise<Uint8Array>;

Parameters:

ParameterTypeDescription
imageTypeImageTypeThe image type in which to save the image.

Returns

The result stream

Remarks

The type of the image is specified by using imageType. The following types are supported: ImageType.Bmp, ImageType.Gif, ImageType.Png, ImageType.Jpeg, ImageType.Tiff, ImageType.Emf.

If the width or height is zero or the chart is not supported according to Supported Charts List, this method will do nothing.

toImageAsync(string, ImageOrPrintOptions)

Creates the chart image and saves it to a file. The extension of the file name determines the format of the image.

toImageAsync(imageFile: string, options: ImageOrPrintOptions) : Promise<void>;

Parameters:

ParameterTypeDescription
imageFilestringThe image file name with full path.
optionsImageOrPrintOptionsAdditional image creation options

Returns

Promise

Remarks

The format of the image is specified by using the extension of the file name. For example, if you specify “myfile.png”, then the image will be saved in the PNG format. The following file extensions are recognized: .bmp, .gif, .png, .jpg, .jpeg, .tiff, .tif, .emf.

If the width or height is zero or the chart is not supported according to Supported Charts List, this method will do nothing. Please refer to Supported Charts List for more details.

toImageAsync(ImageOrPrintOptions)

Creates the chart image and saves it to a stream in the specified format.

toImageAsync(options: ImageOrPrintOptions) : Promise<Uint8Array>;

Parameters:

ParameterTypeDescription
optionsImageOrPrintOptionsAdditional image creation options

Returns

The result stream

Remarks

The type of the image is specified by using options.ImageType. The following formats are supported: ImageType.Bmp, ImageType.Gif, ImageType.Png, ImageType.Jpeg, ImageType.Tiff, ImageType.Emf.

If the width or height is zero or the chart is not supported according to Supported Charts List, this method will do nothing. Please refer to Supported Charts List for more details.

toPdf(string)

Saves the chart to a pdf file.

toPdf(fileName: string) : void;

Parameters:

ParameterTypeDescription
fileNamestringthe pdf file name with full path

toPdf(string, number, number, PageLayoutAlignmentType, PageLayoutAlignmentType)

Saves the chart to a pdf file.

toPdf(fileName: string, desiredPageWidth: number, desiredPageHeight: number, hAlignmentType: PageLayoutAlignmentType, vAlignmentType: PageLayoutAlignmentType) : void;

Parameters:

ParameterTypeDescription
fileNamestringthe pdf file name with full path
desiredPageWidthnumberThe desired page width in inches.
desiredPageHeightnumberThe desired page height in inches.
hAlignmentTypePageLayoutAlignmentTypeThe chart horizontal alignment type in the output page.
vAlignmentTypePageLayoutAlignmentTypeThe chart vertical alignment type in the output page.

toPdf()

Creates the chart pdf and saves it to a stream.

toPdf() : Uint8Array;

Returns

The result stream

toPdf(number, number, PageLayoutAlignmentType, PageLayoutAlignmentType)

Creates the chart pdf and saves it to a stream.

toPdf(desiredPageWidth: number, desiredPageHeight: number, hAlignmentType: PageLayoutAlignmentType, vAlignmentType: PageLayoutAlignmentType) : Uint8Array;

Parameters:

ParameterTypeDescription
desiredPageWidthnumberThe desired page width in inches.
desiredPageHeightnumberThe desired page height in inches.
hAlignmentTypePageLayoutAlignmentTypeThe chart horizontal alignment type in the output page.
vAlignmentTypePageLayoutAlignmentTypeThe chart vertical alignment type in the output page.

Returns

The result stream

toPdfAsync(string)

Saves the chart to a pdf file.

toPdfAsync(fileName: string) : Promise<void>;

Parameters:

ParameterTypeDescription
fileNamestringthe pdf file name with full path

Returns

Promise

toPdfAsync(string, number, number, PageLayoutAlignmentType, PageLayoutAlignmentType)

Saves the chart to a pdf file.

toPdfAsync(fileName: string, desiredPageWidth: number, desiredPageHeight: number, hAlignmentType: PageLayoutAlignmentType, vAlignmentType: PageLayoutAlignmentType) : Promise<void>;

Parameters:

ParameterTypeDescription
fileNamestringthe pdf file name with full path
desiredPageWidthnumberThe desired page width in inches.
desiredPageHeightnumberThe desired page height in inches.
hAlignmentTypePageLayoutAlignmentTypeThe chart horizontal alignment type in the output page.
vAlignmentTypePageLayoutAlignmentTypeThe chart vertical alignment type in the output page.

Returns

Promise

toPdfAsync()

Creates the chart pdf and saves it to a stream.

toPdfAsync() : Promise<Uint8Array>;

Returns

The result stream

toPdfAsync(number, number, PageLayoutAlignmentType, PageLayoutAlignmentType)

Creates the chart pdf and saves it to a stream.

toPdfAsync(desiredPageWidth: number, desiredPageHeight: number, hAlignmentType: PageLayoutAlignmentType, vAlignmentType: PageLayoutAlignmentType) : Promise<Uint8Array>;

Parameters:

ParameterTypeDescription
desiredPageWidthnumberThe desired page width in inches.
desiredPageHeightnumberThe desired page height in inches.
hAlignmentTypePageLayoutAlignmentTypeThe chart horizontal alignment type in the output page.
vAlignmentTypePageLayoutAlignmentTypeThe chart vertical alignment type in the output page.

Returns

The result stream

getActualSize()

Gets actual size of chart in unit of pixels.

getActualSize() : number[];

Returns

Actual size in an array(width and height). [0] is width; [1] is height.

hasAxis(AxisType, boolean)

Returns which axes exist on the chart.

hasAxis(aixsType: AxisType, isPrimary: boolean) : boolean;

Parameters:

ParameterTypeDescription
aixsTypeAxisType
isPrimaryboolean

Remarks

Normally, Pie, PieExploded, PiePie,PieBar, Pie3D, Pie3DExploded,Doughnut, DoughnutExploded is no axis.

switchRowColumn()

Switches row/column.

switchRowColumn() : boolean;

Returns

False means switching row/column fails.

getChartDataRange()

Gets the data source range of the chart.

getChartDataRange() : string;

Returns

The data source.

Remarks

Only supports range.

setChartDataRange(string, boolean)

Specifies data range for a chart.

setChartDataRange(area: string, isVertical: boolean) : void;

Parameters:

ParameterTypeDescription
areastringSpecifies values from which to plot the data series
isVerticalbooleanSpecifies whether to plot the series from a range of cell values by row or by column.

isNull()

Checks whether the implementation object is null.

isNull() : boolean;