Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Highcharts tooltip overflow is hidden

My problem is that when the chart drawing area of is smaller than a highchart tooltip, a part of the tooltip is hidden where it overflows the chart drawing area.

I want the tooltip to be visible all the time, no matter the size of the chart drawing area.

No CSS setting helped and no higher z-index setting helped either.

Here is my example... http://twitpic.com/9omgg5

Any help will be mostly apreciated.

Thank you.

like image 561
AlexRebula Avatar asked May 24 '12 09:05

AlexRebula


3 Answers

This css helped me:

.highcharts-container { overflow: visible !important; }
like image 161
qasem Avatar answered Sep 22 '22 12:09

qasem


OK, sorry for the delay. I could not find a better solution, but I found a workaround.

Here is what I did and what I suggest everyone to try:

Set the tooltip.useHTML property to true (now you can have more control with html and CSS). Like this:

tooltip: {
    useHTML: true    
}

Unset all the default tooltip peoperties that may have something to do with the default tooltip functionalities. Here is what I did...

tooltip: {                        
    shared: false,
    borderRadius: 0,
    borderWidth: 0,
    shadow: false,
    enabled: true,
    backgroundColor: 'none'
}

Make sure that your chart container's css property "overflow" is set to visible. Also make sure that all DOM elements (div, section, etc....) that hold your chart container also have the css "overflow" property set to "visible". In this way you will make sure that your tooltip will be visibile at all times as it overflows his parent and his other "ancestors" (Is this a correct term? :)).

Customize your tooltip formatter as you wish, using standard CSS styling. Here is what I did:

tooltip.formatter: {
    < div class ="tooltipContainer"> Tooltip content here < /div >
}

This is how it all looks like:

tooltip: {                        
    tooltip.formatter: {
        < div class ="tooltipContainer"> Tooltip content here < /div >
    },
    useHTML: true,
    shared: false,
    borderRadius: 0,
    borderWidth: 0,
    shadow: false,
    enabled: true,
    backgroundColor: 'none'
}

If you have a better solution, please post.

like image 24
AlexRebula Avatar answered Sep 23 '22 12:09

AlexRebula


A modern approach (Highcharts 6.1.1 and newer) is to simply use tooltip.outside (API):

Whether to allow the tooltip to render outside the chart's SVG element box. By default (false), the tooltip is rendered within the chart's SVG element, which results in the tooltip being aligned inside the chart area. For small charts, this may result in clipping or overlapping. When true, a separate SVG element is created and overlaid on the page, allowing the tooltip to be aligned inside the page itself.

Quite simply this means setting this one value to true, for example:

Highcharts.chart('container', {
    // Your options...
    tooltip: {
        outside: true
    }
});

See this JSFiddle demonstration of how setting this value to true fixes space/clipping issues.

like image 37
Halvor Holsten Strand Avatar answered Sep 21 '22 12:09

Halvor Holsten Strand