如何更新新的绘图线值,而不是在高图中删除和添加新的绘图线值 [英] How to update new plotline values instead of removing and adding new ones in highcharts

查看:83
本文介绍了如何更新新的绘图线值,而不是在高图中删除和添加新的绘图线值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个动态的报价.水平线表示折线图上的当前位置.要移动它,我必须在每次收到新消息时都删除并添加最后一个.我需要为该绘图线设置动画效果,这就是为什么不应删除它并再次创建它的原因.

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();

小提琴: https://jsfiddle.net/aviram26/v8xte4hL/

这篇关于如何更新新的绘图线值,而不是在高图中删除和添加新的绘图线值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