首页 文章

使用外部按钮切换饼图数据

提问于
浏览
1

我正试图在高潮饼图上切换数据,但我只能找到如何显示/隐藏整个系列 . 基本上我想使用我自己的按钮复制图例行为 .

// the button action
var chart = $('#container').highcharts(),
    $button = $('#button');
$button.click(function() {
    var series = chart.series[0];
    if (series.visible) {
        series.hide();
        $button.html('Show series');
    } else {
        series.show();
        $button.html('Hide series');
    }
});

http://jsfiddle.net/waspinator/JLrc2/2/

1 回答

  • 3

    首先,您要隐藏点/切片,而不是系列 . 然后尝试使用 .setVisible(true/false) ,请参阅:http://jsfiddle.net/JLrc2/3/

    // the button action
    var chart = $('#container').highcharts(),
        $button = $('#button');
    $button.click(function() {
        var ff = chart.series[0].data[0];
        if (ff.visible) {
            ff.setVisible(false);
            $button.html('Show firefox');
        } else {
            ff.setVisible(true);
            $button.html('Hide firefox');
        }
    });
    

相关问题