Decimal separator and localization problems

314 views
Skip to first unread message

Peter Br.

unread,
Feb 14, 2012, 1:44:28 AM2/14/12
to Google Visualization API
I am using Google Java datasource library to generate CSV files, and
read them later for visualization. Visualization is done with Google
Chart Tools.
The problem is with decimal separator in numbers. Depending on locale
used for creating CSV files, decimal separator can be "." or ",". And
when I feed the data from files to visualization charts (I'm testing
with Column chart), depending on locale in browser "." or "," is
playing the role of decimal separator.
That means if the locale in browser is different from locale used for
creating CSV files, decimal separators are ignored and, for example,
123.45 ("." is decimal separator here) transforms to 12 345.

That is a major problem with using Google charts for me, as I don't
know the locale in user browser. It can be anything.

Is there a way to make Google charts always use "." as decimal
separator no matter what locale is?

asgallant

unread,
Feb 14, 2012, 7:55:51 AM2/14/12
to google-visua...@googlegroups.com
IIRC, javascript uses '.' exclusively as the decimal-separator (output can change based on locale, but input must use '.').  I think you have to find some way to detect the decimal separator used by the CSV, then string-replace it with a decimal point for each value and parseFloat() the result before inserting it into the database.
Reply all
Reply to author
Forward
0 new messages