D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
tizon9804
Full window
Github gist
Tutorial D3
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> <div id="chart"></div> <script> data = [100,200,300,400,500] var svg = d3.select("#chart").append("svg") .attr("width", 960) .attr("height", 500) update (data) function update(mdata){ //todo add text into each bar //selection and map data barra = svg.selectAll("rect").data(mdata); //update barra.enter() .append("rect") .merge(barra).transition().duration(500) .attr("x",0) .attr("y",function(d,i){return i*(50+1)}) .attr("width",function (d){return d}) .attr("height",50) .style("fill","green") //remove barra.exit() .transition().duration(500) .remove() } </script> </body>
https://d3js.org/d3.v4.min.js