Template:Pie chart/doc

Usage
The labels and values of up to 30 slices may be specified. All the parameters for six slices are included below; to include more slices, copy the code for one of the others, changing the digit at the end of each parameter name.

• # {{legend|#a6cee3|light blue}}
 * The parameter thumb specifies which side of the page the chart is floated to and defaults to, as with image files. To make the chart appear on the left side of the page, specify left.
 * The parameter caption specifies a string of text that appears on a line just before the legend.
 * The parameter other, if specified, will cause an "Other" item to appear in the legend.
 * Each labelN is a string of text that appears in the legend entry for a slice. Omitting it will cause a legend entry to not be shown for that slice.
 * Each valueN is the percentage that the slice represents. Do not include the percent sign. Also note that it is shown in the legend as written (just after the label), without any rounding or other reformatting.
 * Each colorN is a CSS color code or name. If omitted, it will default to the following hues:

• # {{legend|#1f78b4|strong blue}}

• # {{legend|#b2df8a|light green}}

• # {{legend|#33a02c|strong green}}

• # {{legend|#fb9a99|fuchsia}}

• # {{legend|#e31a1c|red}}

• # {{legend|#fdbf6f|light orange}}

• # {{legend|#ff7f00|strong orange}}

• # {{legend|#cab2d6|light purple}}

• # {{legend|#6a3d9a|strong purple}}

• # {{legend|#ffff99|light yellow}}

• # {{legend|#b15928|brown}}

Limitations

 * Minor issues with printing exist. We also need to implement a good fallback for use with the Wikipedia book tool.
 * The values need to be percentages.
 * Google Chrome and Safari do not appear to anti-alias borders, so the lines are a bit jagged. (For Chrome, this issue seems to be resolved; tested with version 26.)
 * No labels can be put on the slices themselves.
 * Inherently, it is not possible to save a copy of the chart using the browser's "Save Image" function.
 * Max. number of slices that can be displayed: 30

How it works
This is an experimental template that draws pie charts using a single image, a lot of (inline) CSS code generated by parser functions, and absolutely no JavaScript. It uses a technique for drawing diagonal lines in CSS exploiting the fact that borders set on elements are miter joined. Thus, it is possible to set one border to an opaque color, with the others fully transparent, to form a diagonal line. The angle of the line can be controlled by adjusting the widths of two adjacent borders (one of them opaque) relative to each other.

Pie slices are drawn in clockwise order in a counterclockwise direction. These pie slices are positioned: This allows only the part of each slice that is inside the circle to be visible on the page.
 * Inside a square element of 200x200 pixels
 * with  for a circular shape
 * with a white background (visible in the empty space that occurs if the "other" slice is present)
 * and with  set.

Most of the code in is divided into five sections, the first four corresponding to quadrants of the circle and the last to cleanly cover the case in which one slice occupies 100% of the chart.

Example
The following example of Template:Pie chart generates the pie chart shown at right. 