title: Plotly line chart with ASP.NET MVC
body: <p>How can I pass data from MVC controller to AJAX call in Plotly recommended chart data format?</p>
  
  <p>I need data in the below format for multiple line series in javascript</p>
  
  <pre><code>var trace2 = {
      x: [1, 2, 3, 4],
      y: [3, 10, 17, 18],
      type: 'scatter'
  };
  </code></pre>
  
  <p><strong>Current attempt</strong></p>
  
  <p>I have taken data from a Data table and could format it to JSON string (the closest I could for the data for plotly line chart) as below:</p>
  
  <pre><code>{
    "trace1": {
      "name": "trace1",
      "x": [ "30/6/2017 11:40:38", "30/6/2017 11:40:38", "30/6/2017 11:40:38", "30/6/2017 11:40:38" ],
      "y": [ 10.0, 12.0, 95.0, 99.0 ]
    },
    "trace2": {
      "name": "trace2",
      "x": [ "30/6/2017 11:40:38", "30/6/2017 11:40:38", "30/6/2017 11:40:38", "30/6/2017 11:40:38" ],
      "y": [ 10.0, 12.0, 95.0, 99.0 ]
    }
  }
  </code></pre>
  
  <p>Now I am sending this in JSON format to AJAX success method using the below return </p>
  
  <pre><code>string jsonString= "{\"trace1\":{\"name\":\"trace1\",\"x\":[\"30/6/2017 11:32:55\",\"30/6/2017 11:32:55\",\"30/6/2017 11:32:55\",\"30/6/2017 11:32:55\"],\"y\":[10.0,12.0,95.0,99.0]},\"trace2\":{\"name\":\"trace2\",\"x\":[\"30/6/2017 11:32:55\",\"30/6/2017 11:32:55\",\"30/6/2017 11:32:55\",\"30/6/2017 11:32:55\"],\"y\":[10.0,12.0,95.0,99.0]}}";
  return new JsonResult { Data = jsonString, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
  </code></pre>
  
  <p>I need to format this into plotly accepted format for line traces.</p>