Hello, I use the chart with binding for the data and the label.
// Model
public class StatisticRowItem
{
public double ValueDouble { get; set; }
public string Value { get; set; }
public string Name { get; set; }
}
// ViewModel
public class ViewModel
{
public ObservableCollection<StatisticRowItem> RowItemList { get; set; }
}
If only the values are bound, the calculation of the percentage values is correct.
<telerik:RadPieChart Grid.Row="1" Palette="{StaticResource customPalette}">
<telerik:RadPieChart.Series>
<telerik:DoughnutSeries
InnerRadiusFactor="0.35"
ItemsSource="{Binding RowItemList}"
RadiusFactor="0.50">
<telerik:DoughnutSeries.ValueBinding>
<telerik:PropertyNameDataPointBinding PropertyName="ValueDouble" />
</telerik:DoughnutSeries.ValueBinding>
<telerik:DoughnutSeries.LabelConnectorsSettings>
<telerik:ChartSeriesLabelConnectorsSettings />
</telerik:DoughnutSeries.LabelConnectorsSettings>
</telerik:DoughnutSeries>
</telerik:RadPieChart.Series>
</telerik:RadPieChart>
However, if the value and the label are linked, the calculation is incorrect.
<telerik:RadPieChart Grid.Row="1" Palette="{StaticResource customPalette}">
<telerik:RadPieChart.Series>
<telerik:DoughnutSeries
InnerRadiusFactor="0.35"
ItemsSource="{Binding RowItemList}"
RadiusFactor="0.50">
<telerik:DoughnutSeries.ValueBinding>
<telerik:PropertyNameDataPointBinding PropertyName="ValueDouble" />
</telerik:DoughnutSeries.ValueBinding>
<telerik:DoughnutSeries.LabelDefinitions>
<telerik:ChartSeriesLabelDefinition Margin="-15,0,0,0">
<telerik:ChartSeriesLabelDefinition.Template>
<DataTemplate>
<StackPanel>
<TextBlock
Foreground="{DynamicResource Brushes.Text.Dark}"
Text="{Binding DataItem.Name}"
Style="{StaticResource ControlBase.FontStyle.ButtonText}" />
<TextBlock
HorizontalAlignment="Center"
Foreground="{DynamicResource Brushes.Text.Dark}"
Style="{StaticResource ControlBase.FontStyle.ButtonText}"
Text="{Binding Value}" />
<TextBlock
HorizontalAlignment="Center"
Foreground="{DynamicResource Brushes.Text.Dark}"
Style="{StaticResource ControlBase.FontStyle.ButtonText}"
Text="{Binding Percent}" />
</StackPanel>
</DataTemplate>
</telerik:ChartSeriesLabelDefinition.Template>
</telerik:ChartSeriesLabelDefinition>
</telerik:DoughnutSeries.LabelDefinitions>
<telerik:DoughnutSeries.LabelConnectorsSettings>
<telerik:ChartSeriesLabelConnectorsSettings />
</telerik:DoughnutSeries.LabelConnectorsSettings>
</telerik:DoughnutSeries>
</telerik:RadPieChart.Series>
</telerik:RadPieChart>
The Telerik version 2024.1.130.45 of the WPF controls is used.
Hello Gerhard,
I tested the provided code snippets in a sample project, however, I was not able to reproduce the observed behavior.
The result that is present on my end is as follows:
I attached it, so, would it be possible to give it a try?