[英]Click event in treemap in highcharts
單擊樹狀圖的最后一層時,如何創建 onclick 處理程序?
這是我使用 highcharts ( https://jsfiddle.net/r5e0nLkh/2/ ) 創建樹狀圖的代碼。
$('#container').highcharts({
series: [{
type: "treemap",
allowDrillToNode: true,
alternateStartingDirection: true,
levelIsConstant: false,
levels: [{
level: 1,
layoutAlgorithm: 'suarified',
dataLabels: {
enabled: true,
align: 'left',
verticalAlign: 'top',
style: {
fontSize: '15px',
fontWeight: 'bold'
}
}
}, {
level: 2,
borderWidth: 0,
layoutAlgorithm: 'stripes',
dataLabels: {
enabled: false
},
color: 'blue'
}],
data: data
}],
title: {
text: 'Intent Distribution'
}
});
現在我想在最后一級創建一個點擊事件,例如,如果我點擊說促銷,那么我應該看到子部分,然后如果我點擊任何子部分,我可以附加一個事件偵聽器。 我可以在 highcharts 教程中看到折線圖的點擊事件,但不確定如何用於樹狀圖。
通過添加以下方法解決了問題:
$('#container').highcharts({
plotOptions: {
series: {
events: {
click: function (event) {
if(event.point.node.childrenTotal == 0 ){//since last node will have zero childrens
//Perform Task on leaf or last node
}
}
}
},....}
event.point.node.childrenTotal
將包含單擊的標簽的子項數。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.