Skip to content
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

Make common layout and render engines that can be used by many diagrams #5237

Closed
knsv opened this issue Jan 25, 2024 · 3 comments · Fixed by #5604
Closed

Make common layout and render engines that can be used by many diagrams #5237

knsv opened this issue Jan 25, 2024 · 3 comments · Fixed by #5604
Assignees
Labels
Internals: Renderer Status: Approved Is ready to be worked on Type: Enhancement New feature or request

Comments

@knsv
Copy link
Collaborator

knsv commented Jan 25, 2024

Description

Objective: Streamline and enhance diagram rendering across various diagram types in Mermaid.

Current Challenge:
There is noticeable duplication in functionality among different diagram types. Several graph-based diagrams share common features in rendering, but these are implemented separately in each diagram type.

Proposed Solution:

  1. Unified Layout Engine: Implement a singular layout engine for all graph-based diagrams.

    • Benefits:
      • Facilitates the introduction of new layout algorithms universally across all graph-based diagrams.
      • Enhances consistency in diagram layouts.
    • Clarification: Are there specific layout algorithms currently under consideration for initial integration?
  2. Common Renderer: Develop a common renderer for all graph-based diagrams.

    • Benefits:
      • Standardizes interaction, styling, and class handling across diagrams.
      • Enables shape reusability between different diagram types.
      • Potential for extension to non-graph-based diagrams (e.g., block and sequence diagrams).

Diagram Implementation:
The attached Mermaid flowchart illustrates the proposed architecture, showing how different diagram types (e.g., Flowchart, State, Class, ER, Sequence, Block, etc.) will interact with the unified layout engine and renderer.

Expected Outcomes:

  • Simplified maintenance and scalability for diagram types.
  • Reduced effort in integrating new layout algorithms and extending diagram categories.
flowchart LR
    A>"Flowchart code"] --> parser1(["parser"])
    node-u5xnc3yve(["Layout"]) -- Rendering Format --> node-gr8ky0vrb(["Render"])
    parser1 -- Layout Format --> node-u5xnc3yve
    node_qk0z4xkea>"State Diagram Code"] --> parser2(["parser"])
    node_ku68ruhfb>"Class Diagram Code"] --> parser3(["parser"])
    node_8gc4rm2ko>"ER Diagram Code"] --> parser4(["parser"])
    seq>"Sequence Diagram Code"] --> parser6(["parser"])
    block>"Block Diagram Code"] --> parser7(["parser"])
    node_2kijumx6n>"Etc"] --> parser5(["parser"])
    parser2 -- Layout Format --> node-u5xnc3yve
    parser3 -- Layout Format --> node-u5xnc3yve
    parser4 -- Layout Format --> node-u5xnc3yve
    parser5 -- Layout Format --> node-u5xnc3yve
    parser6 --> node-6vdqsxzdx["Layout"]
    node-6vdqsxzdx -- Rendering Format --> node-gr8ky0vrb
    node-s08rige4u["Layout"] -- Rendering Format --> node-gr8ky0vrb
    parser7 --> node-s08rige4u
    style node-u5xnc3yve fill:#2962FF,color:#FFFFFF
    style node-gr8ky0vrb fill:#2962FF,color:#FFFFFF
Loading

Overall, this will make the maintenance of diagrams much more manageable and will decrease the effort of adding new layout algorithms and diagram types.

@knsv knsv added Type: Bug / Error Something isn't working or is incorrect Status: Triage Needs to be verified, categorized, etc Type: Enhancement New feature or request Status: Approved Is ready to be worked on Internals: Renderer and removed Type: Bug / Error Something isn't working or is incorrect Status: Triage Needs to be verified, categorized, etc labels Jan 25, 2024
@knsv knsv self-assigned this Jan 25, 2024
@asknet
Copy link

asknet commented Jan 31, 2024

Great initiative! Just curious, Will there be a plan to define sub-diagrams that are of different types? For example, use flowchart and blockdiagram within the main diagram?

@sidharthv96
Copy link
Member

@asknet that feature will not be part of this change, but this and the new parser lays part of the foundation that's required to support multiple diagrams.

@RawRaw111
Copy link

Latouts

knsv added a commit that referenced this issue Apr 23, 2024
knsv added a commit that referenced this issue Apr 23, 2024
knsv added a commit that referenced this issue Apr 23, 2024
ashishjain0512 added a commit that referenced this issue Apr 24, 2024
knsv added a commit that referenced this issue Apr 24, 2024
knsv added a commit that referenced this issue Apr 24, 2024
ashishjain0512 added a commit that referenced this issue Apr 24, 2024
knsv added a commit that referenced this issue Apr 25, 2024
knsv added a commit that referenced this issue Apr 26, 2024
ashishjain0512 added a commit that referenced this issue Apr 26, 2024
knsv added a commit that referenced this issue Apr 26, 2024
knsv added a commit that referenced this issue Apr 26, 2024
ashishjain0512 added a commit that referenced this issue Apr 29, 2024
knsv added a commit that referenced this issue Apr 29, 2024
knsv added a commit that referenced this issue Apr 30, 2024
knsv added a commit that referenced this issue Jul 3, 2024
knsv added a commit that referenced this issue Jul 3, 2024
sidharthv96 added a commit that referenced this issue Jul 3, 2024
…anup

