Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular GoJS&x2B;角度链接不会避免初始加载时的节点_Angular_Typescript_Rendering_Gojs - Fatal编程技术网

Angular GoJS&x2B;角度链接不会避免初始加载时的节点

Angular GoJS&x2B;角度链接不会避免初始加载时的节点,angular,typescript,rendering,gojs,Angular,Typescript,Rendering,Gojs,嗨,我正在用Angular和GoJS开发一个工作流编辑器和渲染器,除了我遇到了一个恼人的错误,在初始页面加载时链接没有正确地避开节点,但是当你更改图表或单击路由器链接并返回时,链接突然开始正常运行。有人知道为什么会这样吗 下面是我认为相关的代码,如果有人能帮忙,我将不胜感激 constructor(private templatesService: TemplatesService, private router: Router, private route: ActivatedR

嗨,我正在用Angular和GoJS开发一个工作流编辑器和渲染器,除了我遇到了一个恼人的错误,在初始页面加载时链接没有正确地避开节点,但是当你更改图表或单击路由器链接并返回时,链接突然开始正常运行。有人知道为什么会这样吗

下面是我认为相关的代码,如果有人能帮忙,我将不胜感激

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...
 }

我想出来了,这是一个小小的改变

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();


 }

constructor(private templatesService: TemplatesService,
   private router: Router,
   private route: ActivatedRoute,
   private projectsService: ProjectsService) { this.initDiagram(); }

ngOnInit() {

 }

 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.load();
 }