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

Scroll Selected DataPoint into view

1 Answer 94 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Alan
Top achievements
Rank 1
Alan asked on 10 May 2019, 10:09 PM

Hello,

I'm using a RadChartView, with a spline series. I can get the index of the datapoint I'm interested in and I can set the point's IsSelected to True. I then expect that point will then scroll into view, if not already, but it doesn't. What am I missing? Is there another way to do it?

Thanks.

Alan

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 15 May 2019, 12:28 PM
Hi Alan,

The chart doesn't support a scroll to a specific item. You can only define the pan offset in pixels or relative units. To achieve your requirement you can manually set a property. The property that you will need is different based on your set up of the zoom. The zoom can be controlled via the Zoom and PanOffset properties of the chart or the Horizontal/VerticalZoomRangeStart and Horizontal/VerticalZoomRangeEnd properties.
  • If you use the Zoom property you can set the offset via the PanOffset property.
  • If you use the zoom range properties you can set them according to the offset you want to apply.

In both cases, custom calculations will be required. You could check the Conversion API of the chart  ConvertDataToPoint() method which returns specified data to coordinates. More specifically on the  Check more about those properties in the Scroll and Zoom help article. Specifically, you can check the Manual scroll and zoom section.

If you have further questions please let me know.

Regards,
Dinko
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Mehtaz
Top achievements
Rank 1
commented on 19 Nov 2021, 04:28 AM | edited

Hi Dinko,
I tried your approach but failed to achieve it. If the point is outside the view ConvertDataToPoint() returns a very big positive or negative number. setting panOffset to this point doesn't zoom to the point. my sample code.


 chartViewItem.IsSelected = true;
                            DataTuple dataTuple = new DataTuple(((GraphItemProxy)chartViewItem.DataItem).Date, ((GraphItemProxy)chartViewItem.DataItem).Y);
                            Point point = chart.ConvertDataToPoint(dataTuple, chart.HorizontalAxis, chart.Series[0].VerticalAxis);
                            chart.Zoom = new Size(1000, 1);
                            chart.PanOffset = new Point(-point.X, -point.Y);
                            ((ChartTrackBallBehavior)chart.Behaviors[1]).Position = point;
Can any demo project be provided?
Mehtaz
Top achievements
Rank 1
commented on 22 Nov 2021, 12:29 PM

I solved my problem. In my case, I had to do a horizontal zoom to take the scrollbar to the data point.
First, find the minimum and maximum of the data points.
chart.HorizontalzoomRangeStart=(desiredPointValue-minValue)/(maxValue-minValue)
If you are using DateTimeAxis, use Tick property of the minDate,maxDate and desiredDate
Tags
ChartView
Asked by
Alan
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or