All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.aspose.cells.Trendline.html Maven / Gradle / Ivy

There is a newer version: 23.1
Show newest version





Trendline




com.aspose.cells
Class Trendline

java.lang.Object
  extended by Line
      extended by com.aspose.cells.Trendline

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("C:\\book1.xls");


Property Getters/Setters Summary
doublegetBackward()
voidsetBackward(double)
           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 and equal to zero. If the chart type is column ,the number of periods must be between 0 and 0.5
intgetBeginArrowLength()→ inherited from Line
voidsetBeginArrowLength(int)
           Specifies the length of the arrowhead for the begin of a line. The value of the property is MsoArrowheadLength integer constant.
intgetBeginArrowWidth()→ inherited from Line
voidsetBeginArrowWidth(int)
           Specifies the width of the arrowhead for the begin of a line. The value of the property is MsoArrowheadWidth integer constant.
intgetBeginType()→ inherited from Line
voidsetBeginType(int)
           Specifies an arrowhead for the begin of a line. The value of the property is MsoArrowheadStyle integer constant.
intgetCapType()→ inherited from Line
voidsetCapType(int)
           Specifies the ending caps. The value of the property is LineCapType integer constant.
com.aspose.cells.ColorgetColor()→ inherited from Line
voidsetColor(com.aspose.cells.Color)
           Represents the com.aspose.cells.Color of the line.
intgetCompoundType()→ inherited from Line
voidsetCompoundType(int)
           Specifies the compound line type The value of the property is MsoLineStyle integer constant.
intgetDashType()→ inherited from Line
voidsetDashType(int)
           Specifies the dash line type The value of the property is MsoLineDashStyle integer constant.
DataLabelsgetDataLabels()
           Represents the DataLabels object for the specified ASeries.
