Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Use sql queries to draw dynamic chart in NV D3?
    primarykey
    data
    text
    <p>The below code for horizontal bar chart works well but now i need to retrieve data from sql database accordingly the chart should change dynamically, so where could i insert sql queries in this code and what is the format please help me guys.</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;meta charset="utf-8"&gt; &lt;head&gt; &lt;link href="Scripts/nv.d3.css" rel="stylesheet" type="text/css"&gt; &lt;script src="Scripts/d3.v3.js"&gt;&lt;/script&gt; &lt;script src="Scripts/nv.d3.js"&gt;&lt;/script&gt; &lt;script src="Scripts/utils.js"&gt;&lt;/script&gt; &lt;script src="Scripts/tooltip.js"&gt;&lt;/script&gt; &lt;script src="Scripts/models/axis.js"&gt;&lt;/script&gt; &lt;script src="Scripts/models/multiBarHorizontal.js"&gt;&lt;/script&gt; &lt;script src="Scripts/models/multiBarHorizontalChart.js"&gt;&lt;/script&gt; &lt;script src="Scripts/bar.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="chart" style="height:700px"&gt; &lt;svg&gt; &lt;/svg&gt; &lt;/div&gt; &lt;script&gt; d3.json("data.json",function(error,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) .showControls(false); chart.yAxis .tickFormat(d3.format(',.0f')); d3.select('#chart svg') .datum(data) .transition().duration(500) .call(chart); nv.utils.windowResize(chart.update); chart.dispatch.on('stateChange', function(e) { nv.log('New State:', JSON.stringify(e)); }); return chart; }); }); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Here is my 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>
    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. 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