我想知道是否有办法在图表定义中添加if条件。我正在图表中创建MACD,而这部分肯定是需要的。
yAxis : [{
ordinal: false,
height:280,
}, {
title: {
text: 'MACD'
},
top: 360,
height: 87,
offset: 0,
lineWidth: 1
}]
现在我有一个要求,如果窗口加载,那么不显示macd标记行。当删除,macd指标被删除时应该显示。所以,有没有办法添加条件如
yAxis : [{
ordinal: false,
height:280,
}, {
if(document.getElementById('button').clicked == true)
{
title: {
text: 'MACD'
},
top: 360,
height: 87,
offset: 0,
lineWidth: 1
}
}]
答案 0 :(得分:0)
我认为你需要这样的东西:
yAxis: [{
ordinal: false,
height: 280,
}, (document.getElementById('button').clicked ? {
title: {
text: 'MACD'
},
top: 360,
height: 87,
offset: 0,
lineWidth: 1
} : {})]