问题
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