The Google Chart API lets you dynamically generate charts. To see the Chart API in action, open up a browser window and copy the following URL into it:
http://chart.apis.google.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World
Press the Enter or Return key and - presto! - you should see the following image:
This document is intended for programmers who want to include Google Chart API images within a webpage. It provides an introduction to using the API and reference material on the available parameters.
There's no limit to the number of calls per day you can make to the Google Chart API. However, we reserve the right to block any use that we regard as abusive, an apparent denial of service attempt for example. If you think your service will make more than 250,000 API calls per day, please let us know by mailing an estimate to chart-api-notifications@google.com.
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.
You can include a Chart API image in a webpage 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.
All the images in this document were generated with the Chart API. To view the URL of an image :
View image or Properties.Properties.This document describes the required format of Chart API URLs and the available parameters.
Google Chart API URLs must be in the following format:
http://chart.apis.google.com/chart?<parameter 1>&<parameter 2>&<parameter n>
Note: Each URL must be all on one line.
Parameters are separated with 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. 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" />
Note: 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.
| Parameter | Bar chart | Line and Sparkline chart | Radar chart | Scatter plot | Venn diagram | Pie chart | Google- o-meter |
Maps |
|---|---|---|---|---|---|---|---|---|
| Chart colors | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
| Solid fill | Yes | Yes | Yes | Yes | Yes | Yes | Background only | Background only |
| Data scaling | Yes | Yes | Yes | Yes | Yes | Yes | Yes | |
| Linear gradient | Yes | Yes | Yes | Yes | Yes | Background only | ||
| Linear stripes | Yes | Yes | Yes | Yes | Yes | Background only | ||
| Chart title | Yes | Yes | Yes | Yes | Yes | Yes | ||
| Chart legend | Yes | Yes | Yes | Yes | Yes | |||
| Multiple axis labels | Yes | Yes | Yes | Yes | ||||
| Grid lines | Yes | Yes | Yes | Yes | ||||
| Shape markers | Yes | Yes | Yes | Yes | ||||
| Horizontal range markers | Yes | Yes | Yes | Yes | ||||
| Vertical range markers | Yes | Yes | Yes | Yes | ||||
| Line styles | Yes | Yes | Yes | |||||
| Fill area | Yes | Yes | Yes | |||||
| Bar width and spacing | Yes | |||||||
| Bar chart zero line | Yes | |||||||
| Pie chart and Google-o-meter labels | Yes | Yes |
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.
Pie charts are clipped (only partially visible) if the size specified is too small. General size guidelines for pie charts are:
Before you can create a chart you must encode your data into a form that is understood by the Chart API. Use one of the following formats:
A represents 0, B represents
1, and so on up to 9 which represents 61, to provide a resolution
of 62 different values. AA represents
0, AB represents 1, and
so on up to two periods (..) which represent 4095 to provide
a resolution of 4,096 different values.Note: For simple and extended encoding you'll most likely want to encode your data programmatically. See the JavaScript snippet for encoding data for a start point. Also, several Chart Group members have contributed API libraries - either trawl the Group or visit the Useful links to API libraries post.
Specify text encoding with
chd=t:<chart data string>
Where <chart data string> consists of positive floating
point numbers from zero (0.0) to one hundred (100.0),
minus one (-1),
and the pipe character (|) as a separator.
Note:
-1).|).For example: chd=t:10.0,58.0,95.0|30.0,8.0,63.0
Note: For text encoding, scale your data by converting it into percentages of the largest value in your data set.
Specify text encoding with data scaling with two parameters
chd=t:<chart data string>
chds=<data set 1 minimum value>,<data set 1 maximum
value>,<data set n minimum value>,<data set n maximum value>
Where:
<chart data string> consists of any positive or
negative floating point numbers<data set 1 minimum value> is the lowest number
you want to apply to the first data set<data set 1 maximum value> is the highest number
you want to apply to the first data set, omit to specify 100<data set n minimum value> is the lowest number
you want to apply to the nth data set<data set n maximum value> is the highest number
you want to apply to the nth data set, omit to specify 100If you supply fewer data scaling parameters than there are data sets the last scaling parameter is applied to the remaining data sets. Provide just one pair of scaling parameters to apply a single range to a chart.
Note:
|).For example: chd=t:30,-60,50,120,80&chds=-80,140
Specify simple encoding with
chd=s:<chart data string>
Where <chart data string> contains the characters: A to Z, a to z, 0 to 9,
underscore (_), and comma (,) as a separator.
Note:
A = 0, B = 1 and so on to Z = 25.a = 26, b= 27 and so on to z = 51.0) = 52 and so on to 9 = 61._).,). For example, two sets of data: chd=s:ATb19,Mn5tz where — in the first data set — A represents 0, T represents 19, b represents 27, 1 represents 53, and 9 represents 61.
Note: See Simple encoding character values for a complete listing.
Specify extended encoding with
chd=e:<chart data string>
Where <chart data string> contains pairs of
the characters: A to Z, a to z, 0 to 9,
hyphen (-), period (.), underscore (_),
and comma (,) as a separator.
Note:
AA = 0, AZ = 25, Aa = 26, Az = 51, A0 = 52, A9 = 61, A- = 62, A. = 63BA = 64, BZ = 89, Ba = 90, Bz = 115, B0 = 116, B9 = 125, B- = 126, B. = 127.A = 4032, .Z = 4057, .a = 4058, .z = 4083, .0 = 4084, .9 = 4093, .- = 4094, .. = 4095.__) characters.,).Note: See Extended encoding character values for instructions on how to generate a complete listing.
You will most likely find it easier to translate real-life data into Chart API data programmatically rather than manually.
The following snippet of JavaScript encodes a data set into Simple
encoding. The data set must be provided as an array of positive numbers. A data set value that is not a positive number is encoded as a missing value with the underscore character (_).
var simpleEncoding = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
function simpleEncode(valueArray,maxValue) {
var chartData = ['s:'];
for (var i = 0; i < valueArray.length; i++) {
var currentValue = valueArray[i];
if (!isNaN(currentValue) && currentValue >= 0) {
chartData.push(simpleEncoding.charAt(Math.round((simpleEncoding.length-1) * currentValue / maxValue)));
}
else {
chartData.push('_');
}
}
return chartData.join('');
}
Call the simpleEncode function passing in the array (valueArray) and the maximum value (maxValue) within that array. In the following example maxValue is set to be larger than the largest number in the array to create some space between the highest value and the top of the chart:
var valueArray = new Array(0,1,4,4,6,11,14,17,23,28,33,36,43,59,65); var maxValue = 70; simpleEncode(valueArray,maxValue);
Take care not to overestimate the number of data points required for a chart. For example, to show how popular Britney Spears was during the last ten years, aggregating search queries for each day results in more than 3600 values. This would be too much data to pass in a URL, it also would not make any sense to plot a graph at this granularity: on a 1024 pixel wide screen one data point would be about a quarter of a pixel on the screen. The following examples illustrate this point.
200 by 100 chart with 20 data points (10 pixels per data point):
40 data points (5 pixels per data point):
80 data points (only 2.5 pixels per data point):
The following types of charts are available:
Specify a line chart with
cht=<line chart type>
Where <line chart type> is lc or lxy as described in the following table.
lc, multiple data sets are drawn as multiple lines.lxy a pair of data sets is required for each line. | Parameter | Description | Example |
|---|---|---|
|
A line chart, data points are spaced evenly along the x-axis. |
|
|
Provide a pair of data sets for each line you wish to draw, the first data set of each pair specifies the x-axis coordinates, the second the y-axis coordinates. If you pass in an odd number of data sets the last set is ignored. Provide a single undefined value to evenly space the data points along the x-axis. The example chart uses Text encoding so an undefined value is represented by Specify data point shape markers with the Specify line colors as described in Colors. |
cht=lxy |
Specify a sparkline with
cht=ls
A sparkline chart has exactly the same parameters as a line chart. The only difference is that the axis lines are not drawn for sparklines by default. You can add axis labels if you wish, see Multiple axis labels for more information.
Specify a bar chart with
cht=<bar chart type>
Where <bar chart type> is bhs, bhg, bvs or bvg as described in the following table.
| Parameter | Description | Example |
|---|---|---|
|
Horizontal and vertical bar chart respectively. The first example (all bars in dark blue) has a single data set. The second example (bars in dark and pale blue) has two data set. As you can see, multiple data sets are stacked so you must specify a color for each data set. You can also specify a color for each data point within a single data set. See Colors for details. The second example does not use data scaling so data points that have a combined value greater than 100 are off the scale. The third example does use data scaling so the bars are scaled correctly. |
|
|
Horizontal and vertical bar chart, respectively, in specified colors; multiple data sets are grouped. |
cht=bhg
|
|
Bar chart size is handled in a different way than for other chart types. For horizontal bar charts of type Because of this you may wish to specify bar width and spacing with Note: if the third parameter (space between bars) is not supplied, this defaults to half the value of space between groups. |
|
Specify a pie chart with
cht=<pie chart type>
Where <pie chart type> is p or p3 as described in the following table.
Note: The Google Chart API calculates
the circle's radius from the minimum of width and
height specified in the chart size (chs) parameters. The
chart is clipped if the size specified is too small. If you are including
labels you probably need to specify the width to be twice the height.
| Parameter | Description | Example |
|---|---|---|
|
Two dimensional pie chart. Unless specified otherwise, pie segment colors are interpolated from dark orange to pale yellow. Specify other colors as described in Colors. Specify labels with |
|
|
Three dimensional pie chart. Specify labels with |
|
Specify a venn diagram with
cht=v
Supply one data set where:
| Parameter | Description | Example |
|---|---|---|
|
In this example the first circle is specified with 100, the second with 80, and the third with 60. The overlap between all circles is specified with 30. For information on available parameters for Venn diagrams see Optional parameters by chart type. |
|
Specify a scatter plot with
cht=s
| Parameter | Description | Example |
|---|---|---|
|
Supply two data sets: the first data set specifies x coordinates,
the second set specifies y coordinates. The default shape for data points is a circle. Specify a different data point shape with the The default data point color is blue. Specify other colors as described in Colors. In the example, you'll notice the data points vary in size. To do this, specify a third data set. Any size specified with the |
|
Specify a radar chart with
cht=r or cht=rs
For a chart of type r points are connected with straight lines.
For a chart of type rs points are connected with splines
to form a curved line.
| Parameter | Description | Example |
|---|---|---|
|
In a radar chart, data points are drawn between
the center of the chart and the perimeter. Points of value zero ( The points representing the first and last values in the data set are
drawn between the center of the chart and the top of the chart. The remaining
points are evenly spaced traveling clockwise around the chart, and, in
this type of radar chart, a straight line is drawn between each pair of
points. This example shows a simple radar chart, with a single data set. |
|
You can add further information and clarity to a radar chart by adding colors, line styles, and axis labels. This example is a more complex radar chart with two data sets. The color
of each data set is specified with Line styles are specified with Finally axis labels are specified with Note: When labels are included, the spacing of the data points around the chart is determined by either the number of labels or the number of data points minus one, whichever is the larger. |
chco=FF0000,FF9900 |
|
|
This example uses the same parameters as the previous example, but has a Fill area specified for both data sets. It also has an added grid. See Grid lines for more information.
|
chg=25.0,25.0,4.0,4.0 |
|
The final example shows the previous example with
added Shape markers. Note that the horizontal line shape marker (specified
with
See Shape markers and Colors for information. You can also specify range markers, see Range markers for more information. |
chm= |
Specify a map with
cht=t and chtm=<geographical area>
Where <geographical area> is one of the following:
africaasiaeuropemiddle_eastsouth_americausaworldFor example:
chs=440x220
chd=s:_
cht=t
chtm=world
Note: Text encoding with data scaling is not available for maps. Instead use text encoding, simple encoding or extended encoding.
This is the default map for the world. The size used in the example (440 by 220 pixels) is the maximum available for all maps. Also notice the data set contains just one character, an underscore (_). This specifies a missing value in simple encoding and gives us the simplest map possible. You can make your map much more informative - and interesting - than the above example by using color for one or more countries on the map.
Specify the colors on a map, and how they are applied to each country or state within the map, with three parameters in combination:
chco=<default color><colors for gradient>
chld=<list of codes for each country or state to be colored>
chd=<list of values for each country or state to be colored>
Where:
<default color>, <colors for gradient> are RRGGBB format hexadecimal numbers. The default color is applied to countries or states that are not listed in the chld parameter. The other colors specify the extremes of a color gradient that is used to color all countries listed in the chld parameter. The color that is applied depends on the country's value in the chd parameter.<list of codes for each country or state to be colored> is a list of either:
<list of values for each country or state to be colored> are simple, text or extended encoding values. The first value is used for the first country listed in the chld parameter, the second for the second and so on. The lowest data value; A, 0, or AA depending on the type of encoding used, is drawn in the color specified by <color for start of gradient> in chco. The highest; 9, 100, or .. is drawn in the color specified by <color for end of gradient>. Intermediate values give intermediate colors.For example:
chtm=africa
chco=ffffff,edf0d4,13390a
chld=MGKETN
chd=s:Af9
chf=bg,s,EAF7FE
In this example:
ffffff which specifies white) is used for any country not listed in the chld parameteredf0d4) to dark green (13390a)MG), Kenya (KE), and Tunisia (TN)A which is the the minimum value possible in simple encoding and equates to zero.edf0d4)f which equates to 31. Kenya is therefore drawn in a color intermediate between pale and dark green9 which is the the maximum value possible in simple encoding and equates to 61.13390a)EAF7FE) as these are considered to be the map's background. See the chf parameter as described in Chart area and background fill.Here's a more colorful example:
chco=
f5f5f5,
edf0d4,
6c9642,
13390a
Here the default color is f5f5f5. The color gradient is
specified with edf0d4, 6c9642, and 13390a.
It's easiest to explain how this is applied using text encoding:
edf0d4)6c9642)13390a)6c9642) and the darkest green (13390a).Specify a Google-o-meter with
cht=gom
For information on available parameters see Optional parameters by chart type.
| Parameter | Description | Example |
|---|---|---|
|
|
Here's an example of a Google-o-meter using the default colors (red on the left shading through orange and yellow to green on the right). See Chart colors for information on specifying other colors. See Pie chart and Google-o-meter labels for information on specifying the text that appears at the end of the arrow. |
|
QR Codes are a popular type of two-dimensional barcode, which are also known as hardlinks or physical world hyperlinks. QR Codes store text which can be a hyperlink, contact information, telephone number, even whole verses of poems!
To the human eye QR Codes look like hieroglyphics, but they can be read by any device that has the appropriate software installed. Such devices range from dedicated readers to mobile phones. So, a person with a suitable mobile device can scan a QR code, on a magazine say, which causes the phone's browser to launch to the URL in the QR code.
Specify a QR code with
cht=qr
chl=<text to encode>
choe=<output encoding>
where:
<text to encode> is text for
the QR code. This must be url-encoded in UTF8. Note the space between hello and world is
written as %20 in the following example.<output encoding> optionally specifies how the output
is encoded. If this is not specified the default of UTF-8 is
used. Available options are: Shift_JIS, UTF-8,
or ISO-8859-1.For example:
cht=qr
chl=hello%20world
choe=UTF-8
At 21 rows by 21 columns the example QR code above is the simplest possible and is known as version 1:
The Chart API generates the appropriate QR code version depending on the number of characters you provide. For example, if you provide 55 alphanumeric characters the Chart API will generate a version 3 QR code. This is modified by the error correction (EC) level you choose to use, more on EC levels in the following section.
Note: It's easy here to confuse number
of rows and columns with QR code size. The number of characters you provide
determines the number of rows and columns. The pixel
size of
the chart is determined with chs as usual (see Chart
size).
Four levels of EC are available. The default level
(L) allows the QR code to be read even if up to 7% of the
code is misread, missing or obscured. Other levels provide greater EC levels.
The number
of characters that can be encoded decreases with increasing EC level.
See Versions,
error correction and maximum characters for details.
The default margin is 4 modules. This means a blank space equivalent to four rows at the top and bottom and four columns on the left and right are placed around the QR code. This is the minimum required by QR readers.
Optionally, specify an EC level and margin with
chld=<EC level>|<margin>
Where:
<EC level> is one of L allows 7% of a QR code
to be restoredM allows 15% of a QR code
to be restoredQ allows 25% of a QR code
to be restoredH allows 30% of a QR code
to be restored<margin> defines the margin (or blank space) around
the QR code. The default image has a margin equivalent to 4 rows / columns
of the chart.Before generating your QR code consider what kind of device will be used to read your code. The best QR code readers will be able to read version 40 codes, mobile devices may read only up to version 4.
We recommend you stick to version 4, which equates to about 100 alphanumeric characters at the default EC level.
See the following table for information on maximum characters for each version and EC level.
| Version | Rows by columns | EC level | Maximum characters by EC level and character type | |||
|---|---|---|---|---|---|---|
| Digits: 0 to 9 | Alphanumeric: 0 to 9, A to Z, space, $ % * + - . / : |
Binary | Kanji | |||
| 1 | 21x21 | L | 41 | 25 | 17 | 10 |
| M | 34 | 20 | 14 | 8 | ||
| Q | 27 | 16 | 11 | 7 | ||
| H | 17 | 10 | 7 | 4 | ||
| 2 | 25x25 | L | 77 | 47 | 32 | 20 |
| M | 63 | 38 | 26 | 16 | ||
| Q | 48 | 29 | 20 | 12 | ||
| H | 34 | 20 | 14 | 8 | ||
| 3 | 29x29 | L | 127 | 77 | 53 | 32 |
| M | 101 | 61 | 42 | 26 | ||
| Q | 77 | 47 | 32 | 20 | ||
| H | 58 | 35 | 24 | 15 | ||
| 4 | 33x33 | L | 187 | 114 | 78 | 48 |
| M | 149 | 90 | 62 | 38 | ||
| Q | 111 | 67 | 46 | 28 | ||
| H | 82 | 50 | 34 | 21 | ||
| 10 | 57x57 | L | 652 | 395 | 271 | 167 |
| M | 513 | 311 | 213 | 131 | ||
| Q | 364 | 221 | 151 | 93 | ||
| H | 288 | 174 | 119 | 74 | ||
| 40 | 177x177 | L | 7,089 | 4,296 | 2,953 | 1,817 |
| M | 5,596 | 3,391 | 2,331 | 1,435 | ||
| Q | 3,993 | 2,420 | 1,663 | 1,024 | ||
| H | 3,057 | 1,852 | 1,273 | 784 | ||
QR code is trademarked by Denso Wave, inc. As you'd expect, the Denso Wave website includes a lot of useful information about QR codes.
QR code was approved as:
QR code reader software is available from many sources. Google offers a QR Code reader library, Zebra Crossing (ZXing), for free. See http://code.google.com/p/zxing/ for details.
See Barcode Contents for a rough guide to standard encoding of information in barcodes.
Specify a color with at least a 6-letter string of hexadecimal values in the format RRGGBB. For example:
FF0000 = red00FF00 = green0000FF = blue000000 = blackFFFFFF = whiteYou can optionally specify transparency by appending a hexadecimal value
between 00 and FF where 00 is completely
transparent and FF completely opaque. For example:
0000FFFF = solid blue0000FF00 = transparent blueThe following color options are available:
Specify colors for lines, bars, Venn diagrams, Google-o-meters, and pie segments with
chco=
<color1>,
...
<colorn>
Where <color1> and all subsequent color values are RRGGBB format hexadecimal numbers.
| Parameter | Description | Example |
|---|---|---|
|
This example has three data sets and three colors specified. |
|
|
This example also has three data sets, but only two colors are specified.
Because of this the last two lines are both drawn in the last color (red |
|
|
For bar charts, if the number of colors specified is less than the number of data sets then colors are alternated. In the following chart, the third data set, |
|
|
Here's the same chart with three colors specified. |
|
|
Specify a color for each data point within a single data set by separating |
|
|
For pie charts, if the number of colors specified is less than the number of slices, then colors are interpolated. |
|
|
| For Venn diagrams, if the number of colors specified is less than the number of circles the last color specified is repeated. |
|
|
| For Google-o-meters specify at least two colors, more if you want to specify the gradient in between. | chco=ffffff,ffaaaa,ff0000 |
Specify a fill area with
chm=
b,<color>,<start line index>,<end line index>,<any value>|
...
b,<color>,<start line index>,<end line index>,<any value>
Where:
<color> is an RRGGBB format hexadecimal number.<start line index> is the index of the line at which the fill starts. This is determined by the order in which data sets are specified with chd. The first data set specified has an index of zero (0), the second 1, and so on.<end line index> is the index of the line at which the fill ends. This is determined by the order in which data sets are specified with chd. The first data set specified has an index of zero (0), the second 1, and so on.<any value> is ignored. Separate multiple fill areas with the pipe character (|).
| Parameter | Description | Example |
|---|---|---|
|
Take care to specify the data set with the largest values first: To fill from the top of the chart to the first line include a data set with only the highest data value ( To fill from the last line to the bottom of the chart include a data set with only the lowest data value ( The lines themselves are drawn in black using
|
|
By contrast the first and last data sets ( Also, |
|
|
|
For a single data set, it is simpler to use |
|
Specify solid fill with
chf=
<bg or c or a>,s,<color>|
<bg or c or a>,s,<color>
Where:
<bg or c or a> is:bg for background
fillc for
chart area fill a to apply transparency to the whole chart.<s> indicates solid fill.<color> is an RRGGBB format hexadecimal number.|) separates fill definitions. No pipe character is required after the second definition.You can specify:
| Parameter | Description | Example |
|---|---|---|
|
This example fills the image background with pale gray ( |
|
|
This example fills the background with pale gray ( |
|
|
|
Note the effect of specifying transparency using the hexadecimal values of 20 for the background and 80 for the chart area. |
|
|
| This example applies transparency to the whole chart. |
|
Specify linear gradient for line charts, sparklines, bar charts, Venn diagrams, radar charts and scatter plots with
chf=<bg or c>,lg,<angle>,<color 1>,<offset 1>,<color n>,<offset n>
Where:
<bg or c> is bg for background fill or c for chart area fill.lg specifies linear gradient.<angle> specifies the angle of the gradient between 0 (horizontal) and 90 (vertical).<color x> are RRGGBB format hexadecimal numbers.<offset x> specify at what point the color is pure where: 0 specifies the right-most
chart position and 1 the left-most.| Parameter | Description | Example |
|---|---|---|
|
Chart area has a horizontal (left to right) linear gradient, specified with an angle of zero degrees ( Blue ( White ( The chart background is drawn in gray ( |
|
Chart area has a diagonal (bottom left to top right) linear gradient, specified with an angle of forty five degrees ( White ( Blue ( The chart background is again drawn in gray ( |
|
|
Chart area has a vertical (top to bottom) linear gradient, specified with an angle of ninety degrees ( Blue ( White ( The chart background is again drawn in gray ( |
|
Specify linear stripes for line charts, sparklines, bar charts, Venn diagrams, radar charts and scatter plots with
chf=<bg or c>,ls,<angle>,<color 1>,<width 1>,<color n>,<width n>
Where:
<bg or c> is bg for background fill or c for chart area fill.ls specifies linear stripes.<angle> specifies the angle of the gradient between 0 (vertical) and 90 (horizontal).<color> is an RRGGBB format hexadecimal number.<width> must be between 0 and 1 where 1 is the full width of the chart. Stripes are repeated until the chart is filled.| Parameter | Description | Example |
|---|---|---|
|
Chart area with vertical stripes specified with an angle of zero ( The first color specified (dark gray The second color specified (white Stripes alternate until the chart is filled. The chart background is omitted. |
|
Chart area with horizontal stripes specified with an angle of ninety degrees ( The first color specified (the darkest gray The second and third colors specified (the lighter gray Stripes alternate until the chart is filled. The chart background is omitted. |
|
The following types of labels are available:
Specify a chart title with
chtt=<chart title>
Specify a legend with
chdl=<first data set label>|<n data set label>
| Parameter | Description | Example |
|---|---|---|
|
Use In these examples the first data set is drawn in red, the second in green and the third in blue. |
chdl=NASDAQ|FTSE100|DOW |
|
||
chdl and chdlp |
Use
|
|
For a pie chart specify labels with
chl=
<label 1 value>|
...
<label n value>
You can specify a missing value with two consecutive pipe characters (||).
Note: To display labels:
- A two-dimensional chart needs to be roughly twice as wide as it is high.
- A three-dimensional chart needs to be roughly two and a half times wider than it is high.
For a Google-o-meter specify the text that appears above the arrow with
chl=<label>
| Parameter | Description | Example |
|---|---|---|
chl |
Labels for a three-dimensional pie chart. |
|
A good rule of thumb is provided above for how wide you need to make a pie chart to include labels - however, don't forget that you still need to take into account how long your labels are! Here the labels are only partially displayed as the chart is not wide enough. |
|
|
This chart needs a width of 280 pixels to display the labels in full. |
|
|
| Here's an example of a Google-o-meter with a label. |
|
Multiple axis labels are available for line charts, bar charts, radar charts, and scatter plots:
Specify multiple axes with
chxt=
<axis 1>,
...
<axis n>
Available axes are:
x = bottom x-axist = top x-axisy = left y-axisr = right y-axis Axes are specified by the index they have in the chxt parameter
specification. The first axis has an index of 0, the second
has an index of 1, and so on. You can specify multiple axes
by including x, t, y, or r multiple
times.
To create multiple axes at least the chxt parameter is
required. If other parameters are missing the Chart API uses defaults as
described in the following sections.
| Parameter | Description | Example |
|---|---|---|
|
|
These examples show two lower x-axes ( Because axis labels are omitted the Chart API assumes a range of
Note: For the sake of brevity vertical, but not horizontal, bar charts are discussed in the remainder of this section. The behaviour of the y- and r-axes in a horizontal bar chart is the same as the x- and t-axes in a vertical bar chart. |
|
Specify labels with
chxl=
<axis index>:|<label 1>|<label n>|
...
<axis index>:|<label 1>|<label n>
The index parameter specifies the index of the axis to
which the labels apply.
All labels are separated by the pipe character (|).
Note: Axis labels must be specified in sequence (0, then 1, then 2, and so on).
The first label is placed at the start, the last at the end, others are uniformly spaced in between.
| Parameter | Description | Example |
|---|---|---|
|
|
These examples show left and right y-axes ( Note: Bar chart x-axis labels are centred beneath each bar. Because of this, unlike in the line chart, the year is specified for each bar in the bar chart. |
As above for the line chart except: |
|
As above except y-axis labels (index |
|
Specify label positions with
chxp=
<axis index>,<label 1 position>,<label n position>|
...
<axis index>,<label 1 position>,<label n position>
Use floating point numbers for position values. Separate data for a
different axis with a pipe character (|). If labels (chxl)
are omitted, label text is taken from the position value.
| Parameter | Description | Example |
|---|---|---|
|
|
This example shows left and right y-axes ( The x-axis (index The left y-axis (index The r-axis (index |
|
|
This example shows left and right y-axes ( Similar to the example above, except the positions of labels for two
x-axes are specified. This illustrates that you can overide the
Chart API's positioning of labels for a bar chart by using |
chxt=x,y,r,x |
Specify a range with
chxr=
<axis index>,<start of range>,<end of range>|
...
<axis index>,<start of range>,<end of range>
Separate multiple axis ranges with the pipe character (|).
| Parameter | Description | Example |
|---|---|---|
|
|
This example shows left and right y-axes ( Each axis has a defined range. Because no labels or positions are specified, values are evenly spaced and taken from the given range. In the bar chart, note that again the x-axis is handled differently, each bar is given a label. Note: Axis direction is reversed for the
r-axis (index |
|
|
Here only the x-axis is defined ( |
|
Specify font size, color, and alignment for axis labels with
chxs=
<axis index>,<color>,<font size>,<alignment>|
...
<axis index>,<color>,<font size>,<alignment>
where:
<axis index> is the axis index as specified in chxt.<color> is an RRGGBB
format hexadecimal number.<font size> is optional. If used this specifies
the size in pixels.<alignment> is optional. By default: x-axis
labels are centered, left y-axis labels are right aligned, right y-axis
labels are left aligned. To specify alignment, use 0 for centered, -1 for
left aligned, and 1 for right aligned.Separate multiple values with a pipe character (|).
| Parameter | Description | Example |
|---|---|---|
|
|
Font size, color, and alignment are specified for the second x-axis. |
|
| Font size, color, and alignment are specified for both x-axes. |
|
The following styles are available:
For bar charts, specify bar thickness and spacing with
chbh=
<bar width in pixels>,
<optional space between bars in a group>,
<optional space between groups>
| Parameter | Description | Example |
|---|---|---|
|
In the first example, bar width is set to 10 pixels, space between bars defaults to 4 pixels, and the space between groups defaults to 8 pixels. In the second example, bar width is set to 10 pixels, space between bars is 5 pixels, and the space between groups is 15 pixels. Take care if you provide only two values. In the third example space between bars is set to 8 pixels. As this is the default value for space between groups the visual distinction is completely lost. Specifying a value greater than 8 is even worse - the wrong bars appear to be grouped together. |
|
For bar charts, specify a zero line with
chp=
<value between 0 and 1 for dataset 1>,
<value between
0 and 1 for dataset n>
Provide just one value to apply the same zero line to all data sets.
| Parameter | Description | Example |
|---|---|---|
|
|
In this example, a
|
|
|
|
An alternative way to set a zero line is to use the data scaling parameter
( The example has a data set ranging from -60 to 120 and a scale of -80 to 140 to leave space above and below the bars. See text encoding with data scaling for more information. |
chd=t:30,-60,50,120,80 |
You can specify line styles for:
Specify line and sparkline styles with
chls=
<data set 1 line thickness>,<length of line segment>,<length of blank segment>|
...
<data set n line thickness>,<length of line segment>,<length of blank segment>
Parameter values are floating point numbers, multiple line styles are separated
by the pipe character (|). The first line style is applied to the
first data set, the second style to the second data set, and so on.
| Parameter | Description | Example |
|---|---|---|
|
Here the thick dashed line is specified by See Chart colors for information on specifying line colors. |
chls=3,6,3|1,1,0 |
Specify line and bar chart line styles with
chm=D,<color>,<data
set index>,<data point>,<size>,<priority>
where:
<color> is an RRGGBB
format hexadecimal number.<data set index> the index of the data set on
which to draw the line. This is 0 for the first data set, 1 for
the second and so on. <data point> is zero. <size> is the size of the marker in pixels.<priority> determines the order in which bars, lines,
markers, and fills are drawn:1 specifies the line is drawn on top of bars and
markers.
0 is the default and specifies the line is drawn on top
of the bars and beneath markers.-1 specifies the line is drawn underneath bars and
markers.| Parameter | Description | Example |
|---|---|---|
chm=D |
Here's an example of a data
line on a bar chart. The priority is set to |
chm= |
|
Here's an example of a sparkline chart. Sparklines are identical to line charts, except they have no axes by default, they have exactly the same functionality as line charts. |
chm= |
Specify a grid with
chg=
<x axis step size>,
<y axis step size>,
<length of line segment>,
<length of blank segment>
Parameter values can be integers or have a single decimal place - 10.0 or 10.5 for example.
| Parameter | Description< |
|---|