0

I would like to set different properties for my labels on the xAxis (Here is my problem).

I know how to do this for dataLabels : API.

It is similar to this.


But I don't find anything to do the same thing for xAxis.labels.

Does it exist a way to do this ?



Solution :

It changes only y property of xAxis labels.

Here is a jsFiddle.

  chart: {
        renderTo: 'container',
        type: 'column',
        events: {
            load: function () {
                                    var xAxis = this.xAxis[0];
                var serie = this.series[0];

                for (var current_tick in xAxis.ticks) {
                    var tick = xAxis.ticks[current_tick];

                    if(serie.data[current_tick]){
                        if (serie.data[current_tick].y > 0) {
                            tick.label.attr({
                                y: tick.label.y + 18
                            });
                        }
                    }
                }
            }
        }
    }
Community
  • 1
  • 1
kmas
  • 6,401
  • 13
  • 40
  • 62

1 Answers1

1

I am not aware of a way to do that.

What I would probably do in this situation is create to x axes, one for the positive values, and one for the negative.

{{edit - although, it seems the axis offset plugin only works (at least from what I am seeing) if you have opposite: true set for the axis.

SO, you have to offset the labels on one of them. example:

http://jsfiddle.net/jlbriggs/S48eX/

jlbriggs
  • 17,612
  • 4
  • 35
  • 56