Hi,
I was wondering if there was a way to determine which points in a series are currently visible on a chart? The sort of thing I am looking for is a IsVisible property which is updated as you zoom/pan the chart.I have had a look and I can't see anything. Is there an easy way to achieve this?
Thanks,
Steven
I was wondering if there was a way to determine which points in a series are currently visible on a chart? The sort of thing I am looking for is a IsVisible property which is updated as you zoom/pan the chart.I have had a look and I can't see anything. Is there an easy way to achieve this?
Thanks,
Steven
5 Answers, 1 is accepted
0
Hi Steven,
There is no single property (such as IsVisible) that will allow you to perform this check. Can you share with us what is the final goal you are after? Usually there is more than one way to achieve something and we can suggest a better solution if we know a bit about your case.
1. Can you tell us why you need to get the points in view?
2. How often do you need to do this?
3. How many items are there in the items source?
4. What type of series are you using?
Regards,
Petar Marchev
Telerik
There is no single property (such as IsVisible) that will allow you to perform this check. Can you share with us what is the final goal you are after? Usually there is more than one way to achieve something and we can suggest a better solution if we know a bit about your case.
1. Can you tell us why you need to get the points in view?
2. How often do you need to do this?
3. How many items are there in the items source?
4. What type of series are you using?
Regards,
Petar Marchev
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Steven
Top achievements
Rank 1
answered on 27 Jan 2015, 12:00 PM
Hi Petar.
The final goal is to have the table next to the chart which shows the objects which are visible in the chart (allowing the user to see more details).
We need to do this whenever the user pans/zooms.
There will be a maximum of around 3000 data points in the items source.
We are using a combination of ScatterLineSeries and LineSeries. The user can change the x-axis of the chart between a LinearAxis and a DateTimeContinuousAxis. We also have a primary and secondary Y-Axis.
I have manged to get it working problematically but the code behind it is not very nice. I have to determine which axis is being shown so I can test against the correct property. I also have to have different methods to handle the different series types as there is not a base implementation/interface which exposes a way of obtaining the data points from a series. I don't think is very efficient as I am hooking into the zoom/pan events on the chart and doing these calculations each time (when a zoom/pan happens at the same time I am running the code twice as each event is fired once).
To check if the point is visible I am using the ActualVisibleRange class and using the IsInRangeExclusive method passing in the value (I need to rethink this as it I would need to change the code if we change what properties we are charting).
This method works OK but isn't ideal. I was just wondering if you had a cleaner way of achieving this?
As a side note, the IsInRangeInclusive method on ActualVisibleRange always takes in a double, where IsInRangeExclusive takes in T. This doesn't seem correct to me and was a bit annoying as I am using dates so I need to use the IsInRangeExclusive and also compare the values to the min/max for the range.
Any help/advice you can give in helping me obtain a cleaner more efficient solution would be very much appreciated.
Regards,
Steven
The final goal is to have the table next to the chart which shows the objects which are visible in the chart (allowing the user to see more details).
We need to do this whenever the user pans/zooms.
There will be a maximum of around 3000 data points in the items source.
We are using a combination of ScatterLineSeries and LineSeries. The user can change the x-axis of the chart between a LinearAxis and a DateTimeContinuousAxis. We also have a primary and secondary Y-Axis.
I have manged to get it working problematically but the code behind it is not very nice. I have to determine which axis is being shown so I can test against the correct property. I also have to have different methods to handle the different series types as there is not a base implementation/interface which exposes a way of obtaining the data points from a series. I don't think is very efficient as I am hooking into the zoom/pan events on the chart and doing these calculations each time (when a zoom/pan happens at the same time I am running the code twice as each event is fired once).
To check if the point is visible I am using the ActualVisibleRange class and using the IsInRangeExclusive method passing in the value (I need to rethink this as it I would need to change the code if we change what properties we are charting).
This method works OK but isn't ideal. I was just wondering if you had a cleaner way of achieving this?
As a side note, the IsInRangeInclusive method on ActualVisibleRange always takes in a double, where IsInRangeExclusive takes in T. This doesn't seem correct to me and was a bit annoying as I am using dates so I need to use the IsInRangeExclusive and also compare the values to the min/max for the range.
Any help/advice you can give in helping me obtain a cleaner more efficient solution would be very much appreciated.
Regards,
Steven
-1
Accepted
Hi Steven,
Thank you for providing more details on the matter. We understand that having a simple IsVisible property would make this a bit easier.
There is more than one way to get the behavior you need. I can suggest two approaches that will help you determine whether a point is in the visible range.
The first approach assumes you are using a point template. If you are not using a point template and if you are using line series this is not applicable. If you were using a different series (one that has default visuals, like point series) we could tweak the code to make it work.
The first approach involves looking in the visual tree and looking up the visible elements. These visible elements (ContentPresenter in the case of PointTemplate) are the data point presenters. Each visual element contains the data point (in the DataContext). Simply, if a visual element is visible - its associated data point is in the visible range.
The second approach essentially iterates all data points and asks the plot area to calculate whether it contains the point. Both the plot-area and data-point's layout-slot are RadRect objects, so simple rect intersection calculations are done.
I hope that you will find at least one of these solutions to be feasible. Let us know if you need more information.
Regards,
Petar Marchev
Telerik
Thank you for providing more details on the matter. We understand that having a simple IsVisible property would make this a bit easier.
There is more than one way to get the behavior you need. I can suggest two approaches that will help you determine whether a point is in the visible range.
The first approach assumes you are using a point template. If you are not using a point template and if you are using line series this is not applicable. If you were using a different series (one that has default visuals, like point series) we could tweak the code to make it work.
The first approach involves looking in the visual tree and looking up the visible elements. These visible elements (ContentPresenter in the case of PointTemplate) are the data point presenters. Each visual element contains the data point (in the DataContext). Simply, if a visual element is visible - its associated data point is in the visible range.
The second approach essentially iterates all data points and asks the plot area to calculate whether it contains the point. Both the plot-area and data-point's layout-slot are RadRect objects, so simple rect intersection calculations are done.
I hope that you will find at least one of these solutions to be feasible. Let us know if you need more information.
Regards,
Petar Marchev
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Steven
Top achievements
Rank 1
answered on 28 Jan 2015, 09:22 AM
Thanks Petar, I went with the second approach.
I am still a bit curious as to why the IsInRangeInclusive on ValueRange<T> always takes in a double, even when I am using DateTime, Do you have any info on this?
http://docs.telerik.com/devtools/wpf/api/html/M_Telerik_Charting_ValueRange_1_IsInRangeInclusive.htm
IsInRangeExclusive takes in T, which is what I would expect.
http://docs.telerik.com/devtools/wpf/api/html/M_Telerik_Charting_ValueRange_1_IsInRangeExclusive.htm
Thanks,
Steven
I am still a bit curious as to why the IsInRangeInclusive on ValueRange<T> always takes in a double, even when I am using DateTime, Do you have any info on this?
http://docs.telerik.com/devtools/wpf/api/html/M_Telerik_Charting_ValueRange_1_IsInRangeInclusive.htm
IsInRangeExclusive takes in T, which is what I would expect.
http://docs.telerik.com/devtools/wpf/api/html/M_Telerik_Charting_ValueRange_1_IsInRangeExclusive.htm
Thanks,
Steven
0
Hi Steven,
I got so focused on the two approaches yesterday, that I did not address the ValueRange issue. Sorry for this. I think this is just some left over, it should definitely be T, not double. Thank you for reminding me, I have logged it in our feedback portal and increased your Telerik points.
Regards,
Petar Marchev
Telerik
I got so focused on the two approaches yesterday, that I did not address the ValueRange issue. Sorry for this. I think this is just some left over, it should definitely be T, not double. Thank you for reminding me, I have logged it in our feedback portal and increased your Telerik points.
Regards,
Petar Marchev
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.