我正在绘制一个图表,其中元素可能有所不同,例如:
[
{id: 1, type: "type1", name: "Some name" },
{id: 2, type: "type2", name: "Some name" },
{id: 3, type: "type2", name: "Some name" },
{id: 4, type: "type1", name: "Some name" }
]
现在,如果元素的 type=type1 我想添加它
<g>
<rect width="10" height="10" fill="blue" />
<text x="0" y="0" fill="red">Some name</text>
</g>
如果类型=类型2
<g>
<rect width="10" height="10" stroke="blue" />
<rect x="15" y="15" width="10" height="10" stroke="blue" />
<text x="0" y="0" fill="red">Some name</text>
</g>
我如何使用 D3js 来做到这一点?
最佳答案
我同意拉尔斯的观点...但是...如果您真正寻找的是一个很酷的大纲工具,那就别再看了...我为您提供 Kitchen Sink Outliner ...拥有自己的厨房水槽秤系统;-)
d1 = 30;
d2 = d1 + 5;
注意:...工作太辛苦...需要一些轻松...
关于javascript - D3js 与基于数据的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22182090/