Trendline

Inheritance: java.lang.Object, com.aspose.cells.Line

public class Trendline extends Line

Represents a trendline in a chart.

Example

         //Instantiating a Workbook object
         Workbook workbook = new Workbook();
         //Adding a new worksheet to the Excel object
         int sheetIndex = workbook.getWorksheets().add();
         //Obtaining the reference of the newly added worksheet by passing its sheet index
         Worksheet 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
         int chartIndex = worksheet.getCharts().add(ChartType.COLUMN, 5, 0, 15, 5);
         //Accessing the instance of the newly added chart
         Chart 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
         int index = chart.getNSeries().get(0).getTrendLines().add(TrendlineType.LINEAR);
         Trendline 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("book1.xls");

Methods

MethodDescription
equals(Object arg0)
getBackward()Returns or sets the number of periods (or units on a scatter chart) that the trendline extends backward.
getBeginArrowLength()Specifies the length of the arrowhead for the begin of a line.
getBeginArrowWidth()Specifies the width of the arrowhead for the begin of a line.
getBeginType()Specifies an arrowhead for the begin of a line.
getCapType()Specifies the ending caps.
getClass()
getColor()Represents the Color of the line.
getCompoundType()Specifies the compound line type
getDashType()Specifies the dash line type
getDataLabels()Represents the DataLabels object for the specified series.
getDisplayEquation()Represents if the equation for the trendline is displayed on the chart (in the same data label as the R-squared value).
getDisplayRSquared()Represents if the R-squared value of the trendline is displayed on the chart (in the same data label as the equation).
getEndArrowLength()Specifies the length of the arrowhead for the end of a line.
getEndArrowWidth()Specifies the width of the arrowhead for the end of a line.
getEndType()Specifies an arrowhead for the end of a line.
getFormattingType()Gets format type.
getForward()Returns or sets the number of periods (or units on a scatter chart) that the trendline extends forward.
getGradientFill()Represents gradient fill.
getIntercept()Returns or sets the point where the trendline crosses the value axis.
getJoinType()Specifies the joining caps.
getLegendEntry()Gets the legend entry according to this trendline
getName()Returns the name of the trendline.
getOrder()Returns or sets the trendline order (an integer greater than 1) when the trendline type is Polynomial.
getPeriod()Returns or sets the period for the moving-average trendline.
getStyle()Represents the style of the line.
getThemeColor()Gets the theme color.
getTransparency()Returns or sets the degree of transparency of the line as a value from 0.0 (opaque) through 1.0 (clear).
getType()Returns the trendline type.
getWeight()Gets the WeightType of the line.
getWeightPt()Gets the weight of the line in unit of points.
getWeightPx()Gets the weight of the line in unit of pixels.
hashCode()
isAuto()Indicates whether this line style is auto assigned.
isAutomaticColor()Indicates whether the color of line is automatic assigned.
isInterceptAuto()Indicates whether Microsoft Workbook automatically determines the intercept of the trendline.
isNameAuto()Returns if Microsoft Excel automatically determines the name of the trendline.
isVisible()Represents whether the line is visible.
notify()
notifyAll()
setAuto(boolean value)Indicates whether this line style is auto assigned.
setBackward(double value)Returns or sets the number of periods (or units on a scatter chart) that the trendline extends backward.
setBeginArrowLength(int value)Specifies the length of the arrowhead for the begin of a line.
setBeginArrowWidth(int value)Specifies the width of the arrowhead for the begin of a line.
setBeginType(int value)Specifies an arrowhead for the begin of a line.
setCapType(int value)Specifies the ending caps.
setColor(Color value)Represents the Color of the line.
setCompoundType(int value)Specifies the compound line type
setDashType(int value)Specifies the dash line type
setDisplayEquation(boolean value)Represents if the equation for the trendline is displayed on the chart (in the same data label as the R-squared value).
setDisplayRSquared(boolean value)Represents if the R-squared value of the trendline is displayed on the chart (in the same data label as the equation).
setEndArrowLength(int value)Specifies the length of the arrowhead for the end of a line.
setEndArrowWidth(int value)Specifies the width of the arrowhead for the end of a line.
setEndType(int value)Specifies an arrowhead for the end of a line.
setFormattingType(int value)Sets format type.
setForward(double value)Returns or sets the number of periods (or units on a scatter chart) that the trendline extends forward.
setIntercept(double value)Returns or sets the point where the trendline crosses the value axis.
setInterceptAuto(boolean isInterceptAuto)Sets whether Microsoft Workbook automatically determines the intercept of the trendline.
setJoinType(int value)Specifies the joining caps.
setName(String value)Returns the name of the trendline.
setNameAuto(boolean value)Returns if Microsoft Excel automatically determines the name of the trendline.
setOrder(int value)Returns or sets the trendline order (an integer greater than 1) when the trendline type is Polynomial.
setPeriod(int value)Returns or sets the period for the moving-average trendline.
setStyle(int value)Represents the style of the line.
setThemeColor(ThemeColor value)Sets the theme color.
setTransparency(double value)Returns or sets the degree of transparency of the line as a value from 0.0 (opaque) through 1.0 (clear).
setVisible(boolean value)Represents whether the line is visible.
setWeight(int value)Sets the WeightType of the line.
setWeightPt(double value)Sets the weight of the line in unit of points.
setWeightPx(double value)Sets the weight of the line in unit of pixels.
toString()
wait()
wait(long arg0)
wait(long arg0, int arg1)

