Classic D3 Examples
Old school D3 from simpler times
lucguillemot
Full window
Github gist
fresh block
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; } </style> </head> <body> <button onclick=updateData()>update</button> <script> var svg = d3.select("body").append("svg") .attr("width", 960) .attr("height", 500); var data = [4, 8, 16, 20]; var data2 = [10, 20, 30, 40]; var height =300; var viz = svg.selectAll("circle") .data(data).enter() .append("circle") .attr("cx", function(d, i) {return d*10;}) .attr("cy", 100) .attr("r", function(d, i) {return d;}) .style("fill", "steelblue"); var rect = svg.selectAll("rect") .data(data2).enter() .append("rect") .attr("x", function(d) { return d*10; }) .attr("width", 10) .attr("y", 300) .attr("height", function(d) { return d; }) .attr("fill", "#f00") .attr("stroke", "#0ff") .attr("stroke-width", 1); function updateData() { rect.transition().duration(3000) .attr("fill", "#0f0") .attr("width", Math.random()) .attr("height", function(d) { return d*3; }); } </script> </body>
https://d3js.org/d3.v4.min.js