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

Pie Chart Manual Series Mapping

1 Answer 77 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Sirum
Top achievements
Rank 1
Sirum asked on 11 Jan 2012, 01:24 PM
Hi,
I an trying to create a PieChart like:

<chart:RadChart
                                Name="qwe"
                                Content="RadChart"
                                ItemsSource="{Binding PieChartItems}">
                                <chart:RadChart.DefaultView>
                                    <charting:ChartDefaultView>
                                        <charting:ChartDefaultView.ChartArea/>
                                        <charting:ChartDefaultView.ChartTitle>
                                            <charting:ChartTitle Content="CHART TITLE"/>
                                        </charting:ChartDefaultView.ChartTitle>
                                        <charting:ChartDefaultView.ChartLegend>
                                            <charting:ChartLegend
                                                x:Name="ChartLegend2"
                                                Visibility="Visible"
                                                Header="ABC"
                                                Padding="0,0,5,0"
                                                HorizontalContentAlignment="Right"
                                                BorderThickness="0"
                                                Background="Transparent"/>
                                        </charting:ChartDefaultView.ChartLegend>
                                    </charting:ChartDefaultView>
                                </chart:RadChart.DefaultView>

The problem is where in the code I should add a manual series mapping in order to bind labels to a collection in VM.

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 16 Jan 2012, 08:59 AM
Hi,

Please, have a look at the following code snippet, which demonstrates how you can create a Pie chart :
<telerik:RadChart ItemsSource="{Binding Data}" x:Name="chart">
                <telerik:RadChart.SeriesMappings>
                    <telerik:SeriesMapping   >
                        <telerik:SeriesMapping.SeriesDefinition>
                            <telerik:PieSeriesDefinition/>
                        </telerik:SeriesMapping.SeriesDefinition>
                        <telerik:SeriesMapping.ItemMappings>
                            <telerik:ItemMapping DataPointMember="YValue" FieldName="Value1" ></telerik:ItemMapping>
                            <telerik:ItemMapping DataPointMember="LegendLabel"  FieldName="LegendName" ></telerik:ItemMapping>
                        </telerik:SeriesMapping.ItemMappings>
                    </telerik:SeriesMapping>
                </telerik:RadChart.SeriesMappings>
  
                <telerik:RadChart.DefaultView>
                    <telerik:ChartDefaultView>
                        <telerik:ChartDefaultView.ChartLegend>
                            <telerik:ChartLegend x:Name="Legend" Header="Legend" >
                            </telerik:ChartLegend>
                        </telerik:ChartDefaultView.ChartLegend>
                        <telerik:ChartDefaultView.ChartArea>
                            <telerik:ChartArea LegendName="Legend">
                            </telerik:ChartArea>
                        </telerik:ChartDefaultView.ChartArea>
                    </telerik:ChartDefaultView>
                </telerik:RadChart.DefaultView>
            </telerik:RadChart>

Hope this helps.

Greetings,
Nikolay
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Tags
Chart
Asked by
Sirum
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or