jgraph / mxgraph

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

The graph only shows after calling zooming #473

Closed rudaoshi closed 3 years ago

rudaoshi commented 4 years ago

I don't know why this happens.

               graph.getModel().beginUpdate();
                // Adds cells to the model in a single step
                var layout = new mxHierarchicalLayout(graph)
                graph.getModel().beginUpdate()
                graph.removeCells(graph.getChildVertices(parent));
                try {
                    graph.setHtmlLabels(true)
                    for (var node_id = 0; node_id < num_of_nodes; node_id++) {
                        this.view_node(node_id);
                    }
                    for (var i = 0; i < num_of_edges; i++) {
                        this.view_edge(i)
                    }
                    layout.execute(parent)
                } finally {
                    // Updates the display
                    graph.getModel().endUpdate()
                }
                 graph.zoomOut()   // commenting these two lines results in disappear of the graph.
                 graph.zoomIn()
hungtcs commented 4 years ago

Hi @rudaoshi , you can call graph.refresh() to refresh view manually