equals(Object arg0)

public boolean equals(Object arg0)

Parameters:

ParameterTypeDescription
arg0java.lang.Object

Returns: boolean

getBackward()

public double 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

Returns: double

getBeginArrowLength()

public int getBeginArrowLength()

Specifies the length of the arrowhead for the begin of a line.

See MsoArrowheadLength.

Returns: int

getBeginArrowWidth()

public int getBeginArrowWidth()

Specifies the width of the arrowhead for the begin of a line.

See MsoArrowheadWidth.

Returns: int

getBeginType()

public int getBeginType()

Specifies an arrowhead for the begin of a line.

See MsoArrowheadStyle.

Returns: int

getCapType()

public int getCapType()

Specifies the ending caps.

See LineCapType.

Returns: int

getClass()

public final native Class<?> getClass()

Returns: java.lang.Class

getColor()

public Color getColor()

Represents the Color of the line.

Returns: Color

getCompoundType()

public int getCompoundType()

Specifies the compound line type

See MsoLineStyle.

Returns: int

getDashType()

public int getDashType()

Specifies the dash line type

See MsoLineDashStyle.

Returns: int

getDataLabels()

public DataLabels getDataLabels()

Represents the DataLabels object for the specified series.

Returns: DataLabels

getDisplayEquation()

public boolean 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.

Returns: boolean

getDisplayRSquared()

public boolean 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.

Returns: boolean

getEndArrowLength()

public int getEndArrowLength()

Specifies the length of the arrowhead for the end of a line.

See MsoArrowheadLength.

Returns: int

getEndArrowWidth()

public int getEndArrowWidth()

Specifies the width of the arrowhead for the end of a line.

See MsoArrowheadWidth.

Returns: int

getEndType()

public int getEndType()

Specifies an arrowhead for the end of a line.

See MsoArrowheadStyle.

Returns: int

getFormattingType()

public int getFormattingType()

Gets format type.

See ChartLineFormattingType.

Returns: int

getForward()

public double 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.

Returns: double

getGradientFill()

public GradientFill getGradientFill()

Represents gradient fill.

Returns: GradientFill

getIntercept()

public double getIntercept()

Returns or sets the point where the trendline crosses the value axis.

Returns: double

getJoinType()

public int getJoinType()

Specifies the joining caps.

See LineJoinType.

Returns: int

getLegendEntry()

public LegendEntry getLegendEntry()

Gets the legend entry according to this trendline

Returns: LegendEntry

getName()

public String getName()

Returns the name of the trendline.

Returns: java.lang.String

getOrder()

public int 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.

Returns: int

getPeriod()

public int getPeriod()

Returns or sets the period for the moving-average trendline.

Remarks

This value should be between 2 and 255. And it must be less than the number of the chart points in the series

Returns: int

getStyle()

public int getStyle()

Represents the style of the line.

See LineType.

Returns: int

getThemeColor()

public ThemeColor getThemeColor()

Gets the theme color.

Remarks

If the foreground color is not a theme color, NULL will be returned.

Returns: ThemeColor

getTransparency()

public double getTransparency()

Returns or sets the degree of transparency of the line as a value from 0.0 (opaque) through 1.0 (clear).

Returns: double

getType()

public int getType()

Returns the trendline type.

See TrendlineType.

Returns: int

getWeight()

public int getWeight()

Gets the WeightType of the line.

See WeightType.

Returns: int

getWeightPt()

public double getWeightPt()

Gets the weight of the line in unit of points.

Returns: double

getWeightPx()

public double getWeightPx()

Gets the weight of the line in unit of pixels.

Returns: double

hashCode()

public native int hashCode()

Returns: int

isAuto()

public boolean isAuto()

Indicates whether this line style is auto assigned.

Returns: boolean

isAutomaticColor()

public boolean isAutomaticColor()

Indicates whether the color of line is automatic assigned.

Returns: boolean

isInterceptAuto()

public boolean isInterceptAuto()

Indicates whether Microsoft Workbook automatically determines the intercept of the trendline.

Returns: boolean

isNameAuto()

public boolean isNameAuto()

Returns if Microsoft Excel automatically determines the name of the trendline.

Returns: boolean

isVisible()

public boolean isVisible()

Represents whether the line is visible.

Returns: boolean

notify()

public final native void notify()

notifyAll()

public final native void notifyAll()

setAuto(boolean value)

public void setAuto(boolean value)

Indicates whether this line style is auto assigned.

Parameters:

ParameterTypeDescription
valueboolean

setBackward(double value)

public void setBackward(double value)

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

Parameters:

ParameterTypeDescription
valuedouble

setBeginArrowLength(int value)

public void setBeginArrowLength(int value)

Specifies the length of the arrowhead for the begin of a line.

