D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
Esdras08
Full window
Github gist
Barchart (nutriments)
Built with
blockbuilder.org
<!DOCTYPE html> <head> <meta charset="utf-8"> <script src="https://d3js.org/d3.v4.min.js"></script> <style> body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } rect { fill: none; stroke: blue; stroke-width: 2; } </style> <svg width="50" height="50"> <circle cx="25" cy="25" r="22" fill="blue" stroke="gray" stroke-width="2"/> </svg> </head> <body> <script> // Feel free to change or delete any of the code you see in this editor! var svg = d3.select("body").append("svg") .attr("width", 960) .attr("height", 500) var dataset; //Global variable d3.tsv("nutriments.tsv", function(data) { console.log(data); var y = d3.scaleLinear() .domain([0, 67]) .range([0, 100]); data.forEach(function(d, i) { console.log(d); svg.append("rect") .attr("width", 7.5) .attr("height", 10 * y(d.AvN)) .attr("x", i * 11) .attr("y", 200 -10 * y(d.AvN)); }); }); </script> </body>
https://d3js.org/d3.v4.min.js