🎉 JointJS has new documentation! 🥳
Set of shapes for displaying dimensions of objects, the distances between them, and their relative angles.
A line with angle arcs drawn at its ends.
Supportedattrs
properties
Selector | Node | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
root | SVGGElement | Container of all nodes | ||||||||||||||||||
line | SVGPathElement | Visible connection of the link | ||||||||||||||||||
wrapper | SVGPathElement | Invisible wrapper around the connection to make the line thicker, so the user can interact with the link more easily. | ||||||||||||||||||
angles | group of SVGPathElements | Group of both angle arcs (sourceAngle and targetAngle ). Each angle is an arc between this link and another cell (element or link).
There are several custom presentation attributes, which further control the angle behavior.
|
||||||||||||||||||
sourceAngle | SVGPathElement | Angle arc between the link and the source cell (element or link). The node can specify all angles custom presentation attributes; the values set here will overwrite the more generic values from angles . |
||||||||||||||||||
targetAngle | SVGPathElement | Angle arc between the link and the target cell (element or link). The node can specify all angles custom presentation attributes; the values set here will overwrite the more generic values from angles . |
||||||||||||||||||
angleLabels | group of SVGTextElements | Group of both angle labels (sourceAngleLabel and targetAngleLabel ). Each label is a text element positioned within the angle arc; it shows the current angle value, in degrees.
There are several custom presentation attributes, which further control the angle label behavior.
|
||||||||||||||||||
targetAngleLabel | SVGTextElement | Label of the source angle; it shows the current angle value, in degrees. The node can specify all angleLabels custom presentation attributes; the values set here will overwrite the more generic values from angleLabels . |
||||||||||||||||||
sourceAngleLabel | SVGTextElement | Label of the target angle; it shows the current angle value, in degrees. The node can specify all angleLabels custom presentation attributes; the values set here will overwrite the more generic values from angleLabels . |
var angle = new joint.shapes.measurement.Angle();
angle.attr('root/title', 'joint.shapes.measurement.Angle');
angle.attr('line/stroke', '#fe854f');
angle.attr('angleLabels/stroke', '#fe854f');
// Source Connected To An Element
angle.source(element, {
anchor: { name: 'left' },
connectionPoint: { name: 'anchor' }
});
angle.attr('sourceAngle/fill', 'lightgray');
angle.attr('sourceAngle/anglePie', true);
angle.attr('sourceAngleLabel/fill', '#333333');
// Target Connected To A Link
angle.target(link, {
anchor: { name: 'connectionRatio', { args: { ratio: 0.2 }}},
});
angle.attr('targetAngle/angleStart', 'source');
angle.attr('targetAngle/angleDirection', 'anticlockwise');
angled.addTo(graph);
A line with a label that shows the distance between the source and the target of the link (the length of the connection path).
Supportedattrs
properties
Selector | Node | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
root | SVGGElement | Container of all nodes | |||||||||
line | SVGPathElement | Visible connection of the link | |||||||||
wrapper | SVGPathElement | Invisible wrapper around the connection to make the line thicker, so the user can interact with the link more easily. | |||||||||
anchorLines | group of SVGPathElements | Lines between anchor points and connection points of this link. | |||||||||
sourceAnchorLine | SVGPathElement | Line between the source anchor and the source connection point of this link. | |||||||||
targetAnchorLine | SVGPathElement | Line between the target anchor and the target connection point of this link. | |||||||||
distanceLabel | SVGTextElement | Label with the distance between the source and target connection point.
There are several custom presentation attributes, which further control the label behavior.
|
var distance = new joint.shapes.measurement.Distance();
distance.attr('root/title', 'joint.shapes.measurement.Distance');
distance.attr('line/stroke', '#fe854f');
distance.attr('distanceLabel/stroke', '#fe854f');
distance.attr('anchorLines/strokeDasharray', '1,1');
distance.source(el2, {
anchor: { name: 'bottomRight' },
connectionPoint: { name: 'anchor', args: { align: 'right', alignOffset: 30 }}
});
distance.target(el1, {
anchor: { name: 'topRight' },
connectionPoint: { name: 'anchor', args: { align: 'right', alignOffset: 30 }}
});
distance.addTo(graph);