D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
jlipkin8
Full window
Github gist
bar_chart_exercise
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:100; right:0; bottom:0; left:0; background-color: #ffffcc; } .chart div { font: 10px sans-serif; background-color: darkgreen; text-align: right; padding: 3px; margin: 1.5px; color: white; } </style> </head> <body> <div class="chart"> </div> <script> var data = [4, 8, 15, 16, 23, 42]; var x = d3.scaleLinear() .domain([0, d3.max(data)]) .range([0, 420]); d3.select(".chart") .selectAll("div") .data(data) .enter().append("div") .style("width", function(d) { return x(d) + "px"; }) .text(function(d) { return d; }); </script> </body>
https://d3js.org/d3.v4.min.js