ASPX PAGE
]]>
<asp:content id="Content1" contentplaceholderid="HeadContent" runat="Server" xmlns:asp="#unknown">
<asp:content id="Content2" contentplaceholderid="MainContent" runat="Server" xmlns:asp="#unknown">
<%----%>
google.load('visualization', '1', { packages: ['corechart'] });
]]>
$(document).ready(function () {
$.ajax({
type: 'POST',
dataType: 'json',
contentType: 'application/json',
url: 'Default6.aspx/GetData',
data: {},
success:
function (response) {
drawVisualization(response.d);
}
});
})
function drawVisualization(dataValues) {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Column Name');
data.addColumn('number', 'Column Value');
for (var i = 0; i < dataValues.length; i++) {
data.addRow([dataValues[i].ColumnName, dataValues[i].Value]);
}
new google.visualization.PieChart(document.getElementById('visualization')).
draw(data, { title: " JQuery Charts Example" });
}
#todate
{
z-index: 1;
left: 577px;
top: 115px;
position: absolute;
width: 104px;
height:16px;
}
#fromdate
{
z-index: 1;
left: 276px;
top: 115px;
position: absolute;
width: 104px;
height:16px;
}
style="color:#000066; z-index: 1; left: 795px; top: 112px; position: absolute; height: 26px; width: 66px;";
id="go" value="GO" onmouseover="true" title="Click here to get details."/>
<asp:label id="Label1" runat="server" text="to Date">
style="z-index: 1; top: 116px; position: absolute;font-family: 'Tahoma'; left:474px;" Font-Bold="True"
ForeColor="#006697" Font-Size="Small">
<asp:label id="Label2" runat="server" text="from Date">
style="z-index: 1; left: 168px; top: 116px; position: absolute; font-family: 'Tahoma'; width: 101px;" Font-Bold="True"
ForeColor="#006697" Font-Size="Small">
CS PAGE
using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using MySql.Data.MySqlClient;
using System.Web.Script.Serialization;
public partial class Default6 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[WebMethod]
public static List<Data> GetData()
{
List<Data> dataList = new List<Data>();
MySqlConnection con = new MySqlConnection("Server=localhost;Port=3306;Database=projecttt;UID=root;Pwd=techsoft;pooling=false");
string s = string.Empty;
s = "select name,marks from jqchart";
{
MySqlCommand cmd = new MySqlCommand(s, con);
{
con.Open();
cmd.ExecuteNonQuery();
MySqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
string a=dr[0].ToString();
string b = dr[1].ToString();
dataList.Add(new Data(a,int.Parse(b)));
}
return dataList;
}
}
}
public class Data
{
public string ColumnName = "";
public int Value = 0;
public Data(string columnName, int value)
{
ColumnName = columnName;
Value = value;
}
}
}