Skip to content

Commit d2c860e

Browse files
Update PieandDoughnut.md
1 parent 2d8f90e commit d2c860e

File tree

1 file changed

+26
-52
lines changed

1 file changed

+26
-52
lines changed

wpf/Charts/SeriesTypes/PieandDoughnut.md

Lines changed: 26 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -100,32 +100,30 @@ The small segments in the pie chart can be grouped into the “others” categor
100100

101101
{% highlight xaml %}
102102

103-
<Window.Resources>
104-
<local:DataLabelTemplateConverter x:Key="DataLabelConverter"/>
105-
<local:SegmentBrushConverter x:Key="BackgroundConverter"/>
106-
107-
<DataTemplate x:Key="DataLabelTemplate">
108-
<StackPanel Orientation="Vertical" Margin="5">
109-
<TextBlock Text="{Binding Converter={StaticResource DataLabelConverter}}"
110-
Margin="3" Foreground="White">
111-
</TextBlock>
112-
</StackPanel>
113-
</DataTemplate>
114-
</Window.Resources>
115-
116-
<chart:PieSeries ItemsSource="{Binding Data}" XBindingPath="Country" YBindingPath="Count"
117-
GroupMode="Value" GroupTo="1000" >
118-
119-
<chart:PieSeries.AdornmentsInfo>
120-
<chart:ChartAdornmentInfo ShowConnectorLine="True"
121-
ConnectorHeight="80"
122-
ShowLabel="True"
123-
LabelPosition="OutsideExtended"
124-
LabelTemplate="{StaticResource DataLabelTemplate}"
125-
SegmentLabelContent="LabelContentPath">
126-
</chart:ChartAdornmentInfo>
127-
</chart:PieSeries.AdornmentsInfo>
128-
</chart:PieSeries>
103+
<Window.Resources>
104+
<local:DataLabelTemplateConverter x:Key="DataLabelConverter"/>
105+
106+
<DataTemplate x:Key="DataLabelTemplate">
107+
<StackPanel Orientation="Vertical" Margin="5">
108+
<TextBlock Text="{Binding Converter={StaticResource DataLabelConverter}}"
109+
Margin="3" Foreground="White">
110+
</TextBlock>
111+
</StackPanel>
112+
</DataTemplate>
113+
</Window.Resources>
114+
115+
<chart:PieSeries ItemsSource="{Binding Data}" XBindingPath="Country" YBindingPath="Count"
116+
GroupMode="Value" GroupTo="1000" >
117+
118+
<chart:PieSeries.AdornmentsInfo>
119+
<chart:ChartAdornmentInfo ShowConnectorLine="True"
120+
ConnectorHeight="80"
121+
ShowLabel="True"
122+
LabelTemplate="{StaticResource DataLabelTemplate}"
123+
SegmentLabelContent="LabelContentPath">
124+
</chart:ChartAdornmentInfo>
125+
</chart:PieSeries.AdornmentsInfo>
126+
</chart:PieSeries>
129127

130128
{% endhighlight %}
131129

@@ -145,38 +143,14 @@ The small segments in the pie chart can be grouped into the “others” categor
145143

146144
pieSeries.AdornmentsInfo = adornmentInfo;
147145

148-
149-
public class DataLabelTemplateConverter : IValueConverter
150-
{
151-
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
152-
{
153-
if (value is ChartPieAdornment adornment)
154-
{
155-
if (adornment.Item is CountryInfo model)
156-
{
157-
// Case 1: Single data label item
158-
}
159-
else if (adornment.Item is IEnumerable<object> group)
160-
{
161-
// Case 2: Grouped items (e.g., List<CountryInfo>)
162-
}
163-
}
164-
165-
return value;
166-
}
167-
168-
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
169-
{
170-
throw new NotImplementedException();
171-
}
172-
}
173-
174146
{% endhighlight %}
175147

176148
{% endtabs %}
177149

178150
![WPF Pie Chart with Grouping](Series_images/wpf-pie-chart-grouping.png)
179151

152+
You can explore our KB article on showing adornment labels for grouped values in WPF Circular Chart to learn [`how to configure and display labels for grouped values`](https://support.syncfusion.com/kb/article/21684/how-to-show-adornment-labels-for-grouped-values-in-wpf-circular-chart) effectively.
153+
180154
**Pie series with grouping (Mode - Angle)**
181155

182156
{% tabs %}

0 commit comments

Comments
 (0)