title: D3.js - How to use inline JSON as dataset for D3 charts, instead of csv/tsv/json file
body: <p>I'm implementing D3.js charts in my application, I don't want to use file as dataset, I just want to use inline JSON as dataset (JSON would be generated dynamically in application).</p>
  
  <p>I have done implementation for <a href="http://bl.ocks.org/asielen/44ffca2877d0132572cb" rel="nofollow noreferrer">Reusable Responsive Multiline Chart</a> using following code.</p>
  
  <pre>
  <b>var data1 = [ { "My JSON data here" } ];</b>
  
  d3.json(<b>''</b>, function (error, data) {
  
      <b>data1</b>.forEach(function (d) {
          d.year = +d.year;
          d.variableA = +d.variableA;
          d.variableB = +d.variableB;
          d.variableC = +d.variableC;
          d.Temp = +d.Temp;
      });
  
      var chart = makeLineChart(<b>data1</b>, 'year', {
          'Device 1': { column: 'variableA' },
          'Device 2': { column: 'variableB' },
          'Device 3': { column: 'variableC' },
          'Device 4': { column: 'variableD' }
      }, { xAxis: 'Years', yAxis: 'Temperature' });
      chart.bind("#chart-line1");
      chart.render();
  });
  </pre>
  
  <p>Here I'm calling d3.json() but <strong>file name is blank</strong> and also there is <strong>no use of data</strong> in code. Instead of 'data' I'm using 'data1'.
  <strong>It works perfect ...</strong></p>
  
  <p>Now I want to achieve the same for <a href="https://bl.ocks.org/mbostock/3887051" rel="nofollow noreferrer">Grouped Bar Chart</a>, but this chart data binding method is different than "Reusable Responsive Multiline Chart".
  Following is the code to parse data for "Grouped Bar Chart".</p>
  
  <pre><code>d3.csv("\\data.csv", function(d, i, columns) {
    for (var i = 1, n = columns.length; i &lt; n; ++i) d[columns[i]] = +d[columns[i]];
    return d;
  }, function(error, data) {
    if (error) throw error;
  
    var keys = data.columns.slice(1); 
  
    // Rest of code to bind parsed data to chart   
  });
  </code></pre>
  
  <p>Complete code at <a href="https://bl.ocks.org/mbostock/3887051" rel="nofollow noreferrer">Grouped Bar Chart</a></p>
  
  <p>So how I can replace <em>data.csv</em> with inline JSON here.</p>