在Highstocks中用于导航器的Hide系列打破了导航器 [英] Hide series used for navigator in highstocks breaks navigator

查看:105
本文介绍了在Highstocks中用于导航器的Hide系列打破了导航器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我将用于导航器的系列隐藏在高库存中,并动态添加数据,则导航器将停止渲染,并且图表不会滑动到新的点.

If I hide the series used for the navigator in highstocks and add data dynamically the navigator stops rendering and the chart does not slide to the new points.

series.hide();

看看 http://jsfiddle.net/QP2CL/.我添加两个系列,然后在10秒后隐藏第一个.然后导航器不会更新.

Take a look at http://jsfiddle.net/QP2CL/. I add two series and then hide the first after 10 sec. Then the navigator does not update.

我尝试控制导航器并以代码向其添加数据,但是随后该系列不会滑动以自动显示新添加的点. http://jsfiddle.net/zEgEF/1/

I tried taking control of the navigator and add data to it in code, but then the series do not slide to show newly added points automatically. http://jsfiddle.net/zEgEF/1/

关于隐藏源序列+自动滑动以显示动态添加的点时如何始终显示导航器的任何想法?

Any ideas on how to always show the navigator if the source series is hidden + automatically sliding to show dynamically added points?

推荐答案

默认情况下,Navigator包含第一个系列.虽然为隐藏系列添加点不会触发重新计算(以获得更好的性能),但导航器也不会更新.

By default, Navigator contains first series. And while adding points for hidden series doesn't fire recalculations (to get better performance), also Navigator won't be updated.

但是,您的第二个解决方案几乎可以正常工作,您需要添加的只是设置新的极端值,请参见: http://jsfiddle.net/zEgEF/2/

However, your second solution is almost working, all you need to add is setting new extremes, see: http://jsfiddle.net/zEgEF/2/

代码:

                // set up the updating of the chart each second
                var chart = this;
                var axis = chart.xAxis[0];
                var ex = axis.getExtremes();
                var series1 = this.series[0];
                var navigator = this.series[1];
                setInterval(function() {
                    var x = (new Date()).getTime(), // current time
                    y1 = Math.round(Math.random() * 100);
                    y2 = Math.round(Math.random() * 100);
                    series1.addPoint([x, y1], false, false);
                    navigator.addPoint([x, y2], false, false);
                    axis.setExtremes(x - (ex.max- ex.min),x,false); <-- set new extremes
                    chart.redraw();
                }, 1000);

这篇关于在Highstocks中用于导航器的Hide系列打破了导航器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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