How do you set percentage in Google Visualization

2019-04-03 07:00发布

How do you set the vertical axis to display percent such as 25%, 50%, 75%, 100%?

3条回答
Melony?
2楼-- · 2019-04-03 07:29

chart.draw(data, {vAxis: {format:'#%'} } );

To get comma for thousands, use {format:'#,###%'}.

See http://code.google.com/apis/chart/interactive/docs/gallery/linechart.html

查看更多
干净又极端
3楼-- · 2019-04-03 07:35
var options = {
        title: 'Chart Title',
        vAxis: {
            minValue: 0,
            maxValue: 100,
            format: '#\'%\''
        } 
    };

Try escaping the % sign. I've used this to just append the % sign in the y axis.

查看更多
老娘就宠你
4楼-- · 2019-04-03 07:39

Using bar charts, I found my results haphazard and I got to consistency by doing the following: 1. In your data column, set a value of 100, even if you add a dummy value of 100. 2. Select all the numeric cells in the column and format them using Format, Number, Normal 3. Now format them to % using Format, Number, Percent Rounded

Your graph should now show 100% on the vertical scale and if you have a dummy value for 100% you will want to hide it, so you can either format it by clicking on it in the graph and changing the color (but this doesn't seem to work every time) or go to Advanced Edit, Customize, Columns, select your column name (from the graphic legend) and set the bar color to None or whatever your background color is.

Good luck.

查看更多
登录 后发表回答