How to reset Selection Slider in DataBound event handler?

2 posts, 1 answers
  1. Kornelije
    Kornelije avatar
    28 posts
    Member since:
    May 2011

    Posted 06 Aug 2012 Link to this post


    I am trying to get around the bug in RadChart when zooming too much so that no data is visible. In that case, the control looses the slider, shows the "No data series" and is unable to zoom out. 

    The way I approach the problem is that I check the number of points in the DataSeries on DataBound event. For now (and for testing purposes) if there is at least a single data series with 3 or more points, I allow the zoom change.

    However, if all data series have less than 3 points, I reset the zoom to 100% (range from 0 to 1).

    Here is the code:

    private void changeZoomSettingsOnDataBound(object sender, ChartDataBoundEventArgs e)
        if (Chart.DefaultView.ChartArea.DataSeries.Count == 0)
        DataSeriesCollection series = Chart.DefaultView.ChartArea.DataSeries;
        bool isZoomValid = series.Any(dSeries => dSeries.Count >= 3);
        if (!isZoomValid)
            Chart.DefaultView.ChartArea.ZoomScrollSettingsX.SetSelectionRange(0, 1);

    This code works as it should, regarding the zoom level. When the zoom level reaches the point where there would be less than 3 points in all data series, the zoom will reset to show the complete range in the underlying collection.

    However, the slider+s UI is not set to full range. If I click on the slider, it will show the full range, but its UI is not updated by calling SetSelectionRange (nor by manually setting SliderSelectionStart and SliderSelectionEnd) in the DataBound event handler. You can take a look at the video recorded (see this link for the video). Compare the state of the chart at the start. It shows three data series. When I zoom too much, it will reset to the starting state (all three data series visible). However, you will see that the slider remained unchanged. Then I clicked on the slider and it reset its UI to represent the underlying range correctly.

    How can I do this UI update in my DataBound event handler, if possible?

  2. Answer
    Rosko avatar
    137 posts

    Posted 09 Aug 2012 Link to this post

    Hi Kornelije,

    We tested the scenario for this behavior and it behaves as you said. It is happening due to internal changes in the implementation of the slider. For a workaround please check the code snippet below. I hope this will help you.
    Dispatcher.BeginInvoke(() =>radChart.DefaultView.ChartArea.ZoomScrollSettingsX.SetSelectionRange(0, 1));

    Kind regards,
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top