I would like to drag a plotLine
on xAxis and detect this change.
Can someone please provide an example ?
Edit
@DiMono
Here is what I have tried so far. The click event is not firing. By this approach I would like to add, dragstart, dragend etc events to enable drag functionality.
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript" src="http://code.highcharts.com/highcharts.js"></script>
</head>
<body>
<div id="container" style ="height : 400px">
</div>
</body>
<script type="text/javascript">
(function(H){
H.Chart.prototype.callbacks.push(function(chart){
H.addEvent(chart.xAxis[0].plotLinesAndBands[0].svgElem,'click',function(e){
console.log('click from plugin');
});
});
}(Highcharts));
$(document).ready(function(){
var chart = new Highcharts.Chart({
chart : {
renderTo: 'container'
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
plotLines: [{
color: '#FF0000',
width: 2,
value: 5.5
}]
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
});
});
</script>
</html>
svgElem
can be treated as anElement
, so if you use theon()
method to apply your event handler (refer to the documentation here), it should work.Something like:
You can prepare it in JavaScript with the Highcharts translate function.
See working example: http://jsfiddle.net/VXTeR/1/
Highcharts callback