javascript - 如何在 d3.js 中获取没有子元素的元素的工具提示
问题描述
在 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"
}
]
};
解决方案
推荐阅读
- php - 如果数组的键与另一个数组的键匹配,如何替换数组中的元素?
- css - 在 aa ion-grid 中设置相同尺寸的离子卡
- arrays - 在新模块中使用来自另一个模块的非公共数组
- angular - 从 Angular 路由器模块中访问 :id 属性
- rust - 类型推断选择了错误的超特征
- javascript - 错误:UnhandledPromiseRejectionWarning:测试执行期间
- recursion - 使用回溯查找路径总数
- azure - 如何从本地计算机 ping 安装在 Ubuntu Azure Vm 上的 openstack 实例?
- api - 我在 Jenkins 中的 API 存在问题:用户的密码/令牌无效:
- arrays - 创建一个要传递给函数的空数组。使用手臂组件