O'Reilly logo

Supercharged JavaScript Graphics by Raffaele Cecco

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Image Charts

Image charts are designed to allow nonprogrammers with no JavaScript knowledge to create impressive-looking chart images. If you know a little HTML, you can use image charts. In contrast to the interactive charts API, there is no need to include any special JavaScript libraries, as the chart is requested from the Google chart servers with a regular URL request. Figure 8-5 shows the results of the following HTML page:

<html>
    <body>
        <img src = 'https://chart.googleapis.com/chart?
            cht=p3&chd=t:60,40&chs=500x250&chl=Hello|World'/>
    </body>
</html>
Image charts require nothing more than a simple URL request to yield impressive results

Figure 8-5. Image charts require nothing more than a simple URL request to yield impressive results

Not bad for such a short piece of code. However, constructing the URL can be a complicated and unintuitive process. Thankfully, if you are using charts where the data set is static (unchanging values that are known beforehand), Google has provided a useful Chart Wizard that makes the process of creating image chart URLs a whole lot easier (Figure 8-6). You can find the Chart Wizard at http://code.google.com/apis/chart/docs/chart_wizard.html.

Note

In the Google Chart Wizard, a data series is referred to as a data set.

You want charts? You’ve got charts galore—and more—with Google’s Chart Wizard (for image charts).

Figure 8-6. You want charts? You’ve got charts galore—and more—with Google’s Chart Wizard (for image charts).

Although the Chart ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required