使文本适应高级工具提示最大宽度

use*_*791 8 highcharts

我想垂直调整我的highcharts工具提示中的文本(定义了最大宽度,因此如果文本不适合此最大宽度,请增加工具提示高度以适合文本)

什么适用于简单的HTML东西......

#my_div
{
   height:auto;
   max-width:140px;
   overflow:auto
}
Run Code Online (Sandbox Code Playgroud)

不适用于highcharts工具提示,请参阅http://jsfiddle.net/perikut/hNCDb/2/

Ali*_*hşi 17

默认white-space设置nowrap,您应该将其更改为normal.

.highcharts-tooltip span {
    height:auto;
    width:140px;
    background-color:green;
    overflow:auto;
    white-space:normal !important; // add this line...
}
Run Code Online (Sandbox Code Playgroud)

DEMO


Tim*_*ora 5

如果您只想更改white-space单个图表的工具提示行为和/或单独控制每个图表的样式,您可以使用以下方法:

 tooltip: {
    useHTML: true,
    formatter: function() {
        return "<div style='width: 400px; white-space:normal;'>" + this.points[0].point.yourDataPointValue + "</div>";
    }  
 }
Run Code Online (Sandbox Code Playgroud)

演示

请注意,如果您想为多个工具提示重用相同的样式,您可以/应该使用类名而不是内联样式。