booleangetDisplayEquation()
voidsetDisplayEquation(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.
booleangetDisplayRSquared()
voidsetDisplayRSquared(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.
intgetEndArrowLength()→ inherited from Line
voidsetEndArrowLength(int)
           Specifies the length of the arrowhead for the end of a line. The value of the property is MsoArrowheadLength integer constant.
intgetEndArrowWidth()→ inherited from Line
voidsetEndArrowWidth(int)
           Specifies the width of the arrowhead for the end of a line. The value of the property is MsoArrowheadWidth integer constant.
intgetEndType()→ inherited from Line
voidsetEndType(int)
           Specifies an arrowhead for the end of a line. The value of the property is MsoArrowheadStyle integer constant.
intgetFormattingType()→ inherited from Line
voidsetFormattingType(int)
           Gets or sets format type. The value of the property is ChartLineFormattingType integer constant.
doublegetForward()
voidsetForward(double)
           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 and equal to zero.
GradientFillgetGradientFill()→ inherited from Line
           Represents gradient fill.
doublegetIntercept()
voidsetIntercept(double)
           Returns or sets the point where the trendline crosses the value axis.
booleanisAuto()→ inherited from Line
voidsetAuto(boolean)
           Indicates whether this line style is auto assigned.
booleanisAutomaticColor()→ inherited from Line
           Indicates whether the color of line is automatic assigned.
booleanisNameAuto()
voidsetNameAuto(boolean)
           Returns if Microsoft Excel automatically determines the name of the trendline.
booleanisVisible()→ inherited from Line
voidsetVisible(boolean)
           Represents whether the line is visible.
intgetJoinType()→ inherited from Line
voidsetJoinType(int)
           Specifies the joining caps. The value of the property is LineJoinType integer constant.
LegendEntrygetLegendEntry()
           Gets the legend entry according to this trendline
java.lang.StringgetName()
voidsetName(java.lang.String)
           Returns the name of the trendline.
intgetOrder()
voidsetOrder(int)
           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.
intgetPeriod()
voidsetPeriod(int)
           Returns or sets the period for the moving-average trendline.
intgetStyle()→ inherited from Line
voidsetStyle(int)
           Represents the style of the line. The value of the property is LineType integer constant.
ThemeColorgetThemeColor()→ inherited from Line
voidsetThemeColor(ThemeColor)
           Gets and sets the theme color.
doublegetTransparency()→ inherited from Line
voidsetTransparency(double)
           Returns or sets the degree of transparency of the line as a value from 0.0 (opaque) through 1.0 (clear).
intgetType()
           Returns the trendline type. The value of the property is TrendlineType integer constant.
intgetWeight()→ inherited from Line
voidsetWeight(int)
           Gets or sets the WeightType of the line. The value of the property is WeightType integer constant.
doublegetWeightPt()→ inherited from Line
voidsetWeightPt(double)
           Gets or sets the weight of the line in unit of points.
doublegetWeightPx()→ inherited from Line
voidsetWeightPx(double)
           Gets or sets the weight of the line in unit of pixels.
 
Method Summary
booleanisInterceptAuto()
           Indicates whether Microsoft Workbook automatically determines the intercept of the trendline.
voidsetInterceptAuto(boolean isInterceptAuto)
           Sets whether Microsoft Workbook automatically determines the intercept of the trendline.
 

Property Getters/Setters Detail

isNameAuto/setNameAuto

public boolean isNameAuto() / public void setNameAuto(boolean value)
Returns if Microsoft Excel automatically determines the name of the trendline.

setNameAuto

public void setNameAuto(boolean value)
Returns if Microsoft Excel automatically determines the name of the trendline.

getType

public int getType()
Returns the trendline type. The value of the property is TrendlineType integer constant.

getName/setName

public java.lang.String getName() / public void setName(java.lang.String value)
Returns the name of the trendline.

setName

public void setName(java.lang.String value)
Returns the name of the trendline.

getOrder/setOrder

public int getOrder() / 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.

setOrder

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.

getPeriod/setPeriod

public int getPeriod() / public void setPeriod(int value)
Returns or sets the period for the moving-average trendline. This value should be between 2 and 255. And it must be less than the number of the chart points in the series

setPeriod

public void setPeriod(int value)
Returns or sets the period for the moving-average trendline. This value should be between 2 and 255. And it must be less than the number of the chart points in the series

getForward/setForward

public double getForward() / 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 and equal to zero.

setForward

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 and equal to zero.

getBackward/setBackward

public double getBackward() / 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 and equal to zero. If the chart type is column ,the number of periods must be between 0 and 0.5

setBackward

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 and equal to zero. If the chart type is column ,the number of periods must be between 0 and 0.5

getDisplayEquation/setDisplayEquation

public boolean getDisplayEquation() / 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.

setDisplayEquation

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.

getDisplayRSquared/setDisplayRSquared

public boolean getDisplayRSquared() / 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.

setDisplayRSquared

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.

getIntercept/setIntercept

public double getIntercept() / public void setIntercept(double value)
Returns or sets the point where the trendline crosses the value axis.

setIntercept

public void setIntercept(double value)
Returns or sets the point where the trendline crosses the value axis.

getDataLabels

public DataLabels getDataLabels()
Represents the DataLabels object for the specified ASeries.

getLegendEntry

public LegendEntry getLegendEntry()
Gets the legend entry according to this trendline

getCompoundType/setCompoundType

→ inherited from Line
public int getCompoundType() / public void setCompoundType(int value)
Specifies the compound line type The value of the property is MsoLineStyle integer constant.

setCompoundType

→ inherited from Line
public void setCompoundType(int value)
Specifies the compound line type The value of the property is MsoLineStyle integer constant.

getDashType/setDashType

→ inherited from Line
public int getDashType() / public void setDashType(int value)
Specifies the dash line type The value of the property is MsoLineDashStyle integer constant.

setDashType

→ inherited from Line
public void setDashType(int value)
Specifies the dash line type The value of the property is MsoLineDashStyle integer constant.

getCapType/setCapType

→ inherited from Line
public int getCapType() / public void setCapType(int value)
Specifies the ending caps. The value of the property is LineCapType integer constant.

setCapType

→ inherited from Line
public void setCapType(int value)
Specifies the ending caps. The value of the property is LineCapType integer constant.

getJoinType/setJoinType

→ inherited from Line
public int getJoinType() / public void setJoinType(int value)
Specifies the joining caps. The value of the property is LineJoinType integer constant.

setJoinType

→ inherited from Line
public void setJoinType(int value)
Specifies the joining caps. The value of the property is LineJoinType integer constant.

getBeginType/setBeginType

→ inherited from Line
public int getBeginType() / public void setBeginType(int value)
Specifies an arrowhead for the begin of a line. The value of the property is MsoArrowheadStyle integer constant.

setBeginType

→ inherited from Line
public void setBeginType(int value)
Specifies an arrowhead for the begin of a line. The value of the property is MsoArrowheadStyle integer constant.

getEndType/setEndType

→ inherited from Line
public int getEndType() / public void setEndType(int value)
Specifies an arrowhead for the end of a line. The value of the property is MsoArrowheadStyle integer constant.

setEndType

→ inherited from Line
public void setEndType(int value)
Specifies an arrowhead for the end of a line. The value of the property is MsoArrowheadStyle integer constant.

getBeginArrowLength/setBeginArrowLength

→ inherited from Line
public int getBeginArrowLength() / public void setBeginArrowLength(int value)
Specifies the length of the arrowhead for the begin of a line. The value of the property is MsoArrowheadLength integer constant.

setBeginArrowLength

→ inherited from Line
public void setBeginArrowLength(int value)
Specifies the length of the arrowhead for the begin of a line. The value of the property is MsoArrowheadLength integer constant.

getEndArrowLength/setEndArrowLength

→ inherited from Line
public int getEndArrowLength() / public void setEndArrowLength(int value)
Specifies the length of the arrowhead for the end of a line. The value of the property is MsoArrowheadLength integer constant.

setEndArrowLength

→ inherited from Line
public void setEndArrowLength(int value)
Specifies the length of the arrowhead for the end of a line. The value of the property is MsoArrowheadLength integer constant.

getBeginArrowWidth/setBeginArrowWidth

→ inherited from Line
public int getBeginArrowWidth() / public void setBeginArrowWidth(int value)
Specifies the width of the arrowhead for the begin of a line. The value of the property is MsoArrowheadWidth integer constant.

setBeginArrowWidth

→ inherited from Line
public void setBeginArrowWidth(int value)
Specifies the width of the arrowhead for the begin of a line. The value of the property is MsoArrowheadWidth integer constant.

getEndArrowWidth/setEndArrowWidth

→ inherited from Line
public int getEndArrowWidth() / public void setEndArrowWidth(int value)
Specifies the width of the arrowhead for the end of a line. The value of the property is MsoArrowheadWidth integer constant.

setEndArrowWidth

→ inherited from Line
public void setEndArrowWidth(int value)
Specifies the width of the arrowhead for the end of a line. The value of the property is MsoArrowheadWidth integer constant.

getThemeColor/setThemeColor

→ inherited from Line
public ThemeColor getThemeColor() / public void setThemeColor(ThemeColor value)
Gets and sets the theme color. If the foreground color is not a theme color, NULL will be returned.

setThemeColor

→ inherited from Line
public void setThemeColor(ThemeColor value)
Gets and sets the theme color. If the foreground color is not a theme color, NULL will be returned.

getColor/setColor

→ inherited from Line
public com.aspose.cells.Color getColor() / public void setColor(com.aspose.cells.Color value)
Represents the com.aspose.cells.Color of the line.

setColor

→ inherited from Line
public void setColor(com.aspose.cells.Color value)
Represents the com.aspose.cells.Color of the line.

getTransparency/setTransparency

→ inherited from Line
public double getTransparency() / 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).

setTransparency

→ inherited from Line
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).

