How does HighCharts Series.update() handle a new tooltip positioner?

I want to update the way the tooltip is positioned for a series. I have an update(), as shown in the code below. The console.log() statements are being executed for the pointFormatter but not in the positioner. It's as if the positioner is being completely ignored. Why is that? Is it not possible to update the tooltip positioner? Is possible some other way?

for (var j = 0; j < series.length; j++) {
        bubbleChart.addSeries({data: series[j].data, marker:lineWidth: 0}});
            bubbleChart.series[j].update({
                tooltip: {
                    useHTML: true,
                    borderWidth: 0,
                    backgroundColor: "rgba(37,37,37,0.95)",
                    style: {
                        padding: 10
                    },
                    headerFormat: "",
                    pointFormatter: function () {
                        console.log("RARAR");
                        bubbleRadius = this.shapeArgs.r;
                        return self.getToolTip(parseInt(this.hrr_num));
                    },
                    positioner: function (boxWidth, boxHeight, point) {
                        console.log(boxWidth);
                        console.log(boxHeight);
                        console.log(point);
                        return {x: point.plotX + bubbleRadius + 45, y: point.plotY + bubbleRadius + 20};
                    },
                    followPointer: false,
                    shadow: false,
                    shape: "square",
                    hideDelay: 0
                }
            });
    }

Answers


Refer to this jsfiddle, I have implemented two ways to update tooltip positioner.

First one is like what you did which is using HighCharts.Series.update() and as expected console.log('1a'); in my jsFiddle does not get called.

Hence I added another piece of code to update the tooltip.options by calling chart.tooltip.options.positioner and it works.

I noticed that you are accessing bubbleRadius variable in the positioner function so you might need to change your code a bit in order to implement my second suggested solution.


There's no option positioner under series - so updating it won't change anything. There's also no tooltip.update() method, so in general you can not update tooltip in run time.

However, for callbacks (like formatters, positioner or tickPositioner) there is a simple trick to make it work, please check: http://jsfiddle.net/dbqktrhk/2/ In short:

  1. get default positioner:

    var myPositioner = Highcharts.Tooltip.prototype.getPosition;
    
  2. use default positioner using your variable:

    tooltip: {
      xDateFormat: '%Y-%m-%d',
      shared: true,
      positioner: function (labelWidth, labelHeight, point) {
        return myPositioner.call(this, labelWidth, labelHeight, point);
      }
    },
    
  3. In any moment, update your variable:

    myPositioner = function(labelWidth, labelHeight, point) {
      console.log('1a');
      return {
        x: 80,
        y: 50
      };
    };
    

Need Your Help

Override abstract method with different parameters?

java junit

I'd like to define an abstract method, in order to use this method already in my abstract class.

Transfert project from Codeplex/TFS to SourceForge/Git with Visual Studio 2015 / TFS 2015

git tfs codeplex sourceforge myprettycms

I need to transfert the open source cms MyPrettyCMS source code from Codeplex to Source forge.