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

Chart blows up: Items collection must be empty before using ItemsSource

1 Answer 104 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Stuart
Top achievements
Rank 1
Stuart asked on 08 Jun 2010, 01:59 PM
Hi

I'm currently evaluating the Telerik Silverlight chart control but I am struggling to display a fairly simple two series scatter plot using a logarithmic y axis and time scale x axis. My current (working) code is:

<telerik:RadChart ItemsSource="{Binding Data}" > 
                <telerik:RadChart.DefaultView> 
                    <telerik:ChartDefaultView> 
                        <telerik:ChartDefaultView.ChartArea> 
                            <telerik:ChartArea> 
                                <!--<telerik:AxisY IsLogarithmic="True"/>--> 
                                <!--<telerik:AxisX DefaultLabelFormat="HH:mm"/>--> 
                            </telerik:ChartArea> 
                        </telerik:ChartDefaultView.ChartArea> 
                    </telerik:ChartDefaultView> 
                </telerik:RadChart.DefaultView> 
                <telerik:RadChart.SeriesMappings> 
                    <telerik:SeriesMapping LegendLabel="Data">  
                        <telerik:SeriesMapping.SeriesDefinition> 
                            <telerik:ScatterSeriesDefinition/> 
                        </telerik:SeriesMapping.SeriesDefinition> 
                        <telerik:SeriesMapping.ItemMappings> 
                            <telerik:ItemMapping DataPointMember="XValue" FieldName="Time"/>  
                            <telerik:ItemMapping DataPointMember="YValue" FieldName="Ydata"/>  
                        </telerik:SeriesMapping.ItemMappings> 
                    </telerik:SeriesMapping> 
                </telerik:RadChart.SeriesMappings> 
            </telerik:RadChart> 

 

 

 


Trouble is as soon as I uncomment either of the commented axes lines shown above then the chart blows up with the message 'Items collection must be empty before using ItemsSource'

 

 

 

 

 


Has anyone got a fix for this?

Thanks

1 Answer, 1 is accepted

Sort by
0
Stuart
Top achievements
Rank 1
answered on 08 Jun 2010, 02:52 PM
Okay I've fixed my own problem by rearranging the code to

<telerik:RadChart ItemsSource="{Binding Data}" > 
                <telerik:RadChart.SeriesMappings> 
                    <telerik:SeriesMapping LegendLabel="Ydata">  
                        <telerik:SeriesMapping.SeriesDefinition> 
                            <telerik:ScatterSeriesDefinition/> 
                        </telerik:SeriesMapping.SeriesDefinition> 
                        <telerik:SeriesMapping.ItemMappings> 
                            <telerik:ItemMapping DataPointMember="XValue" FieldName="Time"/>  
                            <telerik:ItemMapping DataPointMember="YValue" FieldName="Ydata"/>  
                        </telerik:SeriesMapping.ItemMappings> 
                    </telerik:SeriesMapping> 
                </telerik:RadChart.SeriesMappings> 
                <telerik:RadChart.DefaultView> 
                    <telerik:ChartDefaultView> 
                        <telerik:ChartDefaultView.ChartArea> 
                            <telerik:ChartArea> 
                                <telerik:ChartArea.AxisX> 
                                    <telerik:AxisX DefaultLabelFormat="HH:mm"/>  
                                </telerik:ChartArea.AxisX> 
                                <telerik:ChartArea.AxisY> 
                                    <telerik:AxisY IsLogarithmic="True" MaxValue="2000"/>  
                                </telerik:ChartArea.AxisY> 
                                  
                            </telerik:ChartArea> 
                        </telerik:ChartDefaultView.ChartArea> 
                    </telerik:ChartDefaultView> 
                </telerik:RadChart.DefaultView> 
                  
            </telerik:RadChart> 
Tags
Chart
Asked by
Stuart
Top achievements
Rank 1
Answers by
Stuart
Top achievements
Rank 1
Share this question
or