D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
mukhtyar
Full window
Github gist
D3 - Data Binding 1
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; } #chart { margin: 3em; } .bar { background-color: blue; height: 20px; margin-top: 2px; } </style> </head> <body> <div id="chart"> <div></div> <div></div> <div></div> <div></div> <div></div> </div> <script> var data = [200, 60, 100, 80, 10]; // Pair each number in the array with an empty div // Set color, height, and spacing via CSS d3.select('#chart') .selectAll('div') .data(data) .attr('class', 'bar') .style('width', function(d) { return d + 'px'; }); </script> </body>
https://d3js.org/d3.v4.min.js