-
Notifications
You must be signed in to change notification settings - Fork 0
/
diagram.js
44 lines (36 loc) · 1.34 KB
/
diagram.js
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
32
33
34
35
36
37
38
39
40
41
42
43
44
const ZohoCreator = require('./zohoCreator');
const models = require('./model');
const bookingCreator = new ZohoCreator({ space_name: 'booking', models });
async function renderDiagram() {
const stages = await bookingCreator.getStages();
const transitions = await bookingCreator.getTransitions(); // Assuming you have a method to get transitions
// Convert stages and transitions to a format suitable for JointJS or GoJS
// Example for JointJS:
const graph = new joint.dia.Graph();
const paper = new joint.dia.Paper({
el: document.getElementById('paper'),
model: graph,
width: 800,
height: 600,
gridSize: 10,
drawGrid: true
});
const stageElements = stages.map(stage => {
const rect = new joint.shapes.standard.Rectangle();
rect.position(stage.x, stage.y);
rect.resize(100, 40);
rect.attr({
body: { fill: 'blue' },
label: { text: stage.name, fill: 'white' }
});
return rect;
});
stageElements.forEach(element => element.addTo(graph));
transitions.forEach(transition => {
const link = new joint.shapes.standard.Link();
link.source(stageElements[transition.fromStageIndex]);
link.target(stageElements[transition.toStageIndex]);
link.addTo(graph);
});
}
renderDiagram();