Я могу изменить стиль SVG, но страница не работает, возможно, нужно перерисовать (). Как это сделать?
, чтобы сохранить узел ячейки
let svg = {}
функция щелчка
function clickFn(){
let keys = Object.keys(svg)
keys.forEach((item,i)=>{
if(item.split('.')[0] === 'col' ){
svg[item].style = 'col'
if(me.sourceState.cell.id === item){
svg[item].style = 'active'
//do not work!is need redraw()?
//but svg[item] hasn't redraw()
}else{
svg[item].style = 'col'
}
// svg[item].shape.redraw();
}
})
}
прослушиватель событий
graph.addMouseListener({
mouseDown: function(sender, me){
if(me.sourceState && me.sourceState.cell && me.sourceState.cell.id.split('.')[0] === 'col'){
clickFn()
}
},
});
для вставки узла используйте 'col + col.sort' для сохранения
let WIDTH1 = 280,WIDTH2 = 250,WIDTH3 = 240,id = '';
this.dataBlood.forEach((fold,i)=>{
svg['fold' + fold.sort] = graph.insertVertex(parent, null, '', 0, 0, WIDTH1, 0, 'column');
fold.tables.forEach((table,index)=>{
id = 'fold' + i + '.table' + index;
svg[id] = graph.insertVertex(svg['fold' + fold.sort], id, table.name, 0, 0, WIDTH2, 30,'table');
svg[id].collapsed = true;
table.col.forEach((col)=>{
svg['col.' + col.id] = graph.insertVertex(svg[id], 'col.' + col.id, col.name, 0, 0, WIDTH3, 20,'col');
})
})
})
вставьте ссылку
this.linkBlood.forEach((item=>{
graph.insertEdge(parent, null,'' , svg['col.' + item.source], svg['col.' + item.target],'line');
}))
}