css - 如何在 react-d3-tree 上定义单个链接样式
问题描述
我需要以不同的方式定义每个节点之间的链接样式。现在我的树数据定义如下,而链接样式不起作用。有人可以帮忙吗?
const myTreeData = [
{
name: 'Top Level',
nodeSvgShape: {
shape: 'circle',
shapeProps:{r:30,fill:"red"}
},
Styles:{
links: {
fill:"none",
stroke: "#000",
strokeWidth: "2px",
strokeDasharray:"2,2"
},
}
children: [
{
name: 'Level 2: A',
nodeSvgShape: {
shape: 'circle',
shapeProps:{r:30,fill:”green”}
},
Styles:{
links: {
fill:"none",
stroke: "#222",
strokeWidth: "2px",
strokeDasharray:"2,2"
},
}
},
{
name: 'Level 2: B',
nodeSvgShape: {
shape: 'circle',
shapeProps:{r:30,fill:”yellowfins”}
},
Styles:{
links: {
fill:"none",
stroke: "#000",
strokeWidth: "2px",
strokeDasharray:"2,2"
},
}
},
],
},
];
nodeSvgShape 有效,因此每个节点都显示定义的颜色,但链接样式不起作用。
解决方案
嗯,您是否尝试过使用小写 s 作为样式。这适用于我的主树对象(我不确定个人):
<Tree
data={debugData}
// collapsible={false}
translate={this.state.translate}
scaleExtent={{ min: 1, max: 3 }}
allowForeignObjects
// pathFunc="elbow"
orientation="vertical"
nodeSvgShape={{ shape: "none" }}
nodeSize={{ x: 200, y: this.yClearance }}
onClick={e => this.click(e)}
onMouseOver={e => this.over(e)}
styles={{
links: {
stroke: 'red',
strokeWidth: "2px",
},
}}
推荐阅读
- postgresql - 使用 Dockerized postgres 进行 Spring Boot 集成测试
- c# - 通用委托列表(例如 System.Converter
) - mongodb - MOngoDB 根据条件查询不同字段的 groupby 以返回最新记录
- java - JavaMail 消息传递异常
- apache-spark - 结构化流数据帧的中间操作(Head / Take / First)
- php - 在最后一行之前添加一个部分 ACF get_row_layout()
- java - 如何在 Java 中向下移动表格?
- flutter - Json解析失败_InternalLinkedHashMap
' 不是 'String 类型的子类型 - reactjs - 如何传递密钥来反应路线?
- python - python脚本中的wkhtmltopdf不适用于cronjob