-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
index.html
98 lines (75 loc) · 2.85 KB
/
index.html
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<style>
html, body, #diagram {
height: 100%
}
.highlight:not(.djs-connection) .djs-visual > :nth-child(1) {
fill: green !important; /* color elements as green */
}
.highlight-overlay {
background-color: green; /* color elements as green */
opacity: 0.4;
pointer-events: none; /* no pointer events, allows clicking through onto the element */
border-radius: 10px;
}
</style>
<!--
this is an example of how to add colors to your BPMN diagram using bpmn-js
-->
<title>bpmn-js colors example - bpmn-js-examples</title>
</head>
<body>
<h1>bpmn-js Colors</h1>
<div id="diagram"></div>
<!-- required modeler styles -->
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/assets/diagram-js.css">
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/assets/bpmn-js.css">
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/assets/bpmn-font/css/bpmn.css">
<!-- modeler distro -->
<script src="https://unpkg.com/[email protected]/dist/bpmn-modeler.development.js"></script>
<!-- jquery (required for example only) -->
<script src="https://unpkg.com/[email protected]/dist/jquery.js"></script>
<!-- app -->
<script>
var viewer = new BpmnJS({
container: '#diagram'
});
async function showDiagram(diagramXML) {
await viewer.importXML(diagramXML);
var overlays = viewer.get('overlays'),
canvas = viewer.get('canvas'),
elementRegistry = viewer.get('elementRegistry'),
modeling = viewer.get('modeling');
// Option 1: Color via Overlay
var shape = elementRegistry.get('CalmCustomerTask');
var $overlayHtml = $('<div class="highlight-overlay">')
.css({
width: shape.width,
height: shape.height
});
overlays.add('CalmCustomerTask', {
position: {
top: 0,
left: 0
},
html: $overlayHtml
});
// Option 2: Color via BPMN 2.0 Extension
var elementToColor = elementRegistry.get('SelectAPizzaTask');
modeling.setColor([ elementToColor ], {
stroke: 'green',
fill: 'rgb(152, 203, 152)'
});
// Option 3: Color via Marker + CSS Styling
canvas.addMarker('OrderReceivedEvent', 'highlight');
}
// load + show diagram
$.get('https://cdn.statically.io/gh/bpmn-io/bpmn-js-examples/main/colors/resources/pizza-collaboration.bpmn', showDiagram, 'text');
</script>
</body>
</html>