my code is
<script type="text/javascript">
$(document).ready(function () {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Home.aspx/GetData",
data: "{}",
dataType: "json",
success: function (data) {
debugger
AmCharts.makeChart("chartdivACHEAD",
{
"type": "pie",
"pathToImages": "http://cdn.amcharts.com/lib/3/images/",
"balloonText": "[[title]]<br><span style="font-size:14px">[[value]] ([[percents]]%)</span>",
//"depth3D": 7,
"labelRadius": 2,
"labelText": "[[title]]:[[value]]",
"minRadius": 65,
"labelsEnabled": true,
"pullOutOnlyOne": true,
"titleField": "ac_head",
"valueField": "AssetCount",
"fontSize": 9,
"theme": "default",
"allLabels": [],
"balloon": {},
"titles": [],
"dataProvider": [data.d]
}
);
},
error: function (result) {
alert("Error");
}
});
});
</script>
Code behind..
public static UserDetails[] GetData()
{
DataTable dt = new DataTable();
List<userdetails> details = new List<userdetails>();
//string connectionstring = "Data Source=DCS_SERVER;Initial Catalog=DSIM_CLOUD;User ID=sa;Password=sa123;Timeout=200";
string connectionstring = "Data Source=DCS_SERVER\\SQLEXPRESS;Initial Catalog=NugCloudLiveData;User ID=sa;Password=sa123";
SqlConnection con = new SqlConnection(connectionstring);
con.Open();
SqlCommand comm = new SqlCommand("USP_get_HomePage_count", con);
comm.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da = new SqlDataAdapter(comm);
da.Fill(dt);
foreach (DataRow dtrow in dt.Rows)
{
UserDetails user = new UserDetails();
user.ac_head = dtrow["ac_head"].ToString();
user.AssetCount = dtrow["AssetCount"].ToString();
details.Add(user);
}
con.Close();
// }
return details.ToArray();
}
public class UserDetails
{
public string AssetCount { get; set; }
public string ac_head { get; set; }
}</userdetails></userdetails></br>