score:0

categories functionality works only for constant tick interval equaled to 1. what you're trying to achieve is having a different space reserved for every category. that means that tick interval has to be irregular.

unfortunately highcharts doesn't provide a property to do that automatically - some coding and restructuring the data is required:

  1. all the points have specified x position (integer value)
  2. xaxis.grouping is disabled and xaxis.pointrangeis 1
  3. following code is used to define and position the labels:

    events: {
      render: function() {
        var xaxis = this.xaxis[0];
    
        for (var i = 0; i < xaxis.tickpositions.length; i++) {
          var tickposition = xaxis.tickpositions[i],
            tick = xaxis.ticks[tickposition],
            nexttickposition,
            nexttick;
    
          if (!tick.islast) {
            nexttickposition = xaxis.tickpositions[i + 1];
            nexttick = xaxis.ticks[nexttickposition];
    
            tick.label.attr({
              y: (new number(tick.mark.d.split(' ')[2]) + new number(nexttick.mark.d.split(' ')[2])) / 2 + 3
            });
          }
        }
      }
    }
    (...)
    xaxis: {
      tickpositions: [-0.5, 6.5, 7.5],
      showlastlabel: false,
      labels: {
        formatter: function() {
          switch (this.pos) {
            case -0.5:
              return 'bananas';
            case 6.5:
              return 'apples';
          }
        }
      }
    }
    

live demo: http://jsfiddle.net/blacklabel/2lcs5up5/


Related Query

More Query from same tag