2013-02-05 43 views
1

我在工具提示中有一个url链接,但是,如果工具提示超出了图表区域,并且您尝试点击url,工具提示消失。URL链接在Tooltip

任何解决此问题的方法?

谢谢!

+1

工具提示的用于显示点的信息。如果你想要这样的东西,我建议你在用户点击这个点时显示它,这样你就可以毫无问题地点击工具提示内容。 –

+0

有完全相同的问题,这解决了它,因为我只在手机上使用highcharts,它没有任何区别,如果我overing或点击:http://stackoverflow.com/questions/24204419/highcharts-show-tooltip- on-point-click-instead-mouseover – luiscvalmeida

回答

2

我在这样的情况下发现,这是最好的手动定位提示:

http://api.highcharts.com/highcharts#tooltip.positioner

这样一来,不需要的隐藏是可控的。

编辑:

如果要扩展工具提示的原型,你可以操纵X和Y

Tooltip.prototype.move = function (x, y, anchorX, anchorY) { 
    var tooltip = this, 
     now = tooltip.now, 
     animate = tooltip.options.animation !== false && !tooltip.isHidden; 

      if(x > ?????) 
      { 
       x = x - 50; // or how ever many pixels you want to move it to 
      } 

    // get intermediate values for animation 
    extend(now, { 
     x: animate ? (2 * now.x + x)/3 : x, 
     y: animate ? (now.y + y)/2 : y, 
     anchorX: animate ? (2 * now.anchorX + anchorX)/3 : anchorX, 
     anchorY: animate ? (now.anchorY + anchorY)/2 : anchorY 
    }); 

    // move to the intermediate value 
    tooltip.label.attr(now); 


    // run on next tick of the mouse tracker 
    if (animate && (mathAbs(x - now.x) > 1 || mathAbs(y - now.y) > 1)) { 

     // never allow two timeouts 
     clearTimeout(this.tooltipTimeout); 

     // set the fixed interval ticking for the smooth tooltip 
     this.tooltipTimeout = setTimeout(function() { 
      // The interval function may still be running during destroy, so check that the chart is really there before calling. 
      if (tooltip) { 
       tooltip.move(x, y, anchorX, anchorY); 
      } 
     }, 32); 

    } 
} 
+0

谢谢!这似乎很接近。有没有办法返回工具提示的位置值?说如果它<=图表区域边缘,然后修复到固定位置,否则正常显示 –

+0

从来没有尝试过,但我相信你可以覆盖定位器的方法。看看Highcharts的来源。 – DeweyOx

+0

嗯,有没有办法找到x,y pos的点? –