Google Chart API Truly Awesome!!!!!

My friend blogged about Google Chart API. You can read his post. 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 grades = new List;             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(",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!

This article is part of the GWB Archives. Original Author: Mohammad Azam

New on Geeks with Blogs

  • We Won The One Award I Actually Care About

    Full Scale made the Inc. 5000 for the fifth year straight, the 12th listing across my three companies. Here is why the one award you cannot buy is worth stopping for.

  • Your Customers Build the Features Now

    I let a tool I liked sit dead for a year rather than build the features I wanted. An MCP server meant I never had to, and your customers can do the same to your product.

  • Get the Size of a Directory in Linux the Easy Way

    du -sh for the quick answer, ncdu for the cleanup, df for the disk itself: every command for checking directory size in Linux, plus why du and df never agree.

  • Vim Search and Replace: The Ultimate Guide

    One :%s command replaces every match in a file before a find dialog would even open. The Vim substitute patterns worth the muscle memory: flags, ranges, capture groups, and multi-file edits.