<Grid.Resources>
<local:DecimalConverter x:Key="decimalConverter"/>
</Grid.Resources>
<syncfusion:SfChart x:Name="Chart" Margin="20" >
<syncfusion:PieSeries x:Name="series1" ItemsSource="{Binding Data}"
Stroke="White" XBindingPath="XValue"
YBindingPath="YValue">
<syncfusion:PieSeries.AdornmentsInfo>
<syncfusion:ChartAdornmentInfo ShowLabel="True" Foreground="White">
<syncfusion:ChartAdornmentInfo.LabelTemplate>
<DataTemplate>
<TextBlock Text="{Binding Converter={StaticResource decimalConverter}}" Foreground="White"/>
</DataTemplate>
</syncfusion:ChartAdornmentInfo.LabelTemplate>
</syncfusion:ChartAdornmentInfo>
</syncfusion:PieSeries.AdornmentsInfo>
</syncfusion:PieSeries>
</syncfusion:SfChart>
|
public class ViewModel
{
public ViewModel()
{
Data = new ObservableCollection<Model>();
Data.Add(new Model(1, 100));
Data.Add(new Model(2, 0.1));
}
public ObservableCollection<Model> Data { get; set; }
}
public class DecimalConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
return Math.Round(System.Convert.ToDouble(value), 0);
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
return value;
}
}
|