【问题标题】:toggle pie chart data using external button使用外部按钮切换饼图数据
【发布时间】:2014-05-13 20:08:51
【问题描述】:

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

// 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/

【问题讨论】:

    标签: jquery highcharts


    【解决方案1】:

    首先,您要隐藏点/切片,而不是系列。然后尝试使用.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');
        }
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-20
      • 2015-04-16
      • 2016-06-22
      • 2013-12-12
      • 1970-01-01
      相关资源
      最近更新 更多