Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Line Chart: How to add units?

https://google-developers.appspot.com/chart/interactive/docs/gallery/linechart#Example

How can I add units to the vertical axis like "$" or "€"? In the example, it should be 1.200 $, 1.000 $, 800 $, 600 $ and 400 $.

Just adding '$' like this doesn't work:

var data = google.visualization.arrayToDataTable([
      ['Year', 'Sales', 'Expenses'],
      ['2004',  1000 '$',      400],
      ['2005',  1170 '$',      460],
      ['2006',  660 '$',       1120],
      ['2007',  1030 '$',      540]
    ]);

I know, it's a bad example as sales doesn't have any unit, but it's just an example.

like image 836
Ben Avatar asked Mar 10 '13 18:03

Ben


1 Answers

You need to add a format tag to your graph options as follows:

var options = {
    vAxis: {format:'# $'}
};

Reference: https://google-developers.appspot.com/chart/interactive/docs/gallery/linechart#Configuration_Options

like image 133
Byron Avatar answered Sep 19 '22 11:09

Byron