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: line, bar, and pie charts for example. 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.
| 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 100.0, minus
one (-1),
and the pipe character (|).
Note:
0.0) = 0, 1.0 = 1 and so on up to 100.0 =
100.-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 (,).
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 (,).
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. 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 section 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 axes lines are not drawn for sparklines by default. You can add axes labels if you wish, see section Multiple axis labels.
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 series. 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 section 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 section 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 section 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.
| Parameter | Description | Example |
|---|---|---|
|
Here's a simple example to get started with. Data points are drawn between the center of the chart and the
perimeter. Points of value zero ( The first and last values in the data series are drawn between the center of the chart and the top of the chart. All others are evenly spaced traveling clockwise around the chart. |
|
|
|
Here's a much more interesting example. This chart has two data sets, the color of each is specified with Line styles are specified with 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 is the same example as the one above but with fill area specified for both data sets. See Fill area for more information. Also, a grid is specified, see section Grid lines for more information.
|
chg=25.0,25.0,4.0,4.0 |
|
This example has shape markers specified:
See sections Shape markers and Colors for information. You can also specify range markers. See section 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 section 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. |
|
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 series 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. zz | 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 series, 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=First|Second|Third |
|
For a pie chart specify labels with
chl=
<label 1 value>|
...
<label n value>
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. |
|
Of course, this depends on 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 |
|---|---|---|
|
This example shows two lower x-axes ( Note: Because axis labels are omitted the Chart API assumes a range of 0 to 100 for all axes. |
|
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 |
|---|---|---|
|
This example shows left and right y-axes ( Note: the pipe character ( |
|
As above except left y-axis labels ( Note: the pipe character ( |
|
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 ( The right y-axis ( |
|
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. Note: Axis
direction is reversed for the left y-axis ( |
chxt=x,y,r |
Here only the x-axis is defined ( |
chxl=0:|200|300|400 |
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. | chxt=x,y,r,x |
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 | Example |
|---|---|---|
|
An example where only step size is defined ( |
|
Here step size ( |
|
|
A solid grid is achieved by specifying a blank segment of zero ( |
chg=20,50,1,0 |
For line charts, radar charts, bar charts, and scatter plots specify
shape markers, horizontal, and vertical range markers with chm
Specify shape markers with
chm=
<marker type>,<color>,<data set index>,<data point>,<size>,<priority>|
...
<marker type>,<color>,<data set index>,<data point>,<size>,<priority>
Where:
<marker type> is one of the following characters:a represents an arrow.c represents a cross.d represents a diamond.o represents a circle.s represents a square.t represents text.v represents a vertical line from the x-axis to the data point.V represents a vertical line to the top of the chart.h represents a horizontal line across the chart.x represents an x shape.<color> is an RRGGBB format hexadecimal number.<data set index> the index of the line on which to draw the marker. This is 0 for the first data set, 1 for the second and so on. <data point> for all markers except a horizontal
line, this is a floating point value that specifies on which data point
the marker will be drawn. This is 0 for
the first data point, 1 for the second and so on. Specify
a fraction to interpolate a marker between two data points. For a horizontal
line see the first example in the following table.<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 marker is drawn before all other parts of
the chart. This means the marker will be hidden if another chart element
is drawn in the same place.0 is the default and specifies the marker is drawn on top
of bars or lines and beneath other markers.1 specifies the marker is drawn on top of all other parts
of the chart. This means it will hide another chart element if it is
drawn in the same place. Separate multiple markers with the pipe character (|).
| Parameter | Description | Example |
|---|---|---|
|
Here's an example of the full set of shape and line markers. The last marker in the list, |
|
Here's an example of marker type See the Scatter plot section for details on setting the size of each data point. |
|
|
Here's an example using diamonds and circles for two data sets. If two data points occupy the same place (by having the same x and y values), the first point specified is drawn. Here the circle takes precedence over the diamond. |
chm= |
|
|
Here's a bar chart with text as a marker. Specify text markers in the same order as your data. There is an optional fifth value that determines priority:
|
chm= |
For line charts, radar charts, bar charts, and scatter plots specify horizontal and vertical range markers with
chm=
<r or R>,<color>,<any value>,<start point>,<end point>|
...
<r or R>,<color>,<any value>,<start point>,<end point>
Where:
<r or R> is r for a horizontal range and R for a vertical range.<color> is an RRGGBB format hexadecimal number.<any value> is ignored. <start point> for:0.00 is the bottom and 1.00 is the top.0.00 is the left and 1.00 is the right.<end point> for:0.00 is the bottom and 1.00 is the top.0.00 is the left and 1.00 is the right. Separate multiple range markers with the pipe character (|).
| Parameter | Description | Example |
|---|---|---|
|
Range markers can be a single line or a band of color. Here the first marker is a pale blue ( |
r,E5ECF9,0,0.75,0.25| |
chm=R |
Here's the same example for vertical range markers. In this case, the first marker is a line in red (ff0000) while the second is a pale blue (A0BAE9) band. |
R,ff0000,0,0.1,0.11| |
chm= |
You can mix horizontal and vertical range markers. Note that the last marker specified takes precedence over previous markers if they overlap. Here the horizontal markers are specified last - so they are drawn over the top of the vertical markers. |
|
chm=r |
Here's a sparkline that combines faint horizontal lines with chart labels on the right hand y-axis. | |
Simple encoding mapping is provided below.
| Character | Value |
|---|---|
| A | 0 |
| B | 1 |
| C | 2 |
| D | 3 |
| E | 4 |
| F | 5 |
| G | 6 |
| H | 7 |
| I | 8 |
| J | 9 |
| K | 10 |
| L | 11 |
| M | 12 |
| N | 13 |
| O | 14 |
| P | 15 |
| Q | 16 |
| R | 17 |