devmonster
devmonster

Reputation: 1739

highcharts tooltip text align

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;
    }

},

Upvotes: 4

Views: 11235

Answers (2)

Lucho
Lucho

Reputation: 136

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

Upvotes: 6

babca
babca

Reputation: 786

What exactly do you need?

For example, this creates a shared tooltip with values aligned to right:

tooltip: {
        shared: true,
        useHTML: true,
        formatter: function()
            {
            tooltip_html = Highcharts.dateFormat('%H:%M:%S', this.x * 1000);
            tooltip_html += "<table>";

            this.points.forEach(function(entry)
                {
                tooltip_html += '<tr><td style="font-weight:bold; color:'+ entry.series.color +'">'+ entry.series.name +':</td><td style="text-align: right"> '+entry.y+'</td></tr>';
                });

            tooltip_html += "</table>";

            return tooltip_html;
            }
    },

DEMO: http://jsfiddle.net/babca/4NuTx/1/

Upvotes: 5

Related Questions