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!

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 United Kingdom

5/22/2009 4:11:50 AM

Carla

Winform applications can be really nice and handy.

Carla United States

5/27/2009 8:30:39 PM

thatcom

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

thatcom United States

7/6/2009 4:18:51 PM

Michael

Thanks a lot for this post

Michael

7/7/2009 5:04:03 PM

Jackson

Great post - keep it up man Smile

Jackson

7/10/2009 3:06:57 AM

solar

Finally a blog that im interisted in. Thanks

solar United States

7/10/2009 4:27:40 PM

onlinegambling

Good post and nice design, is this a regular template?

onlinegambling United States

7/10/2009 6:43:13 PM

Electronics

Quite an interesting post. It was quite new to me.

Electronics United Kingdom

7/10/2009 9:03:31 PM

Dana

where can I get this?

Dana United States

7/11/2009 2:59:00 AM

Call Center Services

Great blog, I've just bookmarked it in Internet Explorer. Thanks for sharing.

Call Center Services United Kingdom

7/11/2009 12:43:11 PM

Welborn

this is the only working private profile viewer

Welborn United States

7/11/2009 1:10:38 PM

Peter

Great post - Just subscriped to your RSS feed.. Thanks

Peter United States

7/11/2009 2:33:20 PM

tf2 pyro hat

nice post, good decent blog here.

tf2 pyro hat United States

7/12/2009 11:27:05 AM

Roof Contractor

Very interesting post - Might be old new, but it was new to me. Thanks.

Roof Contractor United States

7/12/2009 10:13:10 PM

Mahommad

thanks for the great info. bookmarked will come back often

Mahommad United States

7/13/2009 10:16:10 AM

Make Money on the Internet

I remember reading about this post. Took me 15 minutes just to find this again in Google.

Make Money on the Internet United States

7/14/2009 9:45:35 PM

Unblock Myspace

http://www.unlockprivateprofiles.com works great

Unblock Myspace United States

7/15/2009 2:28:07 AM

Sex Search Engine

Nice blog, just bookmarked it for later reference.  http://www.mrstiff.com

Sex Search Engine

7/15/2009 8:14:41 AM

Harry Potter

best harry potter movie yet

Harry Potter United States

7/15/2009 11:32:32 AM

GSM telefoon

Nice blog, just bookmarked it for later reference.  http://www.je06.com

GSM telefoon

7/15/2009 4:42:41 PM

Harry Potter Movie

is this a custom theme by chance?

Harry Potter Movie United States

7/16/2009 5:21:22 AM

DUDE

can i do the same example but with double and not with int??? i tried to do it but when i set line1 as double it apears to be a problem with
lineChart.SetData(line1);
which only takes int.

anybody knows what i have to do???

sorry for my english

DUDE Greece

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