D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
eesur
Full window
Github gist
d3 | modulo operation to create a grid
broke this down and wrote about it
on medium
<!DOCTYPE html> <title>d3 | modulo operation to create a grid</title> <link href='dist.css' rel='stylesheet' /> <body> <div> <div id="waffle"></div> <span id="value"></span> </div> <script src='https://d3js.org/d3.v4.min.js'></script> <script src='dist.js'></script> <!-- render code --> <script> const d3 = window.d3 // render an update const chart = d3.waffle d3.interval(function () { let n = Math.floor(d3.randomUniform(5, 100)()) chart('#waffle', n, { strokeCol: '#ccc', margin: {top: 35}, squareSize: 40, strokeWidth: 2 }) d3.select('#value').html(n + '%') }, 1000) </script> </body>
https://d3js.org/d3.v4.min.js