See MsoArrowheadLength.

Parameters:

ParameterTypeDescription
valueint

setBeginArrowWidth(int value)

public void setBeginArrowWidth(int value)

Specifies the width of the arrowhead for the begin of a line.

See MsoArrowheadWidth.

Parameters:

ParameterTypeDescription
valueint

setBeginType(int value)

public void setBeginType(int value)

Specifies an arrowhead for the begin of a line.

See MsoArrowheadStyle.

Parameters:

ParameterTypeDescription
valueint

setCapType(int value)

public void setCapType(int value)

Specifies the ending caps.

See LineCapType.

Parameters:

ParameterTypeDescription
valueint

setColor(Color value)

public void setColor(Color value)

Represents the Color of the line.

Parameters:

ParameterTypeDescription
valueColor

setCompoundType(int value)

public void setCompoundType(int value)

Specifies the compound line type

See MsoLineStyle.

Parameters:

ParameterTypeDescription
valueint

setDashType(int value)

public void setDashType(int value)

Specifies the dash line type

See MsoLineDashStyle.

Parameters:

ParameterTypeDescription
valueint

setDisplayEquation(boolean value)

public void setDisplayEquation(boolean value)

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.

Parameters:

ParameterTypeDescription
valueboolean

setDisplayRSquared(boolean value)

public void setDisplayRSquared(boolean value)

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.

Parameters:

ParameterTypeDescription
valueboolean

setEndArrowLength(int value)

public void setEndArrowLength(int value)

Specifies the length of the arrowhead for the end of a line.

See MsoArrowheadLength.

Parameters:

ParameterTypeDescription
valueint

setEndArrowWidth(int value)

public void setEndArrowWidth(int value)

Specifies the width of the arrowhead for the end of a line.

See MsoArrowheadWidth.

Parameters:

ParameterTypeDescription
valueint

setEndType(int value)

public void setEndType(int value)

Specifies an arrowhead for the end of a line.

See MsoArrowheadStyle.

Parameters:

ParameterTypeDescription
valueint

setFormattingType(int value)

public void setFormattingType(int value)

Sets format type.

See ChartLineFormattingType.

Parameters:

ParameterTypeDescription
valueint

setForward(double value)

public void setForward(double value)

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.

Parameters:

ParameterTypeDescription
valuedouble

setIntercept(double value)

public void setIntercept(double value)

Returns or sets the point where the trendline crosses the value axis.

Parameters:

ParameterTypeDescription
valuedouble

setInterceptAuto(boolean isInterceptAuto)

public void setInterceptAuto(boolean isInterceptAuto)

Sets whether Microsoft Workbook automatically determines the intercept of the trendline.

Parameters:

ParameterTypeDescription
isInterceptAutoboolean

setJoinType(int value)

public void setJoinType(int value)

Specifies the joining caps.

See LineJoinType.

Parameters:

ParameterTypeDescription
valueint

setName(String value)

public void setName(String value)

Returns the name of the trendline.

Parameters:

ParameterTypeDescription
valuejava.lang.String

setNameAuto(boolean value)

public void setNameAuto(boolean value)

Returns if Microsoft Excel automatically determines the name of the trendline.

Parameters:

ParameterTypeDescription
valueboolean

setOrder(int value)

public void setOrder(int value)

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.

Parameters:

ParameterTypeDescription
valueint

setPeriod(int value)

public void setPeriod(int value)

Returns or sets the period for the moving-average trendline.

Remarks

This value should be between 2 and 255. And it must be less than the number of the chart points in the series

Parameters:

ParameterTypeDescription
valueint

setStyle(int value)

public void setStyle(int value)

Represents the style of the line.

See LineType.

Parameters:

ParameterTypeDescription
valueint

setThemeColor(ThemeColor value)

public void setThemeColor(ThemeColor value)

Sets the theme color.

Remarks

If the foreground color is not a theme color, NULL will be returned.

Parameters:

ParameterTypeDescription
valueThemeColor

setTransparency(double value)

public void setTransparency(double value)

Returns or sets the degree of transparency of the line as a value from 0.0 (opaque) through 1.0 (clear).

Parameters:

ParameterTypeDescription
valuedouble

setVisible(boolean value)

public void setVisible(boolean value)

Represents whether the line is visible.

Parameters:

ParameterTypeDescription
valueboolean

setWeight(int value)

public void setWeight(int value)

Sets the WeightType of the line.

See WeightType.

Parameters:

ParameterTypeDescription
valueint

setWeightPt(double value)

public void setWeightPt(double value)

Sets the weight of the line in unit of points.

Parameters:

ParameterTypeDescription
valuedouble

setWeightPx(double value)

public void setWeightPx(double value)

Sets the weight of the line in unit of pixels.

Parameters:

ParameterTypeDescription
valuedouble

toString()

public String toString()

Returns: java.lang.String

wait()

public final void wait()

wait(long arg0)

public final native void wait(long arg0)

Parameters:

ParameterTypeDescription
arg0long

wait(long arg0, int arg1)

public final void wait(long arg0, int arg1)

Parameters:

ParameterTypeDescription
arg0long
arg1int