是否有方法将整个页面的x和y坐标转换为图表的点?
我知道你可以把它倒过来。
var manualPt = {pageX:155, pageY: 242} //<--the point I want to display
//on the chart as a datapoint and not a chartX, chartY coordinate.
function onClick(e) {
$('#report').text('x: ' + e.pageX+ ', y: ' + e.pageY).css({
'position': 'absolute',
'left': e.offsetX,
'top': e.offsetY
})
//this would be the reverse.. knowing where the point on the chart is
//and then get pageX and pageY
}
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container'
},
xAxis: {},
tooltip: {
enabled: false
},
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],
events: {
click: onClick
}
}]
});
http://jsfiddle.net/pinktoadette/yd6vrg4o/
我怎样才能做到这一点?另外,pagex和pagey的坐标可能不是现有图表中的数据系列。