getStyle/setStyle

→ inherited from Line
public int getStyle() / public void setStyle(int value)
Represents the style of the line. The value of the property is LineType integer constant.

setStyle

→ inherited from Line
public void setStyle(int value)
Represents the style of the line. The value of the property is LineType integer constant.

getWeight/setWeight

→ inherited from Line
public int getWeight() / public void setWeight(int value)
Gets or sets the WeightType of the line. The value of the property is WeightType integer constant.

setWeight

→ inherited from Line
public void setWeight(int value)
Gets or sets the WeightType of the line. The value of the property is WeightType integer constant.

getWeightPt/setWeightPt

→ inherited from Line
public double getWeightPt() / public void setWeightPt(double value)
Gets or sets the weight of the line in unit of points.

setWeightPt

→ inherited from Line
public void setWeightPt(double value)
Gets or sets the weight of the line in unit of points.

getWeightPx/setWeightPx

→ inherited from Line
public double getWeightPx() / public void setWeightPx(double value)
Gets or sets the weight of the line in unit of pixels.

setWeightPx

→ inherited from Line
public void setWeightPx(double value)
Gets or sets the weight of the line in unit of pixels.

getFormattingType/setFormattingType

→ inherited from Line
public int getFormattingType() / public void setFormattingType(int value)
Gets or sets format type. The value of the property is ChartLineFormattingType integer constant.

setFormattingType

→ inherited from Line
public void setFormattingType(int value)
Gets or sets format type. The value of the property is ChartLineFormattingType integer constant.

isAutomaticColor

→ inherited from Line
public boolean isAutomaticColor()
Indicates whether the color of line is automatic assigned.

isVisible/setVisible

→ inherited from Line
public boolean isVisible() / public void setVisible(boolean value)
Represents whether the line is visible.

setVisible

→ inherited from Line
public void setVisible(boolean value)
Represents whether the line is visible.

isAuto/setAuto

→ inherited from Line
public boolean isAuto() / public void setAuto(boolean value)
Indicates whether this line style is auto assigned.

setAuto

→ inherited from Line
public void setAuto(boolean value)
Indicates whether this line style is auto assigned.

getGradientFill

→ inherited from Line
public GradientFill getGradientFill()
Represents gradient fill.

Method Detail

isInterceptAuto

public boolean isInterceptAuto()
Indicates whether Microsoft Workbook automatically determines the intercept of the trendline.

setInterceptAuto

public void setInterceptAuto(boolean isInterceptAuto)
Sets whether Microsoft Workbook automatically determines the intercept of the trendline.

See Also:
          Aspose.Cells Documentation - the home page for the Aspose.Cells Product Documentation.
          Aspose.Cells Support Forum - our preferred method of support.





© 2015 - 2024 Weber Informatics LLC | Privacy Policy