How to customize tooltips(text and Format) in Google Vizualization Bar Charts?

fabien7474 picture fabien7474 · Jan 15, 2010 · Viewed 30.8k times · Source

I am using Google Visualization Bar Chart and I would like to customize or change the tooltip text and format that appears when clicking on a bar.

I have been through documentation but I didn't find a way to implement this. Do you know:

  1. Is it even possible?
  2. If so, could you provide some code examples ?

Answer

Richard Poole picture Richard Poole · Nov 9, 2010

You can change the way the number is formatted by using the google.visualization.NumberFormat class.

var formatter = new google.visualization.NumberFormat({
    fractionDigits: 0,
    prefix: '$'
});

formatter.format(data, 1); // Apply formatter to second column.

If you need more flexibility, have a look at the PatternFormat class.

Here's the API reference.