Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add demo "visualize path between two consecutive shapes" #452

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
4ddf20d
Add new example with color shape by click
csouchet Feb 7, 2023
8fac060
Don't add css class to shape, if one is already highlight
csouchet Feb 7, 2023
a8d3973
Disable all shapes & edges when a shape is selected
csouchet Feb 8, 2023
66730d4
Color the possible next step on hover
csouchet Feb 8, 2023
e171d5f
Hightlight the second shape & the edge on click
csouchet Feb 8, 2023
efec3a7
Don't display possible next if the second shape is selected
csouchet Feb 8, 2023
396c8ed
Reset all CSS classes on third selected shape
csouchet Feb 8, 2023
07ffada
disable mouse pointer
csouchet Feb 8, 2023
77db531
Clean code
csouchet Feb 8, 2023
f53948f
Add legend
csouchet Feb 8, 2023
cdeea92
Update the image
csouchet Feb 8, 2023
8d119af
Add bar for the progression
csouchet Feb 8, 2023
b022535
Make possible to not have title for the container
csouchet Feb 8, 2023
24f6a65
Move the legend
csouchet Feb 8, 2023
526f1b3
Move progress bar & reset button
csouchet Feb 8, 2023
d26cd4a
implement behavior on click of the Reset button
csouchet Feb 8, 2023
cf0f56a
Use 'div' and not link in steps
csouchet Feb 14, 2023
5a1d95d
Not possible to click on a end event in first
csouchet Feb 14, 2023
d1734d5
Merge branch 'master' into 433-Add_a_new_demo_to_visualize_the_path_b…
csouchet Feb 14, 2023
344f443
Make possible to click on a edge to highlight a path
csouchet Feb 14, 2023
0edbcc3
Change the wording in the legends
csouchet Feb 14, 2023
9bd6a1a
Fix the navigation on the steps
csouchet Feb 14, 2023
8b23bf7
Make refactoring on edge handler
csouchet Feb 14, 2023
a282723
Refactor PathUseCase
csouchet Feb 14, 2023
a4e84d7
get shapes & edges in dedicated methods
csouchet Feb 14, 2023
fa2e9f1
Extract the configuration of handlers for the shapes & the edges in o…
csouchet Feb 14, 2023
3ee7af6
Not possible to highlight previous path when over on previous edge
csouchet Feb 14, 2023
6c18b19
Simplify the activation of the pointer
csouchet Feb 14, 2023
f93fab6
- Highlight the first selectable shape with the Possible color
csouchet Feb 14, 2023
395e33f
Add a tooltip on the Refresh button
csouchet Feb 14, 2023
51ede0f
Update the tooltip messages
csouchet Feb 14, 2023
2a9dffa
Merge branch 'master' into 433-Add_a_new_demo_to_visualize_the_path_b…
csouchet Feb 14, 2023
57e6c91
Use the workaround to break line in tooltips
csouchet Feb 16, 2023
d00c77f
Update demo/draw-path/index.html
csouchet Feb 16, 2023
c594b5e
Simplify how to get shapes & edges
csouchet Feb 16, 2023
5a823b0
Fix license header in HTML file
tbouffard Feb 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ especially when using `bpmn-visualization` prior version `0.27.0`.
- [Hacktoberfest themes](demo/hacktoberfest-custom-themes/README.md) - special Hacktoberfest diagram with Hacktoberfest colors
- [Monitoring of all process instances demo](demo/monitoring-all-process-instances/README.md) - show how to use `bpmn-visualization` to render the monitoring of all process instances for a defined process
- [Demo for ICPM 2022](demo/icpm-2022/README.md) - show a Process Mining scenario (_Conformance_, _Compliance_ and _Happy path_)
- [Draw a path](demo/draw-path/README.md) - show how to draw a path


## Tutorials
Expand Down
5 changes: 5 additions & 0 deletions demo/draw-path/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Draw me a path

Javascript example to demonstrate how to use `bpmn-visualization` to draw a path.
- [__⏩ live environment__](https://cdn.statically.io/gh/process-analytics/bpmn-visualization-examples/master/demo/draw-path/index.html)
- to run locally, open the [index.html](index.html) directly in a Web Browser
41 changes: 41 additions & 0 deletions demo/draw-path/css/legend.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
fieldset {
border: 1px solid#ddd;
padding: 5px 12px;
}

legend {
font-size: 18px;
padding: 0 10px;
margin: auto;
}

.legend li:first-child::before {
background-color: var(--color-disableAll);
}
.legend li:nth-child(2)::before {
background-color: var(--color-highlight);
}
.legend li:nth-child(3)::before {
background-color: var(--color-possibleNext);
}

.legend li::before {
content: "";
display: inline-block;
vertical-align: middle;
margin-inline-end: .5rem;
border-width: 2px;
border-style: solid;
width: 1rem;
height: 1rem;
border-radius: 3px;
border-color: #000;
}

.legend li {
line-height: 1rem;
}
.legend {
list-style: none;
font-size: 0.8rem;
}
83 changes: 83 additions & 0 deletions demo/draw-path/css/path.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
:root {
--color-disableAll: Silver;
--color-highlight: LightSeaGreen;
--color-possibleNext: MediumVioletRed;
}

#use-case-panel {
padding-bottom: 0;
}

