Spaces:
Running
Running
File size: 1,102 Bytes
c1a1d02 af53b62 2d72d5a af53b62 c1a1d02 2d72d5a 3d534f4 c1a1d02 3d534f4 2d72d5a c1a1d02 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
<script lang="ts">
import { type NodeProps } from '@xyflow/svelte';
import Sigma from 'sigma';
import * as graphology from 'graphology';
import * as graphologyLibrary from 'graphology-library';
import LynxKiteNode from './LynxKiteNode.svelte';
type $$Props = NodeProps;
export let id: $$Props['id'];
export let data: $$Props['data'];
let sigmaCanvas: HTMLElement;
let sigmaInstance: Sigma;
$: if (sigmaCanvas) sigmaInstance = new Sigma(new graphology.Graph(), sigmaCanvas);
$: if (sigmaInstance && data.graph) {
const graph = graphology.Graph.from(data.graph);
graphologyLibrary.layout.random.assign(graph);
const settings = graphologyLibrary.layoutForceAtlas2.inferSettings(graph);
graphologyLibrary.layoutForceAtlas2.assign(graph, { iterations: 10, settings });
graphologyLibrary.layoutNoverlap.assign(graph, { settings: { ratio: 3 } });
sigmaInstance.graph = graph;
sigmaInstance.refresh();
}
</script>
<LynxKiteNode {...$$props}>
<div bind:this={sigmaCanvas} style="height: 200px; width: 200px;" >
</div>
</LynxKiteNode>
<style>
</style>
|