Format number on Fusion Tables

74 views
Skip to first unread message

Rafael

unread,
Feb 3, 2012, 12:13:31 PM2/3/12
to Google Visualization API
Hi,

I would like to format the number on the Fusion Table view. I'm using
this example, with modifications:
https://developers.google.com/fusiontables/docs/samples/gviz_datatable?hl=pt-br.
But, in a number column, i need format with "," and "$". I have
founded this code that suits me (http://code.google.com/intl/pt-BR/
apis/chart/interactive/docs/reference.html#numberformatter), i just
don't know where to use it.

Can anybody help me?

asgallant

unread,
Feb 3, 2012, 1:29:41 PM2/3/12
to google-visua...@googlegroups.com
It is used like this:

var formatter = new google.visualization.NumberFormat({prefix: '$'});
formatter.format(dataTable, column);

create the formatter and call the #format method before you draw the chart.

Rafael

unread,
Feb 4, 2012, 11:11:46 AM2/4/12
to Google Visualization API
I have one more doubt: where exactly should I put this code? And wich
variable I should set in this part dataTable (dataTable, column)? I'm
using, as I said before, this example:
https://developers.google.com/fusiontables/docs/samples/gviz_datatable.

Thanks!

asgallant

unread,
Feb 6, 2012, 9:03:49 AM2/6/12
to google-visua...@googlegroups.com
That example has to be tweaked to make this work (as you need a DataTable object to format first).  I made the modifications here: http://jsfiddle.net/dkYBx/

The first argument for the #format method is the DataTable object to work on and the second is the column within the DataTable.  The #format method must be called after populating the DataTable object but before drawing any charts/tables with the data.

Note that in this example, all columns returned from the fusion table are strings, so the formatter does not do anything.

asgallant

unread,
Feb 6, 2012, 9:05:50 AM2/6/12
to google-visua...@googlegroups.com
Oops, I left a console.log() call in there by mistake, which could cause problems with IE; here's a version without: http://jsfiddle.net/dkYBx/1/

Rafael

unread,
Feb 8, 2012, 12:32:03 AM2/8/12
to Google Visualization API
Thanks a lot!

asgallant

unread,
Feb 8, 2012, 9:05:03 AM2/8/12
to google-visua...@googlegroups.com
You're welcome.
Reply all
Reply to author
Forward
0 new messages