{
customStyle.draw = (cells, resolution, cg) => {
cg.setCanvasTransform();
const minInc = d3.min(cells, (c) => +c.rIncome);
const maxInc = d3.max(cells, (c) => +c.rIncome);
let minPop;
let maxPop;
if (populationAlpha) {
minPop = d3.min(cells, (c) => +c.ind);
maxPop = d3.max(cells, (c) => +c.ind);
}
for (let cell of cells) {
if (!cell.ind) continue;
let transparency = 1;
if (populationAlpha) {
let p = (cell.ind - minPop) / (maxPop - minPop);
p = gviz.sExpRev(p, -pd);
transparency = Math.round(p * 10) / 10;
}
let t = (cell.rIncome - minInc) / (maxInc - minInc);
t = gviz.sExpRev(t, -d);
let c = d3.color(d3.interpolateYlGnBu(t));
c.opacity = transparency;
let color = c.formatRgb();
cg.ctx.fillStyle = color;
cg.ctx.fillRect(cell.x, cell.y, resolution, resolution);
}
};
map.redraw();
}