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

Cannot render server-side

Open trouve-antoine opened this issue 8 years ago • 7 comments

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 !

trouve-antoine avatar Mar 29 '16 20:03 trouve-antoine

I never did never try to use it on server-side

adrai avatar Mar 30 '16 19:03 adrai

See this SO answer

garnets avatar Mar 30 '16 20:03 garnets

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 !

trouve-antoine avatar Mar 31 '16 01:03 trouve-antoine

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.

pizn avatar May 28 '16 00:05 pizn

Try to do a PR...

adrai avatar May 28 '16 05:05 adrai

Does jsdom help?

lwchkg avatar Aug 19 '16 06:08 lwchkg

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

flw

mohamedganiwbc avatar Jan 24 '18 09:01 mohamedganiwbc