🎉 JointJS has new documentation! 🥳
The BPMN plugin provides you with a set of Business Process Model and Notation 2.0 shapes. They are designed to be easily configurable with the ui.Inspector plugin.
The plugin consists of flow shapes (Activities, Events, Gateways), connection objects (Flows), several icons and artifacts (DataObjects, Groups, Annotation). It also covers models introduced in version 2.0: Conversations and Connections.
Include joint.shapes.bpmn.js
file to your HTML:
<script src="joint.shapes.bpmn2.js"></script>
A rectangular Activity shape with icons.
source codeSupported attrs
properties:
Selector | Node | Description |
---|---|---|
root | SVGGElement | Container for all shape nodes |
background | SVGRectElement | Rectangle background of the shape |
border | SVGPathElement | Border of the shape (see built-in border styles and border types) |
icon | SVGImageElement | Image containing the icon (see list of available icons) |
label | SVGTextElement | Text inside the shape |
markers | SVGGElement | Container for marker icons (see list of available markers) |
Usage:
const activity = new joint.shapes.bpmn2.Activity({
attrs: {
'background': { fill: '#6764A7' },
'icon': { iconType: 'receive' },
'label': { text: 'My Activity' },
'markers': {
iconTypes: ['ad-hoc', 'loop'],
iconsFlow: 'column',
iconColor: '#ffffff'
}
}
});
Static property containing several marker icons that can be used with the Activity shape.
none | No image. |
---|---|
parallel | |
sequential | |
sub-process | |
compensation | |
ad-hoc | |
loop |
Add custom icons by defining them in the joint.shapes.bpmn2.Activity.ACTIVITY_MARKER_ICONS
static property.
// define myIcon
joint.shapes.bpmn2.Activity.ACTIVITY_MARKER_ICONS['myIcon'] = 'pathToImage'; // or data URI
// later on in the code
activity.attr('markers/iconTypes', ['myIcon']);
The marker value is stored as a data attribute on the marker icon (SVG path) element. An interaction with the marker icon can be caught and handled on the joint.dia.Paper. In the example bellow the model's marker name is displayed on interaction with the icon.
paper.on('element:marker:pointerdown', function(cellView, evt) {
const markerName = evt.target.dataset.iconType;
if (markerName) {
alert(markerName);
}
});
Static property including Activity type icons that can be used within the shapes.
none | No image. |
---|---|
receive | |
send | |
business-rule | |
service | |
script | |
manual | |
user |
Add custom icons by defining them in the joint.shapes.bpmn2.Activity.ACTIVITY_TYPE_ICONS
static property.
// define myIcon
joint.shapes.bpmn2.Activity.ACTIVITY_TYPE_ICONS['myIcon'] = 'pathToImage'; // or data URI
// later on in the code
activity.attr('icon/iconType', 'myIcon');
solid | Solid style border (default) |
---|---|
dashed | Dashed style border |
dotted | Dotted style border |
Usage:
activity.attr('border/borderStyle', 'dashed');
const task = new joint.shapes.bpmn2.Activity({
attrs: {
border: {
borderStyle: 'dashed'
}
}
});
single | Single line border (default) |
---|---|
thick | Single line border but thicker |
double | Double line border |
Usage:
activity.attr('border/borderType', 'double');
const task = new joint.shapes.bpmn2.Activity({
attrs: {
border: {
borderType: 'double'
}
}
});
Usage:
activity.attr('icon/iconColor', '#6764A7');
const task = new joint.shapes.bpmn2.Activity({
attrs: {
icon: {
iconType: 'send',
iconColor: '#6764A7'
}
}
});
activity.attr('markers/iconColor', '#6764A7');
const task = new joint.shapes.bpmn2.Activity({
attrs: {
markers: {
iconTypes: ['ad-hoc', 'loop'],
iconColor: '#6764A7'
}
}
});
row | Marker icons will be displayed in a row (default) |
---|---|
column | Marker icons will be displayed in a column |
Usage:
activity.attr('markers/iconsFlow', 'column');
const task = new joint.shapes.bpmn2.Activity({
attrs: {
markers: {
iconTypes: ['ad-hoc', 'loop'],
iconsFlow: 'column'
}
}
});
Usage:
activity.attr('markers/iconSize', 24);
const task = new joint.shapes.bpmn2.Activity({
attrs: {
markers: {
iconTypes: ['ad-hoc', 'loop'],
iconSize: 24
}
}
});
left-top | Sets the origin to top left |
---|---|
left-bottom | Sets the origin to left bottom |
right-top | Sets the origin to right top |
right-bottom | Sets the origin to right bottom |
top | Sets the origin to top middle |
bottom | Sets the origin to bottom middle (default) |
right | Sets the origin to right middle |
left | Sets the origin to left middle |
center | Sets the origin to center |
Usage:
activity.attr('markers/iconsOrigin', 'center');
const task = new joint.shapes.bpmn2.Activity({
attrs: {
markers: {
iconTypes: ['ad-hoc', 'loop'],
iconsOrigin: 'center'
}
}
});
Usage:
activity.attr('icon/iconType', 'send');
const task = new joint.shapes.bpmn2.Activity({
attrs: {
icon: {
iconType: 'send'
}
}
});
Usage:
activity.attr('markers/iconTypes', ['parallel', 'sequential'], { rewrite: true }); // pass 'rewrite' option to replace markers, instead of merging them with existing ones
const task = new joint.shapes.bpmn2.Activity({
attrs: {
markers: {
iconTypes: ['parallel', 'sequential']
}
}
});
A rectangular shape with label.
Supported attrs
properties:
Selector | Node | Description |
---|---|---|
root | SVGGElement | Container for all shape nodes |
body | SVGRectElement | Rectangle body of the shape |
border | SVGPathElement | Border of the shape (see border configuration) |
label | SVGTextElement | Annotation text |
Usage:
const group = new joint.shapes.bpmn2.Annotation({
attrs: {
'body': {
stroke: '#fe854f'
},
'label': {
text: 'Group'
}
}
});
annotationD
is an object with the following properties:
Property | Type | Description |
---|---|---|
size | Number | Thickness of Annotation border |
side | String ('left' | 'top' | 'right' | 'bottom') | Side on which to render Annotation border |
Usage:
annotation.attr('border/annotationD', { size: 30, side: 'bottom' });
const task = new joint.shapes.bpmn2.Annotation({
attrs: {
border: {
annotationD: {
size: 30,
side: 'bottom'
}
}
}
});
A dashed link.
Supported attrs
properties:
Selector | Node | Description |
---|---|---|
line | SVGPathElement | Visible connection of the link |
wrapper | SVGPathElement | An invisible, interactable wrapper around the connection used to make clicking on the link easier. |
Usage:
const annotationLink = new joint.shapes.bpmn2.AnnotationLink({});
annotationLink.prop('source', { x: 450, y: 600 });
annotationLink.prop('target', { x: 400, y: 750 });
annotationLink.attr('line/stroke', '#fe854f');
A polygon shape with label and markers.
Supported attrs
properties:
Selector | Node | Description |
---|---|---|
root | SVGGElement | Container for all shape nodes |
body | SVGPolygonElement | Polygon body of the shape |
markers | SVGGElement | Container for marker icons (see list of available markers) |
label | SVGTextElement | Shape text |
Usage:
const conversation = new joint.shapes.bpmn2.Conversation({
attrs: {
'body': {
fill: '#ffc2a7',
stroke: '#fe854f'
},
'label': {
text: 'My Conversation'
}
}
});
The joint.shapes.bpmn2.Conversation.CONVERSATION_MARKER_ICONS
static property includes icons that can be used within the shapes.
none | No image. |
---|---|
parallel | |
sequential | |
sub-process | |
compensation | |
ad-hoc | |
loop |
Add custom icons by defining them in the joint.shapes.bpmn2.Conversation.CONVERSATION_MARKER_ICONS
static property.
joint.shapes.bpmn2.Conversation.CONVERSATION_MARKER_ICONS['myIcon'] = 'pathToImage'; // or data URI
// later on in the code
conversation.attr('markers/iconTypes', ['myIcon']);
The marker value is stored as a data attribute on the marker icon (SVG path) element. An interaction with the marker icon can be caught and handled on the joint.dia.Paper. In the example bellow the model's marker name is displayed on interaction with the icon.
paper.on('element:marker:pointerdown', function(cellView, evt) {
const markerName = evt.target.dataset.iconType;
if (markerName) {
alert(markerName);
}
});
Usage:
conversation.attr('markers/iconColor', '#6764A7');
const task = new joint.shapes.bpmn2.Conversation({
attrs: {
markers: {
iconTypes: ['ad-hoc', 'loop'],
iconColor: '#6764A7'
}
}
});
row | Marker icons will be displayed in a row (default) |
---|---|
column | Marker icons will be displayed in a column |
Usage:
conversation.attr('markers/iconsFlow', 'column');
const task = new joint.shapes.bpmn2.Conversation({
attrs: {
markers: {
iconTypes: ['ad-hoc', 'loop'],
iconsFlow: 'column'
}
}
});
Usage:
conversation.attr('markers/iconSize', 24);
const task = new joint.shapes.bpmn2.Conversation({
attrs: {
markers: {
iconTypes: ['ad-hoc', 'loop'],
iconSize: 24
}
}
});
left-top | Sets the origin to top left |
---|---|
left-bottom | Sets the origin to left bottom |
right-top | Sets the origin to right top |
right-bottom | Sets the origin to right bottom |
top | Sets the origin to top middle |
bottom | Sets the origin to bottom middle (default) |
right | Sets the origin to right middle |
left | Sets the origin to left middle |
center | Sets the origin to center |
Usage:
conversation.attr('markers/iconsOrigin', 'center');
const task = new joint.shapes.bpmn2.Conversation({
attrs: {
markers: {
iconTypes: ['ad-hoc', 'loop'],
iconsOrigin: 'center'
}
}
});
Usage:
conversation.attr('markers/iconTypes', ['ad-hoc', 'loop'], { rewrite: true }); // pass 'rewrite' option to replace markers, instead of merging them with existing ones
const task = new joint.shapes.bpmn2.Conversation({
attrs: {
markers: {
iconTypes: ['ad-hoc', 'loop']
}
}
});
A double lined link.
Supported attrs
properties:
Selector | Node | Description |
---|---|---|
line | SVGPathElement | Visible connection of the link |
outline | SVGPathElement | Outline of the link |
wrapper | SVGPathElement | An invisible, interactive wrapper around the connection used to make clicking on the link easier. |
Usage:
const conversationLink = new joint.shapes.bpmn2.ConversationLink({
source: { x: 250, y: 260 },
target: { x: 700, y: 260 },
attrs: {
line: {
stroke: '#30d0c6',
},
outline: {
stroke: '#5654a0'
}
}
});
A dashed link.
Supported attrs
properties:
Selector | Node | Description |
---|---|---|
line | SVGPathElement | Visible connection of the link |
wrapper | SVGPathElement | An invisible, interactive wrapper around the connection used to make clicking on the link easier. |
Usage:
const dataAssociation1 = new joint.shapes.bpmn2.DataAssociation({
source: { x: 250, y: 260 },
target: { x: 700, y: 260 },
attrs: {
line: {
stroke: '#30d0c6',
}
}
});
A polygon shape with label.
Supported attrs
properties:
Selector | Node | Description |
---|---|---|
root | SVGGElement | Container for all shape nodes |
body | SVGPathElement | Path body of the shape (see body configuration options) |
label | SVGTextElement | Shape text |
dataTypeIcon | SVGImageElement | Image containing the icon (see list of available icons) |
collectionIcon | SVGImageElement | Image containing the collection icon (see list of available icons) |
Usage:
const dataObject = new joint.shapes.bpmn2.DataObject({
attrs: {
'body': {
fill: '#ffc2a7',
stroke: '#fe854f'
},
'label': {
text: 'Data Store'
}
}
});
The joint.shapes.bpmn2.DataObject.DATA_OBJECT_COLLECTION_ICONS
static property includes one icon that can be used within the shapes.
false | No image. |
---|---|
true |
Add custom icons by defining them in the joint.shapes.bpmn2.DataObject.DATA_OBJECT_COLLECTION_ICONS
static property.
joint.shapes.bpmn2.DataObject.DATA_OBJECT_COLLECTION_ICONS['myIcon'] = 'pathToImage'; // or data URI
// later on in the code
dataObject.attr('collectionIcon/iconType', 'myIcon');
The joint.shapes.bpmn2.DataObject.DATA_OBJECT_TYPE_ICONS
static property includes icons that can be used within the shapes.
none | No image. |
---|---|
input | |
output |
Add custom icons by defining them in the joint.shapes.bpmn2.DataObject.DATA_OBJECT_TYPE_ICONS
static property.
joint.shapes.bpmn2.DataObject.DATA_OBJECT_TYPE_ICONS['myIcon'] = 'pathToImage'; // or data URI
// later on in the code
dataObject.attr('dataTypeIcon/iconType', 'myIcon');
Usage:
dataObject.attr('collectionIcon/collection', 'true');
const task = new joint.shapes.bpmn2.DataObject({
attrs: {
collectionIcon: {
collection: 'true'
}
}
});
Usage:
dataObject.attr('collectionIcon/iconColor', '#6764A7');
const task = new joint.shapes.bpmn2.DataObject({
attrs: {
collectionIcon: {
collection: 'true',
iconColor: '#6764A7'
}
}
});
dataObject.attr('dataTypeIcon/iconColor', '#6764A7');
const task = new joint.shapes.bpmn2.DataObject({
attrs: {
dataTypeIcon: {
iconType: 'input',
iconColor: '#6764A7'
}
}
});
Usage:
dataObject.attr('dataTypeIcon/iconType', 'input');
const task = new joint.shapes.bpmn2.DataObject({
attrs: {
dataTypeIcon: {
iconType: 'input'
}
}
});
Usage:
dataObject.attr('body/objectD', 30);
const task = new joint.shapes.bpmn2.DataObject({
attrs: {
body: {
objectD: 30
}
}
});
A polygon shape with label.
Supported attrs
properties:
Selector | Node | Description |
---|---|---|
root | SVGGElement | Container for all shape nodes |
body | SVGPathElement | Path body of the shape |
top | SVGEllipseElement | Top ellipse element |
label | SVGTextElement | Shape text |
Usage:
const dataStore = new joint.shapes.bpmn2.DataStore({
attrs: {
'body': {
fill: '#ffc2a7',
stroke: '#fe854f'
},
'top': {
fill: '#ffc2a7',
stroke: '#fe854f'
},
'label': {
text: 'Data Store'
}
}
});
dataStore.topRy()
Return the vertical radius of the exposed area of the DataStore base (the value of the body/lateralArea
attribute; 10
by default).
dataStore.topRy(t, [opt])
Set the dataStore vertical radius of the exposed area of the cylinder base.
If the provided value is a percentage, it is relative to the refBBox.height
of the shape. In practice, only values between '0%'
and '50%'
make sense. If the provided value is a number, it determines the vertical radius directly. Only values between 0
and half of refBBox.height
make sense.
The function automatically sets the value of several attributes: body/lateralArea
; and top/ry
, top/cy
, top/refRy
and top/refCy
. If these arguments need to be modified further, make sure to assign them only after calling dataStore.topRy
.
Example usage:
const dataStore = new bpmn2.DataStore();
dataStore.resize(100, 200);
dataStore.position(525, 75);
dataStore.attr('root/title', 'joint.shapes.bpmn2.DataStore');
dataStore.attr('body/fill', 'lightgray');
dataStore.attr('top/fill', 'gray');
dataStore.attr('label/text', 'DataStore');
dataStore.topRy('10%');
dataStore.addTo(graph);
A circular shape with icon and label.
Supported attrs
properties:
Selector | Node | Description |
---|---|---|
root | SVGGElement | Container for all shape nodes |
background | SVGEllipseElement | Ellipse background of the shape |
border | SVGPathElement | Border of the shape (see built-in border types) |
icon | SVGImageElement | Image containing the icon (see list of available icons) |
label | SVGTextElement | Shape text |
Usage:
const group = new joint.shapes.bpmn2.Event({
attrs: {
'body': {
stroke: '#fe854f'
},
'label': {
text: 'Group'
}
}
});
The joint.shapes.bpmn2.Event.EVENT_ICONS
static property includes several icons that can be used within the shapes.
none | No image. |
---|---|
message1 | |
message2 | |
timer1 | |
conditional1 | |
link1 | |
link2 | |
signal1 | |
signal2 | |
error1 | |
error2 | |
escalation1 | |
escalation2 | |
termination1 | |
termination2 | |
compensation1 | |
compensation2 | |
cancel1 | |
cancel2 | |
multiple1 | |
multiple2 | |
parallel1 | |
parallel2 |
Add custom icons by defining them in the joint.shapes.bpmn2.Event.EVENT_ICONS
static property.
joint.shapes.bpmn2.Event.EVENT_ICONS['myIcon'] = 'pathToImage'; // or data URI
// later on in the code
event.attr('icon/iconType', 'myIcon');
solid | Solid style border (default) |
---|---|
dashed | Dashed style border |
dotted | Dotted style border |
Usage:
event.attr('border/borderStyle', 'dashed');
const task = new joint.shapes.bpmn2.Event({
attrs: {
border: {
borderStyle: 'dashed'
}
}
});
single | Single line border (default) |
---|---|
thick | Single line border but thicker |
double | Double line border |
Usage:
event.attr('border/borderType', 'double');
const task = new joint.shapes.bpmn2.Event({
attrs: {
border: {
borderType: 'double'
}
}
});
Usage:
event.attr('icon/iconColor', '#6764A7');
const task = new joint.shapes.bpmn2.Event({
attrs: {
icon: {
iconType: 'message1',
iconColor: '#6764A7'
}
}
});
Usage:
event.attr('icon/iconType', 'message1');
const task = new joint.shapes.bpmn2.Event({
attrs: {
icon: {
iconType: 'message1'
}
}
});
A link with configurable flow.
Supported attrs
properties:
Selector | Node | Description |
---|---|---|
line | SVGPathElement | Visible connection of the link (see configuration options) |
wrapper | SVGPathElement | An invisible, interactive wrapper around the connection used to make clicking on the link easier. |
Usage:
const flow = new joint.shapes.bpmn2.Flow({
source: { x: 250, y: 340 },
target: { x: 700, y: 340 },
attrs: {
line: {
flowType: 'message'
}
}
});
The joint.shapes.bpmn2.Flow
link comes with 4 flow types:
sequence | A simple link with no additional elements |
default | Adds crossed line at the source of the link |
conditional | Adds a rhombus at the source of the link |
message | Dashed link with circle at the source of the link |
Usage:
const flow = new joint.shapes.bpmn2.Flow({
source: { x: 100, y: 200 },
target: { x: 500, y: 200 },
attrs: {
line: {
flowType: 'message'
}
}
});
Note: markerFill applies only to message
and conditional
flowTypes.
Usage:
flow.attr('line/markerFill', '#fe854f');
const flow = new joint.shapes.bpmn2.Flow({
source: { x: 100, y: 200 },
target: { x: 500, y: 200 },
attrs: {
line: {
markerFill: '#fe854f',
flowType: 'message'
}
}
});
A polygon shape with icon.
Supported attrs
properties:
Selector | Node | Description |
---|---|---|
root | SVGGElement | Container for all shape nodes |
body | SVGPolygonElement | Polygon body of the shape |
label | SVGTextElement | Shape text |
icon | SVGImageElement | Image containing the icon (see list of available icons) |
Usage:
const gateway = new joint.shapes.bpmn2.Gateway({
attrs: {
'body': { fill: 'gold', stroke: 'black' },
'icon': { iconType: 'exclusive' },
'label': { text: 'My Activity' }
}
});
The joint.shapes.bpmn2.Gateway.GATEWAY_ICONS
static property includes several icons that can be used within the shapes.
exclusive_blank | No image. |
---|---|
exclusive | |
inclusive | |
parallel | |
event | |
exclusive_event | |
parallel_event | |
complex |
Add custom icons by defining them in the joint.shapes.bpmn2.Gateway.GATEWAY_ICONS
static property.
joint.shapes.bpmn2.Gateway.GATEWAY_ICONS['myIcon'] = 'pathToImage'; // or data URI
// later on in the code
gateway.attr('icon/iconType', 'myIcon');
Usage:
gateway.attr('icon/iconColor', '#6764A7');
const task = new joint.shapes.bpmn2.Gateway({
attrs: {
icon: {
iconType: 'exclusive',
iconColor: '#6764A7'
}
}
});
Usage:
gateway.attr('icon/iconType', 'exclusive');
const task = new joint.shapes.bpmn2.Gateway({
attrs: {
icon: {
iconType: 'exclusive'
}
}
});
A rectangle shape with label.
Supported attrs
properties:
Selector | Node | Description |
---|---|---|
root | SVGGElement | Container for all shape nodes |
body | SVGRectElement | Rectangle body of the shape |
wrapper | SVGRectElement | Rectangle wrapper of the shape |
label | SVGTextElement | Shape text |
Usage:
const group = new joint.shapes.bpmn2.Group({
attrs: {
'body': {
stroke: '#fe854f'
},
'label': {
text: 'Group'
}
}
});
A rectangle shape with nested lanes and an additional header. Inherits from joint.shapes.bpmn2.Pool
shape and adds a header
rectangle and headerLabel
text label.
Additional attrs
properties
Selector | Node | Description |
---|---|---|
header | SVGRectElement | Rectangular header of the shape, positioned to the left of the shape's body |
headerLabel | SVGTextElement | Text label inside the header |
To adjust the appearance of a HeaderedPool element, use the Element.attr
function:
const headeredPool = new joint.shapes.bpmn2.HeaderedPool();
headeredPool.resize(700, 400);
headeredPool.position(25, 200);
headeredPool.attr('root/magnet', false);
headeredPool.attr('laneHeaders/fill', '#3cb371');
headeredPool.attr('milestoneHeaders/fill', '#00fa9a');
headeredPool.attr('milestoneHeaders/stroke', '#333333');
headeredPool.attr('milestoneLines/stroke', '#3cb371');
headeredPool.attr('milestoneLines/strokeWidth', 2);
headeredPool.attr('milestoneLabels/fill', '#333333');
headeredPool.attr('milestoneLabels/fontStyle', 'italic');
headeredPool.attr('header/fill', '#00fa9a');
headeredPool.attr('headerLabel/text', 'Headered Pool');
headeredPool.attr('headerLabel/fill', '#ffffff');
headeredPool.addTo(graph);
All methods are inherited from the joint.shapes.bpmn2.Pool
shape.
All configuration properties are inherited from the joint.shapes.bpmn2.Pool
shape.
They are set during shape definition with the Cell.define
function, or anytime later with the Cell.set
function:
headeredPool.set('padding', 20);
headeredPool.set('padding', { top: 10, right: 20, bottom: 5, left: 10 });
headeredPool.set('lanes', [
{
label: 'fixed lane',
size: 80,
headerSize: 40
},
{
label: 'lane with sublanes',
sublanes: [
{
// omit the label property or make it undefined to hide the header
},
{
label: 'sublane 1'
}
]
}
]);
headeredPool.set('milestones', [
{
label: 'milestone'
},
{
label: 'milestone with fixed width',
size: 350
}
]);
A rectangle shape with nested lanes.
Supported attrs
properties:
Selector | Node | Description |
---|---|---|
root | SVGGElement | Container for all shape nodes |
body | SVGRectElement | Rectangle body of the shape |
laneGroups | SVGGElement | Selector for all lane groups |
laneHeaders | SVGRectElement | Selector for all lane rect headers |
laneLabels | SVGTextElement | Selector for all lane text labels |
lanes | SVGRectElement | Selector for all lane rect bodies |
milestoneGroups | SVGGElement | Selector for all milestone groups |
milestoneHeaders | SVGRectElement | Selector for all milestone rect headers |
milestoneLabels | SVGTextElement | Selector for all milestone text labels |
milestoneLines | SVGLineElement | Selector for all milestone lines |
Usage:
const pool = new joint.shapes.bpmn2.Pool({
position: { x: 100, y: 100 },
attrs: {
laneHeaders: {
fill: '#3cb371'
},
milestoneHeaders: {
fill: '#00fa9a',
stroke: '#333333'
},
milestoneLines: {
stroke: '#3cb371',
strokeWidth: 1
},
milestoneLabels: {
fill: '#333333',
fontStyle: 'italic'
}
},
milestonesSize: 30,
milestones: [
{
label: 'milestone',
},
{
label: 'fixed milestone',
size: 200
},
{
label: 'milestone',
}
],
headerSize: 30,
lanes: [
{
label: 'lane',
},
{
label: 'fixed lane',
size: 100
},
{
label: 'lane'
}
]
});
To adjust the appearance of a Pool element, use the Element.attr
function:
const pool = new joint.shapes.bpmn2.Pool();
pool.resize(700, 400);
pool.position(25, 200);
pool.attr('root/magnet', false);
pool.attr('laneHeaders/fill', '#3cb371');
pool.attr('milestoneHeaders/fill', '#00fa9a');
pool.attr('milestoneHeaders/stroke', '#333333');
pool.attr('milestoneLines/stroke', '#3cb371');
pool.attr('milestoneLines/strokeWidth', 2);
pool.attr('milestoneLabels/fill', '#333333');
pool.attr('milestoneLabels/fontStyle', 'italic');
pool.addTo(graph);
The Pool shape exposes functions that enable working with lanes and milestones:
pool.getLaneBBox(laneGroupId)
Get the bounding box of a lane group (header + lane) with laneGroupId
id.
pool.getLanePath(laneGroupId)
Returns the path to the lane in attributes with laneGroupId
id.
Example:
const path = pool.getLanePath('customId') + '/label';
pool.prop(path, 'new label', { rewrite: true });
pool.getLanesFromPoint(point)
Find lanes from a given point
, where point
is an object with x
and y
coordinates in the paper local coordinate system. Returns a sorted array of lane ids (from the most nested lane to the top parent) which bounding box contains the point
.
Note: if lane has a custom id assigned, it will be returned instead.
pool.getMilestoneBBox(milestoneGroupId)
Get the bounding box of a milestone group (including its header) by milestoneGroupId
id.
pool.getMilestoneFromPoint(point)
Find a milestone from a given point
, where point
is an object with x
and y
coordinates in the paper local coordinate system. Returns a string id of the milestone which bounding box contains point
.
Note: if milestone has a custom id assigned, it will be returned instead.
pool.getMinimalSize()
Return the width and height of the minimal bounding box necessary to encompass all of the shape's content.
Configuration properties
Property | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
lanes | object[] | Lanes in the Pool. Each lane is contained in a group along with the header and has a unique id. Each lane may have optional properties:
|
||||||||||||||||||
milestones | object[] | Milestones in the Pool. Each milestone may have optional properties:
|
||||||||||||||||||
milestonesSize | number | Height of all milestones | ||||||||||||||||||
headerSize | number | Default size of all lane headers | ||||||||||||||||||
padding | object | Padding within the Pool's body element, useful when creating another shapes based on Pool |
Configuration properties are set during shape definition with the Cell.define
function, or anytime later with the Cell.set
function:
pool.set('padding', 20);
pool.set('padding', { top: 10, right: 20, bottom: 5, left: 10 });
pool.set('lanes', [
{
label: 'fixed lane',
size: 80,
headerSize: 40
},
{
label: 'lane with sublanes',
sublanes: [
{
id: 'customLane'
// omit the label property or make it undefined to hide the header
},
{
label: 'sublane 1'
}
]
}
]);
pool.set('milestones', [
{
label: 'milestone'
},
{
label: 'milestone with fixed width',
id: 'customMilestone',
size: 350,
}
]);
// change the attrs using custom id
pool.attr('lane_customLane/fill', '#3cb371');
pool.attr('milestoneLabel_customMilestone/fontSize', '18');
Id of lanes and milestones
Each lane and milestone group has a unique id that can be used to target those groups or individual elements within groups. Passing string toid
property of a lane or milestone will create an alias to that given group.
Note: custom id must be unique and the same id cannot be assigned for more than 1 milestone or 1 lane group.
lane
)header
, note that header won't be added if label is undefined)label
, note that label won't be added if it is undefined)lanes: [
{
label: 'lane' // group id: 'lanes_0', lane id: 'lane_0', header id: 'header_0', label id: 'label_0'
},
{
label: 'lane with sublanes', // group id: 'lanes_1', lane id: 'lane_1', header id: 'header_1', label id: 'label_1'
sublanes: [
{
label: 'sublane 1' // group id: 'lanes_1_0', lane id: 'lane_1_0', header id: 'header_1_0', label id: 'label_1_0'
},
{
label: 'sublane 2' // group id: 'lanes_1_1', lane id: 'lane_1_1', header id: 'header_1_1', label id: 'label_1_1'
}
]
},
// example with custom id
{
id: 'customId',
label: 'lane with custom id', // group id: 'lanes_customId', lane id: 'lane_customId', header id: 'header_customId', label id: 'label_customId'
sublanes: [
{
label: 'sublane 1' // group id: 'lanes_2_0', lane id: 'lane_2_0', header id: 'header_2_0', label id: 'label_2_0'
},
{
id: 'sublaneId',
label: 'sublane 2' // group id: 'lanes_sublaneId', lane id: 'lane_sublaneId', header id: 'header_sublaneId', label id: 'label_sublaneId'
}
]
}
]
milestoneHeader
)milestoneLabel
)milestoneLine
)milestones: [
{
label: 'milestone 1' // group id: 'milestone_0', header id: 'milestoneHeader_0', label id: 'milestoneLabel_0', line id: 'milestoneLine_0'
},
{
label: 'milestone 2' // group id: 'milestone_1', header id: 'milestoneHeader_1', label id: 'milestoneLabel_1', line id: 'milestoneLine_1'
},
// example with custom id
{
id: 'customId',
label: 'milestone 3' // group id: 'milestone_customId', header id: 'milestoneHeader_customId', label id: 'milestoneLabel_customId', line id: 'milestoneLine_customId'
}
]
Aligns the label to the specified side, relatively to the header:
left-top | Sets the alignment to top left |
---|---|
left-bottom | Sets the alignment to left bottom |
right-top | Sets the alignment to right top |
right-bottom | Sets the alignment to right bottom |
top | Sets the alignment to top middle |
bottom | Sets the alignment to bottom middle |
right | Sets the alignment to right middle (default for milestone labels) |
left | Sets the alignment to left middle |
center | Sets the alignment to center (default for lane labels) |
Usage:
const pool = new joint.shapes.bpmn2.Pool({
lanes: [
{
label: 'pool lane',
id: 'firstLane'
},
{
label: 'pool lane'
}
],
milestones: [
{
label: 'pool milestone',
id: 'firstMilestone'
},
{
label: 'pool milestone'
}
],
attrs: {
laneLabels: {
labelAlignment: 'left' // aligns all lane labels to the left side
},
milestoneLabels: {
labelAlignment: 'center' // aligns all milestone labels in the center
},
label_firstLane: {
labelAlignment: 'right' // align lane label with custom id
},
milestoneLabel_firstMilestone: {
labelAlignment: 'right' // align milestone label with custom id
}
}
});
// align all labels
pool.attr('laneLabels/labelAlignment', 'left');
pool.attr('milestoneLabels/labelAlignment', 'center');
// align individual labels with custom id
pool.attr('label_firstLane/labelAlignment', 'right');
pool.attr('milestoneLabel_firstMilestone/labelAlignment', 'right');
Applies margin around the label. The util.normalizeSides
is used to understand the provided value.
A single number is applied as padding to all sides of the elements. An object may be provided to specify values for
left
, top
, right
, bottom
, horizontal
and/or vertical
sides.
Usage:
const pool = new joint.shapes.bpmn2.Pool({
headerSize: 32,
milestonesSize: 32,
lanes: [
{
label: 'pool lane',
id: 'firstLane'
},
{
label: 'pool lane'
}
],
milestones: [
{
label: 'pool milestone',
id: 'firstMilestone'
},
{
label: 'pool milestone'
}
],
attrs: {
laneLabels: {
labelMargin: 4 // adds 4px margin on all sides to all lane labels
},
milestoneLabels: {
labelMargin: { vertical: 10 } // adds 10px top and 10px bottom margin to all milestone labels
},
// control margin of individual labels with custom id
label_firstLane: {
labelMargin: 0
},
milestoneLabel_firstMilestone: {
labelMargin: { horizontal: 8 }
}
}
});
// add margin to all labels
pool.attr('laneLabels/labelMargin', 4);
pool.attr('milestoneLabels/labelMargin', { vertical: 6 });
// control the margin of individual labels with custom id
pool.attr('label_firstLane/labelMargin', 0);
pool.attr('milestoneLabel_firstMilestone/labelMargin', { vertical: 4, horizontal: 20 });