I am trying to create a random polygon color ranging in the hex field from 0-999 generated for each voronoi cell.
Right now I have have color randomised but it is required for each cell.
var voronoi = d3.voronoi()
var svg = d3.select("svg"),
width = +svg.attr("width"),
height = +svg.attr("height")
var sites = d3.range(300)
.map(function(d){return[Math.random()*(width/2)+100,
Math.random()*(height/2)+100,
"#"+Math.round(Math.random()*999)]})
var voronoi = d3.voronoi()
var polygon = svg.append("g")
.attr("class", "polygons")
.style("stroke", "tan")
.style("stroke-width", 0.2)
.selectAll("path")
.data(voronoi.polygons(sites))
.enter().append("path")
.call(redrawPolygon)
.style("fill", "beige")
function redrawPolygon(polygon) {
polygon.attr("d",function(d) { return d ? "M" + d.join("L") + "Z" : null; })
}
<svg width="1000" height="1000">
</svg>
<h1>d3</h1>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="1104.js"></script>