jQWidgets Forums
jQuery UI Widgets › Forums › Chart › getItemsCount inside range selector of a chart
This topic contains 4 replies, has 2 voices, and was last updated by baykouch 10 years, 2 months ago.
-
Author
-
Hi,
I am quite new to the jqx library but it looks most impressive!
I had a look at the zooming chart example with a range selector:
According to the API documentation getItemsCount method of jqxChart can be used to retrieve the number of points/items rendered in a specific serie.
Is there any possibility to get the number of points inside the range selector (displayed in the chart) or even to get a list of this items, which are probably a sub-set of all items of the source.
Thank you for your help!Hi baykouch,
Currently there’s no function to get the items count in the range selecor. We can consider adding such function but it might not be that useful because it will simply return the number of items in your data source. Is there a specific reason why you need it?
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter,
thank you for the quick replay.
I don’t need the number of items in the data source, but the number of items between min and max of the range selector as modified by the user every time the range is changed.
I have an application that needs this number of items to show what portion of the data is currently selected. In my case it will be some amount of money, calculated based on the number of items between min and max.
Of course one can loop through all the items of the data source, and check if an item is between, but it’s definitely not the smart way.
Best regards
AntonHi baykouch,
Yes, your request makes sense. However, getItemsCount will actually not return only the currently visible items but all items that were considered during the rendering.
The best you can do is to bind the rangeSelector’s events and work directly with the data source. Check this demo:
http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxchart/index.htm#demos/jqxchart/javascript_chart_events_range_selector.htmThe range selector event will give you the min and max of the range. Then you can loop through your source data to calculate the desired value. You don’t actually have to loop through the entire data set. Assuming that the data is sorted on the x-Axis (it should be in most cases, and even if it is not, it won’t hurt sorting it), you will be able to binary search the min and the max to get the start and end offset. This will give you quite reasonable performance even on a relatively large data set.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter,
Thank you for your hints and for the example. How can I see the source code of it?
Am I right in the suggestion in case of datetime x-axis the library has to sort the data in the source for rendering? Can this sorted data be accessed?Best regards,
Anton -
AuthorPosts
You must be logged in to reply to this topic.