flowchart.js icon indicating copy to clipboard operation
flowchart.js copied to clipboard

JS Object to animate flowchart?

Open Stwissel opened this issue 7 years ago • 5 comments

After drawing the initial chart, is there a JS Object I can use for animations? I have in mind to show how a process flows through the chart by altering the css or class properties of boxes and arrows. What would be a starting point?

Stwissel avatar Jan 22 '18 07:01 Stwissel

Oh... wow... sounds interesting... but I have no idea...

adrai avatar Jan 22 '18 08:01 adrai

You have a JS Object in memory before rendering it out. Eventually could use that to manipulate the result. Naming the elements after their name in the definition

Stwissel avatar Jan 22 '18 08:01 Stwissel

Since the chart is in SVG, maybe you can modify the SVG directly? But indeed the biggest problem would be to identify the elements. Not sure if it can be made easier by changing the instructions that go to the Raphaël library.

hilvarenbeek avatar Jan 22 '18 14:01 hilvarenbeek

I had a look at the code. These are the lines that might need to be altered:

  this.symbols = [];
  this.lines = [];

If we change the arrays to objects {} (and adjust the respective code that loops through the arrays now) we could capture the symbols and lines by their name. For lines it could be “start-end” with “start” and “end” being symbol names. Then a function changeSymbol(symbol, class) and changeLine(line, class|style) could do the trick.

I’ll see what I can come up with.

Quick q: which file contains the rendering enhancements for the line format? Didn’t see it

Stwissel avatar Jan 23 '18 01:01 Stwissel

Added my fork to CodeClimate: https://codeclimate.com/github/Stwissel/flowchart.js - quite interesting results 😈

Stwissel avatar Jan 23 '18 02:01 Stwissel