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

SelectionRange

1 Answer 72 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Chris Thierry
Top achievements
Rank 1
Chris Thierry asked on 31 Aug 2010, 08:10 PM
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;

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 03 Sep 2010, 12:22 PM
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
Tags
Chart
Asked by
Chris Thierry
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or