-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Cannot read property 'layout' of undefined #37
Comments
Hello there! Could you please provide a little bit more information? I want to be able to reproduce your problem. Whats the url you use, in wha context to you use mermaid etc Thanks! |
I have a Single Page app loading mermaid using requirejs. We have out own requirejs config and loading mermaid fails at line This happens after |
This might be a conflict between the require in browserify and the one in requirejs. Have you tried loading mermaid outside of requirejs and if so before or after your requirejs script? |
@ankurp: Is still problem for you? |
@knsv I haven't tried but will let you know when I do next time. |
To recap from #127: the IPython/Jupyter notebook would be a wonderful place to use mermaid. Its frontend has markdown as a first-class citizen, so hand editing would already be very natural... and it would be easy to generate mermaid DSL from any number of the supported backends. Sadly, we encounter the dagre.layout issue: here are my explorations of the kinds of errors: Aside from the dagre error, some things appear to be broken around There is no option to not have require, or change the order in which things load, and punting to an iframe is pretty much unacceptable. So let's solve this thing. I'd love to pitch in trying to solve this. As i mention on the dupe, there could be some build options that might just solve this, or it may be appropriate to create a separate AMD build. |
@bollwyvl, thanks for your effort. Help is always welcome! I tested loading mermaid using requirejs and could replicate the TypeError. After some reading I found that require creates a define method that confuses the package created by browserify. To handle that I have wrapped mermaid so that the requires define function remains undefined in mermaids context. For my test page this removed the error. I will commit the fix and would appreciate if you could try it in your context before release. |
I think we have a winner, at least for nbviewer: That will render two separate embedded mermaid figures. Great! Thanks so much @knsv! A few remaining issues:
var init = function (sequenceConfig, arr) {
arr = arr == null ? document.querySelectorAll('.mermaid')
: typeof arr === "string" ? document.querySelectorAll(arr)
: arr instanceof Node ? [arr]
: arr;
...
var id = 'mermaidChart' + mermaid.nextIdx++;
... Looking good already, though! |
Actually just tried that hack out: works great! Here is a notebook that uses it: If you look at the source, you'll see that there are no dirty tricks, like embedding the output: Note that you can try out the whole shebang by downloading the ipynb file up there, and dragging into the tree page you get when you hit http://tmpnb.org I've added a touch of CSS to make it visible in the bootstrap environment. Note that it is still breaking things, with the |
Ha, I didn't even circle back and try the original failing approaches. Mermaid as of f4b2211 can be directly loaded with require: require(["./wherever/is/mermaid.full.js"], function(d3){ mermaid.init(); }); I would say that that closes the issue, as it works now, even if it is slightly outside what a requirejs user would expect: it still installs itself on As to its integration into IPython (my original goal): here is a working notebook that uses require to both do an initial draw (as on nbviewer) as well as the live-editing: The only error now is because the actual editor scripts are not available in nbviewer, but this is fine! I'll raise separate PRs for my hacks! |
Also #134. |
I think this is solved with the umd stuff. On 13:22, Wed, May 13, 2015 Knut Sveidqvist [email protected]
|
OK, will close then. Thx! |
Bumps [cypress](https://github.com/cypress-io/cypress) from 8.0.0 to 8.1.0. - [Release notes](https://github.com/cypress-io/cypress/releases) - [Changelog](https://github.com/cypress-io/cypress/blob/develop/.releaserc.base.js) - [Commits](cypress-io/cypress@v8.0.0...v8.1.0) --- updated-dependencies: - dependency-name: cypress dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…-4.17.19 Bump lodash from 4.17.15 to 4.17.19
Error at this expression
require("./dagre").layout;
when loading the full mermaid script from dist folder of this github project.The text was updated successfully, but these errors were encountered: