@@ -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,32 +143,6 @@ 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 %}
@@ -685,4 +657,4 @@ N> You can refer to our [WPF Doughnut Chart](https://www.syncfusion.com/wpf-cont
685657
686658## See also
687659
688- [ ` How to create Pie Chart in C# WPF ` ] ( https://www.syncfusion.com/kb/10789/how-to-create-pie-chart-in-c-wpf )
660+ [ ` How to create Pie Chart in C# WPF ` ] ( https://www.syncfusion.com/kb/10789/how-to-create-pie-chart-in-c-wpf )
0 commit comments