ChartAPI.org logotype

ChartAPI.org


Developer's Guide

ChartAPI.org lets you generate charts for your web site. To illustrate how the API works, please copy and paste the following URL into your browser's address bar:

http://api.chartapi.org/chart?s=200x200&t=pie1&d=30,25,45&l=Yes|No|Not%20sure

The following chart should appear in your browser:

Example chart

Terms and Conditions

Using the chart API is free, both for commercial and non-commercial use. You must however link back to chartAPI.org. The link must be placed nearby the generated chart. See the chart to right for an example.
If your service will make more than 25000 API calls per day, please send your estimate to support@chartapi.org.

The Basics

ChartAPI.org generates a .png chart image based on a URL. You can specify a number of parameters, such a the image size, colors and labels. Each parameter is separated by the & character. For example, the URL below generates an image that is 200x200 pixels (s=200x200), it is a pie chart (t=pie1) and the data values are 30, 25, 45 (d=30,25,45). The URL also specify three labels, "Yes", "No" and "Not sure" (l=Yes|No|Not%20sure).

http://api.chartapi.org/chart?s=200x200&t=pie1&d=30,25,45&l=Yes|No|Not%20sure

You can embed the chart in a HTML document with the img tag. For example:

<img src="http://api.chartapi.org/chart?s=200x200&amp;t=pie1&amp;d=30,25,45&amp;l=Yes|No|Not%20sure" />

Please note that you should use &amp; to separate the parameters while embedding the chart in a HTML document.

Chart Types

Pie chart

The following table shows the pie chart parameters:

ParameterDescriptionExample
t The chart type. Use pie1 for this chart. Required. t=pie1
s Size of the resulting .png image in pixels. Required. s=200x150
d The data values separated with commas. Required. d=30,25,45
l Labels separated by the | character. l=Yes|No
r Pie radius in pixels. The default value is 50. r=65
p The pie's center position in pixel. The default value is 100,100. p=75,95
lc Color of the lines that separate the pie sectors. lc=ffffff
dc Color of the pie sectors. If the number of colors are less than the number of sectors the colors are interpolated. dc=ff3333,ff9999,ffcccc
sa The initial rotation of the pie chart in degrees. sa=90
jlc The color of the join lines that connect labels and sectors. jlc=808080
ll The label layout. There are two layouts for the labels. The "circle layout", specified with ll=1, where sector labels are positioned around the perimeter of the pie. This is the default layout. The other label layout mode is "side layout", specified with ll=0, where labels are placed only on the left and right side of the chart to avoid overlapping labels. Since labels with this label layout may be far away for the sectors, it is recommended to set the join line color to connect them. ll=0

Pie Chart Examples

Pie chart example

Work in Progress

Just to let you know, I'm currently working on adding more chart types, such as a bar chart, a sparkline chart and a 3D pie chart. To get notification about the updates, please RSS feed icon subscribe to the updates feed.

About

ChartAPI.org is developed and developed and maintained by Roger Karlsson. The ChartAPI.org back-end is based in part on the work of the Independent JPEG Group and the FreeType Team. The ChartAPI.org logotype is created by Goce Mitevski.

Revision History

04 Feb 2009

A new layout mode for pie charts has been added to reduce the risk of overlapping labels. Users can also specify the join line color and set the initial rotation angle of the pie chart.

09 Dec 2008

ChartAPI.org is live!