Reputation: 626
I am trying to set an option for a specific graph in the decimal form. I went through many questions, but I can't seem to figure out why it isn't working for me.
var temp_chart_options = {
title: 'Temperature',
hAxis: {title: 'Date', titleTextStyle: {color: '#262626'}, format:'decimal' },
vAxis: {minValue: 0, format: 'decimal'},
keepInBounds: true,
};
temp_chart.draw(temp_data, temp_chart_options);
I tried doing format: 'decimal'
, or format: { pattern: 'decimal' }
and even did temp_chart.draw(data, google.charts.Line.convertOptions(temp_chart_options));
and even looked at these questions:
But none of them seem to work :(
EDIT
Does anyone know how to change the format of the hover?
Upvotes: 1
Views: 8349
Reputation: 3299
As an addition to the accepted answer, I needed to do a currency in GBP with 1000's separators and 2 decimal places.
The given Google 'currency' was unsuitable as it renders the currency symbol in your local currency.
I came up with this:
format: '£#,###.##'
Which could theoretically be used with any currency symbol.
This was the result:
Upvotes: 1
Reputation: 4174
The format parameter on your vertical axis needs to specify a proper format pattern. For example, vaxis: {format:'0.00'}
will give you a number with two decimal places after it.
Note that Google's documentation is very incomplete about this. They give an example using the presets, and an example of using separators (e.g. '#,###'
), but there is no example showing decimal places, nor is there any complete documentation on number format specifiers that I could find. Perhaps it is documented elsewhere, but the page I linked to above ought to at least provide a link to it if so. It does not. I discovered the 0.00
format by experimentation.
Upvotes: 7