non-english chars in google charts label?

2019-08-31 05:32发布

问题:

Does non-english characters work in google charts labels/legends ?

This works, the legends shows up fine:

var chart_url = 'http://chart.apis.google.com/chart?' + 'cht=bvs' + ...some other stuff... + '&chdl=Lowest price|Average price';

This doesn't work, the legends don't show at all:

var chart_url = 'http://chart.apis.google.com/chart?' + 'cht=bvs' + ...some other stuff... + '&chdl=L' + unescape("%E4") + 'gsta pris|Genomsnittligt pris';

Any ideas? Thanks in advance!

/toby

-----------edit-----------

Neither of these works:

'&chdl=Lägsta pris|Genomsnittligt pris'

'&chdl=L& auml;gsta pris|Genomsnittligt pris' (without the space after &)

'&chdl=L%E4gsta pris|Genomsnittligt pris'

%E4 == ä urlencoded.

回答1:

My guess is that most letters will work, but you have to do the equivalent of urlencoding them (see urlencode()).



回答2:

Struggled with the same problem and it turned out that google charts want the texts urlencoded in UTF-8 (of course...)

So "Lägsta pris" should be == L%C3%A4gsta+pris