D_Naish D_Naish - 1 year ago 192
Javascript Question

Highstock - change range input beyond the data max

I'm using Highstock on a project and want to allow for dynamically adding more data to the beginning or end of a series by changing the rangeInputs.

The problem is that out of the box, HighStock doesn't seem to validate rangeInput inputs that are beyond the chart's current max/min.

Here's a link to one of their jsfiddles: jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/stock/xaxis/events-setextremes/

In this example, I would want to type "2011-05-11" into the "To" field and fire an event to go get data. However, typing "2011-05-11" doesn't ever fire the "setExtremes" event or do anything.

Any ideas?


Based on the answer I marked as accepted, I created a Highcharts plugin that overwrites the current functionality. https://github.com/d-nation/highstock-beyond-extremes.

Answer Source

Yes, Highstock checks if input date is beyond extremes, and overwrites to min/max value of data. Possible solution is to add two null points and the end and beginning of data, for example:

data: [ [timestamp0, null] , [timestamp1, x] .... [timestampN, xN], [timestampN+1, xN] ]

Live example: http://jsfiddle.net/MCLXV/

Another solution is to edit sources to prevent that.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download