How to find the series data corresponding to the point displayed on the current chart

0 Answers 71 Views
Charts
Steve
Top achievements
Rank 1
Iron
Iron
Steve asked on 15 Dec 2022, 06:06 AM

When I don't set baseUnit={"days"} for ChartCategoryAxisItem and the XAxis range is large, not all points are displayed, but I don't know how to find the series data corresponding to the displayed points.  How can I find the data corresponding to the 11 points in the second picture from the existing instance?

\

Steve
Top achievements
Rank 1
Iron
Iron
commented on 15 Dec 2022, 07:14 AM

I want to get all the displayed points to set the maximum and minimum values of the Y axis
Konstantin Dikov
Telerik team
commented on 16 Dec 2022, 07:42 PM

Hi Steve,

The Chart will display the data that is being passed to it and with the enabled navigator, the displayed points will be within that range. Relying on the information coming from the Chart to adjust the range afterwards might not be the best idea, so I would recommend using the initial navigator range with the initial data that you have and going through the points find the range within those points that will fit in the current navigator range will be. This should be done before passing the data to the Chart, so that you can avoid unnecessary re-rendering.

If I am not understanding the exact scenario, you can share a stackblitz example with your current configuration, so we can test it locally. 

Steve
Top achievements
Rank 1
Iron
Iron
commented on 17 Dec 2022, 01:53 AM

Hi, Kon
 I mean, is there any way I can get the data corresponding to the visible points on the chart in stock-data.json
naughty-black-4e5fcv - CodeSandbox
Konstantin Dikov
Telerik team
commented on 20 Dec 2022, 03:53 PM

Although that there is no built-in way for retrieving the render points, you can use the "from" and "to" values from the navigator to filter the series data based on the date field values. I have created a simple example demonstrating how you can use the "onRender" event and "onNavigatorFilter" to get the current points in the view:

Hope this helps.

Steve
Top achievements
Rank 1
Iron
Iron
commented on 21 Dec 2022, 05:38 AM

Hi Kon
  First of all thanks for your suggestion. I also tried using from and to to filter the data. However, I can't find out the data corresponding to the points shown in the chart. For example, I adjusted the navigation range from the beginning to the end to filter out 51 data, but there are only 6 points in the chart.
Konstantin Dikov
Telerik team
commented on 21 Dec 2022, 01:48 PM

The example that I have shared will give you the points from the original data that are within the current date range. Note that changing the range will also change the base units and the aggregation of the values and I have to say that there is no built-in way for retrieving those aggregated values. The Chart calculates internally which points should be rendered.

The only workaround that I could suggest is to add a "visual" for the item labels and store the values for each of them, although that there are still some issues with the corner points (in some cases the visual will be called for points outside of the plot area:

I can also suggest that you log a feature request in our feedback portal for exposing a method that will return the visible points:

No answers yet. Maybe you can help?

Tags
Charts
Asked by
Steve
Top achievements
Rank 1
Iron
Iron
Share this question
or