Display google chart on your C# application
1.Down load and build this project on your machine http://googlechartsharp.googlecode.com/files/GoogleChartSharp-1.0.2-source.zip or download this project from this url http://code.google.com/p/googlechartsharp/.
2. Create a new project and copy bin folder of above project.
2. Create image or drag and drop image on your page and name "pictureBox1". (
asp:image id="pictureBox1" runat="server)
3 code Behind
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using GoogleChartSharp;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
pictureBox1.ImageUrl = SimpleGrid();
}
public static string SimpleGrid()
{
// Instantiate the chart object
LineChart lineChart = new LineChart(350, 250);
// Values to be charted
int[] line1 = new int[] { 5, 10, 50, 34, 10, 25, 50, 0 };
// Set chart title using default color and font
lineChart.SetTitle("Step Size Test");
// This is a x and y axis chart. Create two new axis objects
lineChart.AddAxis(new ChartAxis(ChartAxisType.Left));
lineChart.AddAxis(new ChartAxis(ChartAxisType.Bottom));
// Load the chart with the dataset (line int array)
lineChart.SetData(line1);
// Add a grid to the chart (dotted grid lines)
lineChart.SetGrid(20, 50);
// retuns the FQDN of the chart
return lineChart.GetUrl();
}
}
1 comment:
Thanks a lot i cudnt find this tutorial anywhere it really helped :)
Post a Comment