nowthis / sankeymatic

Make Beautiful Flow Diagrams
http://sankeymatic.com/build/
ISC License
841 stars 122 forks source link

Suggestion: Separate the code responsible for generating a diagram from the user interface #70

Open ggrossetie opened 10 months ago

ggrossetie commented 10 months ago

Hey!

My use case is to use SankeyMATIC as a rendering engine. Basically, I want to send text input and get an image as a result (with as few dependency as possible).

As far as I can tell, the parser/render function are coupled with the UI. For instance, the msg "class" is using DOM element on the page to display messages. Similarly, there are a lot of interactions between the rendering process and the UI elements (node colors, labels, layout, size...).

I would like to introduce the following function:

/**
 *
 * @param {string} input Text input
 * @param  {} options A list of options
 */
export default function sankey(input, options)

Not sure what the function should return but as a first step we can specify an element ID (on the HTML page) where the <svg> will be generated (and return void)

The UI will be built upon this library.

Please let me know if you would consider a pull request. I made a quick prototype on my fork: https://github.com/yuzutech/sankeymatic