传奇正在消失在HighCharts馅饼上

时间:2012-03-23 16:02:58

标签: javascript jquery charts highcharts

这是我的代码:

                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]
                    ]);
            });
        });

应该刷新饼图中的点击数据。它发生了,但传说正在消失。我做错了什么?我怎样才能将传说留在同一个地方?

提前完成。

1 个答案:

答案 0 :(得分:2)

我有同样的问题,虽然这不是一个很好的修复,但我添加了false作为setData的第二个参数(这使得它不会自动重绘图表),然后手动重绘图表。所以在你的情况下:

chart.series[0].setData( [
    ['item1',   75],
    ['item2',       15],
    ['item3',    10]
], false);

chart.redraw();

为我修好了。