highcharts tooltip text align

devmonster picture devmonster · Jun 21, 2012 · Viewed 9.5k times · Source

I have created a graph using high charts. The tooltip works fine in FF and IE but in chorme the text goes out of the frame.

I tried using HTML

tooltip:
    {
     //Tried this also
    /* formatter: function()
    {
    return '' + Highcharts.dateFormat('%H:%M:%S', this.x) +'; '+ this.y;
    }, */
    useHTML: true,
    formatter: function() {
    var html="<div style='width:140px;text-align:center; direction:ltr'>"+
    Highcharts.dateFormat('%H:%M:%S', this.x) +'; '+ this.y+
    "</div>"; 
    return html;
    }

},

Answer

Lucho picture Lucho · Mar 11, 2014

Answer from Highcharts.com:

tooltip: {
        shared: true,
        useHTML: true,
        headerFormat: '<small>{point.key}</small><table>',
        pointFormat: '<tr><td style="color: {series.color}">{series.name}: </td>' +
        '<td style="text-align: right"><b>{point.y} EUR</b></td></tr>',
        footerFormat: '</table>',
        valueDecimals: 2
    },

Fiddle Here