fivePurpSmallMultbar = {
const {visWidth, visHeight, margin} = dimensions;
const svg = d3.create('svg')
.attr('width',visWidth + margin.left + margin.right)
.attr('height',visHeight + margin.top + margin.bottom)
const g = svg.append('g')
.attr('font-family', 'sans-serif')
.attr('transform',`translate(${margin.left},${margin.top})`);
g.append('text')
.text('Top Five Purposes of Donations')
const cells = g.selectAll('g')
.data(top5PurpSmlMul)
.join('g')
.attr('transform',(d,i) => {
const r = Math.floor(i / numCols);
const c = i % numCols;
return `translate(${cols(c)},${rows(r)})`
});
cells.each(function(d) {
const group = d3.select(this);
const axis = d3.axisLeft(d.freqY)
.ticks(3)
.tickSizeOuter(0);
group.call(axis)
.call(g => g.select('.domain').remove())
});
cells.each(function (d) {
const bars = d3.select(this);
const rects = d3.selectAll('rect')
.data(d, e => e.freq)
.join('rect')
.attr('x',(r,i) => xAxis(i))
.attr('width',xAxis.bandwidth())
.attr('height',(r,i) =>d.freqY(r))
.attr('y',d.freqY(0))
})
const xAxes = cells.append('g')
.attr('transform', d => `translate(0,${rows.bandwidth()})`)
.call(d3.axisBottom(xAxis))
.call(g => g.select('.domain').remove())
return svg.node()
}