Published
Edited
Nov 20, 2019
1 fork
4 stars
Insert cell
Insert cell
Insert cell
{
await visibility()
return renderUmap(triangles, dynamic)
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// fixed = new UMAP({
// nComponents: 2,
// minDist: 0.9,
// nNeighbors: 50
// }).fit(points)
Insert cell
Insert cell
function renderUmap(triangles, points) {
let height = width
const canvas = DOM.canvas(width, height)
const ctx = canvas.getContext("2d")
let downScale = 0.2
let scale = baseScale * downScale
let padding = downScale * basePadding
let nx = Math.floor(width / (scale + padding))
let xextent = d3.extent(dynamic, (d) => d[0])
let yextent = d3.extent(dynamic, (d) => d[1])
let xscale = d3.scaleLinear()
.domain(xextent)
.range([padding, width - padding])
let yscale = d3.scaleLinear()
.domain(yextent)
.range([padding * 2, height - padding * 3])
// ctx.fillRect(0,0,width, 140)
triangles.forEach(function(triangle, i) {
renderTriangle(ctx, geometric.polygonScale(triangle, downScale), [
xscale(points[i][0]),
yscale(points[i][1])],
1)
})
return canvas
}
Insert cell
Insert cell
Insert cell
Insert cell
geometric = require("geometric");
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