在Highcharts自定义导出按钮上切换显示/隐藏

时间:2015-05-08 15:22:12

标签: javascript c# jquery highcharts

我有自定义导出按钮。截至目前,它是一个下拉列表,显示两个选项显示和隐藏。而不是显示menuItems显示和隐藏,如何在符号点击上切换显示/隐藏?

customButton: {

                        align: 'right',                           
                        menuItems: [
                            {
                                text: 'Show',
                                onclick: function() {
                                    for (i = 0; i < chart.series.length; i++) {
                                        chart.series[i].hide();
                                    }

                                }
                            },
                            {
                                text: 'Show',
                                onclick: function() {
                                    for (i = 0; i < chart.series.length; i++) {
                                        chart.series[i].show();
                                    }                                      
                                }
                            }
                        ],                           
                        symbol: 'circle',
                        seperator: true
                    }

1 个答案:

答案 0 :(得分:2)

用此

替换您的function foreach(array, callback) { for (var i = 0; i < array.length; i++) { array[i] = callback(array[i]); // ^ assign the new value (from the callback function) }; } var myArray = [1,2,3] foreach( myArray, function (element){ return element * 2 } ); // ^ return the new value document.querySelector('#result').textContent = myArray;
<pre id="result"></pre>