D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
ericd9799
Full window
Github gist
D3 V5 Color Schemes
Built with
blockbuilder.org
<!DOCTYPE html> <head> <meta charset="utf-8"> <script src="https://d3js.org/d3.v5.min.js"></script> <style> body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } </style> </head> <body> <script> var margin={top:50,right:50,bottom:50,left:50}; var width = 960 - margin.left - margin.right; var height = 525 - margin.top - margin.bottom; var circleArray = []; var colorArray = [d3.schemeCategory10, d3.schemeAccent]; var svg = d3.select("body").append("svg") .style("border", "solid") .attr("width", width+margin.left+margin.right) .attr("height", height+margin.top+margin.bottom); var g = svg.append("g") .attr("transform", "translate("+margin.top+","+margin.left+")"); var colorScheme = d3.scaleOrdinal(colorArray[0]); for(i = 0; i < colorArray[0].length; i++){ var circleDict = {}; circleDict.cx = (i * 15) / 0.2; circleDict.cy = 15; circleDict.r = 15; circleDict.color = colorScheme(i); circleArray.push(circleDict); } g.append("g").selectAll("circle").data(circleArray).enter().append("circle") .attr("cx", function(d){return d.cx;}) .attr("cy", function(d){return d.cy;}) .attr("r", function(d){return d.r;}) .attr("fill", function(d){return d.color;}); </script> </body>
https://d3js.org/d3.v5.min.js