【发布时间】:2019-12-05 19:24:57
【问题描述】:
您好,我正在 Angular 和 GoJS 中开发工作流编辑器和渲染器,一切正常,除了我遇到了一个恼人的错误,在初始页面加载时链接没有正确避开节点,但是第二个你更改图表或单击路由器链接并返回链接突然开始表现得像他们应该的那样。有谁知道为什么会这样?
Links not avoiding and properly avoiding nodes
以下是我认为是相关代码,如果有人可以提供帮助,将不胜感激
constructor(private templatesService: TemplatesService,
private router: Router,
private route: ActivatedRoute,
private projectsService: ProjectsService) { this.initDiagram(); }
...
ngOnInit() {
// Get data
this.load();
setTimeout(() => { this.load(); });
}
ngAfterViewInit() {
// We have data page is loaded => show graph
this._diagram.div = this._diagramRef.nativeElement;
this.scaleDiagramDivToHeightOf(window, -50);
if (this.route.data['value']['label'] === 'design' ||
this.route.data['value']['label'] === 'design-proto') {
this.initDiagramDesign();
this.initPalette();
}
this._diagram.requestUpdate();
}
initDiagram() {
this._diagram.commandHandler.defaultScale = 1.0;
const that = this;
this._diagram = new go.Diagram();
this._diagram.initialContentAlignment = go.Spot.TopCenter;
this._diagram.allowDrop = this.editMode;
this._diagram.isReadOnly = !this.editMode;
this._diagram.toolManager.draggingTool = new GuidedDraggingTool();
this._diagram.undoManager.isEnabled = true;
this._diagram.layout = $(go.TreeLayout, {
angle: 90,
nodeSpacing: 10,
layerSpacing: 25,
layerStyle: go.TreeLayout.LayerUniform,
arrangement: go.TreeLayout.ArrangementHorizontal
});
this._diagram.nodeTemplateMap.add(""...
this._diagram.linkTemplate =
$(go.Link, // the whole link panel
{
routing: go.Link.AvoidsNodes,
curve: go.Link.JumpOver,
corner: 10, toShortLength: 4,
relinkableFrom: true,
relinkableTo: true,
reshapable: true,
resegmentable: true,
// mouse-overs subtly highlight links:
selectionAdorned: false,
},
// new go.Binding("points").makeTwoWay(),
$(go.Shape, // the highlight shape, normally transparent
{ isPanelMain: true, strokeWidth: 8, stroke: "transparent", name: "HIGHLIGHT" }),
$(go.Shape, // the link path shape
{ isPanelMain: true, stroke: "gray", strokeWidth: 2 },
new go.Binding("stroke", "isSelected", function (sel) { return sel ? "dodgerblue" : "gray"; }).ofObject()),
$(go.Shape, // the arrowhead
{ toArrow: "standard", strokeWidth: 0, fill: "gray" }),
$(go.Panel, "Auto", // the link label, normally not visible
{ visible: false, name: "LABEL", segmentIndex: 2, segmentFraction: 0.5 },
new go.Binding("visible", "visible").makeTwoWay(),
$(go.Shape, "RoundedRectangle", // the label shape
{ fill: "#F8F8F8", strokeWidth: 0 }),
$(go.TextBlock, "Yes", // the label
{
textAlign: "center",
font: "10pt helvetica, arial, sans-serif",
stroke: "#333333",
editable: true
},
new go.Binding("text").makeTwoWay())
)
);
this._diagram.layout.invalidateLayout();
}
load() {
...load data from backend...
}
【问题讨论】:
标签: angular typescript rendering gojs