样式
可以覆盖默认样式属性,修改图的外观。将 defaultStyles 放入图构造函数的选项对象即可。
const graph = new Graph(schema, {
defaultStyles: {
background: {
color: 'black'
}
}
})
defaultStyles 包含背景、节点和边等样式,完整可覆盖属性详见源码。
要为特定类型的节点或边定制样式,可在对应 schema 中覆盖 defaultStyles 的节点或边属性:
const schema = {
nodes: {
0: {
name: 'standard node'
},
1: {
name: 'red node'
fill: 'red' // Update the background color of any nodes of this type to red
},
}
};
const graph = new Graph(schema, {
defaultStyles: {
node: {
fill: 'grey' // All other node types will have a grey background
}
}
})