Highcharts tooltip is hidden behind other charts

懵懂的女人 提交于 2020-01-15 03:30:10

问题


When putting multiple charts tooltips from upper charts are hidden behind others.

I found some tips on how to it but nothing helped. Is there anyway to keep tooltips on top of charts?

The example is here: http://jsfiddle.net/Zw3uM/

Thanks a lot!


回答1:


This is pure html : Any div element loaded after ( meaning appearing after on the html page) will always be in front.

In order to get the first chart tooltip be in front of the second : load the second in first and set its y position on the page using an absolute or relative position in css :

I've change their order, putting the container2 in first in html:

<div id="container2" style="height: 200px"></div>
<div id="container1" style="height: 200px"></div>

Then set the position of container2 to be under the first one (thanks to the top style attribute) :

div[id="container2"] {
    position:absolute;
    top:200px;
}

Here is the result : http://jsfiddle.net/Zw3uM/3/




回答2:


You can use tooltip pisitioner:

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




回答3:


The problem is due to each highchart container having its own stacking context. This is because the highcharts-container has both position: relative and z-index: 0 (css dynamically applied by the highcharts library).

So the z-index of the tooltip has meaning only in its parent highchart container.

To fix this we need to override the (z-index: 0) rule for the highcharts-container using the following:

.highcharts-container 
{ 
    z-index: auto !important;
    ...
}

This way all hightcharts-containers & their children would share the same stacking context and their z-indices would apply the desired effect.

You can check the fix here: http://jsfiddle.net/w5bLo1cw/4/



来源:https://stackoverflow.com/questions/16441635/highcharts-tooltip-is-hidden-behind-other-charts

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!