I was playing around with the excellent Google Chart API and I wanted to illustrate just how crazy simple it is to
implement 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!