Highcharts Demo
author(s):
Torstein Hønsi
HTML
<script src="http://code.highcharts.com/highcharts.js"></script>
<div id="container" style="height: 400px; width: 500px"></div>
<div>Click points on line. Ctrl+Click to select multiple points. All currently selected points should be shown below. But... the getSelectedPoints() function is always "1 behind", showing the points selected after the previous click.</div>
<div id="report"></div>
JavaScript
$(function () {
// get the jQuery wrapper
var $report= $('#report');
// create the chart
$('#container').highcharts({
chart: {
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
plotOptions: {
series: {
allowPointSelect: true,
point: {
events: {
select: function() {
setTimeout(function(){
var chart = $('#container').highcharts();
// when is the chart object updated? after this function finshes?
var selectedPoints = chart.getSelectedPoints();
var selectedPointsStr = "";
$.each(selectedPoints, function(i, value) {
selectedPointsStr += "<br>"+value.category;
});
$report.html(selectedPointsStr);
}, 100);
}
}
}
}
},
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]
}]
});
});