传奇正在HighCharts上消失,令人耳目一新

Legend is disappearing on HighCharts pie refreshing

本文关键字:耳目一新 消失 HighCharts 传奇      更新时间:2023-09-26

这是我的代码:

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

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

提前Thanx。

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

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

这为我修复了它。