Why is the tooltip for my sigma js graph out of position?

723 Views Asked by At

I am using sigmajs with some linkurious plugin for my graph. I implemented a tooltip and its working but the position seems off place. I have the position set to "left" for the tooltip but it still doesn't change. I've tried all other positions as well.

 node: [{
            show: 'clickNode',
            hide: 'clickStage',
            //cssClass: 'sigma-tooltip',
            position: 'left',
            ...

enter image description here

1

There are 1 best solutions below

0
On

In my case, the problem was that the plugin thought the position of my div container was static. So, it wasn't computing the right relative value for some reason (in Chrome 58.0.x).

I did a quick hack in the sigma.plugins.tooltips.js (I had to find the non-min version so that's it's readable) to fix it like so:

  if (options.position !== 'css') { //IF @ Line 220
    if(containerPosition === 'static') {
      _tooltip.style.position = 'absolute';
    }

    //Hack to force re-compute tooltip position
    var containerRect = renderer.container.getBoundingClientRect();
    x = ~~(x - containerRect.left);
    y = ~~(y - containerRect.top);
    //Hack end

    // Default position is mouse position:
    _tooltip.style.left = x + 'px';
    _tooltip.style.top = y + 'px';
  }