SeriesView.LegendPointPattern Property
Specifies a string pattern that formats legend item text for series points.
Namespace: DevExpress.WinUI.Charts
Assembly: DevExpress.WinUI.Charts.v23.2.dll
NuGet Package: DevExpress.WinUI
#Declaration
#Property Value
Type | Description |
---|---|
String | A string pattern. |
#Remarks
The legend shows point data instead of series names in the following cases:
- In Cartesian charts, when the CartesianSeriesView.ColorEach property is set to true.
- In pie and funnel charts.
Patterns can contain placeholders with format specifiers and plain text. Placeholders enclosed in braces correspond to the available display patterns. For example, a pair of placeholders specified together ({A} - {V}) makes each legend item show a data point’s argument and value separated by a hyphen.
The following table lists available placeholders:
Placeholder | Description |
---|---|
{A} | Displays a series point argument. |
{V} | Displays a series point value. |
{VP} | Displays series point values as percentages (for pie and full-stacked series). |
You can apply format specifiers to the placeholder to format numeric and date/time values. A placeholder and specifier are separated by a colon. See the following topics for more information about specifiers:
If a pattern starts with a placeholder in the XAML markup, insert empty brackets into the beginning of the pattern as follows: “{}{V}”.
#Example
The following example demonstrates how to create a simple Pie Chart with one series.
<Window
x:Class="PieChartSample.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:PieChartSample"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:Charts="using:DevExpress.WinUI.Charts"
mc:Ignorable="d">
<Grid>
<Grid.DataContext>
<local:ChartViewModel/>
</Grid.DataContext>
<Charts:PieChart x:Name="chart" ToolTipEnabled="True">
<Charts:PieChart.Legend>
<Charts:Legend HorizontalPosition="RightOutside"
VerticalPosition="Center"
Orientation="Horizontal"
MaximumRowsOrColumns="1"/>
</Charts:PieChart.Legend>
<Charts:PieChart.Series>
<Charts:PieSeries x:Name="series">
<Charts:PieSeries.View>
<Charts:PieSeriesView ToolTipPointPattern="{}{A}: {VP:p}"
LegendPointPattern="{}{A} (${V}K)"
ShowLabels="True"
LabelPattern="{}{VP:p}"
LabelPosition="TwoColumns">
<Charts:PieSeriesView.Title>
<TextBlock Text="Sales Volume by Products" Margin="10"/>
</Charts:PieSeriesView.Title>
</Charts:PieSeriesView>
</Charts:PieSeries.View>
<Charts:PieSeries.Data>
<Charts:DataSource PointSource="{Binding DataPoints}"
ArgumentDataMember="Product"
ArgumentScaleType="Qualitative"
ValueDataMember="Income"
ValueScaleType="Numerical"/>
</Charts:PieSeries.Data>
</Charts:PieSeries>
</Charts:PieChart.Series>
</Charts:PieChart>
</Grid>
</Window>
using DevExpress.Mvvm;
using Microsoft.UI.Xaml;
using System.Collections.Generic;
namespace PieChartSample {
public sealed partial class MainWindow : Window {
public MainWindow() {
this.InitializeComponent();
}
}
public class DataPoint {
public string Product { get; set; }
public double Income { get; set; }
}
public class ChartViewModel : ViewModelBase {
public ChartViewModel() {
List<DataPoint> dataPoints = new List<DataPoint> {
new DataPoint() { Product = "Camera", Income = 78 },
new DataPoint() { Product = "Flash", Income = 92 },
new DataPoint() { Product = "Smartphone", Income = 43 },
new DataPoint() { Product = "Tripod", Income = 98 },
new DataPoint() { Product = "Mobile Phone", Income = 70 },
new DataPoint() { Product = "Smart Watch", Income = 98 },
new DataPoint() { Product = "Laptop", Income = 85 },
new DataPoint() { Product = "Tablet", Income = 99 },
new DataPoint() { Product = "Headphone", Income = 94 }
};
DataPoints = dataPoints;
}
public List<DataPoint> DataPoints { get; }
}
}
For step-by-step instructions on how to create a Pie chart, refer to the following help topic: Lesson 2 - Create a Pie Chart.