[英]Hide/Show multiple series in HighCharts
我正在使用HighCharts。 我有餅圖中呈現的數據。 單擊圖例標簽時,可以隱藏/顯示不同的餅圖。 嗚!
我想做的是在此視圖中隱藏/顯示不同的列以達到相同的效果。 (單擊“狗/鳥”應刪除該列-與餅圖相同)。
我的系列是:
series: [{
type: "pie", //Change to "column"
data:[{
name: "dog",
age: 52,
y: 52
},
{
name: "bird",
age: 12,
y: 12
}]
}]
如何更改我的結構,使其對兩者都適用?
為了使它在柱形圖中相同,您必須使用兩個系列,而不是一個:
series: [{
type: "column",
name: "dog",
data: [{
age: 52,
x: 0,
y: 52
}]
}, {
type: "column",
name: "bird",
data: [{
age: 12,
x: 1,
y: 12
}]
}]
另外,您還必須為xAxis定義categories
:
xAxis: {
type: 'category',
tickWidth: 0,
lineColor: "#C0D0E0",
lineWidth: 1,
categories: ['dog', 'bird']
}
為了使各列等距,您需要將plotOptions.column.grouping
設置為false:
plotOptions: {
colorByPoint: true,
column: {
grouping: false
}
}
這是DEMO 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.