Draggable points
Click and drag points on line charts and a correspoinding PointModified event so backend data can be updated.
This will allow features to be built so users can modify data using the chart itself.
draggable-points is an official module.
API reference: https://api.highcharts.com/highcharts/series.line.dragDrop
-
Anonymous
commented
FIxed it with
chart.fireEvent('resetDragPoint') only -
Anonymous
commented
Very much appreciated, Torstein! Your solution is simple!
I learned from zoomreset and add a button for resetting dragpoint by adding
...
dragPoint = dragX = dragY = undefined;
// Show the Reset zoom button
if (!chart.resetDragPointButton) {
showResetDragPointBtn();
}and two more functions
function showResetDragPointBtn() { } similar to showResetZoom
// Hook to chart.events function to be defined, one for each chart
function resetDragPoint() {
var resetDragPointButton = chart.resetDragPointButton;
//HOOK TO CUSTOMISED CHART EVENT THAT DEFINES FUNCTIONALITIES FOR EACH INDIVIDUAL CHART
Highcharts.fireEvent(chart, 'DragPoint', null, function() {console.log('working');});
if (resetDragPointButton) {
chart.resetDragPointButton = resetDragPointButton.destroy();
}
}The Button is shown. However, when it is clicked
Highcharts.fireEvent(chart, 'dragPoint', null, function() {console.log('working');});
keeps return an error "Highcharts.fireEvent is not a function"
Any suggestion of how to register a dragPoint event and fire it to execute DragPoint: function() from chart.events.
Thank you -
I have updated the plugin so that it doesn't zoom while a point is being dragged. Zooming can still be performed if initiated outside a point.
-
Anonymous
commented
I tried to prevent selectionMarker when mousemove in http://jsfiddle.net/AyUbx/ by
addEvent(container, 'mousemove', function(e) {
...
chart.mousetracker.selectionMarker = false;}
This prevents zooming. However the chart is painted with blue when mouse moves?
Any idea why and how to fix this? Thank you -
Anonymous
commented
Great! Any suggestion to prevent zooming if points are dragged. I tried
chart.container.onmousemove = null in mousedown and
chart.container.onmousemove = original at the end of drop.
But it is not working -
Anonymous
commented
Thanks
-
You can read series.data.
-
Anonymous
commented
How can you retrieve the updated series after its been dragged?
i.e. - if you want to save the updated series (array) in a DB?
-
Anonymous
commented
It seems that if i use double y- axis, then this prototype would have some bugs. such as i could not drag the point to the top border of the chart. could you help me to check it ?
-
Anonymous
commented
Greate !!! thank you
-
I just added an option, draggableX, to the demo.
-
Yakir Manor
commented
for those who are interested in dragging points in x direction, are we talking on dragging an entire series or just one point? or both with ctrl?
-
kasik
commented
Also interesting in dragging points in x direction. How it can be implemented?
-
alessandro
commented
Very cool!!!
It would be nice to move in x direction also! -
Anonymous
commented
Ok, this is actuelly working on iOS: http://jsfiddle.net/7UsbM/7/
-
Anonymous
commented
Has anyone successfully tested this on an iPhone or iPad.
I'm sure its just about the touchhandling... any help yould be apprechiated. -
I'd recommend that you enable selection, (http://www.highcharts.com/ref/#plotOptions-series--allowPointSelect). Then dragging one of the selected points will move all selected points.
-
Yakir Manor
commented
-
Yakir Manor
commented
iv made some changes to the script so you can drag entire series,
http://jsfiddle.net/AyUbx/172/
after you drop a point all the consecutive dots move as well, to move the entire series you can move the first dot.
naturally iv tried to move all the dots with the draggable dot by putting the call to moveConsecutiveDots in the mousemove event and not the mouse drop but i got some weird behavior...
-
Yakir Manor
commented
any possibility that dragging a point will drag the entire following series?
meaning from the example:http://jsfiddle.net/highcharts/AyUbx
if i drag down march in 20 points then march through december will all go down 20 point?