Here, we'll discuss about creating a pie chart in asp.net
Step-1: Create a table in your database.
Step-2: Insert your values into your table.
Step-3: Then add a chart control to your page.
Step-1: Create a table in your database.
Step-3: Then add a chart control to your page.
<asp:Chart ID="Chart1" runat="server">
<Series>
<asp:Series Name="Series1"
ChartType="Pie">
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1">
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
Step-4: Then add this code behind method to your page and call this method whenever you want to load your chart.
protected void Load_Chart()
{
SqlConnection con = new
SqlConnection("-------
Your connection string--------“);
SqlCommand com;
com =
new SqlCommand("select ProjectTitle,ProgressPercentage from
Project", con);
DataTable dt = new
DataTable();
SqlDataAdapter da = new
SqlDataAdapter(com);
da.Fill(dt);
Chart1.DataSource
= dt;
Chart1.DataBind();
Chart1.Series[0].XValueMember
= "ProjectTitle";
Chart1.Series[0].YValueMembers
= "ProgressPercentage";
Chart1.Series[0].ToolTip
= "Completed : " + "#PERCENT";//--Used to show tooltip
Chart1.ChartAreas[0].Area3DStyle.Enable3D
= true;
}
Step-5: The final output:
Output with showing tool tip:
Regards,
Prajanuranjan....
No comments:
Post a Comment