Published
Edited
Jul 28, 2018
1 fork
27 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
hexbin = d3.hexbin()
.radius(hexRadius)
.x(function(d) { return d.x; })
.y(function(d) { return d.y; })
Insert cell
Insert cell
Insert cell
hexPoints = hexbin(usPoints)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function addPoints(pointData, inc, ctx, barBase) {
const barScaleX = d3.scaleBand().domain(d3.range(nPoints)).range([cxShape + edge, width - edge/2]);
const barScaleY = d3.scaleLinear().domain([0, maxDist]).range([barBase, barBase-squareDiameter/2]);

resizeCanvas(ctx);
const pointDataDraw = pointData.filter((el, i) => i >= inc);

ctx.clearRect(0, 0, width, h);

pointDataDraw.forEach(el => {

// Draw inner points.
ctx.beginPath();
ctx.arc(el.x, el.y, 1, 0, 2*Math.PI);
ctx.fillStyle = colScale(el.dist);
ctx.fill();
// Draw lines.
ctx.beginPath();
ctx.moveTo(barScaleX(el.index), barBase);
ctx.lineTo(barScaleX(el.index), barScaleY(el.dist));
ctx.lineWidth = 1;
ctx.strokeStyle = colScale(el.dist);
ctx.stroke();
});
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
drawHexagonPoints = { addPoints(pointsHexInCircle, incrementCircleHex, hexCtxAn, h/2 + hexSide) }
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more