SeriesMapping and weird behavior with XCategory

2 posts, 0 answers
  1. Jatinder
    Jatinder avatar
    12 posts
    Member since:
    Oct 2011

    Posted 28 Dec 2011 Link to this post

    I have a SeriesMapping bound to IList<Tuple<string,int>>. The XAxis is bound to the string as a XCategory and the yaxis to the int.

    Below is my xaml and my viewmodel.

    The data is presented just as i want to but with a strange thing happening when i bound to a large list. It seems that the xcategory breaks down once the collection is past 200 items (in code below the for loop where i<190 - change that to say 210 and hell breaks loose). The xcategory gets messed up to numbers and not categorized anymore. See the 2 screenshots. 

    <chart:RadChart x:Name="RadChart1" ItemsSource="{Binding Items}">
                <chart:RadChart.SeriesMappings>
                    <charting:SeriesMapping>
                        <charting:SeriesMapping.SeriesDefinition>
                            <charting:ScatterSeriesDefinition ShowItemToolTips="True" LegendDisplayMode="None"/>
                        </charting:SeriesMapping.SeriesDefinition>
                        <charting:ItemMapping FieldName="Item1" DataPointMember="XCategory" />
                        <charting:ItemMapping FieldName="Item2" DataPointMember="YValue" />
                    </charting:SeriesMapping>
                </chart:RadChart.SeriesMappings>
      
                <chart:RadChart.DefaultView>
                    <charting:ChartDefaultView>
                        <charting:ChartDefaultView.ChartArea>
                            <charting:ChartArea ItemToolTipOpening="ChartArea_ItemToolTipOpening">
                                <charting:ChartArea.AxisX>
                                    <charting:AxisX />
                                </charting:ChartArea.AxisX>
                                <charting:ChartArea.AxisY>
                                    <charting:AxisY MinorTicksVisibility="Collapsed" />
                                </charting:ChartArea.AxisY>
                            </charting:ChartArea>
                        </charting:ChartDefaultView.ChartArea>
                    </charting:ChartDefaultView>
                </chart:RadChart.DefaultView>

    private Random ran;
            public DetailsViewModel()
            {
                ran = new Random();
                createName();
                createData();
            }
      
            private void createName()
            {
                names = new List<string>()
                {
                    "One","two","three","four","five","six","seven","eight","nine","ten","One1","two1",
                    "three1","four1","five1","six1","seven1","eight1","nine1","ten1","One2","two2","three2",
                    "four2","five2","six2","seven2","eight2","nine2","ten2","One3","two3","three3",
                    "four3","five3","six3","seven3","eight3","nine3","ten3"
                };
            }
      
            private void createData()
            {
                int count = names.Count;
                var t = new ObservableCollection<Tuple<string, int>>();
                for (int i = 0; i < 190; i++)
                {
                    int val = ran.Next(5000);
                    t.Add(new Tuple<string, int>(names[val % count], val));
                }
                Items = t;
            }
      
            public List<string> names { get; set; }
            public ObservableCollection<Tuple<string, int>> Items { get; set; }
  2. Bartholomeo Rocca
    Bartholomeo Rocca avatar
    247 posts
    Member since:
    May 2006

    Posted 29 Dec 2011 Link to this post

    Hello Jatinder,

    200 is the default sampling threshold value for RadChart. You will need to set the SamplingThreshold value to 0 in the sampling settings to disable the built-in sampling mechanism (http://www.telerik.com/help/silverlight/radchart-features-sampling.html) and your chart should work as expected.


    Greetings,
    Bart.
Back to Top