Click here to Skip to main content
15,887,474 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
C#
public partial class chartDummy : System.Web.UI.Page
{
    SqlConnection con;
    SqlCommand cmd;
    SqlDataAdapter da;
    DataSet ds;

    protected void Page_Load(object sender, EventArgs e)
    {
        con = new SqlConnection(@"ConnectionString");
        cmd = new SqlCommand("Select Mains_Run_Hrs, DG_Run_Auto_Mode, Battery_Run_Hrs, Solar_Run_hrs from tbl_runtime_report", con);
        da = new SqlDataAdapter(cmd);
        ds = new DataSet();
        da.Fill(ds);
        DataView source = new DataView(ds.Tables[0]);
            Chart1.DataSource = ds;
            Chart1.Series[0].XValueMember = "Mains_Run_Hrs";
            Chart1.Series[0].XValueMember = "DG_Run_Auto_Mode";
            Chart1.Series[0].XValueMember = "Battery_Run_Hrs";
            Chart1.Series[0].XValueMember = "Solar_Run_hrs";
            Chart1.DataBind();

    }   
}


Source:

C#
<div>
      <asp:Chart ID="Chart1" runat="server" CssClass="auto-style1" Width="558px">
          <Series>
              <asp:Series Name="Main Run Hrs"></asp:Series>
              <asp:Series Name="DG Run Auto Mode"></asp:Series>
              <asp:Series Name="Battery Run Hrs"></asp:Series>
              <asp:Series Name="Solar Run Hrs"></asp:Series>
          </Series>
          <ChartAreas>
              <asp:ChartArea Name="ChartArea1"></asp:ChartArea>
          </ChartAreas>
          <Legends>
              <asp:Legend Title="Solar Data"></asp:Legend>
          </Legends> 
      </asp:Chart>           
  </div>
Posted
Comments
ZurdoDev 23-Sep-14 9:09am    
1. What's your question?
2. You keep changing the XValueMember. Why? Perhaps you want to add multiple series instead of changing the same property over and over.

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