D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
mforando
Full window
Github gist
Color Palette Reference
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> <div id="cont"> </div> <body> <script> var divs = d3.select("#cont") .selectAll(".colordivs") .data(["#A05DA5","#2B92D0","#84A743","#5A514C","#F24F26","#8B827D","#EFAC41","#008465"]) divs.enter() .append('div') .attr('class', 'colordivs'); d3.selectAll('.colordivs') .append('div') .style('display', 'inline-block') .style('background', (d)=>{return d}) .style('width', '15px') .style('height', '15px').style('margin-right', '10px') .style('border', '1px solid black'); d3.selectAll('.colordivs') .append('div') .style('display', 'inline-block') .text((d)=>{return d}) </script> </body>
https://d3js.org/d3.v4.min.js