* 5237-unified-layout-common-renderer: (36 commits)
  5237 New default width for flowchart edges
  #5237 Fix for rough styling of regular states and dividers in state diagrams
  chore: Remove "sideEffects: false"
  Added test for divider alignment
  Remove logs
  chore: Fix eslint errors
  chore: eslint autofix
  chore: Cleanup tsconfig
  chore: Fix lint
  Apply suggestions from code review
  chore: Remove extra words from cspell
  chore: Log granular rebuild times
  fix: Message wrap
  fix: Message wrap
  chore: Use `??` instead of `||`
  chore: Organise imports
  chore: Remove unused variables
  chore: Remove cross-env from eslint
  chore: Cleanup rules
  chore: Fix eslint issues
  ...
knsv added a commit that referenced this issue Jul 3, 2024
sidharthv96 added a commit that referenced this issue Jul 4, 2024
…anup

* 5237-unified-layout-common-renderer:
  #5237 Fix fir subgraphs with elk
  #5237 Fix for diamond intersections with ELK, tweak
  #5237 Fix for diamond intersections with ELK
  fix for note with a composite state
  #5237 Handling of subgraphs using elk
  #5237 Handling of subgraphs using elk
  Fix fro direction in layout data
knsv added a commit that referenced this issue Jul 22, 2024
@knsv knsv mentioned this issue Jul 23, 2024
15 tasks
knsv added a commit that referenced this issue Aug 9, 2024
knsv added a commit that referenced this issue Aug 9, 2024
knsv added a commit that referenced this issue Aug 9, 2024
knsv added a commit that referenced this issue Aug 9, 2024
knsv added a commit that referenced this issue Aug 9, 2024
sidharthv96 added a commit to FutzMonitor/mermaid that referenced this issue Aug 20, 2024
* develop: (485 commits)
  [autofix.ci] apply automated fixes
  add MonsterWriter to list of community integrations
  fix: Making insertCluster async
  Ignore codeql warning
  Removed the un-necessary test
  Fixed broken test
  [autofix.ci] apply automated fixes
  Fixed lint issue
  mermaid-js#5237 Fix for text alignment for handdrawn text using svg labels
  mermaid-js#5237 Fix for subroutine positioning
  Updated handDrawn cypress test
  adding handDrawn cypress test
  mermaid-js#5237 Async fix for clusters
  sequence diagram NaN values issue
  review comment fixes
  mermaid-js#5237 Replace generic object with Map
  mermaid-js#5237 Removing old flowchart renderer
  mermaid-js#5237 Fixes from comments
  Adding elk test
  chore(deps): update eslint
  ...
sidharthv96 added a commit to FutzMonitor/mermaid that referenced this issue Aug 20, 2024
* develop: (485 commits)
  [autofix.ci] apply automated fixes
  add MonsterWriter to list of community integrations
  fix: Making insertCluster async
  Ignore codeql warning
  Removed the un-necessary test
  Fixed broken test
  [autofix.ci] apply automated fixes
  Fixed lint issue
  mermaid-js#5237 Fix for text alignment for handdrawn text using svg labels
  mermaid-js#5237 Fix for subroutine positioning
  Updated handDrawn cypress test
  adding handDrawn cypress test
  mermaid-js#5237 Async fix for clusters
  sequence diagram NaN values issue
  review comment fixes
  mermaid-js#5237 Replace generic object with Map
  mermaid-js#5237 Removing old flowchart renderer
  mermaid-js#5237 Fixes from comments
  Adding elk test
  chore(deps): update eslint
  ...
knsv added a commit that referenced this issue Aug 21, 2024
sidharthv96 added a commit that referenced this issue Aug 22, 2024
…into release/11.0.0

* 'release/11.0.0' of https://github.com/mermaid-js/mermaid:
  #5237 Proper setting of the handdrawn seed in the visual tests
knsv added a commit that referenced this issue Aug 22, 2024
sidharthv96 added a commit to Austin-Fulbright/mermaid that referenced this issue Aug 23, 2024
* develop: (34 commits)
  Mermaid version v11.0.0
  Run release drafter in release branch
  [autofix.ci] apply automated fixes
  Updating syntax reference with code showing how to select layout and look.
  Fix for selecting the correct diagramPadding for flowcharts
  Fix for turned arrow heads and missing edge sections
  Basic fix for handdrawn subgraph styling
  Fix for text alignment issue
  mermaid-js#5237 Fix for weird line intersection
  Fix config
  docs: Update release version
  docs: Update release version
  chore: Revert version changes
  chore: Revert version changes
  Remove release drafter
  Add changeset to PR template
  Remove changesets
  Update changelog format
  verify Docs version before publish
  chore: Remove prePublishOnly
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Internals: Renderer Status: Approved Is ready to be worked on Type: Enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants