在D3.js布局中,工具提示仅对具有子节点的节点可见。
找到我的附加代码 https://codesandbox.io/s/affectionate-thunder-l024x
我有一个对象,其中有些包含子对象,有些不是。在图表中显示它们时,工具提示仅对其中具有子对象的对象可见。
const dataObj = {
name: "Home",
children: [
{
name: "A",
metricsValue: "ma",
children: [
{
name: "A-B",
value: 1.2,
metricsValue: "ma-mb"
},
{
name: "A-B-C",
metricsValue: "ma-mb-mc",
children: [
{
name: "A-B-C-D-1",
value: 2.5,
metricsValue: "ma-mb-mc-md-1"
},
{
name: "A-B-C-D-2",
value: 2.566,
metricsValue: "ma-mb-mc-md-2"
}
]
}
]
},
{
name: "BCD",
value: "6.5",
metricsValue: "m1"
}
]
};