title: Dygraph with javascript array?
body: <p>First of all, I have just started learning JavaScript, so please don't bash me if this question is too trivial.</p>
  
  <p>So.. For the last 2 days I am trying to plot x-y graph using dygraph without any success. </p>
  
  <p><strong>Dygrahp takes 'data' as csv input (Official Documentation):</strong></p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script type="text/javascript"
    src="dygraph-combined-dev.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div id="graphdiv"&gt;&lt;/div&gt;
  &lt;script type="text/javascript"&gt;
    g = new Dygraph(
  
      // containing div
      document.getElementById("graphdiv"),
  
      // CSV or path to a CSV file.
      "Date,Temperature\n" +
      "2008-05-07,75\n" +
      "2008-05-08,70\n" +
      "2008-05-09,80\n"
  
    );
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>In the jsp file, I am storing the data to a javascript array and then converting that array to comma separated values. Then I pass this csv to Dygraph. But for some reason the graph does not show. </p>
  
  <p><strong>Here is my code:</strong></p>
  
  <pre><code>&lt;div id="graphdiv"&gt;&lt;/div&gt;
  
          &lt;script type="text/javascript"&gt;
              $(document).ready(function() {
                  var list = ${dateAndWaitTimes};
                  var x = document.write(list);
                  g = new Dygraph( document.getElementById("graphdiv"), x);
              });
          &lt;/script&gt;
  </code></pre>
  
  <h2><strong>Here's chrome debugger output:</strong></h2>
  
  <p><a href="https://i.stack.imgur.com/2KJg4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2KJg4.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/cHchH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cHchH.png" alt="enter image description here"></a></p>
  
  <p>Please help me, I am really frustrated.</p>
  
  <p>Thanks.</p>