Back to Devexpress

Trendline.Label Property

officefileapi-devexpress-dot-spreadsheet-dot-charts-dot-trendline.md

latest6.2 KB
Original Source

Trendline.Label Property

Retrieves trendline label options.

Namespace : DevExpress.Spreadsheet.Charts

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
TrendlineLabel Label { get; }
vb
ReadOnly Property Label As TrendlineLabel

Property Value

TypeDescription
TrendlineLabel

An object that contains label properties.

|

Example

The code snippet below formats and positions a trendline’s label.

View Example

csharp
Worksheet worksheet = workbook.Worksheets["chartTask3"];
workbook.Worksheets.ActiveWorksheet = worksheet;

// Create a chart and specify its location.
Chart chart = worksheet.Charts.Add(ChartType.ScatterMarkers);
chart.SelectData(worksheet["C2:F3"], ChartDataDirection.Row);
chart.TopLeftCell = worksheet.Cells["H2"];
chart.BottomRightCell = worksheet.Cells["N14"];

// Display a polynomial trendline.
chart.Series[0].Trendlines.Add(ChartTrendlineType.Polynomial);

// Customize the trendline.
Trendline tline = chart.Series[0].Trendlines[0];
tline.DisplayEquation = true;
tline.CustomName = "Trend";
tline.DisplayRSquare = true;
tline.Outline.SetSolidFill(Color.Red);

// Format the trend label.
TrendlineLabel tlabel = tline.Label;
tlabel.Font.Name = "Tahoma";
tlabel.Font.Italic = true;
tlabel.Fill.SetGradientFill(ShapeGradientType.Linear, Color.Orange, Color.White);
// Position the label in the right quarter of the chart area.
tlabel.Layout.Left.SetPosition(LayoutMode.Edge, 0.75);
vb
Dim worksheet As Worksheet = workbook.Worksheets("chartTask3")
workbook.Worksheets.ActiveWorksheet = worksheet

' Create a chart and specify its location.
Dim chart As Chart = worksheet.Charts.Add(ChartType.ScatterMarkers)
chart.SelectData(worksheet("C2:F3"), ChartDataDirection.Row)
chart.TopLeftCell = worksheet.Cells("H2")
chart.BottomRightCell = worksheet.Cells("N14")

' Display a polynomial trendline.
chart.Series(0).Trendlines.Add(ChartTrendlineType.Polynomial)

' Customize the trendline.
Dim tline As Trendline = chart.Series(0).Trendlines(0)
tline.DisplayEquation = True
tline.CustomName = "Trend"
tline.DisplayRSquare = True
tline.Outline.SetSolidFill(Color.Red)

' Format the trend label.
Dim tlabel As TrendlineLabel = tline.Label
tlabel.Font.Name = "Tahoma"
tlabel.Font.Italic = True
tlabel.Fill.SetGradientFill(ShapeGradientType.Linear, Color.Orange, Color.White)
' Position the label in the right quarter of the chart area.
tlabel.Layout.Left.SetPosition(LayoutMode.Edge, 0.75)

The following code snippets (auto-collected from DevExpress Examples) contain references to the Label property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

spreadsheet-document-api-chart-examples/CS/SpreadsheetDocServerChartAPISamples/CodeExamples/TrendlineActions.cs#L94

csharp
// Format the trend label.
TrendlineLabel tlabel = tline.Label;
tlabel.Font.Name = "Tahoma";

wpf-spreadsheet-chart-api/CS/SpreadsheetWPFChartAPISamples/CodeExamples/TrendlineActions.cs#L94

csharp
// Format the trend label.
TrendlineLabel tlabel = tline.Label;
tlabel.Font.Name = "Tahoma";

winforms-spreadsheet-chart-api/CS/SpreadsheetChartAPISamples/CodeExamples/TrendlineActions.cs#L94

csharp
// Format the trend label.
TrendlineLabel tlabel = tline.Label;
tlabel.Font.Name = "Tahoma";

spreadsheet-document-api-chart-examples/VB/SpreadsheetDocServerChartAPISamples/CodeExamples/TrendlineActions.vb#L93

vb
' Format the trend label.
Dim tlabel As TrendlineLabel = tline.Label
tlabel.Font.Name = "Tahoma"

wpf-spreadsheet-chart-api/VB/SpreadsheetWPFChartAPISamples/CodeExamples/TrendlineActions.vb#L88

vb
' Format the trend label.
Dim tlabel As TrendlineLabel = tline.Label
tlabel.Font.Name = "Tahoma"

winforms-spreadsheet-chart-api/VB/SpreadsheetChartAPISamples/CodeExamples/TrendlineActions.vb#L87

vb
' Format the trend label.
Dim tlabel As TrendlineLabel = tline.Label
tlabel.Font.Name = "Tahoma"

See Also

Trendline Interface

Trendline Members

DevExpress.Spreadsheet.Charts Namespace