-
Notifications
You must be signed in to change notification settings - Fork 11.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] Select a range on line/time chart #5349
Comments
Hi, Is there any updates on this thread, I'm also looking for the same. |
I am also very interested by this feature |
We are working on one product and we also need this feature. We will implement it and then we can contribute. |
Hi, |
hello |
If I understand correctly, this already exists. It looks exactly like the drag functionality of the zoom plugin: https://github.com/chartjs/chartjs-plugin-zoom (Note that we've fixed a lot of bugs in that plugin in the past couple weeks, so hopefully the next version will improve upon the currently released version) |
Ah, I just found a working vizwit example (most are broken). vizwit looks very similar to the zoom plugin except it doesn't zoom. It only does the selection part. Still, I imagine it should give you a pretty good idea of how to implement. The zoom plugin has a superset of the functionality, so you'd just have to remove the actual zoom call. |
@benmccann does the zoom plugin allow you to select a range on the chart with your cursor? In the codepen demo I can only scroll to zoom. |
You have to set the |
+1 |
3 similar comments
+1 |
+1 |
+1 |
Thanks for posting. I tried the plugin, but didn't like the results. With a large dataset, when you zoom in, it gives you a pixelated view of the timeframe. I'm not a JavaScript developer by any means, but it would be nice to have the ability to "remove" the old chart and "draw" a new chart with the given time range as is discussed in this example: https://stackoverflow.com/questions/47624414/update-chart-js-with-date-range-selector |
@CincyBC I'm quite confused by your comment. The zoom plugin actually does redraw the chart with the given time range. Could you share an interactive example on plunker, codepen, or a similar site that shows the pixelation issue you describe? I've never seen that happen |
A plugin is the correct way to achieve this. Most of the selection logic could be based off of the zoom plugin except instead of zooming at the end of the mouse up handler, it would simply notify some other code of the total range selected. See a very simplistic plugin in https://jsfiddle.net/6La1t3zu/ as an example |
I don't like this approach, it is not intuitive for users how to use it and there is no much configuration or limits you can put on. Because of the amount of data in the chart. For example I would like to restrict the range (up to one day), and user wants to see the entire range when looking at the filtered data. I think the
|
@fairking could you share the reasons why you think the zoom plugin is bad? |
Few examples: |
@fairking thank you for through explanations! I'm not sure what you mean. It does not use the data on the chart for zoom/pan, only scales. So you don't really need any data for it to work. That is a good point. We could possibly add some indicators for the current position. Maybe "snap" to some unit (second, day, month etc) in time scale would be good.
I guess you are talking about a smaller chart to control the main chart? Zoom does not have that, but it should be possible to do something like that with zoom. Should create an example about that.
Pan is available on the main chart, or using API. You'd need to draw the focus rectangle though.
Pinch zoom is natural for mobile users, which is available.
The category scale is really bad option for zooming.
Its possible, but hard. Easier with drag.
Again easier with drag, but
Another one with category scale. It only moves by full categories, so its jumpy. |
+1 for this feature request, I'm looking to implement the same functionality |
This seems like this should be a first class feature |
This video tutorial could also be the basis for such plugin. It seems such a common problem. Too bad no body has taken upon himself to implement a plugin yet. |
Expected Behavior
I would like to propose the ability to select a range of data in a line/area/time series chart.
Current Behavior
Currently you can select a single point of data.
Possible Solution
I asked how to implement a custom solution in stack overflow and Jony Adamit proposed an idea. I had some difficulty implementing it, and it doesn't work in FireFox, but may be a start.
An implementation would likely involve a cursor that follows the mouse, an overlay that appears when the mouse is held down, and an event that's fired when the mouse is released.
Context
I'm trying to rebuild VizWit, an interactive open data visualization tool, using Chart.js. I have personally tried nearly every JS charting library out there and this feature only seems to be available in giant/monolith libraries like highcharts, amcharts, plotly, and echarts. Plottable offers the functionality, but it's broken and they don't seem too active in GH issues. Chart.js is fantastic in every other way! Unfortunately I've been completely blocked on rebuilding this open source tool because of this missing feature :/
Environment
The text was updated successfully, but these errors were encountered: