-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
tutorial for creating new type of graph/layout #44
Comments
Sure! Hope the text below helps. Will add this to the wiki as well. Don't hesitate to add to that text if there are steps that could be better explained. Things to be done for a new diagram type:Step 1: Grammar & ParsingGrammarThis would be to define a jison grammar for the new diagram type. That should start with a way to identify that the text in the mermaid tag is a diagram of that type. This leads us to step 2. Store data found during parsingThere are some jison specific sub steps here where the parser stores the data encountered when parsing the diagram, this data is later used by the renderer. Step 2: RenderingWrite a renderer that given the data found during parsing renders the diagram. To look at an example look at sequendeRenderer.js rather then the flowchart renderer as this is a more generic example. Step 3: Detection of the new diagram typeThe second thing to do is to add the capability to detect the new new diagram to type to the detectType in utils.js. The detection should return a key for the new diagram type. Step 4: The final piece - triggering the renderingingAt this point when mermaid is trying to render the diagram it will detect it as being of the new type but there will be no match when trying to render the diagram. To fix this add a new case in the switch statement in main.js:init this should match the diagram type returned from step num 2. The code in this new case statement should call the renderer for the diagram type with the data found by the parser as an argument |
Its in the wikie. Closing this. Let me know if anything is unclear. |
Hello,
Could you tell us how (even quickly) the steps to create a new type of diagram/layout?
Thanks for your help!
The text was updated successfully, but these errors were encountered: