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

How to reset Selection Slider in DataBound event handler?

1 Answer 99 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Kornelije
Top achievements
Rank 1
Kornelije asked on 06 Aug 2012, 09:12 AM

Hi!

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)
        return;
  
    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?

1 Answer, 1 is accepted

Sort by
0
Accepted
Rosko
Telerik team
answered on 09 Aug 2012, 07:43 AM
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,
Rosko
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Chart
Asked by
Kornelije
Top achievements
Rank 1
Answers by
Rosko
Telerik team
Share this question
or