.bpmn-type-event:hover, .bpmn-type-gateway:hover, .bpmn-type-activity:hover, .bpmn-type-flow:hover {
cursor: pointer;
}

.disablePointer.bpmn-type-event:hover, .disablePointer.bpmn-type-gateway:hover, .disablePointer.bpmn-type-activity:hover, .disablePointer.bpmn-type-flow:hover {
cursor: default;
}

/* ------------------------------------------------ DISABLE EVERYTHING ------------------------------------------------ */
/* SHAPE & EDGE */
.disableAll.bpmn-type-activity > *,
.disableAll.bpmn-type-event > *,
.disableAll.bpmn-type-gateway > *,
.disableAll.bpmn-type-flow > * {
stroke: var(--color-disableAll);
}

/* ICON */
.disableAll.bpmn-type-gateway > path:nth-child(2), .disableAll.bpmn-type-flow > path:nth-child(3) {
fill: var(--color-disableAll);
}

/* LABEL */
.disableAll.bpmn-type-activity > g > foreignObject > div > div > div,
.disableAll.bpmn-type-event > g > foreignObject > div > div > div,
.disableAll.bpmn-type-gateway > g > foreignObject > div > div > div,
.disableAll.bpmn-type-flow > g > foreignObject > div > div > div {
color: var(--color-disableAll) !important;
}

/* ------------------------------------------------ HIGHLIGHT ------------------------------------------------ */
/* SHAPE */
.highlight.bpmn-type-activity > rect:first-child,
.highlight.bpmn-type-event > ellipse:first-child,
.highlight.bpmn-type-gateway > path:first-child,
.highlight.bpmn-type-flow > * {
stroke: var(--color-highlight);
filter: drop-shadow(0 0 0.75rem var(--color-highlight));
}

/* ICON */
.highlight.bpmn-type-gateway > :not(:first-child) {
stroke: var(--color-highlight);
}

.highlight.bpmn-type-gateway > path:nth-child(2), .highlight.bpmn-type-flow > path:nth-child(3) {
fill: var(--color-highlight);
}

/* ------------------------------------------------ POSSIBLE NEXT ------------------------------------------------ */
/* SHAPE & EDGE */
.possibleNext.bpmn-type-activity > *,
.possibleNext.bpmn-type-event > *,
.possibleNext.bpmn-type-gateway > *,
.possibleNext.bpmn-type-flow > * {
stroke: var(--color-possibleNext) !important;
}

/* ICON */
.possibleNext.bpmn-type-gateway > path:nth-child(2), .possibleNext.bpmn-type-flow > path:nth-child(3) {
fill: var(--color-possibleNext) !important;
}

/* LABEL */
.possibleNext.bpmn-type-activity > g > foreignObject > div > div > div,
.possibleNext.bpmn-type-event > g > foreignObject > div > div > div,
.possibleNext.bpmn-type-gateway > g > foreignObject > div > div > div,
.possibleNext.bpmn-type-flow > g > foreignObject > div > div > div {
color: var(--color-possibleNext) !important;
}



33 changes: 33 additions & 0 deletions demo/draw-path/css/step.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* To override the kind of the children of a .step of SPECTRE.CSS */
.step .step-item.active ~ .step-item div {
color: #bcc3ce;
}
.step .step-item div {
color: #5755d9;
display: inline-block;
padding: 20px 10px 0;
text-decoration: none;
}

.step .step-item.active ~ .step-item div::before {
background: #dadee4;
}

