javascript - Creating a basic bar chart in d3js -


I did it to create a simple bar chart in D3js, but I do not see any charts!

HTML:

  & lt ;! DOCTYPE html public "- // W3C / // DTT XHTML 1.0 Transcription // N" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" & gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Meta charset = "UTF-8" & gt; & Lt; Title & gt; Learning Javascript! & Lt; / Title & gt; & Lt; Link rel = "stylesheet" href = "main.css" & gt; & Lt; Script src = "http://code.jquery.com/jquery-1.10.1.min.js" & gt; & Lt; / Script & gt; & Lt; Script src = "http://d3js.org/d3.v3.min.js" charset = "utf-8" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" src = "script.js" & gt; & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; H1 & gt; Learn javascript and html / css! & Lt; / H1> & Lt; P class = "special" & gt; This is the first paraprof. & Lt; / P & gt; & Lt; Div class = "chart" & gt; & Lt; / Div & gt; & Lt; / Body & gt; & Lt; / Html & gt;  

Javascript:

  var data = [4, 8, 15, 16, 23, 42]; Var x = d3.scale.linear () .domain ([0, D3. Max]). Ranges ([0, 420]); D3.select ("chart") .selectAll ("div"). Data (data) Center () .andend ("div"). Style ("width", function (d) {return x (d) + "px";}) .text (function (d) {return d;});  

You can change your & lt; Div & gt; / Code> visible.

Demo:

Add it:

 . Chart div {background-red color; Border: 1px solid blue; }  


Comments