- 
                Notifications
    You must be signed in to change notification settings 
- Fork 109
Open
Labels
Description
We have been using d3-graphviz for a few weeks now, and it is just amazing!
However, there seems to be a really bad bug and it only happens when re-rendering, and there is already a somewhat large graph on screen. It is really fast most of the time, but if I re-render a big graph and the new graph is very similar to the old graph, things get super slow.
In one of my experiments, I got the following performance measurements:
- original render time: 1s
- Re-rendering time: 8s
- Re-rendering time with workaround (see below): 1s (just like the initial render)
- dotstring is about 170k in length
It happens, regardless of whether or not I added transitions.
Workaround
It seems to have to do with the internally stored graphviz state on the element. The only workaround I found so far is to simply re-create the graph element every time, something like this:
      if (this.graphEl) {
        this.graphEl.remove();
      }
      const graphEl = this.graphEl = compileHtmlElement('<div id="timeline-graph"></div>');
      this.els.graphcont.appendChild(graphEl);
      this.graphviz = d3Graphviz.graphviz(graphEl, { ...GraphVizCfg });
      console.debug('re-initializing graph');