Chart Types
This document gives an overview of the types of charts you can create using the Chart API.
Table of Contents
Line charts
Specify a line chart with
cht=<line chart style>
Where <line chart style>
is lc
, ls
, or lxy
as described in the following table.
Parameter | Description | Example |
---|---|---|
|
For charts of type For information on how to specify multiple data sets see Using multiple data series. For information on available parameters, see Optional parameters by chart type. |
|
|
Line charts of type For information on how to add axis lines and labels to a line chart, see Axis styles and labels. |
|
|
For charts of type If you pass in an odd number of data sets, the last set is ignored. To space the data points evenly along the x-axis, provide a single undefined value as the first data set of the pair. For more information about undefined values, see Data formats. |
cht=lxy |
Bar charts
Specify a bar chart with
cht=<bar chart style>
Where <bar chart style>
is bhs
, bhg
, bvs
or bvg
as described in the following table.
Depending on the bar chart style, multiple data sets are drawn as stacked or grouped bars. For information on how to specify multiple data sets, see Using multiple data series.
For information on available parameters, see Optional parameters by chart type.
Parameter | Description | Example |
---|---|---|
|
Horizontal bar chart, with stacked bars. 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 sets. As you can see, multiple data sets are stacked. You must specify a color for each data set. You can also specify a color for each data point, or bar, within a single data set. See Colors for information about specifying colors. The second example does not use data scaling. Data points that have a combined value greater than 100 are only partially visible. See Text encoding with data scaling for more information about data scaling. |
|
|
Vertical bar chart, with stacked bars. This example has two data sets, and uses data scaling to ensure that the bars are fully visible. |
|
|
Horizontal bar chart, with grouped bars. |
cht=bhg |
|
Vertical bar chart, with grouped bars. |
|
|
The default width for bars is 23 pixels. If you specify too many bars for the available chart size, not all bars appear. Use For more options, see Bar width and spacing. |
chbh omitted
|
Pie charts
Specify a pie chart with
cht=<pie chart style>
Where <pie chart style>
is p
, p3
, or pc
as described in the following table. For information on available parameters, see Optional parameters by chart type.
Parameter | Description | Example |
---|---|---|
|
Two dimensional pie chart. Supply one data set only; subsequent data sets are ignored. By default, pie segment colors are interpolated from dark orange to pale yellow. Specify other colors as described in Colors. Specify labels with The Google Chart API calculates the circle's radius from the minimum of width and height specified in the chart size ( |
|
|
Three dimensional pie chart. Specify data and formatting in the same way as for two dimensional pie charts, above. If you are including labels in a three dimensional pie chart, you probably need to specify the size of the width to be 2.5 times the size of the height, to ensure that your labels are fully visible. |
|
|
Concentric pie charts. Supply two or more data sets. |
|
|
Pie chart orientation. To change the orientation of a pie chart, use |
|
Venn diagrams
Specify a venn diagram with
cht=v
Supply one data set where:
- The first three values specify the relative sizes of three circles: A, B, and C.
- The fourth value specifies the area of A intersecting B.
- The fifth value specifies the area of A intersecting C.
- The sixth value specifies the area of B intersecting C.
- The seventh value specifies the area of A intersecting B intersecting C.
Parameter | Description | Example |
---|---|---|
|
In this example, the value For information on available parameters for Venn diagrams, see Optional parameters by chart type. |
|
Scatter plots
Specify a scatter plot with
cht=s
For information on available parameters, see Optional parameters by chart type.
Parameter | Description | Example |
---|---|---|
|
The default shape for data points in a scatter plot is a circle. The default color for data points is blue. To use a different shape or color, specify the shape markers by using the At least two data sets should be supplied. The first data set specifies x-coordinates, and the second data set specifies y-coordinates. A third data set can be used to provide points of varying sizes. If you use |
|
Radar charts
Specify a radar chart with
cht=r
or cht=rs
For information on available parameters, see Optional parameters by chart type.
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 clockwise around the chart, and a line is drawn between each pair of points. For a chart of type 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 Axis labels are specified with When labels are included in a radar chart, the spacing of the data points around the chart is determined by the number of labels, or the number of data points, whichever is larger. |
chco=FF0000,FF9900 | |
|
This example uses the same parameters as the previous example, but has a Fill area specified for both data sets. This example includes an added grid. See Grid lines for more information. For charts of type |
chg=25.0,25.0,4.0,4.0 |
The final example shows the previous example with added Shape markers. The horizontal line shape marker (specified with The shape markers are specified as follows:
See Shape markers for more information about available shapes. You can also specify range markers. See Range markers for more information. |
chm= |
Maps
Specify a map with
cht=t
, and chtm=<geographical area>
Where <geographical area>
is one of the following:
africa
asia
europe
middle_east
south_america
usa
world
For example:
chs=440x220
chd=s:_
cht=t
chtm=world
This is the default map for the world. The size used in the example (440 by 220 pixels) is the maximum for all maps. Note that the data set contains just one character, an underscore (_). The underscore specifies a missing value in simple encoding and gives us the simplest map possible. You can make your map more informative and interesting by using color for one or more countries.
Specify the colors on a map, and how they are applied to each country or state, with three parameters in combination:
chco=<default color>,<start of gradient>,<end of gradient>
chld=<country or state codes>
chd=<color levels>
Where:
<default color>
,<start of gradient>
, and<end of gradient>
are RRGGBB format hexadecimal numbers. The default color is applied to countries or states that are not listed in thechld
parameter. The other colors specify the extremes of a color gradient that is used to color all countries listed in thechld
parameter. The color that is applied depends on the country's value in thechd
parameter. To control the gradient further, specify more colors.<country or state codes>
is a list of either of the following:- ISO 3166-1-alpha-2 codes for countries as defined by ISO3166, see ISO 3166 Country codes.
- USA state codes as listed in United States of America state codes.
<color levels>
are text encoding, simple encoding, or extended encoding values. Text encoding with data scaling is not available for maps. The first value is used for the first country listed in thechld
parameter, the second value is used for the second country listed, and so on. The lowest data value (A
,0
, orAA
depending on the type of encoding used) is drawn in the color specified by<start of gradient>
inchco
. The highest value (9
,100
, or..
) is drawn in the color specified by<end of gradient>
. Intermediate values give intermediate colors.
For example:
chtm=africa
chco=FFFFFF,FF0000,FFFF00,00FF00
chld=DZEGMGAOBWNGCFKECGCVSNDJTZGHMZZM
chd=t:0,100,50,32,60,40,43,12,14,54,98,17,70,76,18,29
chf=bg,s,EAF7FE
In this example:
- The first color is
FFFFFF
, which specifies white. This color is used for any country not listed in thechld
parameter. - The other colors specify a color gradient from red, through yellow, to green.
- The first country listed is Algeria (
DZ
). The first value listed is0
. Therefore, Algeria is drawn with the color at the beginning of the gradient, and appears in red. - The second country listed is Madagascar (
MG
). The second value listed is100
. Therefore, Madagascar is drawn with the color at the end of the gradient, and appears in green. - The third country listed is Egypt (
EG
). The third value listed is50
. Therefore, Egypt is drawn with the color that lies midway across the gradient. The gradient is specified as going from red, through yellow, to green. Egypt appears in yellow. - Water masses are considered to be the map's background. They are drawn in pale blue (
EAF7FE
), as specified in thechf
parameter. See Chart area and background fill for more details on background colors.
Google-o-meters
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. See Chart colors for information on specifying other colors. See Google-o-meter labels for information on specifying the text that appears at the end of the arrow. |
|
QR codes
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 URL, contact information, telephone number, even whole verses of poems!
QR codes can be read by any device that has the appropriate software installed. Such devices range from dedicated QR code readers to mobile phones.
Specify a QR code with
cht=qr
chl=<text to encode>
choe=<output encoding>
Where:
<text to encode>
is the text for the QR code. The text must be url-encoded in UTF8. Note that the space betweenhello
andworld
is written as%20
in the following example.<output encoding>
specifies how the output is encoded. If this parameter is omitted, the default encoding ofUTF-8
is used. Available encodings areShift_JIS
,UTF-8
, orISO-8859-1
.
For example:cht=qr
chl=hello%20world
choe=UTF-8
The example QR code above is the simplest possible type of QR code, and is known as Version 1. It has 21 rows and 21 columns.
- Version 1 has 21 rows and 21 columns, and can encode up to 25 alphanumeric characters
- Version 2 has 25 rows and 25 columns, and can encode up to 47 alphanumeric characters
- Version 3 has 29 rows and 29 columns, and can encode up to 77 alphanumeric characters
- ...
- Version 40 has 177 rows and 177 columns, and can encode up to 4,296 alphanumeric characters
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 may be modified by the error correction (EC) level you choose to use.
Don't confuse the number of rows and columns with size of the QR code image. 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).
Error correction and margins
Four levels of error correction (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 error correction for codes where up to 30% of the code cannot be read. The number of characters that can be encoded decreases as the EC level increases. See Versions, error correction and maximum characters for details.
The default margin is 4 modules. This means that a blank space equivalent to four rows at the top and bottom and four columns on the left and right is 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 the following: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.
Versions, error correction and maximum characters
Before generating your QR code, consider what kind of device is used to read your code. The best QR code readers are able to read Version 40 codes, mobile devices may read only up to Version 4.
See the following table for information on maximum number of 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 |
Further information and standards
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:
- AIM International (Automatic Identification Manufacturers International) standard (ISS - QR Code) in October 1997.
- JEIDA (Japanese Electronic Industry Development Association) standard (JEIDA-55) in March 1998.
- JIS (Japanese Industrial Standards) standard (JIS X 0510) in January 1999.
- ISO international standard (ISO/IEC18004) in June 2000.
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.