4

我想一次自定义选中和取消选中的图例元素,我不知道,我们可以这样做吗?让我知道如何做到这一点..

4

3 回答 3

17

This is an example that does that, plus a variety of other things with legend items and checkboxes, using a series of external controls:

http://jsfiddle.net/simo/57SR9/94/

function:

$('#checkAll').click(function(){
    for(i=0; i < chart.series.length; i++) {
        if(chart.series[i].selected == false){
            chart.series[i].select();
            showSeries.call(chart.series[i], {checked: true});
        }
    }
});
于 2013-05-03T14:08:06.557 回答
1

您可以遍历图表中的每个系列并调用show()hide()函数,具体取决于您想要做什么。此解决方案与之前的答案类似,但使用show/hide函数调用

i = 0;

while (i < chart.series.length) {
    if (chart.series[i].visible === false) { // here you can filter the visible series
        chart.series[i].select();
        chart.series[i].show(); // here you can call hide()
        i++;
        return;
    }
}
于 2018-08-29T20:22:18.900 回答
-1

You can use something like this:

 var legendLeft = $j('<div>')
               .css({
                   width: 160,
                   maxHeight: 210,
                   padding: 10,
                   position: 'absolute',
                   overflow: 'auto',
                   right: 500,
                   top: 380,
                   borderRadius: options.borderRadius
               })
               .appendTo(chart.container);

           var legendRight = $j('<div>') .css({
                width: 260,
                maxHeight: 210,
                padding: 10,
                position: 'absolute',
                overflow: 'auto',
                right: 165,
                top: 383,
                borderRadius: options.borderRadius
           }).appendTo(chart.container);

Check this: http://highslide.com/forum/viewtopic.php?f=9&t=15782

Example 1: http://jsfiddle.net/Fusher/ArmRM/14587/

Example 2: http://jsfiddle.net/hfrntt/EQGWV/

于 2013-05-03T14:07:16.573 回答