Trendline
Trendline class
Represents a trendline in a chart.
class Trendline extends Line;
Example
const { Workbook, ChartType, TrendlineType } = 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");
//adding a linear trendline
var index = chart.getNSeries().get(0).getTrendLines().add(TrendlineType.Linear);
var trendline = chart.getNSeries().get(0).getTrendLines().get(index);
//Setting the custom name of the trendline.
trendline.setName("Linear");
//Displaying the equation on chart
trendline.setDisplayEquation(true);
//Displaying the R-Squared value on chart
trendline.setDisplayRSquared(true);
//Saving the Excel file
workbook.save("output/ChartsTrendline.xls");
Constructors
Name | Description |
---|---|
constructor(Line) | Constructs from a parent object convertible to this. |
Methods
Method | Description |
---|---|
isNameAuto() | Returns if Microsoft Excel automatically determines the name of the trendline. |
setIsNameAuto(boolean) | Returns if Microsoft Excel automatically determines the name of the trendline. |
getType() | Returns the trendline type. |
getName() | Returns the name of the trendline. |
setName(string) | Returns the name of the trendline. |
getOrder() | Returns or sets the trendline order (an integer greater than 1) when the trendline type is Polynomial. The order must be between 2 and 6. |
setOrder(number) | Returns or sets the trendline order (an integer greater than 1) when the trendline type is Polynomial. The order must be between 2 and 6. |
getPeriod() | Returns or sets the period for the moving-average trendline. |
setPeriod(number) | Returns or sets the period for the moving-average trendline. |
getForward() | Returns or sets the number of periods (or units on a scatter chart) that the trendline extends forward. The number of periods must be greater than or equal to zero. |
setForward(number) | Returns or sets the number of periods (or units on a scatter chart) that the trendline extends forward. The number of periods must be greater than or equal to zero. |
getBackward() | Returns or sets the number of periods (or units on a scatter chart) that the trendline extends backward. The number of periods must be greater than or equal to zero. If the chart type is column ,the number of periods must be between 0 and 0.5 |
setBackward(number) | Returns or sets the number of periods (or units on a scatter chart) that the trendline extends backward. The number of periods must be greater than or equal to zero. If the chart type is column ,the number of periods must be between 0 and 0.5 |
getDisplayEquation() | Represents if the equation for the trendline is displayed on the chart (in the same data label as the R-squared value). Setting this property to True automatically turns on data labels. |
setDisplayEquation(boolean) | Represents if the equation for the trendline is displayed on the chart (in the same data label as the R-squared value). Setting this property to True automatically turns on data labels. |
getDisplayRSquared() | Represents if the R-squared value of the trendline is displayed on the chart (in the same data label as the equation). Setting this property to True automatically turns on data labels. |
setDisplayRSquared(boolean) | Represents if the R-squared value of the trendline is displayed on the chart (in the same data label as the equation). Setting this property to True automatically turns on data labels. |
getIntercept() | Returns or sets the point where the trendline crosses the value axis. |
setIntercept(number) | Returns or sets the point where the trendline crosses the value axis. |
getDataLabels() | Represents the DataLabels object for the specified series. |
getLegendEntry() | Gets the legend entry according to this trendline |
isNull() | Checks whether the implementation object is null. |
getCompoundType() | Specifies the compound line type |
setCompoundType(MsoLineStyle) | Specifies the compound line type |
getDashType() | Specifies the dash line type |
setDashType(MsoLineDashStyle) | Specifies the dash line type |
getCapType() | Specifies the ending caps. |
setCapType(LineCapType) | Specifies the ending caps. |
getJoinType() | Specifies the joining caps. |
setJoinType(LineJoinType) | Specifies the joining caps. |
getBeginType() | Specifies an arrowhead for the begin of a line. |
setBeginType(MsoArrowheadStyle) | Specifies an arrowhead for the begin of a line. |
getEndType() | Specifies an arrowhead for the end of a line. |
setEndType(MsoArrowheadStyle) | Specifies an arrowhead for the end of a line. |
getBeginArrowLength() | Specifies the length of the arrowhead for the begin of a line. |
setBeginArrowLength(MsoArrowheadLength) | Specifies the length of the arrowhead for the begin of a line. |
getEndArrowLength() | Specifies the length of the arrowhead for the end of a line. |
setEndArrowLength(MsoArrowheadLength) | Specifies the length of the arrowhead for the end of a line. |
getBeginArrowWidth() | Specifies the width of the arrowhead for the begin of a line. |
setBeginArrowWidth(MsoArrowheadWidth) | Specifies the width of the arrowhead for the begin of a line. |
getEndArrowWidth() | Specifies the width of the arrowhead for the end of a line. |
setEndArrowWidth(MsoArrowheadWidth) | Specifies the width of the arrowhead for the end of a line. |
getThemeColor() | Gets and sets the theme color. |
setThemeColor(ThemeColor) | Gets and sets the theme color. |
getColor() | Represents the Color of the line. |
setColor(Color) | Represents the Color of the line. |
getTransparency() | Returns or sets the degree of transparency of the line as a value from 0.0 (opaque) through 1.0 (clear). |
setTransparency(number) | Returns or sets the degree of transparency of the line as a value from 0.0 (opaque) through 1.0 (clear). |
getStyle() | Represents the style of the line. |
setStyle(LineType) | Represents the style of the line. |
getWeight() | Gets or sets the WeightType of the line. |
setWeight(WeightType) | Gets or sets the WeightType of the line. |
getWeightPt() | Gets or sets the weight of the line in unit of points. |
setWeightPt(number) | Gets or sets the weight of the line in unit of points. |
getWeightPx() | Gets or sets the weight of the line in unit of pixels. |
setWeightPx(number) | Gets or sets the weight of the line in unit of pixels. |
getFormattingType() | Gets or sets format type. |
setFormattingType(ChartLineFormattingType) | Gets or sets format type. |
isAutomaticColor() | Indicates whether the color of line is automatic assigned. |
isVisible() | Represents whether the line is visible. |
setIsVisible(boolean) | Represents whether the line is visible. |
isAuto() | Indicates whether this line style is auto assigned. |
setIsAuto(boolean) | Indicates whether this line style is auto assigned. |
getGradientFill() | Represents gradient fill. |
constructor(Line)
Constructs from a parent object convertible to this.
constructor(obj: Line);
Parameters:
Parameter | Type | Description |
---|---|---|
obj | Line | The parent object. |
isNameAuto()
Returns if Microsoft Excel automatically determines the name of the trendline.
isNameAuto() : boolean;
setIsNameAuto(boolean)
Returns if Microsoft Excel automatically determines the name of the trendline.
setIsNameAuto(value: boolean) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The value to set. |
getType()
Returns the trendline type.
getType() : TrendlineType;
Returns
getName()
Returns the name of the trendline.
getName() : string;
setName(string)
Returns the name of the trendline.
setName(value: string) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | string | The value to set. |
getOrder()
Returns or sets the trendline order (an integer greater than 1) when the trendline type is Polynomial. The order must be between 2 and 6.
getOrder() : number;
setOrder(number)
Returns or sets the trendline order (an integer greater than 1) when the trendline type is Polynomial. The order must be between 2 and 6.
setOrder(value: number) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | number | The value to set. |
getPeriod()
Returns or sets the period for the moving-average trendline.
getPeriod() : number;
Remarks
This value should be between 2 and 255. And it must be less than the number of the chart points in the series
setPeriod(number)
Returns or sets the period for the moving-average trendline.
setPeriod(value: number) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | number | The value to set. |
Remarks
This value should be between 2 and 255. And it must be less than the number of the chart points in the series
getForward()
Returns or sets the number of periods (or units on a scatter chart) that the trendline extends forward. The number of periods must be greater than or equal to zero.
getForward() : number;
setForward(number)
Returns or sets the number of periods (or units on a scatter chart) that the trendline extends forward. The number of periods must be greater than or equal to zero.
setForward(value: number) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | number | The value to set. |
getBackward()
Returns or sets the number of periods (or units on a scatter chart) that the trendline extends backward. The number of periods must be greater than or equal to zero. If the chart type is column ,the number of periods must be between 0 and 0.5
getBackward() : number;
setBackward(number)
Returns or sets the number of periods (or units on a scatter chart) that the trendline extends backward. The number of periods must be greater than or equal to zero. If the chart type is column ,the number of periods must be between 0 and 0.5
setBackward(value: number) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | number | The value to set. |
getDisplayEquation()
Represents if the equation for the trendline is displayed on the chart (in the same data label as the R-squared value). Setting this property to True automatically turns on data labels.
getDisplayEquation() : boolean;
setDisplayEquation(boolean)
Represents if the equation for the trendline is displayed on the chart (in the same data label as the R-squared value). Setting this property to True automatically turns on data labels.
setDisplayEquation(value: boolean) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The value to set. |
getDisplayRSquared()
Represents if the R-squared value of the trendline is displayed on the chart (in the same data label as the equation). Setting this property to True automatically turns on data labels.
getDisplayRSquared() : boolean;
setDisplayRSquared(boolean)
Represents if the R-squared value of the trendline is displayed on the chart (in the same data label as the equation). Setting this property to True automatically turns on data labels.
setDisplayRSquared(value: boolean) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The value to set. |
getIntercept()
Returns or sets the point where the trendline crosses the value axis.
getIntercept() : number;
setIntercept(number)
Returns or sets the point where the trendline crosses the value axis.
setIntercept(value: number) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | number | The value to set. |
getDataLabels()
Represents the DataLabels object for the specified series.
getDataLabels() : DataLabels;
Returns
getLegendEntry()
Gets the legend entry according to this trendline
getLegendEntry() : LegendEntry;
Returns
isNull()
Checks whether the implementation object is null.
isNull() : boolean;
getCompoundType()
Specifies the compound line type
getCompoundType() : MsoLineStyle;
Returns
setCompoundType(MsoLineStyle)
Specifies the compound line type
setCompoundType(value: MsoLineStyle) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | MsoLineStyle | The value to set. |
getDashType()
Specifies the dash line type
getDashType() : MsoLineDashStyle;
Returns
setDashType(MsoLineDashStyle)
Specifies the dash line type
setDashType(value: MsoLineDashStyle) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | MsoLineDashStyle | The value to set. |
getCapType()
Specifies the ending caps.
getCapType() : LineCapType;
Returns
setCapType(LineCapType)
Specifies the ending caps.
setCapType(value: LineCapType) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | LineCapType | The value to set. |
getJoinType()
Specifies the joining caps.
getJoinType() : LineJoinType;
Returns
setJoinType(LineJoinType)
Specifies the joining caps.
setJoinType(value: LineJoinType) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | LineJoinType | The value to set. |
getBeginType()
Specifies an arrowhead for the begin of a line.
getBeginType() : MsoArrowheadStyle;
Returns
setBeginType(MsoArrowheadStyle)
Specifies an arrowhead for the begin of a line.
setBeginType(value: MsoArrowheadStyle) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | MsoArrowheadStyle | The value to set. |
getEndType()
Specifies an arrowhead for the end of a line.
getEndType() : MsoArrowheadStyle;
Returns
setEndType(MsoArrowheadStyle)
Specifies an arrowhead for the end of a line.
setEndType(value: MsoArrowheadStyle) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | MsoArrowheadStyle | The value to set. |
getBeginArrowLength()
Specifies the length of the arrowhead for the begin of a line.
getBeginArrowLength() : MsoArrowheadLength;
Returns
setBeginArrowLength(MsoArrowheadLength)
Specifies the length of the arrowhead for the begin of a line.
setBeginArrowLength(value: MsoArrowheadLength) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | MsoArrowheadLength | The value to set. |
getEndArrowLength()
Specifies the length of the arrowhead for the end of a line.
getEndArrowLength() : MsoArrowheadLength;
Returns
setEndArrowLength(MsoArrowheadLength)
Specifies the length of the arrowhead for the end of a line.
setEndArrowLength(value: MsoArrowheadLength) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | MsoArrowheadLength | The value to set. |
getBeginArrowWidth()
Specifies the width of the arrowhead for the begin of a line.
getBeginArrowWidth() : MsoArrowheadWidth;
Returns
setBeginArrowWidth(MsoArrowheadWidth)
Specifies the width of the arrowhead for the begin of a line.
setBeginArrowWidth(value: MsoArrowheadWidth) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | MsoArrowheadWidth | The value to set. |
getEndArrowWidth()
Specifies the width of the arrowhead for the end of a line.
getEndArrowWidth() : MsoArrowheadWidth;
Returns
setEndArrowWidth(MsoArrowheadWidth)
Specifies the width of the arrowhead for the end of a line.
setEndArrowWidth(value: MsoArrowheadWidth) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | MsoArrowheadWidth | The value to set. |
getThemeColor()
Gets and sets the theme color.
getThemeColor() : ThemeColor;
Returns
Remarks
If the foreground color is not a theme color, NULL will be returned.
setThemeColor(ThemeColor)
Gets and sets the theme color.
setThemeColor(value: ThemeColor) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | ThemeColor | The value to set. |
Remarks
If the foreground color is not a theme color, NULL will be returned.
getColor()
Represents the Color of the line.
getColor() : Color;
Returns
setColor(Color)
Represents the Color of the line.
setColor(value: Color) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | Color | The value to set. |
getTransparency()
Returns or sets the degree of transparency of the line as a value from 0.0 (opaque) through 1.0 (clear).
getTransparency() : number;
setTransparency(number)
Returns or sets the degree of transparency of the line as a value from 0.0 (opaque) through 1.0 (clear).
setTransparency(value: number) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | number | The value to set. |
getStyle()
Represents the style of the line.
getStyle() : LineType;
Returns
setStyle(LineType)
Represents the style of the line.
setStyle(value: LineType) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | LineType | The value to set. |
getWeight()
Gets or sets the WeightType of the line.
getWeight() : WeightType;
Returns
setWeight(WeightType)
Gets or sets the WeightType of the line.
setWeight(value: WeightType) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | WeightType | The value to set. |
getWeightPt()
Gets or sets the weight of the line in unit of points.
getWeightPt() : number;
setWeightPt(number)
Gets or sets the weight of the line in unit of points.
setWeightPt(value: number) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | number | The value to set. |
getWeightPx()
Gets or sets the weight of the line in unit of pixels.
getWeightPx() : number;
setWeightPx(number)
Gets or sets the weight of the line in unit of pixels.
setWeightPx(value: number) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | number | The value to set. |
getFormattingType()
Gets or sets format type.
getFormattingType() : ChartLineFormattingType;
Returns
setFormattingType(ChartLineFormattingType)
Gets or sets format type.
setFormattingType(value: ChartLineFormattingType) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | ChartLineFormattingType | The value to set. |
isAutomaticColor()
Indicates whether the color of line is automatic assigned.
isAutomaticColor() : boolean;
isVisible()
Represents whether the line is visible.
isVisible() : boolean;
setIsVisible(boolean)
Represents whether the line is visible.
setIsVisible(value: boolean) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The value to set. |
isAuto()
Indicates whether this line style is auto assigned.
isAuto() : boolean;
setIsAuto(boolean)
Indicates whether this line style is auto assigned.
setIsAuto(value: boolean) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The value to set. |
getGradientFill()
Represents gradient fill.
getGradientFill() : GradientFill;
Returns