Google Chart Tools

Overview

Pie charts are good for showing simple proportional part-to-whole information. You can create a single series pie chart, where each series is made of multiple slices, or multi-series, concentric charts.

Each series describes one pie, and each data value specifies one slice. When using nested pie charts (described below), use multiple series.

To display the text associated with a slice, you will have to use either pie chart labels or a chart legend. Pie chart labels are text around the chart with lines pointing toward the slice. Legends are text associated by color.

Labels Legend Labels and Legend

chl=January|February|March|April

chdl=January|February|March|April

chl=January|February|March|April
chdl=30°|40°|50°|60°

Values are displayed relative to each other: so a chart with values 1,2,3 will look the same as a chart with values 100,200,300. However, when using text format data, values greater than 100 are trimmed to 100, so you will need to use text format with custom scaling to display slices greater than 100 properly (use the chds parameter with min/max values of chds=0,<max-slice-size>).

Negative values display as empty slices of the appropriate size.

Chart Types

There are three general types of pie charts that you can create: flat, concentric, or 3D. Specify a pie chart with the following syntax:

Syntax

cht=<chart_type>

Where <chart_type> is one of the the following types:

Parameter Description Example

p

Two dimensional pie chart.

Supply one data series only; subsequent data series are ignored.

By default, pie segment colors are interpolated from dark orange to pale yellow. Specify other colors as described in Series Colors.

Specify labels with chl as described in Pie chart labels.

The Google Chart API calculates the circle's radius from the minimum of width and height specified in the chart size (chs) parameter. If you are including labels, you probably need to specify the size of the width to be twice the size of the height, to ensure that your labels are fully visible.

Two-dimensional pie chart with four segments where segment colors are interpolated from dark to pale orange

cht=p
chs=200x100

p3

A 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.

Three-dimensional pie chart with four segments where segment colors are interpolated from dark to pale orange

cht=p3
chs=250x100

pc

A concentric pie chart.

Supply two or more data series.

Two concentric pie charts with four segments each, where segment colors are interpolated from dark to pale orange

cht=pc
chd=s:Helo,Wrld

All types Negative numbers in data cause "blank" slices. Two concentric pie charts with four segments each, where segment colors are interpolated from dark to pale orange
cht=pc
chd=t:
10,-10,10,-10|
5,-5,5,-5,5,-5,5,-5,5,-5

 http://code.google.com/apis/chart/docs/making_charts.html


posted @ 2011-03-25 17:26  周宏伟  阅读(3975)  评论(0编辑  收藏  举报