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

Elk renderer not wokring on empty subgraph #5402

Open
Alexandre-SCHOEPP opened this issue Mar 22, 2024 · 2 comments
Open

Elk renderer not wokring on empty subgraph #5402

Alexandre-SCHOEPP opened this issue Mar 22, 2024 · 2 comments
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect

Comments

@Alexandre-SCHOEPP
Copy link

Alexandre-SCHOEPP commented Mar 22, 2024

Description

When using the elk renderer when a subgraph is empty, I get the following error : Cannot read properties of null (reading 're')

Steps to reproduce

  1. Using Meramid 10.8.0 locally or live editor
  2. select flowchart
  3. initialize with default renderer set to "elk" as documented
  4. create an empty subgraph
  5. weep

Screenshots

image

Code Sample

Here is my minimum reproducible example:

## Works

:::mermaid
%%{init: {"flowchart": {"defaultRenderer": "dagre"}} }%%
flowchart TD
subgraph A
end
:::
## Does not work
:::mermaid
%%{init: {"flowchart": {"defaultRenderer": "elk"}} }%%
flowchart TD
subgraph B
end
:::

Here is my minimum reproducible example:

Works

:::mermaid
%%{init: {"flowchart": {"defaultRenderer": "dagre"}} }%%
flowchart TD
subgraph A
end
:::

## Does not work
:::mermaid
%%{init: {"flowchart": {"defaultRenderer": "elk"}} }%%
flowchart TD
subgraph B
end
:::

Setup

  • Mermaid version: 10.8.0, latest in live editor
  • Browser and Version: Tested on Edge, Chrome, and VSCode via the vscode-markdown-mermaid extension

Suggested Solutions

variable re seems to be at the root of the issue.

Additional Context

No response

@Alexandre-SCHOEPP Alexandre-SCHOEPP added Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect labels Mar 22, 2024
@Yokozuna59
Copy link
Member

Hi @Alexandre-SCHOEPP, thanks for reporting the issue.

But I wouldn’t really consider this an issue; subgraphs are just rectangles that wrap nodes according to their size; there is no point in creating empty rectangles with no nodes inside.

It’s kind of similar to the empty namespace in class diagram, see #4625 (comment).

Unless you’re suggesting to make the behavior similar to the default renderer, degre, to consider it a regular node:

flowchart
subgraph a
end

@Alexandre-SCHOEPP
Copy link
Author

Hi @Yokozuna59 !

there is no point in creating empty rectangles with no nodes inside.

I regularly use this functionality in mermaid with the default renderer as it allows for flowchart that evolve with development. For example, if I suspect that there will be subsystems in the future, I often leave an empty subgraph.

I also tend to make rather complex graphs, which, I understand, is a bit beyond the typical usecase for mermaid, but having empty subgraphs allows me to :

  • use the live editor to make the general structure before focusing on details (and, since order of items has an impact on the rendering, i do need it to work with the final renderer for readability)
  • remove subcomponents quickly to make a copy of particularly complex graphs that focus only on one aspect.

Unless you’re suggesting to make the behavior similar to the default renderer, degre, to consider it a regular node:

I think that this needs to either be properly documented (as I didn't find my answer in your documentation) with an error message saying that this is an intentional choice, or, as you've said, be brought to consistency with both renderer.

Thank you for the work you do on mermaid, I love that it does not have to be a static graph, and I think that this would help move the project in that direction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

No branches or pull requests

2 participants