Published
Edited
May 6, 2020
Insert cell
md`# regl-scatterplot with a background image`
Insert cell
canvas = html`<canvas width="${width}" height="${height}"></canvas>`
Insert cell
width = 240
Insert cell
Insert cell
regl = createScatterplot.createRegl(canvas);
Insert cell
backgroundImage = await createScatterplot.createTextureFromUrl(
regl,
`https://picsum.photos/${Math.min(640, width)}/${Math.min(640, height)}/?random`,
true
);
Insert cell
scatterplot = createScatterplot.default({
regl: regl,
canvas: canvas,
width: width,
height: height,
pointSize: 4,
colors: ['#ff0000', '#00ff00', '#0000ff'],
backgroundImage
})
Insert cell
points = new Array(1000)
.fill()
.map(() => [-1 + Math.random() * 2, -1 + Math.random() * 2, '#ff33aa'])
Insert cell
scatterplot.draw(points)
Insert cell
Insert cell
Insert cell
Insert cell
require('regl@1.3.13/dist/regl.min.js');
Insert cell
require('pub-sub-es@1.2.1/dist/pub-sub-es.min.js');
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more