[英]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. 我在一个项目上使用Highstock,并且希望允许通过更改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. 问题在于,开箱即用,HighStock似乎没有验证超出图表当前最大/最小值的rangeInput输入。
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/ 这是他们的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. 在此示例中,我想在“ To”字段中键入“ 2011-05-11”并触发一个事件以获取数据。 However, typing "2011-05-11" doesn't ever fire the "setExtremes" event or do anything.
但是,键入“ 2011-05-11”永远不会触发“ setExtremes”事件或执行任何操作。
Any ideas? 有任何想法吗?
EDIT 编辑
Based on the answer I marked as accepted, I created a Highcharts plugin that overwrites the current functionality. 根据我标记为接受的答案,我创建了一个Highcharts插件来覆盖当前功能。 https://github.com/d-nation/highstock-beyond-extremes .
https://github.com/d-nation/highstock-beyond-extremes 。
Yes, Highstock checks if input date is beyond extremes, and overwrites to min/max value of data. 是的,Highstock检查输入日期是否超出极限,并覆盖数据的最小/最大值。 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/ 实时示例: http : //jsfiddle.net/MCLXV/
Another solution is to edit sources to prevent that. 另一个解决方案是编辑源以防止这种情况。
Setting xAxis.ordinal = false
does the trick. 设置
xAxis.ordinal = false
可以解决问题。 See documentation: http://api.highcharts.com/highstock/xAxis.ordinal 请参阅文档: http : //api.highcharts.com/highstock/xAxis.ordinal
Taken from this answer: Highstock - Set extremes beyond the data range 从以下答案中得出: Highstock-设置超出数据范围的极限
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.