Public
Edited
Apr 24, 2023
1 fork
1 star
Insert cell
Insert cell
Insert cell
Insert cell
layoutWASM = await require(`@antv/layout-wasm@${version}`)
Insert cell
await layoutWASM.initThreads(true)
Insert cell
canvas = {
const canvas = createCanvas();
canvas.document.documentElement.translate(200, 200);
canvas.document.documentElement.scale(0.5);
const stepTime = 0.035;
const center = [200, 200];

// const edges = [];
// sim.edges.forEach((edge) => {
// let source = edge.source;
// let target = edge.target;

// const line = new G.Line({
// style: {
// x1: source.location[0],
// y1: source.location[1],
// x2: target.location[0],
// y2: target.location[1],
// lineWidth: 1,
// stroke: "grey"
// }
// });
// edges.push(line);
// canvas.appendChild(line);
// });

// const nodes = [];
// sim.nodes.forEach((node) => {
// const circle = new G.Circle({
// style: {
// cx: node.location[0],
// cy: node.location[1],
// r: 6,
// fill: "rgb(207,226,252)",
// stroke: "rgb(118,145,241)",
// lineWidth: 2
// }
// });
// nodes.push(circle);
// canvas.appendChild(circle);
// });

// canvas.addEventListener("afterrender", () => {
// sim.nodes.forEach((node, i) => {
// const circle = nodes[i];
// circle.style.cx = node.location[0];
// circle.style.cy = node.location[1];
// });
// sim.edges.forEach((edge, i) => {
// let source = edge.source;
// let target = edge.target;
// const line = edges[i];
// line.attr({
// x1: source.location[0],
// y1: source.location[1],
// x2: target.location[0],
// y2: target.location[1]
// });
// });

// sim.update(stepTime);
// });

invalidation.then(() => {
// sim.resetNodePlacement();
canvas.destroy();
});

return canvas.getConfig().container;
}
Insert cell
Insert cell
G = require("@antv/g")
Insert cell
Canvas2D = require("@antv/g-canvas")
Insert cell
Insert cell
Insert cell
Insert cell
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