Geeks With Blogs

@azamsharp
  • azamsharp The WWDC app says that there are new videos but there is nothing under videos!!! about 498 days ago
  • azamsharp Can I post my opinion on iOS 7 Beta or is it under NDA or something? about 498 days ago
  • azamsharp iOS 7 BETA installed successfully! about 498 days ago
  • azamsharp iOS 7 BETA installed! Now restoring! I am on NET10 which uses AT&T network. Hopefully 3G will still work! Lets c.. about 498 days ago
  • azamsharp The missing of button borders in Xcode 5 makes it hard to determine the clickable area. about 498 days ago
  • azamsharp I might wait for iOS to be released before I can put it on my device! Don't want a bricked or unstable device! about 498 days ago
  • azamsharp Android has many features that no one uses, number of versions that no one upgrades to and thousands of apps that no one pays for. about 498 days ago
  • azamsharp Maybe it is just me but the new iOS 7 UI looks like Windows Phone 8 UI! #maybeIamCrazy about 499 days ago
  • azamsharp Anyone using H20 network upgraded to iOS 7 BETA Keep me updated if you face any problems. about 499 days ago
  • azamsharp @merowing_ You already downloaded it! I cannot even load the developer's website! :( about 499 days 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