Hide series used for navigator in highstocks breaks navigator

大兔子大兔子 提交于 2019-12-11 10:52:48

问题


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

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.

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?


回答1:


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.

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

Code:

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


来源:https://stackoverflow.com/questions/15971263/hide-series-used-for-navigator-in-highstocks-breaks-navigator

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!