D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
js418
Full window
Github gist
test
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> <script> // Feel free to change or delete any of the code you see in this editor! var svg = d3.select("body").append("svg") .attr("width",800) .attr("height",400), margin = {top: 30, right: 20, bottom: 30, left: 20}, width = +svg.attr("width") - margin.left - margin.right, height = +svg.attr("height") - margin.top - margin.bottom, g = svg.append("g").attr("transform", "translate(" + margin.left + "," + margin.top + ")"); var x1 = d3.scaleBand() .range([0,width]) .paddingInner(0.2) .align(0.1); var x2 = d3.scaleBand() .range([0,width]) .paddingInner(0.2); var x3 = d3.scaleBand() .range([0,width]) .paddingInner(0.2); var y1 = d3.scaleLinear() .range([height,0]) var y2 = d3.scaleLinear() .range([height,0]) var y3 = d3.scaleLinear() .range([height,0]) d3.csv("test.csv",type, function(d){ x1.domain([0,10]) y1.domain([0,d3.max(d, function(d){return d.one;})]) g.selectAll("text") .data(d) .enter() .append("rect") .attr("x", function(d,i){ return i*20 + 30; }) .attr("y", function(d){return height - y1(d.one);}) .attr("width", 10) .attr("height", function(d){return y1(d.one);}) }); function type(d){ d.one = +d.one; d.two = +d.two; d.three = +d.three; return d; }; </script> </body>
https://d3js.org/d3.v4.min.js