D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
alexjtray
Full window
Github gist
London Data
Built with
blockbuilder.org
<!DOCTYPE html> <head> <meta charset="utf-8"> <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script> </head> <body> <div id="chart"></div> <script> var height = 400, width = 600; var svg = d3.select('#chart') .append('svg') .attr('height', height) .attr('width', width); d3.csv("fire.csv", function(error,data) { data.forEach(function(d) { d.count = +d.count; }); console.log(data); svg.selectAll("rect") .data(data) .enter() .append("rect") .attr("x", function(d) { return x(d.borough); }) .attr("width", x.rangeBand()) .attr("y", function(d) { return y(d.count); }) .attr("height", function(d) { return height - y(d.count); }) .attr("fill", "steelblue"); }); /* var margin = {top: 20, right: 10, bottom: 20, left: 10}; var width = 960 - margin.left - margin.right; var height = 500 - margin.top - margin.bottom; var svg = d3.select("body").append("svg") .attr("width", width + margin.left + margin.right) .attr("height", height + margin.top + margin.bottom) .append("g") .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); */ </script> </body>
https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js