A Google Chart API Custom Server Control

Category: ASP.NET Questions    |    6 views

Last week’s article, Creating Charts with the Google Chart API, looked at how
to use Google’s free Chart API to generate line, pie, bar, and other types of charts from an ASP.NET page. The Google Chart API is callable via a
URL that contains the chart type, size, data, and other parameters in the querystring and returns the chart as an image. Displaying a chart
using this API is as simple as adding an Image Web control to a page and setting its ImageUrl property to the Google Chart API URL with
an appropriately formatted querystring.

Last week’s article explored the essential querystring parameters and provided an example on how to programmatically
construct this querystring to plot data from a database query. In a nutshell, constructing this querystring involved about 50 lines of code
to get the data, express the data as percentages relative to one another, and build up the other parameters. Wouldn’t it be much easier if we could
create a chart by dropping a Google Chart API Web control on the page, set a few properties, and then bind it to a data source control, like a
SqlDataSource or ObjectDataSource? That way we could create and display charts using the Google Chart API without having to write a lick of code.

Over the past week I built such a Web control. The Web control does not provide the full suite of Google Chart API features - it only allows for the
creation of line, bar, and pie charts, and it only allows a single data series - but it makes creating and displaying data-driven charts as easy as
drag-and-drop and point-and-click. This article shows how to use this free custom server control and highlights some of its more interesting aspects.
You can download the compiled server control, its complete source code, and a demo application at the end of this article. Read on to learn more!

Read More >

Share/Save/Bookmark

1 Star2 Stars
Loading ... Loading ...

0 responses so far!

Leave a Comment

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word