Appmixer
Search…
Custom Component Shapes
Fully customize appearance of components in diagrams.

Usage

Shape registration in the Appmixer SDK:
1
var appmixer = new Appmixer({
2
componentShapes: {
3
action: myCustomComponentShape,
4
trigger: myCustomComponentShape,
5
myUniqueShape: myCustomComponentShape
6
},
7
});
Copied!
Use "action" and "trigger" keys to override defaults. You can define a custom shape for any component in the system, shape reference in a component manifest looks like this:
1
{
2
shape: "myUniqueShape"
3
}
Copied!
Built-in shapes are action, trigger, actionVertical and triggerVertical.

Definition

Key
Description
options.updateCallback
An optional method called before the component is updated. Accepts element argument.
attributes
Element attributes, see: jointjs.dia.Cell.define
states
Definition for particular states of the component. The object structure is the same as the current scope (except for the "states" entry).
@active- the component is being modified
@invalid- the component configuration is invalid
@referenced- the component is highlighted
@unchecked- the component is unchecked
@checked- the component is checked
@running- the flow is in a running state
@selected- the component is selected
ports.attributes
Ports attributes of joint.dia.Element.ports.interface
ports.states
Definition for particular states of individual ports.
The object structure is the same as the current scope (except for the "states" entry).
@connected - the port is connected
link.attributes
Link attributes, see: jointjs.dia.Link

Special selectors

Dynamic properties of the component, such as label and icon, are mapped to optional selectors in the markup.
Selector
tagName
Description
label
text
Component label.
icon
image
Component icon.
element-halo-copy-tooltip
title
"Copy" button tooltip.
element-halo-cut-tooltip
title
"Cut" button tooltip.
element-halo-remove-tooltip
title
"Remove" button tooltip.

Special attributes

Key
Value
Description
event
"remove"
The entry acts as a remove button.
1
var myCustomComponentShape = {
2
attributes: {
3
size: { height: 60, width: 60 },
4
markup: [{
5
tagName: 'rect',
6
selector: 'body',
7
}, {
8
tagName: 'text',
9
selector: 'label'
10
}, {
11
tagName: 'image',
12
selector: 'icon',
13
}],
14
attrs: {
15
body: {
16
event: 'remove', // Click on the "body" will remove the element
17
refWidth: '100%',
18
refHeight: '100%',
19
stroke: 'black',
20
strokeWidth: '4px',
21
fill: 'white',
22
},
23
label: {
24
ref: 'body',
25
textAnchor: 'middle',
26
refX: 0.5,
27
refY: '100%',
28
refY2: 12,
29
fill: 'black',
30
fontFamily: 'Helvetica, Arial, sans-serif',
31
},
32
icon: {
33
ref: 'body',
34
refX: 0.5,
35
refY: 0.5,
36
xAlignment: 'middle',
37
yAlignment: 'middle',
38
height: 30,
39
width: 30,
40
},
41
},
42
},
43
ports: {
44
attributes: {
45
in: {
46
attrs: {
47
'.port-label': {
48
fontFamily: 'Helvetica, Arial, sans-serif',
49
fontSize: 12,
50
},
51
},
52
},
53
out: {
54
attrs: {
55
'.port-label': {
56
fontFamily: 'Helvetica, Arial, sans-serif',
57
fontSize: 12,
58
},
59
},
60
},
61
},
62
},
63
link: {
64
attributes: {
65
router: {
66
name: 'metro',
67
},
68
},
69
attrs: {
70
line: {
71
event: "remove", // Click on the line will remove the link
72
},
73
},
74
},
75
states: {
76
'@active': {
77
attributes: {
78
attrs: {
79
body: {
80
stroke: 'blue',
81
},
82
},
83
},
84
link: {
85
attributes: {
86
attrs: {
87
line: {
88
stroke: 'blue',
89
},
90
},
91
},
92
},
93
},
94
},
95
};
Copied!
Last modified 11mo ago
Copy link