Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you set percentage in Google Visualization Chart API?

Tags:

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

like image 424
B Seven Avatar asked Jun 25 '11 14:06

B Seven


People also ask

How do I remove a percentage from a Google chart?

Percentage is being automatically added to Google Pie charts tooltips, and there is no built-in option to remove it. However, you can use wpDataChart callbacks to tweak this. Charts usually support custom options appropriate to that visualization. You can use it for adding options that are available in Google Api.

How do you implement a Google Chart API?

The <div> element must have a unique id. Then load the Google Graph API: Load the Visualization API and the corechart package. Set a callback function to call when the API is loaded.

What type of chart is used for percentages?

A pie chart, sometimes called a circle chart, is a way of summarizing a set of nominal data or displaying the different values of a given variable (e.g. percentage distribution). This type of chart is a circle divided into a series of segments.


2 Answers

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.

like image 163
jroi_web Avatar answered Sep 20 '22 13:09

jroi_web


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

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

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

like image 30
B Seven Avatar answered Sep 21 '22 13:09

B Seven