Google Chart C# API

B3y steven 2/3/2008 9:45:00 PM

I was playing around with the excellent Google Chart API and I wanted to illustrate just how crazy simple it is to ScreenShot013implement this, even on a WinForm app (see nifty screen capture ->).

First grab the Google C# API Wrapper source code. Then take and unzip that and open that project in Visual Studio and compile the DLL. Then add a new Windows Application Project to the solution, drag a new PictureBox on the form, and then paste this into Form1.cs:

   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.ComponentModel;
   4:  using System.Data;
   5:  using System.Drawing;
   6:  using System.Text;
   7:  using System.Windows.Forms;
   8:  using GoogleChartSharp;
   9:   
  10:  namespace Tester
  11:  {
  12:      public partial class Form1 : Form
  13:      {
  14:          public Form1()
  15:          {
  16:              InitializeComponent();
  17:          }
  18:   
  19:          private void Form1_Load(object sender, EventArgs e)
  20:          {
  21:              // Set the image to be directly loaded from the FQDN of the chart
  22:              this.pictureBox1.ImageLocation = SimpleGrid();            
  23:          }
  24:   
  25:          public static string SimpleGrid()
  26:          {
  27:              // Instantiate the chart object
  28:              LineChart lineChart = new LineChart(250, 150);
  29:   
  30:              // Values to be charted
  31:              int[] line1 = new int[] { 5, 10, 50, 34, 10, 25 };
  32:   
  33:              // Set chart title using default color and font
  34:              lineChart.SetTitle("Step Size Test");
  35:              
  36:              // This is a x and y axis chart. Create two new axis objects
  37:              lineChart.AddAxis(new ChartAxis(ChartAxisType.Left));
  38:              lineChart.AddAxis(new ChartAxis(ChartAxisType.Bottom));
  39:              
  40:              // Load the chart with the dataset (line int array)
  41:              lineChart.SetData(line1);
  42:   
  43:              // Add a grid to the chart (dotted grid lines)
  44:              lineChart.SetGrid(20, 50);
  45:   
  46:              // retuns the FQDN of the chart
  47:              return lineChart.GetUrl();
  48:          }
  49:   
  50:      }
  51:  }
  
Super simple. Good stuff indeed.
 
Enjoy!

Currently rated 4.0 by 7 people

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

Tags: , ,

Comments

2/4/2008 1:14:04 PM

pingback

Pingback from code-inside.de

Wöchentliche Rundablage: ASP.NET, ASP.NET MVC, System.AddIn, Silverlight, LINQ, C# 3.0, WPF, XBAP… | Code-Inside Blog

code-inside.de

2/5/2008 7:24:13 AM

pingback

Pingback from alvinashcraft.com

» Daily Bits - February 5, 2008 Alvin Ashcraft’s Daily Geek Bits: Daily links, development, gadgets and raising rugrats.

alvinashcraft.com

2/5/2008 2:21:29 PM

pingback

Pingback from weblogs.asp.net

Link List: jQuery, WF, WCF, OOP and Patterns, ASP.NET, Scrum,... - Guru Stop

weblogs.asp.net

2/5/2008 6:46:43 PM

pingback

Pingback from vincenthomedev.wordpress.com

Developer’s Guide - Google Chart API « vincenthome’s Software Development

vincenthomedev.wordpress.com

2/11/2008 9:18:27 AM

pingback

Pingback from mhinze.com

4 Links Today (2008-02-11)

mhinze.com

6/5/2008 5:05:21 AM

leo21

chk this out http://visifire.com its making lot of news in the field of charting component.and i found it amazing just take a look

leo21 gb

5/22/2009 4:11:50 AM

Carla

Winform applications can be really nice and handy.

Carla us

5/27/2009 8:30:39 PM

thatcom

Thank you fro the information and for illustrating us the excellent of Google Chart API.

thatcom us

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered By BlogEngine Enhanced with Snapshots

About the author

Steven Hildreth Steven Hildreth
Proof that anyone can setup a blog.

E-mail me LinkedIn Profile

Send mail Sign in

Recent posts