-
-
Notifications
You must be signed in to change notification settings - Fork 398
Open
Description
Is it possible to render in node.js using canvas/skia-canvas? I'm trying to do something like this but it complains about missing 'window':
main.mjs
import { Network } from 'vis-network';
import { DataSet } from 'vis-data';
import { Canvas } from 'skia-canvas';
const nodes = new DataSet([
{ id: 1, label: "Node 1" },
{ id: 2, label: "Node 2" },
{ id: 3, label: "Node 3" },
{ id: 4, label: "Node 4" },
{ id: 5, label: "Node 5" },
]);
// create an array with edges
const edges = new DataSet([
{ from: 1, to: 3 },
{ from: 1, to: 2 },
{ from: 2, to: 4 },
{ from: 2, to: 5 },
{ from: 3, to: 3 },
]);
// create a network
const container = new Canvas(400, 400);
const data = {
nodes: nodes,
edges: edges,
};
const options = {};
new Network(container, data, options);
await canvas.saveAs("graph.png", {density:2})node_modules/vis-network/peer/umd/vis-network.js:26803
if (window !== undefined) {
^
ReferenceError: window is not defined
(...)
Node.js v22.12.0
Metadata
Metadata
Assignees
Labels
No labels