SelectionRange

2 posts, 0 answers
  1. Chris Thierry
    Chris Thierry avatar
    138 posts
    Member since:
    Jun 2010

    Posted 31 Aug 2010 Link to this post

    Hi,
    This is a part of my code where my chart is populated by the a list(myList).  I want to see only 12 bars in my chart, so when the list goes over 12 items,the user needs to use the scroll to see the rest of the bars.  This code is executed on "onclick" of a button,
    -when it is first clicked and the list has more than 12 items, everything works as expected.
    -when it is clicked a second time and the list has less than 12 items, I do see the correct bars but I see the scrollAndZoom where I have put "zoomSettings.ScrollMode = ScrollMode.None; "
    -on a third click when the list has more than 12 items, I see the scrollbar, but I can not go to then next 12 items....Any help?

    if (mytList.Count > 12)
                    {
      
                        ZoomScrollSettings zoomSettings = new ZoomScrollSettings();
                        zoomSettings.RangeEnd = (12d / myList.Count);
                        zoomSettings.RangeStart = 0;
                        zoomSettings.ScrollMode = ScrollMode.ScrollAndZoom;
                        myCostChart.DefaultView.ChartArea.ZoomScrollSettingsX = null;
                        myCostChart.DefaultView.ChartArea.ZoomScrollSettingsX =zoomSettings;
                          
                    }
                    else
                    {
                        ZoomScrollSettings zoomSettings = new ZoomScrollSettings();
                        zoomSettings.ScrollMode = ScrollMode.None;
                        zoomSettings.SetSelectionRange(0, 1);
                        myCostChart.DefaultView.ChartArea.ZoomScrollSettingsX = null;
                        myCostChart.DefaultView.ChartArea.ZoomScrollSettingsX = zoomSettings;
                        
                    }
      myCostChart.ItemsSource = myList;
  2. Nikolay
    Admin
    Nikolay avatar
    385 posts

    Posted 03 Sep 2010 Link to this post

    Hi Chris Thierry,

    Please, have a look at this code snippet we've used on our side to simulate your scenario :
    private void button_Click(object sender, RoutedEventArgs e)
            {
                if (mytList.Count > 12)
                    {
                        RadChart1.DefaultView.ChartArea.ZoomScrollSettingsX.ScrollMode = ScrollMode.ScrollAndZoom;
                        RadChart1.DefaultView.ChartArea.ZoomScrollSettingsX.RangeEnd = 12d / mytList.Count;
                    }
                    else
                    {
                        RadChart1.DefaultView.ChartArea.ZoomScrollSettingsX.ScrollMode = ScrollMode.None;
                    }
      
                RadChart1.ItemsSource = mytList;
            }

    If there are less than 12 items, the ScrollBar would not be displayed. When there are more than 12 items, RangeEnd would update so that only the first 12 would be visible. You may scroll to view the rest but please note that unless XValue/XCategory is mapped, the corresponding X-Axis labels would not update and would only display the given range of 1 to 12. Perhaps this answers your third point about not being able to go to the next items.

    Hope this helps. 

    Kind regards,
    Nikolay
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
Back to Top