简体   繁体   English

d3js多个目标到单个节点

[英]d3js multiple targets to a single node

I'm using d3js to create a visual that is supposed to help me show dependencies of certain javascript files. 我正在使用d3js创建视觉对象,该视觉对象应该可以帮助我显示某些javascript文件的依赖关系。

The current format that shows the relationship between the source and the target in d3 is: 在d3中显示源和目标之间关系的当前格式为:

var links = [
  { source: "A", target: "X"},
  { source: "Z", target: "Y"},
  { source: "A", target: "Z"},
  { source: "A", target: "W"},
];

Could anyone that is experienced with d3 and/or Javascript tell me how I can change the code so I can add multiple targets to look like: 能够使用d3和/或Javascript的人可以告诉我如何更改代码,以便可以添加多个目标,例如:

var links = [
  { source: "A", target: "X", "Y", "Z"},
  { source: "Z", target: "Y"},
  { source: "A", target: "Z"},
  { source: "A", target: "W"},
];

If you want to list several values in the target attributes, you can use a Javascript array 如果要在target属性中列出几个值,则可以使用Javascript数组

like so : 像这样:

var links = [
  { source: "A", target: ["X", "Y", "Z"]},
  { source: "Z", target: "Y"},
  { source: "A", target: "Z"},
  { source: "A", target: "W"},
];

The array is created directly using the [] constructor. 该数组是使用[]构造函数直接创建的。 Actually links is also an array 其实links也是一个数组

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM