Re: Line Chart: Y axis format for large numbers? (20,000,000 -> 20 Million)

809 views
Skip to first unread message

asgallant

unread,
Jun 20, 2012, 10:26:26 PM6/20/12
to google-visua...@googlegroups.com
There is no way to make the charts dynamically shorten the axis values.  The best you can do is modify your data to put it in the scale you want and then manually append the 'Million' in the axis format.  Something like this:

// this assumes that you have already formatted the data in the DataTable
var view new google.visualization.DataView(data);
view.setColumns([0{
    labeldata.getColumnLabel(1),
    type'number',
    calcfunction (dtrow{
        // reformat the data in millions
        return {vdt.getValue(row11000000fdt.getFormattedValue(row1)};
    }
}]);

chart.draw(view{
    vAxis{
        // format the axis values to millions
        format'### Million'
    }
}); 

There is no way to have the charts change from millions to billions (or other values) without explicitly changing the format and redrawing (ie, the axis values can't be: ...800M, 900M, 1B, 1.1B...)

On Monday, June 18, 2012 6:12:05 PM UTC-4, Zhengli Sun wrote:
I have large numbers on Y axis in my data. 

I want to make it show as 20Million instead of 20,000,000. How can I write the formatter?
Reply all
Reply to author
Forward
0 new messages