Closed HanKienjd closed 1 year ago
Hey @HanKienjd,
you can do something like the following to limit dragging to the x-axis:
let original_y_value;
const config = {
responsive: true,
plugins:{
dragData: {
round: 0,
dragX: true,
showTooltip: true,
onDragStart:function (e, datasetIndex, index, value) {
original_y_value = value.y;
},
onDrag: function (e, datasetIndex, index, value) {
e.target.style.cursor = 'grabbing'
//console.log("Drag Value: ", value.x)
value.y = original_y_value;
},
onDragEnd: function (e, datasetIndex, index, value) {
e.target.style.cursor = 'default'
},
},
},
JSfiddle: https://jsfiddle.net/3yreh5bL/1/
Hope this helps, please re-open if the issue persists
Hi, hava a nice day. I am having a Line Chart. And use your library for drag and drop points. But now points on Axis Y are also dragged. Is there any way I can make them not move
Here this is my config
JSfiddle: https://jsfiddle.net/Hanjd/6c5opab3/1/