Friday, December 07, 2007

.NET wrapper for Google Chart API

As you may know, Google created a simple and easy way to dynamically generate charts to use in web projects with the new Google Chart API.

I started a project to wrap the library to simplify usage of it in .NET projects.

As example - say, you need to visually compare two line charts:

Chart chart = new Chart(ChartType.Line,
                          new ChartSize(200, 125),
                          new ChartData(new int[][]
                                            {
                                                new int[] { 0, 1, 25, 26, 51, 52, 61, 1 },
                                                new int[] {7, 12, 60, 57, 4}
                                         }),
                          new Color[] { Color.DodgerBlue, Color.Gainsboro });
return chart.ToString();

It will generate the following url:

http://chart.apis.google.com/chart?cht=lc&chs=200x125&chd=s:ABZaz09B,HM85E&chco=1E90FFFF,DCDCDCFF

And the generated url shows the following chart:

Generated chart

Labels: , , , , , , , ,

2 Comments:

Blogger Unknown said...

Thank you for the class library. So far it has been helpful.

I am trying to make a similar two line line graph like the one you have shown here. However, I'm getting the error "NGChart.Chart does not contain a constructor that takes 4 arguments.

What should I do?

12:03 PM  
Blogger digizzle said...

Hi John,

Actually, the library is under development, and the sample in my post is obsolete now.

Could you check the samples page for correct syntax?

http://code.google.com/p/ngchart/wiki/NGChartSamples


Please, let me know if it did not solved the problem.

- Eugene

3:04 AM  

Post a Comment

<< Home