Home forums Using CanvasJS Multi-dataPoints on bar Chart Draggable Reply To: Multi-dataPoints on bar Chart Draggable

#22774

There’re two bars in the bar chart, but only one is draggable at a time.

First bar is draggable when “0” is passed in “data[0]” and Second bar is draggable when “1” is passed in “data[1]”.

jQuery(“#barChartContainer > .canvasjs-chart-container”).on({
mousedown: function(e) {
mouseDown = true;
getPosition(e);
searchDataPoint();
},
mousemove: function(e) {
getPosition(e);
if(mouseDown) {
clearTimeout(timerId);
timerId = setTimeout(function(){
if(selected != null) {
chart.data[0].dataPoints[selected].y = yValue;
chart.render();
}
}, 0);
}
else {
searchDataPoint();
if(changeCursor) {
chart.data[0].set(“cursor”, “n-resize”);
} else {
chart.data[0].set(“cursor”, “default”);
}
}
},
mouseup: function(e) {
if(selected != null) {
chart.data[0].dataPoints[selected].y = yValue;
chart.render();
mouseDown = false;
}
}
});