javascript - Highcharts x axis date full range even if there is not enough data - Stack Overflow

I have an highcharts linechart with data. I want to display the data with datetime on the x-axis. This

I have an highcharts linechart with data. I want to display the data with datetime on the x-axis. This works fine, my only problem is that the x-axis always seems to end at the end of my data.

I want to display the whole year in months, even if there are only 3 months available.

Is there a way to "Force" the x-axis to do this?

I have an highcharts linechart with data. I want to display the data with datetime on the x-axis. This works fine, my only problem is that the x-axis always seems to end at the end of my data.

I want to display the whole year in months, even if there are only 3 months available.

Is there a way to "Force" the x-axis to do this?

Share Improve this question asked May 15, 2014 at 7:24 Jelle SmeetsJelle Smeets 1584 silver badges11 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

You don't have to pass any null values - all you have to do is set an axis min and max.

That way, no matter what data you send, the full time span will be displayed.

  • http://api.highcharts./highcharts#xAxis.min
  • http://api.highcharts./highcharts#xAxis.max

for example:

  • http://jsfiddle/jlbriggs/LeXmz/

Highcharts will only show the last data point that is specified. If you want to force it to show the the whole year ,you will have to pass it all the data points for the those times you want displayed, but for the value pass null.

series: [{
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6,
               null, null, null, null, null, null, null, null, null, 
               null, null, null, null, null, null, null, null],
        pointStart: Date.UTC(2010, 0, 1),
        pointInterval: 1 * 3600 * 1000 * 24 // one hour
    }]

Fiddle example

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745105279a4611520.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信