This sample demonstrates a custom Tool, LinkLabelOnPathDraggingTool, that allows the user to drag the label of a Link, but that keeps the label exactly on the path of the link. The tool is defined at LinkLabelOnPathDraggingTool.js.
The label on the link can be any arbitrarily complex object. It is positioned by the GraphObject.segmentIndex and GraphObject.segmentFraction properties. The segmentIndex is set to NaN such that the whole link path acts as the segment, and the segmentFraction is set by the LinkLabelOnPathDraggingTool. A two-way data binding on segmentFraction automatically remembers any modified value on the link data object in the model.
The tool is derived from a similar tool, LinkLabelDraggingTool.js, that allows the user to drag the label in any direction from the mid-point of the Link path.