Highcharts,把点击点变成链接



我正在使用Highcharts (https://www.highcharts.com/)构建一个可点击的地图,因为它是适合我需要的唯一选项。我使用的地图是在这个codepen (https://codepen.io/mushigh/pen/xxRmpWy)上找到的。我只有一个问题我不可能把这些标记变成链接

地图中关键点图像

我稍微改变了一下这些参数,这样它们就会返回一个链接,但是没有任何效果。

tooltip: {
formatter: function () {
return this.point.id + (
this.point.lat ?
'<br>Lat: ' + this.point.lat + ' Lon: ' + this.point.lon : ''
);
}
},
plotOptions: {
series: {
marker: {
fillColor: '#FFFFFF',
lineWidth: 2,
lineColor: Highcharts.getOptions().colors[1],
//'<button onclick="href='www.facebook.com'">Kliko</button>'
}
}
},

您需要使用点的click事件来实现这一点。向该系列添加以下代码:

cursor: 'pointer',
point: {
events: {
click() {
let point = this;
location.href = `https://en.wikipedia.org/wiki/${point.name}`
}
}
}

演示:https://jsfiddle.net/BlackLabel/6bh34w5k/

API参考:https://api.highcharts.com/highmaps/series.mappoint.point.events.click

最新更新