Java Reference
In-Depth Information
cause that API also needs a “Hello, World” example, here's the URL for a three-dimen-
sional pie chart:
https://chart.apis.google.com/chart?
cht=p3&
chs=250x100&
chd=t:60,40&
chl=Hello|World
This URL would be all on one line but is written out here (and in the documentation) for
illustration purposes. After the base URL, the parameters list the chart type ( cht ) as a 3D
pie chart, the chart size ( chs ) as 250 by 100 pixels, the chart data ( chd ) as 60 and 40 in
simple text format, and the chart labels ( chl ) “Hello” and “World.” Type that URL into a
browser and the resulting image is returned, as shown in figure 2.1 .
Figure 2.1. The Google Chart API “Hello, World” example
The URL shown is hard-wired to produce the chart in figure 2.1 . To make this more gener-
al, I'll show how to produce the URL from strings, lists, maps, closures, and builders.
GOAL
Write a Groovy script to generate the “Hello, World” 3D pie chart as a desktop application.
In the process, I'll discuss
• String manipulation
• Lists and maps
• Processing data using closures
• Groovy builder classes
 
Search WWH ::




Custom Search