How to set tooltips to display percentages to match axis?

37 views
Skip to first unread message

B7

unread,
Dec 9, 2011, 10:57:22 AM12/9/11
to Google Visualization API
I used the tooltips to display percentages using the following code:

var formatter = new google.visualization.NumberFormat({
fractionDigits: 2,
suffix: '%'
});
formatter.format(data, 1); // Apply formatter to first column.

Is there a way for NumberFormat to multiply each element by 100?
Otherwise the tooltip appears as .50%.

I am using vAxis.format = "format:'#%' " which does multiply by 100.
So .5 is displayed as 50% on the vertical axis.

According to the documentation(icu-project.org/apiref), this can be
overwritten by enclosing the % in single quotes, but this did not
work.

The net result is that the tooltips do not match the axis. What is the
best way to do this?

Thanks.

asgallant

unread,
Dec 9, 2011, 12:16:27 PM12/9/11
to google-visua...@googlegroups.com
Use the NumberFormat's 'pattern' option:

var formatter = new google.visualization.NumberFormat({
    pattern: '#%',
    fractionDigits: 2
});

B7

unread,
Dec 9, 2011, 12:41:23 PM12/9/11
to Google Visualization API
That worked. Thank you!
Reply all
Reply to author
Forward
0 new messages