NGX-Charts 节点颜色

NGX-Charts Color of nodes

我正在尝试理解这个 'simple' NGX-Charts 示例:

https://stackblitz.com/edit/ngx-graph-simple-example

图中的每个节点都有不同的颜色,如果您查看 component.ts 文件,节点对象没有颜色字段。

但是每个节点的 HTML 模板使用:

<svg:rect [attr.width]="node.width" [attr.height]="node.height" [attr.fill]="node.options.color" />

node.options.color 来自哪里?

根据 @swimlane/ngx-graph library used in the example, the ngx-graph template expects nodes of type Node. Now, looking at the github code of this library, the type Node 的文档,是一个具有许多附加属性的接口。

例子中这个库的版本是4.1.1。根据他们的 github 回购,这个版本很旧,所以我找不到与 4.1.1 版本对应的 coe。我建议使用最新版本的库,然后您就可以理解所使用的属性。请参阅 github 存储库以更好地了解这些属性。