我在我的 Backbone 应用程序中使用 Highcharts 在柱形图中显示一些信息。
我使用图表中的数据标签允许用户点击并移动到该数据点的详细信息页面。这不是正常的 window.location 调用,而应该是 window.location.hash 调用。这是因为我想移动到一个 anchor ,它将被我的主干路由器拾取。
这是一个典型的标签(使用格式化程序)被转换成的样子:
<tspan onclick="location.href="/#/test/1"" style="cursor: pointer; " x="360">Sectie nummer 6</tspan>
换句话说,是否可以让 Highcharts 执行 onclick="window.location.hash=..."而不是 location.href?
提前致谢!
最佳答案
替代解决方案(不是最跨浏览器的解决方案,因为它依赖于 <text>
,但您可以使用不兼容的 IE 版本)
$(".highcharts-data-labels").on("click", "text", function() {
window.location.hash = "anchor";
});
关于javascript - highcharts 可点击标签如何转到 anchor ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12307443/