formatting a result of a column in a new group

28 views
Skip to first unread message

Yoram

unread,
Jan 20, 2013, 12:30:56 PM1/20/13
to google-visua...@googlegroups.com
Hi all

I'm using a group to group data and display the average.
here's the code:
var group = google.visualization.data.group(view, [0], [{
column: 1,
type: 'number',
aggregation: google.visualization.data.avg
}]);

The problem is that I get a nasty result (e.g 4.3917849887239784) and it's 'hard on the eye' when the result is shown in a tooltip when hovering on the column chart data.
How can I truncate the grouped column to display only 2 digits after the point (e.g. 4.39)??

Thanks,
Yoram

asgallant

unread,
Jan 20, 2013, 4:30:19 PM1/20/13
to google-visua...@googlegroups.com
Create a NumberFormatter and format the column in the "group" DataTable:

var formatter = new google.visualization.NumberFormat({pattern: '#.##'});
formatter.format(group, 1);

Yoram

unread,
Jan 21, 2013, 2:30:24 AM1/21/13
to google-visua...@googlegroups.com
Thanks!
That did the job.
תודה
Reply all
Reply to author
Forward
0 new messages