A simple example of using the layout and scale functions of this d3 icon array plugin
xxxxxxxxxx
<html>
<head>
<title>Simple icon array example</title>
<script src="//d3js.org/d3.v4.0.0-alpha.18.min.js" charset="utf-8"></script>
<script type="text/javascript" src="d3-iconarray.js"></script>
<style type="text/css">
*{
font-family: sans-serif;
font-weight: bold;
letter-spacing: 1px;
}
</style>
</head>
<body>
<div id="simple-example">
</div>
</body>
<script type="text/javascript">
var layout = d3_iconarray.layout();
var data = d3.range(1, 145, 1);
var grid = layout(data);
var dotRadius = 10;
var width = 600,
height = 600,
margin = {top:20, bottom:20, left:20, right:20 };
var arrayScale = d3_iconarray.scale()
.domain([ 0, layout.maxDimension(data.length) ])
.range([0, width-(margin.left+margin.right)])
.gapSize(1)
.gapInterval(4);
var svg = d3.select('#simple-example')
.append('svg')
.attr('width',width)
.attr('height',height)
.append('g')
.attr('transform','translate('+margin.left+','+margin.top+')');
svg.selectAll('g')
.data(grid)
.enter()
.append('g').attr('transform', function(d){
return 'translate('+arrayScale(d.position.x)+','+arrayScale(d.position.y)+')'
})
.call(function(parent){
parent.append('text')
.text(function(d){ return d.data; })
.attr('stroke','#000')
.attr('stroke-width',8)
.attr('stroke-linejoin','round')
.attr('text-anchor','middle')
.attr('x',dotRadius)
.attr('y',dotRadius*6/4)
parent.append('text')
.text(function(d){ return d.data; })
.attr('fill','#FFF')
.attr('text-anchor','middle')
.attr('y',dotRadius*6/4)
.attr('x',dotRadius)
})
d3.select(self.frameElement).style("height", height + "px");
</script>
</html>
https://d3js.org/d3.v4.0.0-alpha.18.min.js