title: JQuery Line Chart's X Axis not display in ASP.NET, C#, SQL Server
body: <p>I have a SQL Server database table and I want to that record display in jQuery line chart. I tried more time to display my data in chart. but that asp page is loaded successfully and no chart viewed.</p>
  <p>My aspx markup is as follows:</p>
  <pre><code>&lt;form id=&quot;form1&quot; runat=&quot;server&quot;&gt;
  &lt;div&gt;
    &lt;asp:Literal ID=&quot;ltChart&quot; runat=&quot;server&quot;&gt;&lt;/asp:Literal&gt;
  &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  <p>My <code>aspx.cs</code> code behind is this:</p>
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      if (!IsPostBack)
          ShowData();
  }
  
  private void ShowData()
  {
      String myConnection = ConfigurationManager.ConnectionStrings[&quot;FFASDBConnectionString&quot;].ToString();
  
      SqlConnection con = new SqlConnection(myConnection);
  
      String query = &quot;SELECT TOP 10 [temperature],[dateTime] FROM [FFAS].[dbo].[ForestFireDataset] ORDER BY [dateTime] DESC&quot;;
  
      SqlCommand cmd = new SqlCommand(query, con);
  
      DataTable tb = new DataTable();
  
      try
      {
          con.Open();
  
          SqlDataReader dr = cmd.ExecuteReader();
          tb.Load(dr, LoadOption.OverwriteChanges);
  
          con.Close();
      }
      catch { }
  
      if (tb != null)
      {
          String chart = &quot;&quot;;
          chart = &quot;&lt;canvas id=\&quot;line-chart\&quot; width=\&quot;100%\&quot; height=\&quot;40\&quot;&gt;&lt;/canvas&gt;&quot;;
          chart += &quot;&lt;script&gt;&quot;;
          chart += &quot;new Chart(document.getElementById(\&quot;line-chart\&quot;), { type: 'line', data: {labels: [&quot;;
  
          string valueX = &quot;&quot;;
  
          for (int i = 0; i &lt; tb.Rows.Count; i++)
              valueX += tb.Rows[i][&quot;dateTime&quot;].ToString() + &quot;,&quot;;
  
          chart += valueX;
  
          chart += &quot;],datasets: [{ data: [&quot;;
  
          // get data from database and add to chart
          String value = &quot;&quot;;
  
          for (int i = 0; i &lt; tb.Rows.Count; i++)
              value += tb.Rows[i][&quot;temperature&quot;].ToString() + &quot;,&quot;;
  
          value = value.Substring(0, value.Length - 1);
          chart += value;
  
          chart += &quot;],label: \&quot;Air Temperature\&quot;,borderColor: \&quot;#3e95cd\&quot;,fill: true}&quot;; // Chart color
          chart += &quot;]},options: { title: { display: true,text: 'Air Temperature (oC)'} }&quot;; // Chart title
          chart += &quot;});&quot;;
          chart += &quot;&lt;/script&gt;&quot;;
  
          ltChart.Text = chart;
      }
  }
  </code></pre>