It still doesn’t work. When I drag the link from the palette to the diagram and drop it, the label remains on the diagram.
This is the definition of my link template :
dia.linkTemplate =
$(go.Link, // the whole link panel
{
// a mouse-over highlights the link by changing the first main path shape's stroke:
mouseEnter: (e, link: go.Link) => { link.path.stroke = 'rgba(0,90,156,0.3)'; },
mouseLeave: (e, link: go.Link) => { link.path.stroke = 'transparent'; }
},
{ selectable: true, selectionAdornmentTemplate: linkSelectionAdornmentTemplate },
{ relinkableFrom: true, relinkableTo: true, reshapable: true },
{
routing: go.Link.AvoidsNodes,
curve: go.Link.JumpOver,
corner: 5,
toShortLength: 4
},
new go.Binding('points').makeTwoWay(),
$(go.Shape, { isPanelMain: true, stroke: 'transparent', strokeWidth: 8 }), // thick undrawn path
$(go.Shape, { isPanelMain: true },
new go.Binding('stroke', 'color'),
new go.Binding('strokeWidth', 'thickness'),
new go.Binding('strokeDashArray', 'lineType')),
$(go.Shape, // the arrowhead
new go.Binding('toArrow', 'arrowheadTo')),
$(go.Shape, // the arrowhead
new go.Binding('fromArrow', 'arrowheadFrom')),
$(go.TextBlock, new go.Binding('text', 'label'), { segmentOffset: new go.Point(0, -10) })
);
And the drop event listener of the diagram
dia.addDiagramListener('ExternalObjectsDropped', (e: go.DiagramEvent) => {
e.subject.each(p => {
if (p instanceof go.Node) {
p.data.stepDefinitionCode = p.data.key;
}
if (p instanceof go.Link) {
p.data.transitionCode = p.data.key;
p.data.label = '';
p.data.parsingOrder = 0;
e.diagram.model.set(p.data, 'label', '')
}
});
});
I can see p.data changes from “linear” (this is the label of the link in the palette) to an empty string, but the label still shows in the diagram :