Can anyone help to get the percent symbol[%]
in Y axis value.
I have attched png. in that in y axis 0 t0 18
values are there I want to see it as 0% to 18%.
https://i.stack.imgur.com/pF6U0.png
Can anyone help to get the percent symbol[%]
in Y axis value.
I have attched png. in that in y axis 0 t0 18
values are there I want to see it as 0% to 18%.
https://i.stack.imgur.com/pF6U0.png
You need to format in two places: the data and the axis. To format the data, use a NumberFormatter:
var formatter = new google.visualization.NumberFormat({pattern: '#%'});
// format column 1 of the DataTable
formatter.format(data, 1);
Format the axis values, via the vAxis.format
option:
vAxis: {
format: '#%'
}
No need of the google.visualization
line, just the next line is needed:
vAxis: {
format: "#'%'"
}
Explanation:
The difference is the double quotes and simple quote. format
property follows ICU pattern (as per GChart specs) that is used for formatting. When the simple quotes are not used, the presence of %
multiplies x100 the value per the ICU specs. So by adding the simple quotes, the %
is kind of escaped (more info)