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

2 posts, 0 answers
  1. Stuart
    Stuart avatar
    30 posts
    Member since:
    Jun 2010

    Posted 08 Jun 2010 Link to this post

    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
  2. Stuart
    Stuart avatar
    30 posts
    Member since:
    Jun 2010

    Posted 08 Jun 2010 Link to this post

    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> 
Back to Top