Javascript 获取位置标记线图和高度图
在下面的示例中,是否有可能使用Highcharts获得标记圆的准确位置Javascript 获取位置标记线图和高度图,javascript,highcharts,Javascript,Highcharts,在下面的示例中,是否有可能使用Highcharts获得标记圆的准确位置 Highcharts.chart('container', { chart: { type: 'area', zoomType: 'x', panning: true, panKey: 'shift', scrollablePlotArea: { minWidth: 600 } }, title: { text: '2017 Tour de Fran
Highcharts.chart('container', {
chart: {
type: 'area',
zoomType: 'x',
panning: true,
panKey: 'shift',
scrollablePlotArea: {
minWidth: 600
}
},
title: {
text: '2017 Tour de France Stage 8: Dole - Station des Rousses'
},
subtitle: {
text: 'An annotated chart in Highcharts'
},
annotations: [{
labelOptions: {
backgroundColor: 'rgba(255,255,255,0.5)',
verticalAlign: 'top',
y: 15
},
labels: [{
point: {
xAxis: 0,
yAxis: 0,
x: 27.98,
y: 255
},
text: 'Arbois'
}, {
point: {
xAxis: 0,
yAxis: 0,
x: 45.5,
y: 611
},
text: 'Montrond'
}, {
point: {
xAxis: 0,
yAxis: 0,
x: 63,
y: 651
},
text: 'Mont-sur-Monnet'
}, {
point: {
xAxis: 0,
yAxis: 0,
x: 84,
y: 789
},
x: -10,
text: 'Bonlieu'
}, {
point: {
xAxis: 0,
yAxis: 0,
x: 129.5,
y: 382
},
text: 'Chassal'
}, {
point: {
xAxis: 0,
yAxis: 0,
x: 159,
y: 443
},
text: 'Saint-Claude'
}]
}, {
labels: [{
point: {
xAxis: 0,
yAxis: 0,
x: 101.44,
y: 1026
},
x: -30,
text: 'Col de la Joux'
}, {
point: {
xAxis: 0,
yAxis: 0,
x: 138.5,
y: 748
},
text: 'Côte de Viry'
}, {
point: {
xAxis: 0,
yAxis: 0,
x: 176.4,
y: 1202
},
text: 'Montée de la Combe<br>de Laisia Les Molunes'
}]
}, {
labelOptions: {
shape: 'connector',
align: 'right',
justify: false,
crop: true,
style: {
fontSize: '0.8em',
textOutline: '1px white'
}
},
labels: [{
point: {
xAxis: 0,
yAxis: 0,
x: 96.2,
y: 783
},
text: '6.1 km climb<br>4.6% on avg.'
}, {
point: {
xAxis: 0,
yAxis: 0,
x: 134.5,
y: 540
},
text: '7.6 km climb<br>5.2% on avg.'
}, {
point: {
xAxis: 0,
yAxis: 0,
x: 172.2,
y: 925
},
text: '11.7 km climb<br>6.4% on avg.'
}]
}],
xAxis: {
labels: {
format: '{value} km'
},
minRange: 5,
title: {
text: 'Distance'
}
},
yAxis: {
startOnTick: true,
endOnTick: false,
maxPadding: 0.35,
title: {
text: null
},
labels: {
format: '{value} m'
}
},
tooltip: {
headerFormat: 'Distance: {point.x:.1f} km<br>',
pointFormat: '{point.y} m a. s. l.',
shared: true
},
legend: {
enabled: false
},
series: [{
data: elevationData,
lineColor: Highcharts.getOptions().colors[1],
color: Highcharts.getOptions().colors[2],
fillOpacity: 0.5,
name: 'Elevation',
marker: {
enabled: false
},
threshold: null
}]
Highcharts.chart('container'{
图表:{
类型:'区域',
zoomType:'x',
平移:是的,
平移键:“shift”,
可滚动绘图区:{
最小宽度:600
}
},
标题:{
文字:“2017环法自行车赛第8阶段:多尔-罗斯车站”
},
副标题:{
文本:“Highcharts中的注释图表”
},
注释:[{
标签选项:{
背景颜色:“rgba(255255,0.5)”,
垂直排列:“顶部”,
y:15
},
标签:[{
要点:{
xAxis:0,
雅克斯:0,
x:27.98,
y:255
},
文本:“Arbois”
}, {
要点:{
xAxis:0,
雅克斯:0,
x:45.5,
y:611
},
文字:“蒙特朗”
}, {
要点:{
xAxis:0,
雅克斯:0,
x:63,
y:651
},
文字:“蒙内山”
}, {
要点:{
xAxis:0,
雅克斯:0,
x:84,
y:789
},
x:-10,
文本:“Bonlieu”
}, {
要点:{
xAxis:0,
雅克斯:0,
x:129.5,
y:382
},
文字:“Chassal”
}, {
要点:{
xAxis:0,
雅克斯:0,
x:159,
y:443
},
文字:“圣克劳德”
}]
}, {
标签:[{
要点:{
xAxis:0,
雅克斯:0,
x:101.44,
y:1026
},
x:-30,
文字:“Col de la Joux”
}, {
要点:{
xAxis:0,
雅克斯:0,
x:138.5,
y:748
},
案文:“科特迪瓦”
}, {
要点:{
xAxis:0,
雅克斯:0,
x:176.4,
y:1202
},
文字:“科姆山”
de Laisia Les Molunes'
}]
}, {
标签选项:{
形状:“连接器”,
对齐:“右”,
证明:错,
作物:是的,
风格:{
fontSize:'0.8em',
textOutline:'1px白色'
}
},
标签:[{
要点:{
xAxis:0,
雅克斯:0,
x:96.2,
y:783
},
文字:“平均爬升6.1公里
4.6%。”
}, {
要点:{
xAxis:0,
雅克斯:0,
x:134.5,
y:540
},
文字:“平均爬升7.6公里
5.2%。”
}, {
要点:{
xAxis:0,
雅克斯:0,
x:172.2,
y:925
},
文字:“平均爬升11.7公里
6.4%。”
}]
}],
xAxis:{
标签:{
格式:“{value}km”
},
最小范围:5,
标题:{
文本:“距离”
}
},
亚克斯:{
是的,
恩东蒂克:错,
最大填充:0.35,
标题:{
文本:空
},
标签:{
格式:“{value}m”
}
},
工具提示:{
HeadePerformat:'距离:{point.x:.1f}公里
',
pointFormat:“{point.y}m a.s.l.”,
分享:真的
},
图例:{
已启用:false
},
系列:[{
数据:高程数据,
lineColor:Highcharts.getOptions().Color[1],
颜色:Highcharts.getOptions().colors[2],
填充不透明度:0.5,
名称:'立面',
标记:{
已启用:false
},
阈值:空
}]
}))
我想要的是,当用户点击图表时,得到标记圆的位置
它与annotations插件一起使用,获取该点或圆的坐标,并在那里创建注释
为了说明这一点:
我解决了我的问题
使用数据数组,并使用以下代码
events:{
click: function(e){
var x = e.xAxis[0].value,
y = elevationData[x.toFixed(1)*10][1];
this.addAnnotation({
xValue: x,
yValue: y,
allowDragX: false,
allowDragY: false,
title:{
text: "Hola"
} ,
shape: 'text'
});
//this.redraw();
this.redrawAnnotations();
console.log(this.annotations);
}
}
如果你使用这里的代码:你可以找到鼠标的位置,你需要做的就是添加一个点击事件来捕捉当时的位置。我已经知道了,就像我现在有了它,但我不想把注释放在屏幕上的任何地方,否则,小圆圈的确切位置你可以用这个:太忙了,现在不能正确地做,但是你明白了。