.step .step-item.active div::before {
background: #fff;
border: .1rem solid #5755d9;
}
.step .step-item div::before {
background: #5755d9;
border: .1rem solid #fff;
border-radius: 50%;
content: "";
display: block;
height: .6rem;
left: 50%;
position: absolute;
top: .2rem;
transform: translateX(-50%);
width: .6rem;
z-index: 1;
}
121 changes: 121 additions & 0 deletions demo/draw-path/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<!--
Copyright 2023 Bonitasoft S.A.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>bpmn-visualization - Draw me a path</title>
<link rel="icon" type="image/svg+xml" href="../../examples/favicon.svg">
<link rel="stylesheet" href="../../examples/static/css/spectre.min.css" type="text/css">
<link rel="stylesheet" href="../../examples/static/css/icons.min.css" type="text/css">
<link rel="stylesheet" href="../../examples/static/css/main.css" type="text/css">
<link rel="stylesheet" href="../static/css/style.css" type="text/css">
<link rel="stylesheet" href="./css/path.css" type="text/css">
<link rel="stylesheet" href="./css/legend.css" type="text/css">
<link rel="stylesheet" href="./css/step.css" type="text/css">
<script defer src="../../examples/static/js/link-to-sources.js"></script>
<!-- load bpmn-visualization -->
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/bpmn-visualization.min.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/index.umd.js" integrity="sha256-lNJnNIdh5oXecah6rOix/TxyGcOYnfkybx4Qii2uxSo="
crossorigin="anonymous"></script>
<script defer src="https://variancecharts.com/cdn/variance-noncommercial-standalone-6d26aa2.min.js" charset="UTF-8"></script>
<script defer src="../../examples/static/js/diagram/bpmn-diagrams.js"></script>
<script defer src="../static/js/use-case.js"></script>
<script defer src="./js/paths.js"></script>
<script defer src="./js/steps.js"></script>
<script defer src="./js/path-use-case.js"></script>
<script defer src="./js/index.js"></script>
</head>
<body>
<header class="navbar bg-dark p-2">
<section class="navbar-section ml-2">
<a class="home" href="../../examples/index.html">
<img src="../../examples/static/img/logo_64x64_white.png" alt="logo" class="logo">
<span class="h3 text-light ml-2 lib-name-text">bpmn-visualization examples</span>
</a>
</section>
<section class="navbar-section">
<a href="https://process-analytics.github.io/bpmn-visualization-js/" class="mr-2 btn btn-secondary">Docs</a>
<div class="dropdown mr-2">
<a href="#" class="btn btn-primary dropdown-toggle" tabindex="0">
GitHub <span class="icon icon-caret icon-in-the-middle"></span>
</a>
<ul class="menu">
<li><a href="https://github.com/process-analytics/bpmn-visualization-js"
class="mr-2 btn btn-link">Library</a></li>
<li><a href="https://github.com/process-analytics/bpmn-visualization-examples"
class="mr-2 btn btn-link">Examples</a></li>
</ul>
</div>
</section>
</header>

<section class="container col-12 flex-centered" style="margin-top: .8rem !important">
<div class="col-11 col-mx-auto">
<div class="col-10 col-mx-auto">
<h2>Draw me a path</h2>
<p>Visualize the path between two consecutive shapes.</p>
</div>

<div class="col-11 col-mx-auto" style="margin-top: 2rem; margin-bottom: 1rem">
<div id="controls" class="column bg-secondary pt-2 pb-2">
<div class="columns">
<div id="choose-use-case-panel" class="col-10" style="margin: auto">
<h5>Progress</h5>
<ul class="step">
<li id="step1" class="step-item active">
<div class="tooltip" data-tooltip="Click on an event, a gateway or an activity">Click on a shape</div>
</li>
<li id="step2" class="step-item">
<!-- According to the official documentation of Spectre.css, we should only add \n to have multiple lines on the tooltip,
csouchet marked this conversation as resolved.
Show resolved Hide resolved
but it doesn't work: https://picturepan2.github.io/spectre/components/tooltips.html#tooltips-multiline
The workaround: https://github.com/picturepan2/spectre/issues/692#issuecomment-1310063019 -->
<div class="tooltip" data-tooltip="Click on a next consecutive event,&#010a next consecutive gateway&#010or a next consecutive activity">Click on a next shape
</div>
</li>
<li id="step3" class="step-item">
<div class="tooltip" data-tooltip="Click on 'Refresh' button,&#010another event,&#010another gateway&#010or another activity">Reset</div>
</li>
</ul>
</div>
<div class="col-auto" style="margin: auto">
<button id="btn-reset" type="reset" class="btn btn-error btn-action s-circle tooltip" data-tooltip="Refresh the diagram">
<i class="icon icon-refresh"></i>
</button>
</div>
</div>
</div>
<div id="use-case-panel">
<div class="columns" style="padding-left: 2rem">
<div id="legend" class="column col-2 col-mx-auto" style="margin: auto">
<fieldset>
<legend>Legend</legend>
<ul class="legend">
<li>Disabled items</li>
<li>Selected items</li>
<li>Possible path</li>
</ul>
</fieldset>
</div>
<div class="column col-10 col-mx-auto">
<div id="path-bpmn-container" class="col-12 bpmn-container"></div>
</div>
</div>
</div>
</div>
</div>
</section>
<footer class="flex-centered"></footer>
</body>
</html>
8 changes: 8 additions & 0 deletions demo/draw-path/js/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Initialize UseCase
const useCase = new PathUseCase(getHardwareRetailerDiagram);

document.addEventListener('DOMContentLoaded', function () {
// Waiting for the displayed page before to load diagram & display data
useCase.display();
})

Loading