Geotob
Geotob

Reputation: 2945

Highstock, split tooltip and opposite xAxis?

I'm displaying the x-axis of my Highstock chart at the top of the chart area with xAxis: { opposite: true}.

However the tooltip continues to show the x-axis value at the bottom of the chart, see for example here http://jsfiddle.net/ckj7kf2y/

Is there any way I can change the positioning of this be at the top, close to the x-axis?

Bonus points if someone knows why the tooltip.positioner callback isn't called when tooltip: { split: true }

Upvotes: 1

Views: 224

Answers (1)

Kacper Madej
Kacper Madej

Reputation: 7896

It's possible to wrap core code to add this feature like in this demo: http://jsfiddle.net/ygmbwxtx/

(function(H){
    H.wrap(H.Tooltip.prototype, 'renderSplit', function (proceed) {
        proceed.apply(this, [].slice.call(arguments, 1));

      var tooltip = this,
        topAxis = tooltip.options.topAxis,
        axisTT = tooltip.tt,
        top = tooltip.chart.plotTop;

      if (topAxis) {
        axisTT.attr({
            y: top - axisTT.height,
          anchorY: top + 10
        });
      }
    });
}(Highcharts))

and in chart's options:

...
    tooltip: {
        split: true,
        topAxis: true
...

Bonus: positioner is not used for split tooltip - split uses own logic for positioning

Upvotes: 1

Related Questions