Click here to Skip to main content
15,887,999 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
friends i need to create pie chart in asp.net using Database ,please help me
Posted

1 solution

XML
<div>
       <asp:Chart ID="Chart1" runat="server" Width="500px">
           <Series>
               <asp:Series Name="Education" XValueMember="name" YValueMembers="currency"
                   IsVisibleInLegend="true" ChartType="Pie">
               </asp:Series>
           </Series>
           <ChartAreas>
               <asp:ChartArea Name="ChartArea1" Area3DStyle-Enable3D="true">
                   <AxisX LineColor="DarkGray">
                       <MajorGrid LineColor="LightGray" />
                   </AxisX>
                   <AxisY LineColor="DarkGray">
                       <MajorGrid LineColor="LightGray" />
                   </AxisY>
                     <Area3DStyle Enable3D="True"></Area3DStyle>
               </asp:ChartArea>
           </ChartAreas>
           <Legends>
               <asp:Legend>

               </asp:Legend>
           </Legends>
       </asp:Chart>
   </div>


private void CreateChart()
{
SqlConnection sqlconn = new SqlConnection(connection);
SqlCommand cmd = new SqlCommand();

cmd.Parameters.AddWithValue("@Queryno", "3");
cmd.CommandText = "Satish_Pro";
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.Connection = sqlconn;
SqlDataAdapter adp = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adp.Fill(ds);

if (ds.Tables[0].Rows.Count > 0)

{
Chart1.DataSource = ds;
Chart1.DataBind();
}

}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900