Aspose::Cells::Charts::Trendline class
Contents
[
Hide
]Trendline class
Represents a trendline in a chart.
class Trendline : public Aspose::Cells::Drawing::Line
Methods
Method | Description |
---|---|
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. |
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. |
GetColor() | Represents the System.Drawing.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). 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. |
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 or sets format type. |
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. |
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. The order must be between 2 and 6. |
GetPeriod() | Returns or sets the period for the moving-average trendline. |
GetStyle() | Represents the style of the line. |
GetThemeColor() | Gets and sets 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 or sets the WeightType of the line. |
GetWeightPt() | 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. |
IsAuto() | Indicates whether this line style is auto assigned. |
IsAutomaticColor() | Indicates whether the color of line is automatic assigned. |
IsNameAuto() | Returns if Microsoft Excel automatically determines the name of the trendline. |
IsNull() const | Checks whether the implementation object is nullptr. |
IsVisible() | Represents whether the line is visible. |
Line(Line_Impl* impl) | Constructs from an implementation object. |
Line(const Line& src) | Copy constructor. |
explicit operator bool() const | operator bool() |
operator=(const Trendline& src) | operator= |
operator=(const Line& src) | operator= |
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. |
SetBeginArrowLength(MsoArrowheadLength value) | Specifies the length of the arrowhead for the begin of a line. |
SetBeginArrowWidth(MsoArrowheadWidth value) | Specifies the width of the arrowhead for the begin of a line. |
SetBeginType(MsoArrowheadStyle value) | Specifies an arrowhead for the begin of a line. |
SetCapType(LineCapType value) | Specifies the ending caps. |
SetColor(const Aspose::Cells::Color& value) | Represents the System.Drawing.Color of the line. |
SetCompoundType(MsoLineStyle value) | Specifies the compound line type. |
SetDashType(MsoLineDashStyle value) | Specifies the dash line type. |
SetDisplayEquation(bool 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. |
SetDisplayRSquared(bool 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. |
SetEndArrowLength(MsoArrowheadLength value) | Specifies the length of the arrowhead for the end of a line. |
SetEndArrowWidth(MsoArrowheadWidth value) | Specifies the width of the arrowhead for the end of a line. |
SetEndType(MsoArrowheadStyle value) | Specifies an arrowhead for the end of a line. |
SetFormattingType(ChartLineFormattingType value) | Gets or sets format type. |
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. |
SetIntercept(double value) | Returns or sets the point where the trendline crosses the value axis. |
SetIsAuto(bool value) | Indicates whether this line style is auto assigned. |
SetIsNameAuto(bool value) | Returns if Microsoft Excel automatically determines the name of the trendline. |
SetIsVisible(bool value) | Represents whether the line is visible. |
SetJoinType(LineJoinType value) | Specifies the joining caps. |
SetName(const U16String& value) | Returns the name of the trendline. |
SetName(const char16_t* value) | Returns the name of the trendline. |
SetOrder(int32_t 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. |
SetPeriod(int32_t value) | Returns or sets the period for the moving-average trendline. |
SetStyle(LineType value) | Represents the style of the line. |
SetThemeColor(const ThemeColor& value) | Gets and 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). |
SetWeight(WeightType value) | Gets or sets the WeightType of the line. |
SetWeightPt(double value) | Gets or sets the weight of the line in unit of points. |
SetWeightPx(double value) | Gets or sets the weight of the line in unit of pixels. |
Trendline(Trendline_Impl* impl) | Constructs from an implementation object. |
Trendline(const Trendline& src) | Copy constructor. |
Trendline(const Line& src) | Constructs from a parent object. |
~Line() | Destructor. |
~Trendline() | Destructor. |
Fields
Field | Description |
---|---|
_impl | The implementation object. |
Examples
Aspose::Cells::Startup();
//Instantiating a Workbook object
Workbook 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(u"A1").PutValue(50);
//Adding a sample value to "A2" cell
worksheet.GetCells().Get(u"A2").PutValue(100);
//Adding a sample value to "A3" cell
worksheet.GetCells().Get(u"A3").PutValue(150);
//Adding a sample value to "A4" cell
worksheet.GetCells().Get(u"A4").PutValue(200);
//Adding a sample value to "B1" cell
worksheet.GetCells().Get(u"B1").PutValue(60);
//Adding a sample value to "B2" cell
worksheet.GetCells().Get(u"B2").PutValue(32);
//Adding a sample value to "B3" cell
worksheet.GetCells().Get(u"B3").PutValue(50);
//Adding a sample value to "B4" cell
worksheet.GetCells().Get(u"B4").PutValue(40);
//Adding a sample value to "C1" cell as category data
worksheet.GetCells().Get(u"C1").PutValue(u"Q1");
//Adding a sample value to "C2" cell as category data
worksheet.GetCells().Get(u"C2").PutValue(u"Q2");
//Adding a sample value to "C3" cell as category data
worksheet.GetCells().Get(u"C3").PutValue(u"Y1");
//Adding a sample value to "C4" cell as category data
worksheet.GetCells().Get(u"C4").PutValue(u"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(u"A1:B4", true);
//Setting the data source for the category data of NSeries
chart.GetNSeries().SetCategoryData(u"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(u"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(u"book1.xls");
Aspose::Cells::Cleanup();
See Also
- Class Line
- Namespace Aspose::Cells::Charts
- Library Aspose.Cells for C++