Geeks With Blogs

@azamsharp
  • azamsharp Anyone done Blackberry development using Blackberry JDE tool? about 6 hours ago
  • azamsharp One person gave a bad review of my app and now the rank fell to the bottom! :( Sad about 9 hours ago
  • azamsharp Coming back to Windows after using Mac exclusively for 6-8 months. Windows feel slow, crappy. Every freaking thing takes time! WTF about 13 hours ago
  • azamsharp Everyone! If you have bought Vegetable Tree app then I would appreciate if you can rate and review the app on the app store. about 1 day ago
  • azamsharp Idea: An iOS hangout on Google hangouts. devs join hangout first come first service basis. Talk about iOS, apps stuff. Everything recorded! about 1 day ago
  • azamsharp @BalestraPatrick A forums within the app so people can post their questions and get answers like a discussion forum. about 1 day ago

AzamSharp Some day I will know everything. I hope that day never comes.

My friend Ben Scheirman blogged about Google Chart API. You can read his post here. The chart API is a URL based API which means you will pass the data in the URL and Google will create a chart for you. This is truly awesome since creating the chart is a pretty hard performance kill operation specially when your chart is very very complex. Delegating this work to Google will save us from the trouble.

Anyway, there are many kinds of graphs that you can plot using the Google Chart API. In the example below I am plotting the vertical bar graph.

Here is the code to create the graph:

 private void CreateChart()
        {

            List<Grade> grades = new List<Grade>();
            grades.Add(new Grade() { Title = "Exam 1", Score = 10 });
            grades.Add(new Grade() { Title = "Exam 2", Score = 30 });
            grades.Add(new Grade() { Title = "Exam 3", Score = 90 });
            grades.Add(new Grade() { Title = "Exam 4", Score = 45 });

            string chartValue = String.Empty;
            string chartScale = String.Empty;

            foreach (Grade grade in grades)
            {
                chartValue += grade.Score + ",";
                chartScale += grade.Title + "|";
            }          

            Image img = new Image();
            img.ImageUrl = String.Format("http://chart.apis.google.com/chart?chs=400x400&chbh=50,100&chd=t:{0}&cht=bvg&chxt=x,y&chxl=0:|{1}|9:|0|10|20|30|50",chartValue.TrimEnd(','),chartScale.TrimEnd('|'));
            panelChart.Controls.Add(img);
            panelChart.DataBind();         

        }

The most important line is the URL that is being populated with the graph scale and values. Check out the graph that is created below:

GoogleChartDemoBarChart

Pretty awesome right!

Posted on Wednesday, December 12, 2007 8:17 AM | Back to top


Comments on this post: Google Chart API Truly Awesome!!!!!

# re: Google Chart API Truly Awesome!!!!!
Requesting Gravatar...
Yes, their charts are pretty cool, especially the map chart. So easy to configure. I will definitely be using their charts for my web projects.
Left by Jeeremie on Jun 06, 2008 5:59 AM

Your comment:
 (will show your gravatar)
 


Copyright © Mohammad Azam | Powered by: GeeksWithBlogs.net | Join free