【问题标题】:Why is the tooltip for my sigma js graph out of position?为什么我的 sigma js 图表的工具提示不在位置?
【发布时间】:2017-01-18 23:10:23
【问题描述】:

我正在为我的图表使用带有一些链接插件的 sigmajs。我实现了一个工具提示及其工作,但该位置似乎不合适。我将工具提示的位置设置为“左”,但它仍然没有改变。我也尝试过所有其他位置。

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

【问题讨论】:

    标签: javascript graph sigma.js linkurious


    【解决方案1】:

    就我而言,问题在于插件认为我的 div 容器的位置是静态的。因此,由于某种原因(在 Chrome 58.0.x 中),它没有计算正确的相对值。

    我在 sigma.plugins.tooltips.js 中做了一个快速破解(我必须找到非最小版本,这样它才可读)来修复它:

      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';
      }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-28
      • 2018-10-21
      • 1970-01-01
      相关资源
      最近更新 更多