[英]D3js with element base on data
我正在绘制元素可能不同的图形,例如:
[
{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>
如果type = type2
<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做到这一点?
我同意Lars ......但是......如果您真正想要的是一个很酷的大纲,请不要再看了......我为您提供Kitchen Sink Outliner ...带有自己的厨房水槽秤系统;-)
d1 = 30;
d2 = d1 + 5;
注意:......工作太辛苦......需要一些轻松......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.