Microsoft Most Valuable Professional

Chris Pietschmann

An MVP From Wisconsin



Google Charts API: an ASP.NET 2.0 Server Control

Today, I just saw that Google released their Chart API. Basically, the Google Chart API allows you to dynamically generate charts for use in your web applications. All you do is pass your data in the querystring and an image is returned. This isn't really a service to get too excited about, but it is pretty simple to use. And, it's Free.

I decided to code up a small ASP.NET Server Control that uses the Google Chart API to put simple line graph charts on a page. The image on the right is actually a screenshot I took after using my new control to add a couple charts to a page.

How to use this control:

Put the Chart control on the page:

<GoogleAPI:Chart runat="server" id="Chart1"
Width="200" Height="150" LineColor="ff0000"
BackgroundColor="efefef"
ToolTip="Hello World">
</GoogleAPI:Chart>

In the page load event define the values to be charted

Chart1.MaxValue = 60;

Chart1.Values.Clear();

Chart1.Values.Add("Jan", 10);
Chart1.Values.Add(
"Feb", 20);
Chart1.Values.Add(
"Mar", 30);
Chart1.Values.Add(
"Apr", 50);
Chart1.Values.Add(
"May", 5);
Chart1.YAxisLabels.Add(
"0 Kb");
Chart1.YAxisLabels.Add(
"25+ Kb");
Chart1.YAxisLabels.Add(
"50+ Kb");

And, that's all you have to do to put a Chart on your page using my little control.

Download the Source Code here

This source code is licensed under the Creative Commons Attribution 3.0 United States License.

Currently rated 4.0 by 4 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,
Categories: asp.net | General
Posted by crpietschmann on Friday, December 07, 2007 5:53 PM
Permalink | Comments (4) | Post RSSRSS comment feed

Related posts

Comments

OmegaSupreme

Sunday, December 09, 2007 6:37 AM

OmegaSupreme

That was quick ! Nice work.

BD

Tuesday, February 05, 2008 6:04 AM

BD

Nice jobs.

notgartner.wordpress.com

Thursday, March 06, 2008 10:48 AM

pingback

Pingback from notgartner.wordpress.com

I just implemented IE8 WebSlices in an internal application - three minutes. « notgartner

gringod.com

Friday, March 07, 2008 10:38 AM

pingback

Pingback from gringod.com

GrinGod [dot] Com » Blog Archive » Google Charts API for .Net 2.0

Comments are closed

About the author

I'm Chris Pietschmann, go to the About Me page to learn more about me.

Search

Sponsors

Web.Maps.VE - ASP.NET AJAX Virtual Earth Mapping Server Control

Recent comments

Disclaimer


This work is licensed under a Creative Commons Attribution 3.0 United States License, unless explicitly stated otherwise within the posted content.
© Copyright 2004 - 2008 Chris Pietschmann