Highcharts Draggable Points
by Torstein Hønsi
HTML
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-more.js"></script>
<script src="https://rawgithub.com/highcharts/draggable-points/master/draggable-points.js?1"></script>
<div id="container" style="height: 400px"></div>
<div id="drag"></div>
<div id="drop"></div>
CSS
body {
font-family: Arial, Verdana, sans-serif;
font-size: 0.8em;
}
JavaScript
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
animation: false
},
title: {
text: 'Highcharts draggable bubbles demo'
},
plotOptions: {
series: {
point: {
events: {
drag: function (e) {
// Returning false stops the drag and drops. Example:
/*
if (e.newY > 300) {
this.y = 300;
return false;
}
*/
$('#drag').html(
'Dragging ' + this.series.name + ' point to <b>[' + Highcharts.numberFormat(e.x, 2) + ', ' + Highcharts.numberFormat(e.y, 2) + ']</b>');
},
drop: function () {
$('#drop').html(
'Dropped ' + this.series.name + ' at <b>[' + Highcharts.numberFormat(this.x, 2) + ', ' + Highcharts.numberFormat(this.y, 2) + ']</b>');
}
}
}
}
},
tooltip: {
yDecimals: 2
},
series: [{
type: 'bubble',
cursor: 'move',
draggableX: true,
draggableY: true,
data: [
[1, 240, 3],
[2, 130, 10],
[4.5, 290, 15]
]
}]
});