0
votes

Is there a way to have a point specific positionning of the xAxis labels ?

I am using a waterfall chart and for some bars I would like the label to appear directly under the bar like below :

enter image description here

I have found the following code in the xAxis plotOptions but at this point I don't see how I can acces the info on the bottom of the chart.

xAxis: {
    labels: {
        y:-100 //label's y position 
    }
},
1

1 Answers

0
votes

You can use point dataLabels to achieve such result:

dataLabels: {
    crop: false,
    overflow: 'none',
    verticalAlign: 'bottom',
    format: 'label1',
    y: 20
}

Live demo: https://jsfiddle.net/BlackLabel/71jtp5mf/

API Reference: https://api.highcharts.com/highcharts/series.waterfall.dataLabels

Another way is to create your own custom function to position the xAxis labels, for example:

events: {
  load: function() {
    var chart = this,
      point;

    Highcharts.objectEach(chart.xAxis[0].ticks, function(tick) {
      if (!tick.isNewLabel) {
        point = chart.series[0].points[tick.pos];
        tick.label.attr({
          y: point.plotY + chart.plotTop + point.shapeArgs.height + 15
        })
      }
    });
  }
}

Live demo: https://jsfiddle.net/BlackLabel/oaj9bgt4/