Is there a straightforward way to attach labels to be located near the beginning and end of edges.

Basically, I would like to have the ability for three labels; one in the middle (the standard one), and then one located near each end.

Is this possible?

asked 17 Feb '12, 11:15

scishop's gravatar image

scishop
80210
accept rate: 100%

edited 06 Feb '15, 12:51

David's gravatar image

David
4.9k21831


We use relative child cells, eg.

var width = 200;
var height = 0;

var assoc = new mxCell('Association', new mxGeometry(0, 0, width, height), 'endArrow=open;endSize=12;startArrow=diamond;startSize=10;startFill=0;edgeStyle=orthogonalEdgeStyle');
assoc.geometry.setTerminalPoint(new mxPoint(0, height), true);
assoc.geometry.setTerminalPoint(new mxPoint(width, 0), false);
assoc.edge = true;

var sourceLabel = new mxCell('0..n', new mxGeometry(-1, 0, 0, 0), 'resizable=0;editable=1;align=left;verticalAlign=top;labelBackgroundColor=white;fontSize=10');
sourceLabel.geometry.relative = true;
sourceLabel.setConnectable(false);
sourceLabel.vertex = true;
assoc.insert(sourceLabel);

var targetLabel = new mxCell('1', new mxGeometry(1, 0, 0, 0), 'resizable=0;editable=1;align=right;verticalAlign=top;labelBackgroundColor=white;fontSize=10');
targetLabel.geometry.relative = true;
targetLabel.setConnectable(false);
targetLabel.vertex = true;
assoc.insert(targetLabel);
link

answered 18 Feb '12, 05:09

Gaudenz's gravatar image

Gaudenz
80.1k1310
accept rate: 39%

edited 06 Feb '15, 12:52

David's gravatar image

David
4.9k21831

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×228

Asked: 17 Feb '12, 11:15

Seen: 1,486 times

Last updated: 06 Feb '15, 12:52