D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
tgsuarez
Full window
Github gist
Toms first 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> <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", 899) .attr("height", 617) var xScale = d3.scaleLinear() .domain([0,34404]) .range([85,783]); var yScale = d3.scaleLinear() .domain([-56,66]) .range([1004,106]); var rScale = d3.scaleSqrt() .domain([0,938105715]) .range([0,100]); d3.csv("gapminder_avg.csv",function(dataWeLoaded) { console.log(dataWeLoaded); svg.selectAll("circle") .data(dataWeLoaded) .enter() .append("circle") .attr("cy", function(d) { return yScale(+d.lifeexp);}) .attr("cx", function(d) { return xScale(+d.gdp);}) .attr("r", function(d) { return rScale(+d.population);}) .attr("fill-opacity", 0.5) .attr("stroke", "Orange") .attr("stroke-width", 2) .attr("fill", function(d) {return d.color}) }) </script> </body>
https://d3js.org/d3.v4.min.js