如何更新新的绘图线值,而不是在高图中删除和添加新的绘图线值
问题描述:
我有一个动态的报价.水平线表示折线图上的当前位置.要移动它,我必须在每次收到新消息时都删除并添加最后一个.我需要为该绘图线设置动画效果,这就是为什么不应删除它并再次创建它的原因.
I have a dynamic value for a quote. Horizontal line indicates the current position on a line chart. To move it i have to remove and add last one each time i receive new. I need to animate transition of this plotline, that's why it should not be removed and created again.
这就是现在的样子:
chart.yAxis[0].removePlotLine('current-price');
chart.yAxis[0].addPlotLine({
value: parsedData.quote,
color: 'black',
width: 0.5,
id: 'current-price',
useHTML:true
},
zIndex:100
});
答
您可以直接更新选项,然后更新轴:
you can update the options directly and then update the axis:
var newValue = (chart.xAxis[0].options.plotLines[0].value + 1) % 10;
chart.xAxis[0].options.plotLines[0].value = newValue;
chart.xAxis[0].update();