mirelon
mirelon

Reputation: 4996

Highcharts datetime axis labels according to data point groups

Is it possible to have labels on datetime xAxis that correspond to dataGrouping? For example I have dataGrouping such that data are grouped into days / weeks / months / year:

dataGrouping : {
  groupPixelWidth: 250,
  units : [
    ['day', [1]], ['week', [1]], ['month', [1]], ['year', [1]]
  ]
}

http://jsfiddle.net/CHR7F/2/

There is plenty of options in the highcharts api, but no one seems to achieve the same result as dataGrouping.

The most promising was:

xAxis: {
   labels: {
       step: 1
   }
}

but still there are two weeks between ticks while data is grouped by months.

Upvotes: 1

Views: 1983

Answers (2)

mirelon
mirelon

Reputation: 4996

I found a solution with tickPositioner. It is still a workaround, but at least it works.

xAxis: {
  tickPositioner: function(){
    ticks = this.series[0].processedXData;
    ticks.info = this.series[0].currentDataGrouping;
    return ticks;
  }
}

http://jsfiddle.net/CHR7F/3/

Upvotes: 1

Paweł Fus
Paweł Fus

Reputation: 45079

On thesame level as setting units you cna set datetimeLebelFormats, see: http://api.highcharts.com/highstock#plotOptions.area.dataGrouping.dateTimeLabelFormats

Upvotes: 0

Related Questions