英文:
Clickable columns to redirect to another page amcharts stacked bar chart
问题
I am using stacked bar chart in amcharts am5.
想要为每个列条添加网址,并在有人点击列条时重定向到一个网址。
关于如何在列条上添加链接,stackoverflow上有一些帖子,但它们是针对Amcharts4的,不适用于Amcharts5。
我会感激任何建议。
英文:
i am using stacked bar chart in amcharts am5
want to add url's for each column bar and redirecting on a url when someone clicks on a column bar
There are some posts on the stackoverflow on how to add links to columns, but they are for Amcharts4 and don't work on Amcharts5. .
I will appreciate any suggestions
答案1
得分: 0
/* 鼠标指针在列上的更改 /
series.columns.template.events.on("pointerover", function (ev) {
document.body.style.cursor = "pointer";
});
series.columns.template.events.on("pointerout", function (ev) {
document.body.style.cursor = "default";
});
/ 单击列跳转到URL */
series.columns.template.events.on("click", function(ev) {
console.log(ev.target.dataItem.dataContext.url);
window.location.assign(ev.target.dataItem.dataContext.url);
}
英文:
Found a way to do that by adding
/* Mouse pointer change for columns */
series.columns.template.events.on("pointerover", function (ev) {
document.body.style.cursor = "pointer";
});
series.columns.template.events.on("pointerout", function (ev) {
document.body.style.cursor = "default";
});
/* column click to url */
series.columns.template.events.on("click", function(ev) {
console.log(ev.target.dataItem.dataContext.url);
window.location.assign(ev.target.dataItem.dataContext.url); }
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论