This is a migrated thread and some comments may be shown as answers.

RadPieChart and PivotChartViewModel

1 Answer 47 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Jared
Top achievements
Rank 1
Jared asked on 17 Jul 2018, 09:53 AM

I'm trying to bind a RadPieChart to data the user has selected using the RadPivotFieldList.  I would like to know how to customise the labels and also how to use the legend with the PieSeries data.

Below is what I have so far, I maybe wildly off the mark with how I'm approaching this.  Any feedback would be welcome.

Thanks

<pivot:RadPivotFieldList x:Name="FieldList"  DataProvider="{Binding DataProvider}"/>
 
<telerik:RadPieChart x:Name="pieChart" Grid.Column="1" Palette="Windows8" DataContext="{Binding ChartViewModel}">
 
    <telerik:PieSeries ValueBinding="Value" ItemsSource="{Binding SeriesSource[0].Items}" ShowLabels="True" >
    </telerik:PieSeries>
</telerik:RadPieChart>

 

In the viewmodel

public LocalDataSourceProvider DataProvider
{
    get => _dataProvider;
    set
    {
        _dataProvider = value;
        OnPropertyChanged(() => DataProvider);
    }
}
 
public PivotChartViewModel ChartViewModel { get; set; }

 

I'm setting the DataProvider of the ChartViewModel like this.

ChartViewModel.DataProvider = DataProvider

 

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 19 Jul 2018, 10:01 AM
Hi Jared,

In order to customize the labels of the PieSeries you can set the Style of the DefaultVisual. Please, take a look at the snippet below.
<telerik:PieSeries.LabelDefinitions>
                    <telerik:ChartSeriesLabelDefinition Margin="-30,0,0,0">
                        <telerik:ChartSeriesLabelDefinition.DefaultVisualStyle>
                            <Style TargetType="TextBlock">
                                <Setter Property="FontSize" Value="25"/>
                            </Style>
                        </telerik:ChartSeriesLabelDefinition.DefaultVisualStyle>
                    </telerik:ChartSeriesLabelDefinition>
                </telerik:PieSeries.LabelDefinitions>

Furthermore, you can take a look at the Customizing PieChart Series article and Pie Series SDK Example for a more detailed look over defining customized labels.

I hope this helps, Jared.

Best Regards,
Stefan
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
Chart
Asked by
Jared
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or