admin管理员组

文章数量:1314315

I've got some charts where I'm passing date values as the x axis labels. They could start and end on any date range.

If the date range is >2 months then I need the x axis to only show label values on the 1st of each month.

I know I can achieve the spacing with a tickinterval option, but I can't seem to force the labels to start on the 1st of the month or the first Monday, they always start from the first value in the range.

Here's an example of what I have now. The date range is 13th Nov to 3rd Feb:

And this is what I want the x axis to look like (this is photoshopped):

Is there a way to achieve this?

I've got some charts where I'm passing date values as the x axis labels. They could start and end on any date range.

If the date range is >2 months then I need the x axis to only show label values on the 1st of each month.

I know I can achieve the spacing with a tickinterval option, but I can't seem to force the labels to start on the 1st of the month or the first Monday, they always start from the first value in the range.

Here's an example of what I have now. The date range is 13th Nov to 3rd Feb:

And this is what I want the x axis to look like (this is photoshopped):

Is there a way to achieve this?

Share Improve this question edited Feb 5, 2012 at 16:12 hud asked Feb 3, 2012 at 21:45 hudhud 2031 gold badge5 silver badges13 bronze badges 2
  • Step option? Do you mean tickInterval? And what does "If the date range is is" mean? – Mark Commented Feb 4, 2012 at 21:35
  • The angle bracket had hidden some of my text - updated – hud Commented Feb 5, 2012 at 16:13
Add a ment  | 

1 Answer 1

Reset to default 7

Does a bination of tickInterval and dateTimeLabelFormats achieve what you want?

xAxis: {
    type: 'datetime',
    dateTimeLabelFormats: {
                    month: '%d %b',
                },
    tickInterval: 86400000 * 31  // one month
}

Sample (fiddle here):

本文标签: javascriptHighcharts step amp offset x axis labelsStack Overflow