This document describes the required format of Chart API URLs and lists the available parameters.
The Google Chart API returns a PNG-format image in response to a URL. Several types of image can be generated, including line, bar, and pie charts. For each image type, you can specify attributes such as size, colors, and labels.
All the images in this document were generated with the Chart API. To view the URL of any image, do the following:
View Image or Properties.Properties.To make a URL easier to read, this document often shows it on multiple lines. When you are using the Google Chart API, you must supply a URL on a single line.
Google Chart API URLs must be in the following format:
http://chart.apis.google.com/chart?<parameter 1>&<parameter 2>&<parameter n>
Parameters are separated using the ampersand character (&).
You can specify as many parameters as you like, in any order. For example, the Chart API returns the following chart in response to the URL below:
http://chart.apis.google.com/chart?
chs=250x100
&chd=t:60,40
&cht=p3
&chl=Hello|World
Where:
http://chart.apis.google.com/chart? is the Chart API's location.& separates parameters.chs=250x100 is the chart's size in pixels.chd=t:60,40 is the chart's data.cht=p3 is the chart's type.chl=Hello|World is the chart's label.You can include a Chart API image in an HTML document by embedding a URL
within an <img> tag. When the webpage is displayed in a
browser, the Chart API renders the image within the page.
For example, the following <img> tag results in the same image as above:
<img src="http://chart.apis.google.com/chart?
chs=250x100
&chd=t:60,40
&cht=p3
&chl=Hello|World"
alt="Sample chart" />
When you embed a URL in an HTML <img> tag, take care to use the character entity reference & in place of an ampersand (&).
You must provide at least the following parameters:
All other parameters are optional. Optional parameters by chart type are listed in the following table. Note that QR Codes are omitted as they have no optional parameters.
Specify chart size with chs=<width in pixels>x<height in pixels>
For example, chs=300x200 generates a chart 300 pixels wide
and 200 pixels high.
The largest possible area for all charts except maps is 300,000 pixels. As the maximum height or width is 1000 pixels, examples of maximum sizes are 1000x300, 300x1000, 600x500, 500x600, 800x375, and 375x800.
For maps, the maximum size is 440 pixels wide by 220 pixels high.