Ngx-graph 显示不正确

问题描述

我在我的 Angular 应用程序中使用了 ngx-graph,并且一切正常,除了当我运行该应用程序时,它并不总是按应有的方式显示。 它应该是这样的:

enter image description here

但是在我可能执行的任何操作之后,即路由到另一个组件并返回,图形如下所示:

enter image description here

我尝试使用 node.dimension.width 属性,但如果我手动设置或添加它,它只会与箭头重叠。 这是我的代码

<ngx-graph class="chart-container"
                [showMiniMap]="true"
                [draggingEnabled]="false"
                [view]="[1500,1000]"
                [links]="links"
                [nodes]="nodes"
                layout="dagre">
                <ng-template #defstemplate>
                   <svg:marker id="arrow" viewBox="0 -5 10 10" refX="8" refY="0" 
                               markerWidth="4" markerHeight="4" orient="auto">
                        <svg:path d="M0,-5L10,0L0,5" class="arrow-head" />
                   </svg:marker>
                </ng-template>
                <ng-template #nodeTemplate let-node>
                    <mde-popover #appPopover="mdePopover" [mdePopoverOverlapTrigger]="true" >
                        <!-- card info -->
                        </mde-popover>
                        <svg:g class="node" [mdePopoverTriggerFor]="appPopover" 
                              mdePopoverTriggerOn="click" >
                            <svg:rect
                            [attr.width]="node.dimension.width"
                            [attr.height]="node.dimension.height"
                            [attr.fill]="node.data.color"
                            />
                            <svg:text alignment-baseline="central" [attr.x]="10" 
                                      [attr.y]="node.dimension.height / 2">
                                {{node.label}}
                            </svg:text>
                        </svg:g>
                    </ng-template>
                    <ng-template #linkTemplate let-link>
                        <svg:g class="edge">
                            <svg:path class="line" stroke-width="2" marker-end="url(#arrow)"> 
                            </svg:path>
                        </svg:g>
                    </ng-template>
                </ngx-graph>

知道为什么 ngx-graph 组件会这样吗?

感谢您的帮助:)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)