maui-devexpress-dot-maui-dot-charts-dot-seriesbase-30318fde.md
Gets or sets a text pattern that configures strings the series provides for legend items. This is a bindable property.
Namespace : DevExpress.Maui.Charts
Assembly : DevExpress.Maui.Charts.dll
NuGet Package : DevExpress.Maui.Charts
public string LegendTextPattern { get; set; }
| Type | Description |
|---|---|
| String |
The text pattern that configures strings the series provides for legend items.
|
Use the LegendTextPattern property to format legend items for the series. The series generates legend items for entire series or for each series point depending on the LegendItemsBehavior property (for example, refer to the PointSeries.LegendItemsBehavior property).
The pattern can comprise regular text (which is displayed as is) and placeholders with format specifiers enclosed in braces. Placeholders define which values are shown in labels.
The following sections list the available placeholders: ChartView Placeholders and PieChartView Placeholders.
You can use standard format specifiers after the $ sign to format placeholder values.
For example, in the {V$#.##} string, V is a placeholder, $ is a format string separator, and #.## is a format string.
Refer to the following pages for more information about format specifiers:
In XAML, insert empty brackets at the beginning of a pattern if it starts with a placeholder. Refer to the following page for more information: {} Escape sequence / markup extension.
This section lists placeholders you can use for ChartView series.
| Placeholder | Description |
|---|---|
| {S} | Displays the series name obtained from the SeriesBase.DisplayName property. |
| {A} | Displays the series point argument if the series LegendItemsBehavior property is “EachPoint”. |
| {V} | Displays the series point value if the series LegendItemsBehavior property is “EachPoint”. |
This section describes placeholders specific for bubble series:
| Placeholder | Description |
|---|---|
| {W} | Displays weight values of bubbles if the LegendItemsBehavior property of the series is “EachPoint”. |
This section describes placeholders for range series – RangeAreaSeries and RangeBarSeries:
| Placeholder | Description |
|---|---|
| {LV} | Displays lower values of range points if the series LegendItemsBehavior property is “EachPoint”. |
| {HV} | Displays higher values of range points if the series LegendItemsBehavior property is “EachPoint”. |
This section contains placeholders specific for ValueBandPointColorizer:
| Placeholder | Description |
|---|---|
| {CLV} | Displays the value that specifies the lower boundary of a color range. This placeholder can be applied if the series LegendItemsBehavior is “Series”. |
| {CHV} | Displays the value that specifies the higher boundary of a color range. This placeholder can be applied if the series LegendItemsBehavior is “Series”. |
This section lists placeholders you can use for PieChartView series:
| Placeholder | Description |
|---|---|
| {S} | Displays the pie series name obtained from the DisplayName property. |
| {L} | Displays a pie sector’s label text. Use the PieSeriesDataAdapter.LabelDataMember property to define the data member that contains pie sector labels. |
| {V} | Displays a pie sector’s value. Use the PieSeriesDataAdapter.ValueDataMember property to define the data member that contains pie sector values. |
| {VP} | Displays the pie sector value as percentage in the range from 0 to 100. |
| {TV} | Displays the center label value. |
In this example, the temperature curve in the spline chart is colored based on ranges of temperature values.
View Example: DeVExpress .NET MAUI Charts - Colorize Line Segments
<ContentPage xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:dxc="clr-namespace:DevExpress.Maui.Charts;assembly=DevExpress.Maui.Charts"
x:Class="SegmentColorizerExample.MainPage"
xmlns:local="clr-namespace:SegmentColorizerExample">
<ContentPage.BindingContext>
<local:ViewModel/>
</ContentPage.BindingContext>
<dxc:ChartView>
<dxc:ChartView.Series>
<dxc:SplineSeries LegendTextPattern="{}{CLV}°C — {CHV}°C">
<dxc:SplineSeries.Data>
<dxc:SeriesDataAdapter DataSource="{Binding Data}" ArgumentDataMember="Argument">
<dxc:ValueDataMember Member="Value" Type="Value" />
</dxc:SeriesDataAdapter>
</dxc:SplineSeries.Data>
<dxc:SplineSeries.SegmentColorizer>
<dxc:GradientPointBasedSegmentColorizer>
<dxc:GradientPointBasedSegmentColorizer.PointColorizer>
<dxc:ValueBandPointColorizer>
<dxc:ValueBandPointColorizer.ColorStops>
<dxc:ColorStop Color="#00008b" Value1="-40" Value2="-30"/>
<dxc:ColorStop Color="#222b9d" Value1="-30" Value2="-20"/>
<dxc:ColorStop Color="#4556af" Value1="-20" Value2="-15"/>
<dxc:ColorStop Color="#6781c1" Value1="-15" Value2="-10"/>
<dxc:ColorStop Color="#8aacd3" Value1="-10" Value2="-5"/>
<dxc:ColorStop Color="#add8e6" Value1="-5" Value2="0"/>
<dxc:ColorStop Color="#bdbab8" Value1="0" Value2="5"/>
<dxc:ColorStop Color="#cd9d8a" Value1="5" Value2="10"/>
<dxc:ColorStop Color="#de7f5b" Value1="10" Value2="15"/>
<dxc:ColorStop Color="#ee622d" Value1="15" Value2="20"/>
<dxc:ColorStop Color="#ff4500" Value1="20" Value2="30"/>
</dxc:ValueBandPointColorizer.ColorStops>
</dxc:ValueBandPointColorizer>
</dxc:GradientPointBasedSegmentColorizer.PointColorizer>
</dxc:GradientPointBasedSegmentColorizer>
</dxc:SplineSeries.SegmentColorizer>
</dxc:SplineSeries>
</dxc:ChartView.Series>
<dxc:ChartView.Legend>
<dxc:Legend Orientation="TopToBottom"
HorizontalPosition="RightOutside"
VerticalPosition="Center"/>
</dxc:ChartView.Legend>
<dxc:ChartView.AxisX>
<dxc:DateTimeAxisX>
<dxc:DateTimeAxisX.Label>
<dxc:AxisLabel TextFormat="MMM"/>
</dxc:DateTimeAxisX.Label>
</dxc:DateTimeAxisX>
</dxc:ChartView.AxisX>
</dxc:ChartView>
</ContentPage>
using System;
using System.Collections.Generic;
namespace SegmentColorizerExample
{
public class ViewModel
{
public List<DataItem> Data { get; }
public ViewModel()
{
Data = new List<DataItem>() {
new DataItem() { Argument = new DateTime(2018, 1, 1), Value = -17.5 },
new DataItem() { Argument = new DateTime(2018, 1, 10), Value = -1.4 },
new DataItem() { Argument = new DateTime(2018, 1, 20), Value = -22 },
new DataItem() { Argument = new DateTime(2018, 1, 30), Value = -26.2 },
new DataItem() { Argument = new DateTime(2018, 2, 10), Value = -17.5 },
new DataItem() { Argument = new DateTime(2018, 2, 20), Value = -15.7 },
new DataItem() { Argument = new DateTime(2018, 2, 28), Value = -7.8 },
new DataItem() { Argument = new DateTime(2018, 3, 10), Value = -8.8 },
new DataItem() { Argument = new DateTime(2018, 3, 20), Value = 1.3 },
new DataItem() { Argument = new DateTime(2018, 3, 30), Value = -7.5 },
new DataItem() { Argument = new DateTime(2018, 4, 10), Value = 1.5 },
new DataItem() { Argument = new DateTime(2018, 4, 20), Value = 8.5 },
new DataItem() { Argument = new DateTime(2018, 4, 30), Value = 11 },
new DataItem() { Argument = new DateTime(2018, 5, 10), Value = 12.2 },
new DataItem() { Argument = new DateTime(2018, 5, 20), Value = 13.7 },
new DataItem() { Argument = new DateTime(2018, 5, 30), Value = 8.3 },
new DataItem() { Argument = new DateTime(2018, 6, 10), Value = 15.3 },
new DataItem() { Argument = new DateTime(2018, 6, 20), Value = 19.1 },
new DataItem() { Argument = new DateTime(2018, 6, 30), Value = 22.3 },
new DataItem() { Argument = new DateTime(2018, 7, 10), Value = 22.2 },
new DataItem() { Argument = new DateTime(2018, 7, 20), Value = 24.5 },
new DataItem() { Argument = new DateTime(2018, 7, 30), Value = 21.4 },
new DataItem() { Argument = new DateTime(2018, 8, 10), Value = 21.2 },
new DataItem() { Argument = new DateTime(2018, 8, 20), Value = 15.6 },
new DataItem() { Argument = new DateTime(2018, 8, 30), Value = 15 },
};
}
}
public class DataItem
{
public DateTime Argument { get; set; }
public double Value { get; set; }
}
}
See Also