jgraph / mxgraph

mxGraph is a fully client side JavaScript diagramming library
Other
6.82k stars 2.06k forks source link

Problem with connections #453

Closed wo-wo-3s closed 4 years ago

wo-wo-3s commented 4 years ago

Hi, mxGraph Team, mxGraph is a great tool! We need a help :)

We are working in a project where we are using mxGraph version 4.1.1 We have a problem with connections. We have a diagram with many components , the components are connected to each other. For some connections we are setting connection-label (cell.value) using function like below:

setConnectionName(name: string)
{
    const model = graph.getModel();
    model.beginUpdate();
    try {
        cell.value = name;
        graph.refresh(cell);
    } finally {
        model.endUpdate();
    }
}

When we set label for one connection, some other connections are moved. Components are connected but connection path is getting different.

When we did not call

graph.refresh(cell);

connections remain in correct place but connection label is not visible. What we have to do in order to set connection label and make it visible without refreshing whole model.

Thanks in advance and thanks a lot for building mxGraph.

PrudhviMadasu commented 4 years ago

try using graph.view.refresh(cell); to refresh only that particular cell.

wo-wo-3s commented 4 years ago

Thank you very much @PrudhviMadasu but your solution does not work.

davidjgraph commented 4 years ago

You're editing the cell in-place. mxGraph is designed with an API layer to go through to create proper, undoable actions within a model update, see https://jgraph.github.io/mxgraph/docs/manual.html#3.1.2.1

graph.getModel().setValue(name) is the function to use to set the label.

wo-wo-3s commented 4 years ago

graph.getModel().setValue(name) is the function to use to set the label.

I used it and it works perfect. Cell label is changing despite I do not refresh whole model.