How do you set percentage in Google Visualization Chart API?

前端 未结 3 540
挽巷
挽巷 2021-02-18 19:47

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

相关标签:
3条回答
  • 2021-02-18 20:20

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

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

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

    0 讨论(0)
  • 2021-02-18 20:27

    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.

    0 讨论(0)
  • 2021-02-18 20: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.

    0 讨论(0)
提交回复
热议问题