D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
sivakarasala
Full window
Github gist
Responsive Bar chart
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{ width: 100%; max-width: 800px; background-color: #7f00ff; margin: 0 auto; } .bar{ display: inline-block; background-color: #4b0082; width: 25px; margin-right: 5px; } </style> </head> <body> <div id="chart"></div> <script> var svg = d3.select("#chart").append("svg") // .attr("width", 960) // .attr("height", 500) .attr('viewBox', '0 0 800 400') .attr('preserveAspectRatio', 'xMidYMid'); </script> </body>
https://d3js.org/d3.v4.min.js