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

PieChart - getting error for dataitem property

1 Answer 52 Views
Chart
This is a migrated thread and some comments may be shown as answers.
joy
Top achievements
Rank 1
joy asked on 04 Dec 2012, 05:08 AM
Hi,

We are using Silverlight telerik RadPieChart.  It displays data collection from WCF RIA datasource.  We want to display custom fields (StationGivenName, CountOfBarcode) in labels like in your example (pie chart with countries=>  http://demos.telerik.com/silverlight/#ChartView/Selection)


We have copied the code for <telerik:ChartSeriesLabelDefinition.Template>, our code is:


                <telerik:RadPieChart x:Name="radChart1" Palette="Summer" Foreground="White" Grid.Row="1" Width="500" Height="300">

                    <telerik:PieSeries ValueBinding="CountOfBarcode" ItemsSource="{Binding Data, ElementName=chartDataSource}"
                                       
                                       RadiusFactor="0.77">
                        <telerik:PieSeries.LabelDefinitions>
                           
                            <telerik:ChartSeriesLabelDefinition Margin="-8 0 0 0" >
                                <telerik:ChartSeriesLabelDefinition.Template>
                                    <DataTemplate>
                                        <StackPanel>
                                            <TextBlock Text="{Binding DataItem.StationGivenName}"
                                                   HorizontalAlignment="Center" Foreground="White"/>
                                            <TextBlock Text="{Binding DataItem.CountOfBarcode}"
                                                   HorizontalAlignment="Center" Foreground="White"/>
                                        </StackPanel>
                                    </DataTemplate>
                                </telerik:ChartSeriesLabelDefinition.Template>
                            </telerik:ChartSeriesLabelDefinition>




Below is the error we are getting in the result. It means that DataContext of template is string "50%", and there is no member "DataItem".
So how can we access data record and fields in    <telerik:ChartSeriesLabelDefinition.Template>?


Error:
System.Windows.Data Error: BindingExpression path error: 'DataItem' property not found on '50 %' 'System.String' (HashCode=-1138646827). BindingExpression: Path='DataItem.StationGivenName' DataItem='50 %' (HashCode=-1138646827); target element is 'System.Windows.Controls.TextBlock' (Name=''); target property is 'Text' (type 'System.String')..


Thank you for your help.

Joy Gomez

1 Answer, 1 is accepted

Sort by
0
Petar Marchev
Telerik team
answered on 06 Dec 2012, 07:32 AM
Hi Joy,

Perhaps you are using an older version of our controls. Try it with assemblies from the official 2012 Q3 release or with the service pack and let us know how that goes.

All the best,
Petar Marchev
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Chart
Asked by
joy
Top achievements
Rank 1
Answers by
Petar Marchev
Telerik team
Share this question
or