Highcharts test tool
HTML
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type='text/javascript'>
var ctrlMode = false; // if true the ctrl key is down
///this works
$(document).keydown(function(e){
if(e.ctrlKey){
ctrlMode = true;
};
});
$(document).keyup(function(e){
ctrlMode = false;
});
</script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<div id="container" style="height: 300px"></div>
JavaScript
/**
* Experimental Draggable points plugin
* Revised 2012-02-08
*
* On Saving this jsbin, remember to update http://jsfiddle.net/highcharts/AyUbx/
*/
(function(Highcharts) {
var addEvent = Highcharts.addEvent,
each = Highcharts.each;
/**
* Filter by dragMin and dragMax
*/
function filterRange(newY, series) {
var options = series.options,
dragMin = options.dragMin,
dragMax = options.dragMax;
if (newY < dragMin) {
newY = dragMin;
} else if (newY > dragMax) {
newY = dragMax;
}
return newY;
}
Highcharts.Chart.prototype.callbacks.push(function (chart) {
var container = chart.container,
dragPoint,
dragY,
dragPlotY,
dragPoint1,
dragPlotY1;
// my code:
var dragPointSeries;
var dragSeries;
chart.redraw(); // kill animation (why was this again?)
addEvent(container, 'mousedown', function(e) {
var hoverPoint = chart.hoverPoint;
if (hoverPoint && hoverPoint.series.options.draggable) {
dragSeries = false;
if (!(ctrlMode)){
dragPoint = hoverPoint;
dragY = e.pageY;
dragPlotY = dragPoint.plotY + (chart.plotHeight - (dragPoint.yBottom || chart.plotHeight));
}else{
dragPoint = hoverPoint;
dragY = e.pageY;
dragPlotY = dragPoint.plotY + (chart.plotHeight - (dragPoint.yBottom || chart.plotHeight));
// my code:
dragSeries = true;
//dragPointSeries = jQuery.extend(true, {}, dragPoint.series.points);// Deep copy
dragPointSeries = new Array(2);
dragPointSeries[0] = new Array(dragPoint.series.points.length); //...