I want to display the club name and the number of children from the table below in a piechart
Here is the behind code for the PieChart webform I have created:
public partial class PieChart : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
string club_name;
int no_children;
public int TargetClub_No()
{
string CS = ConfigurationManager.ConnectionStrings["dbyouthworkConnectionString"].ConnectionString;
using (MySqlConnection con = new MySqlConnection(CS))
{
MySqlCommand cmd = new MySqlCommand("SELECT no_children, club_name FROM pie_chart WHERE club_name = 'Target Club'", con);
con.Open();
MySqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
club_name = rdr["club_name"].ToString();
no_children = Convert.ToInt32(rdr["no_children"]);
}
return no_children;
}
}
}
I have already downloaded the js.chart file and jquery file
Here is the code in the PieChart.aspx file I have created :
<body>
<form id="form1" runat="server">
<canvas id="mycanvas" width="256" height="256"></canvas>
<script>
$(document).ready(function () {
var ctx = $("#mycanvas").get(0).getContext("2d");
// pie chart data
var t = <% TargetClub_No(); %>;
var data = [
{
value: t,
color: "cornflowerblue",
highlight: "lightskyblue",
label: "Target Club"
},
{
value: 50,
color: "lightgreen",
highlight: "yellowgreen",
label: "Lightgreen"
},
{
value: 40,
color: "orange",
highlight: "darkorange",
label: "Orange"
}
];
//draw
var piechart = new Chart(ctx).Pie(data);
});
</script>
<div>
</div>
</form>
*Here I have firstly tried to input the number of children from target club however when I run the code I get a blank page instead of a pie chart
SCREEN SHOTS USING DEV TOOLS IN CHROME:
This one shows that I have done something wrong in calling 'public int TargetClub_No()'

Here is the screen shot of the networks tab:

Not sure what this tab means though...
