I am populating a High Charts Stock chart. This chart shows both the data points on the y-axis as well as a zoom in/out view at bottom. The data points display fine.

My problem is with the x-axis: I cannot get the years in the x-axis or the zoom to correspond with the years in the data points, that is, 1831 - 2014; instead, the zoom feature and the x-axis only go up to the 1990s (as opposed to this year.)

I think the problem lies in how the pointinterval is calculated

pointInterval: 24 * 3600 * 1000000 // one day

Here is a fiddle: http://jsfiddle.net/8HLCF/

Thanks for reading.

有帮助吗?

解决方案

Highstock options reference for pointInterval:

pointInterval: Number If no x values are given for the points in a series, pointInterval defines the interval of the x values in milliseconds. For example, if a series contains one value each day, set pointInterval to 24 * 3600 * 1000.

You have defined x values. There is no need to use pointInterval. And additionaly your comment is wrong, you defined 1000 days instead of 1 day.

Default buttons for rangeSelector are not much useful for your data. I defined new range selector for 1y, 5y and All.

And it seems that data format is wrong. I change years to returns primitive value of Date object. See MDN docs for Date

Updated jsfiddle example

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top