我有自定义导出按钮。截至目前,它是一个下拉列表,显示两个选项显示和隐藏。而不是显示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
}
答案 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>