D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
sxywu
Full window
Github gist
Metis Class 7, #1
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> var width = 500; var height = 500; var radius = 5; var colors = d3.scaleOrdinal(d3.schemeCategory10); var svg = d3.select("body").append("svg") .attr("width", width) .attr("height", height); d3.json('miserables.json', function(err, data) { var circles = svg.selectAll('circle') .data(data.nodes, function(d) {return d.id}) .enter().append('circle') .attr('r', radius) .attr('fill', function(d) {return colors(d.group)}); // define force var simulation = d3.forceSimulation(data.nodes) .on('tick', function() { }); }); </script> </body>
https://d3js.org/d3.v4.min.js