[英]Verify if Pie in Highcharts Pie charts is selected or deselected
I have to show a popup whenever a pie is selected and do nothing when it is deselected. 我無法弄清楚點擊事件如何確定派是被用戶選擇還是被刪除。 我試圖在那里做Palin JS Logic,但它有點小錯誤。 Highcharts 提供的任何解決方案?
chart: {
type: 'pie',
marginLeft: 0,
options3d: {
enabled: false,
alpha: 45,
beta: 0
}
},
tooltip: {
formatter: function(){
}
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
depth: 35,
dataLabels: {
enabled: true,
formatter: function(){
}
},
showInLegend: true,
point: {
events: {
click: function(){
var selectedPieSliceIndex;
if(!this.selected) {
selectedPieSliceIndex = this.x;
}
else {
selectedPieSliceIndex = null;
}
chartComponent.trigger("onPieSliceClick", selectedPieSliceIndex);
var that = this;
if (this.pieSelected && clickedSliced.length > 0){
that.pieSelected = false;
clickedSliced = [];
} else {
that.pieSelected = true;
clickedSliced.push(that.name)
}
if(this.pieSelected && clickedSliced.length){
uiDialogue.loadDialog('Chart Initiatives', jsonData);
}
}
}
}
}
},
series: [
{
type: 'pie',
innerSize: 100 ,
depth: 45 ,
name: '',
data: pieChartSeries
}
],
title: {
text: "",
verticalAlign: 'middle',
x: -3,
y: -4,
floating: true,
},
exporting: {
chartOptions: {
plotOptions: {
pie: {
dataLabels: {
}
}
}
}
}
}
}
Highchart 有任何建議或任何內置解決方案嗎?
你試過做這樣的事情嗎?
演示: https://jsfiddle.net/BlackLabel/3qxL5r7f/
point: {
events: {
click: function() {
if (!this.selected) {
console.log('show popup')
} else {
console.log('hide popup')
}
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.