@llopht wrote:
I want to add new links data properties (with computed value) in a linkDataArray before it was draw by the diagram. Is the only solution is to add a listener on the modelChangedListener and to modify each links after the end of the transaction ? Something like that (not tested) :
myDiagram.model = () => { return this.go(go.GraphLinksModel, { linkDataArray: [ { from: '1', to: '2' } ] ... }); } myDiagram.addModelChangedListener((e) => { if (e.model instanceof go.GraphLinksModel && e.isTransactionFinished) { e.model.linkDataArray.forEach((link) => { e.model.setDataProperty(link, 'stroke', '#FF0000'); }); } }); myDiagram.linkTemplate = () => { return this.go(go.Link, { /* remove to simplify */ }, this.go(go.Shape, { /* remove to simplify */ }), new go.Binding('stroke', 'stroke'), ); }
Is this correct ?
Posts: 4
Participants: 2