Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>OK, what I have done is gone back to the original example file that is included in the nvd3 downloaded zip file. Starting with the <code>multiBarHorizontalChart.html</code> file that is the examples folder. I was able to edit that file so that it looked like this;</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;meta charset="utf-8"&gt; &lt;link href="../src/nv.d3.css" rel="stylesheet" type="text/css"&gt; &lt;style&gt; body { overflow-y:scroll; } text { font: 12px sans-serif; } #chart1 { margin: 10px; min-width: 100px; min-height: 100px; } #chart1 svg { height: 500px; } &lt;/style&gt; &lt;body&gt; &lt;div id="chart1"&gt; &lt;svg&gt;&lt;/svg&gt; &lt;/div&gt; &lt;script src="../lib/d3.v2.js"&gt;&lt;/script&gt; &lt;script src="../nv.d3.js"&gt;&lt;/script&gt; &lt;script src="../src/utils.js"&gt;&lt;/script&gt; &lt;script src="../src/tooltip.js"&gt;&lt;/script&gt; &lt;script src="../src/models/legend.js"&gt;&lt;/script&gt; &lt;script src="../src/models/axis.js"&gt;&lt;/script&gt; &lt;script src="../src/models/multiBarHorizontal.js"&gt;&lt;/script&gt; &lt;script src="../src/models/multiBarHorizontalChart.js"&gt;&lt;/script&gt; &lt;script src="stream_layers.js"&gt;&lt;/script&gt; &lt;script&gt; d3.json('data.json', function(data) { var chart; nv.addGraph(function() { chart = nv.models.multiBarHorizontalChart() .x(function(d) { return d.label }) .y(function(d) { return d.value }) .margin({top: 30, right: 20, bottom: 50, left: 175}) .showValues(true) .tooltips(false) .barColor(d3.scale.category20().range()) .showControls(true); chart.yAxis .tickFormat(d3.format(',.2f')); d3.select('#chart1 svg') .datum(data) .transition().duration(500) .call(chart); nv.utils.windowResize(chart.update); return chart; }); }); &lt;/script&gt; </code></pre> <p>You should be able to note the <code>d3.json('data.json', function(data) {</code> line in there which will load your JSON file which is called data.json.</p> <pre><code>[ {"values": [ {"label":"Alaska","value":3}, {"label":"Alabama","value":4}, {"label":"Arkansas","value":5}, {"label":"Arizona","value":7}, {"label":"California","value":8}, {"label":"Colorado","value":9}, {"label":"Missouri","value":31} ] } ] </code></pre> <p>It is possible that this is where you were striking problems as you will see that there is an extra set of square brackets <code>[]</code> outside the data. If you have a look at the sample data that was included with the example, they are in there too (otherwise I wouldn't have known either).</p> <p><img src="https://i.stack.imgur.com/waCcG.png" alt="enter image description here"></p> <p>Hopefully that set's you a little further along.</p> <p>You will want to now check out how to use a php script to query your database, return the data in correctly formatted JSON and then call that script from the point where you initially called the data.json file.</p> <p>Good luck.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload