highcharts / highcharts

Highcharts JS, the JavaScript charting framework
https://www.highcharts.com
Other
12.04k stars 3.63k forks source link

setExtremes no zoom on navigator OR navigator.extremes.unionOfAllSeries=false option? #2039

Closed nhitchins closed 6 years ago

nhitchins commented 11 years ago

It would be great to be able to pass a flag to setExtremes to prevent the navigator chart from also updating its extremes, or have a configuration option to NOT use a union of all series when calculating extremes for the navigator.

The problem: On initial load I need to load 2 series: a series for the navigator chart which starts at time B and finishes at time Y. The main series/chart then has a very similar dataset but starts at time A and finishes on Z (ie. extra datapoint either side). I then need to be able to zoom that main chart on load so that the X axis starts at time B and finishes at Y. but i do NOT want the navigator chart to have its extremes reset based on this.

The reason: We need the series to continue to the edges of the visible area of the chart (incase there are no datapoints on the extremes). rather than interpolating and generating datapoints for the extemes we include a value either side of the extremes (start/end of viewable area). We are also using the adaptToUpdatedData=false option for the navigator so that when we zoom-in on the main chart to load higher resolution data the navigator updates its selection of the data to indicate the new zoomed in period (without the navigator reloading new data).

A good example of the required functionality is the highstock 1.7million datapoint async loading example, but displayed as a line chart with data at irregular intervals (and not grouped) and without gaps in the line at the edges of the chart due to no datapoints falling on the start/end extremes. We do nott want to include interpolated values as a user moving the mouse over these datapoints may think it was an "actual" event (vs. interpolated). The best solution seems to be to include an extra datapoint either side of the x-axis extremes (after a zoom event) in the returned data, then call setExtremes on the main chart x-axis (with the actual extremes from the zoom) so that the extra points are now out of view but allow the line chart to be drawn to the edges of the chart.

The temporary workaround: on initial load i set the series and navigator without rendering the chart, then call setExtremes so that the main chart is zoomed to the correct start/end times (although the extra points are still included in the series for a non-broken line at edges). This however causes the navigator chart to have it's extremes reset (and no longer takes up 100% of the width), so a temp workaround was to comment out a couple lines in the Scroller.Prototype.Render function (~ line#17677) that does the check to see if there is a new min/max and calls the setExtremes.

I can see that it might be complicated to add the flag directly to the setExtremes method as the extremes are only re-drawn based on the isDirtyExtremes flag during a render, but maybe there is another way to achieve the same result or an option can be added to navigator to always use the extremes of it's assigned series and not taking into account the baseSeries?. ie. option > navigator.extremes.unionOfAllSeries: false

TorsteinHonsi commented 11 years ago

Did you try http://api.highcharts.com/highstock#navigator.adaptToUpdatedData ?

nhitchins commented 11 years ago

I've currently got the "adaptToUpdatedData" set to false as we want the navigator chart to retain the initially loaded data (and we're loading new data into the main chart async on zoom). Looking into another solution though rather than trying to return points outside of the zoom period and trying to stop the navigator from including them in its selection we might just return some interpolated values for the extremes (so we get our line to be continuous across the chart even if there are only a few datapoints) and display a different "quality" value in the tooltip for these datapoints. Although there is still some benefits to being able to include the extra datapoints just out of view area, its just going to be complicated to keep the correct selection area in the navigator chart in sync.

oysteinmoseng commented 6 years ago

Closing this, as it should be doable with adaptToUpdatedData, and also stock charts now draw to the edge of the plot area by default.