Published
Edited
Jan 11, 2020
1 fork
Insert cell
md`# Demo SVG and Canvas 2d`
Insert cell
Insert cell
{
let svg = DOM.svg(width, height)
let stage = d3.select(svg)
stage.html(transformed_polygon.svg({fill:"lightcyan"}))
return svg;
}
Insert cell
Insert cell
{
const canvas = DOM.canvas(width, height);
const context = canvas.getContext("2d");

context.clearRect(0, 0, width, height);

for (let face of transformed_polygon.faces) {
const p = new Path2D(face.svg());
// text.stroke = "1px";
context.fillStyle = 'lightcyan'
context.fill(p);
context.stroke(p);
}

return canvas;
}
Insert cell
height = 400
Insert cell
Insert cell
Insert cell
import {data2center} from "@alexbol99/lib"
Insert cell
Insert cell
Flatten = require("@flatten-js/core")
Insert cell
d3 = require("d3")
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