这是我的代码:
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
borderWidth: 3,
size: '90%',
dataLabels: {
enabled: false
},
showInLegend: true
}
},
series: [{
type: 'pie',
name: 'Browser share',
data: [
['item1', 35],
['item2', 35],
['item3', 30]
]
}]
});
$('.poll1 a').click(function() {
$('.poll1 a').removeClass('active');
$(this).addClass('active');
chart.series[0].setData( [
['item1', 75],
['item2', 15],
['item3', 10]
]);
});
});
应该刷新饼图中的点击数据。它发生了,但传说正在消失。我做错了什么?我怎样才能将传说留在同一个地方?
提前完成。
答案 0 :(得分:2)
我有同样的问题,虽然这不是一个很好的修复,但我添加了false作为setData的第二个参数(这使得它不会自动重绘图表),然后手动重绘图表。所以在你的情况下:
chart.series[0].setData( [
['item1', 75],
['item2', 15],
['item3', 10]
], false);
chart.redraw();
为我修好了。