I want create a pie chart on my web page. I read data from my database and set them in two variable credit and remain_cost.
I want show a pie chart with that two values. And I find a pie chart that created with DevExpress company.
This is my asp.net code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>chart</title>
<meta charset="utf-8" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/globalize/0.1.1/globalize.min.js"></script>
<script type="text/javascript" src="http://cdn3.devexpress.com/jslib/14.1.7/js/dx.chartjs.js"></script>
<script>
var pieChartDataSource = [
{ category: 'Credit', value: 44 },
{ category: 'reamaincost', value: 34 },
];
$(function () {
$("#pieChartContainer").dxPieChart({
dataSource: pieChartDataSource,
series: {
argumentField: 'category',
valueField: 'value',
label: {
visible: true,
connector: {
visible: true
}
}
},
tooltip: {
enabled: true,
percentPrecision: 2,
customizeTooltip: function (value) {
return {
text: value.percentText
};
}
},
title: {
text: 'user over view'
},
legend: {
horizontalAlignment: 'center',
verticalAlignment: 'bottom'
}
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<div>
<asp:Literal ID="credittxt" runat="server" /> <br /> <asp:Literal ID="remain_costtxt" runat="server" />
<asp:TextBox runat="server" ClientIDMode="Static" ID="txt" />
</div>
<div id="pieChartContainer" style="height:400px; max-width:700px; margin: 0 auto"></div>
</div>
</form>
</body>
</html>
and this is my code behind:
protected void Page_Load(object sender, EventArgs e)
{
DataSet1.usersDataTable ousersDataTable = new DataSet1.usersDataTable();
DataSet1TableAdapters.usersTableAdapter ousersTableAdapter = new DataSet1TableAdapters.usersTableAdapter();
ousersTableAdapter.FillBysip(ousersDataTable, "my_data");
DataSet1.usersRow ousersRow = ousersDataTable[0];
string credit = ousersRow.credit.ToString();
string remain_cost = ousersRow.schduled_cost.ToString();
credittxt.Text = credit;
remain_costtxt.Text = remain_cost;
txt.Text = credit;
}
The data successfully appeared in literal and text box control.
My question is that I want set the credit value in c# to credit value in jQuery and remain _cost in c# to remain_cost variable in jQuery.
Please help me.
Page.ClientScript.RegisterHiddenField("HiddenField", (string) Session["C#ValueInputforJquery"]);