-
Notifications
You must be signed in to change notification settings - Fork 56
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
Toggle dragData to true/false #21
Comments
Hi @KrishAWS, |
Hi Christoph, I couldn't make it in Fiddle, but I have placed the source files in my S3. Demo: http://dbrestorefroms3.s3-website.eu-central-1.amazonaws.com/ Its a Angular project, once downloaded, you need to run "npm install". You can find the code inside app.components.ts I combined two plugins here, one for zoom and one for drag(yours). see this link http://dbrestorefroms3.s3-website.eu-central-1.amazonaws.com/graph.gif - I need to mark a specific range and drag a single data point. But I need all the data points within this range to be dragged. This is my prime use case. Feel free to ask me if anything is unclear. Your support would be highly appreciated. |
Alrigth, I'm sorry that I won't dig through the code, but the following should get you what you want: dragData: true,
onDragStart: function (e) {
if (dragDisabled) return false
// other code in the onDragStart function
}, Now you can set-up a button that controls the value of the var dragDisabled = false
var button = document.getElementById("toggleDragButton");
button.onclick = function () {
dragDisabled = dragDisabled ? false : true
button.innerText = dragDisabled ? "Drag: Off" : "Drag: On"
}; and that's it. Best, |
Thanks for this. it helps me to toggle the drag feature on or off by clicking a button. Highly appreciated. However, it doesn't help fix my problem. Because the chartjs-plugin-zoom acts weird (drag selection is not working anymore i when I set dragData to true). I know your plugin is an awesome tool. If you have any idea, please let me know. Thanks for your time. |
Hey again @KrishAWS, sorry for taking me so long. I had another look at it your issue today, mainly focusing on the compatibility of the plugin-zoom and the dragData one. As I was fiddling around, I realised that the toughest part of using these two plugins in combination actually lies in the UI design. For instance, if a user wanted to zoom in on a particular part of the chart, and then drag one of the data points. At first, the user might want to drag the entire chart, so that the data point is in the center, and then pan to zoom. Now, imagine what happens if the user accidentally starts dragging right on the data point. How would you determine what the user intents to do? Dragging the data point? Or dragging the entire field of view? I realised that this has a lot of potential for bad UI design -> leading to frustrated users. So, my current opinion on this is to EITHER allow panning/zooming OR dragging a specific data point. This way, a user clearly knows (or at least has the possibility to find out) which of the features is currently active, and what can be expected when interacting with the chart. To demonstrate this, I updated the previous fiddle, https://jsfiddle.net/ehyz5vj9/3/ which allows toggling between the zooming and dragging features. Anyways, as the fiddles demonstrated how to toggle dragData, and how to combine the two plugins, may I close this issue then? |
Thanks a lot for your timely help. Although the use case is outside the scope of this plugin. this workaround helped me a lot. Appreciation for your effort. |
I know that this ticket is closed, but if found another workaround for this issue, so i wanted to share it :).
In this manner, I disable the panning when I want the user to drag points in my graph. |
Hi Christoph,
I am looking for an option to toggle the dragging feature. I placed a button for toggle dragData property to true or false and updated the chart but it doesn't work.
By default, it considers the value set on page load. I can't change it afterwards.
Could you please provide me with a solution?
The text was updated successfully, but these errors were encountered: