[英]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.