flowchart.js
flowchart.js copied to clipboard
Cannot render server-side
In node.js, when I call
require('flowchart.js')
I get the Raphael exception below:
/.../node_modules/raphael/dev/raphael.core.js:96
doc: document,
^
ReferenceError: document is not defined
at /.../node_modules/raphael/dev/raphael.core.js:96:18
at /.../node_modules/raphael/dev/raphael.core.js:15:26
at Object.<anonymous> (/.../node_modules/raphael/dev/raphael.core.js:19:2)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at /.../node_modules/raphael/raphael.amd.js:16:23
Thank you for the good work !
I never did never try to use it on server-side
See this SO answer
OK, so flowchart.js was not meant to be run server side from the beginning. I'll see if it can be ported (Raphael might work server side if I believe their website) Thank you for the answer !
Can it support renderToString? When I work on server-side, I can use this method to parse the code, and add style it will draw the flowchart.
Try to do a PR...
Does jsdom
help?
I tried to load on server-side. It's working. Please try return Raw data using Json.(Like)
On Server-Side
StringBuilder syntaxBuilder = new StringBuilder(); syntaxBuilder.AppendLine("st=>start: Start|past"); syntaxBuilder.AppendLine("e=>end:> End"); syntaxBuilder.AppendLine("op1=>operation: My Operation"); syntaxBuilder.AppendLine("io=>inputoutput: catch something"); syntaxBuilder.AppendLine("st->e"); var psSynax = syntaxBuilder.ToString(); return Json(new { status = true, response = psSynax }, JsonRequestBehavior.AllowGet);
Client-Side