Replies: 1 comment 4 replies
-
@liewshin the example has got to provide a prototype how to manage draggable annotations. Our goal was only that and not include it in the plugin.
@liewshin when you have a relative Y coordinate of the canvas, you should use APIs (methods/functions) of the Chartjs
|
Beta Was this translation helpful? Give feedback.
-
I am following the example on this page to create a horizontal threshold line, where the selected line can be dragged up or down onmousedown, and then the final position of the line will be the position where onmouseup is called. The current example provided only supports dragging of annotations when the mouse is directly on the annotation, so if I move my mouse too quickly and it moves out of the annotation, it stops being draggable. What would be the best way to fix this? I have tried running the handleElementDragging function on 'mouseout', but it causes the threshold line to reset to the default value when the mouse moves out of the chart, which is not what i want.
Secondly, I am having trouble retrieving the y-value of where I drop the horizontal line. The example provided showcases how the dragging can be handled using MouseEvent.y, which is the value of the mouse at the viewport rather than in relation to the graph itself. Are there any methods to directly retrieve the y-value of the graph? I saw an example here, but a slider would not work for our use case.
Below is an example graph for my use case. Currently I am working with react-chartjs-2 to use this library. In the future I do plan to implement multiple horizontal line annotations in a single chart as well.
Beta Was this translation helpful? Give feedback.
All reactions