我試圖更新「餡餅」圖表類型的系列數據的選項:如何通過一系列繪製在highcharts選項
我使用導出按鈕顯示選項更改圖表類型,所有其他類型的圖表工作除了需要不同格式的系列數據的餡餅之外。
exporting: {
buttons: {
lineButton: {
text: 'line',
onclick: function() {
for(i=0;i<this.series.length;i++) {
this.series[i].update({
type: "line"
});
}
}
},
barButton: {
text: 'bar',
onclick: function() {
for(i=0;i<this.series.length;i++) {
this.series[i].update({
type: "column"
});
}
}
},
pieButton: {
text: 'pie',
onclick: function() {
var pieSeries = [];
$.each(category_totals, function(j, k) {
pieSeries.push({ name: j , y: k });
});
for(i=0;i<this.series.length;i++) {
this.series[i].remove();
}
this.series = [{
name: title,
colorByPoint: true,
data: pieSeries
}];
this.series[0].update({
type: "pie"
});
}
}
}
...
而且我得到這個錯誤:Uncaught TypeError: this.series[0].update is not a function
一個簡單的問題,爲什麼你就不能定義類型在其中定義系列?即:this.series = [name:title, colorByPoint:true, data:pieSeries, type:'pie' }]'? –
@RahulSharma嘗試過。同樣的錯誤。 – ImpendingDoom
同樣的錯誤?你的代碼中是否還有'this.series [0] .update'語句?如果你按我在第一條評論中提到的那樣做,你就不需要這個陳述。 –