We currently don't have a tutorial with Svelte, but we plan on making one in the future. You can get some ideas of project setup for other JS frameworks from our tutorials here:
afterwards.
In the main App.svelte file, you could copy the following as the <script> and <main> tag:
<script>
import { onMount } from 'svelte';
import { dia, shapes } from 'jointjs';
onMount(async () => {
var namespace = shapes;
var graph = new dia.Graph({}, { cellNamespace: namespace });
var paper = new dia.Paper({
el: document.getElementById('app'),
model: graph,
width: 600,
height: 100,
gridSize: 1,
cellViewNamespace: namespace
});
var rect = new shapes.standard.Rectangle();
rect.position(100, 30);
rect.resize(100, 40);
rect.attr({
body: {
fill: 'blue'
},
label: {
text: 'Hello',
fill: 'white'
}
});
rect.addTo(graph);
var rect2 = rect.clone();
rect2.translate(300, 0);
rect2.attr('label/text', 'World!');
rect2.addTo(graph);
var link = new shapes.standard.Link();
link.source(rect);
link.target(rect2);
link.addTo(graph);
});
</script>
<main id="app">
</main>
It follows the tutorial here:
https://resources.jointjs.com/tutorial/hello-worldIt is very basic, but should be enough to get you started. We hope to include some information on Sveltekit in our tutorial too.
Thanks,
James