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

titleTopMargin option for flowchart does not affect subgraph titles #4935

Closed
zoeyTM opened this issue Oct 9, 2023 · 11 comments · Fixed by #5041
Closed

titleTopMargin option for flowchart does not affect subgraph titles #4935

zoeyTM opened this issue Oct 9, 2023 · 11 comments · Fixed by #5041

Comments

@zoeyTM
Copy link

zoeyTM commented Oct 9, 2023

Description

When using subgraphs in a flowchart, there is currently no way to customize the padding around a subgraph's title. Larger diagrams consisting of multiple concurrent subgraphs cause mermaid to render the subgraph titles extremely close to the subgraphs top border, making the graph appear unpolished.

I hoped that titleTopMargin would affect subgraph titles too, but it currently only applies to the main flowchart title. There is no other config option that allows for this specific type of customization either.

--

The current workaround I've found is to nest subgraphs inside each other to give the illusion of a padded subgraph title, like in this live editor snippet, however this comes with its own drawbacks such as the subgraph scaling inconsistently in size and there being a lot of extra empty space everywhere else in the graph as well.

Steps to reproduce

Here's a live editor snippet demonstrating a flowchart with a title containing a subgraph that also has a title. The titleTopMargin config option has also been set, but it's only affecting the flowchart title, not the subgraph title.

Screenshots

Screenshot showing the subgraph without the desired padding:
Screen Shot 2023-10-09 at 5 35 30 PM

Screenshot showing the workaround solution (still not ideal, but at least the subgraphs title is padded):
Screen Shot 2023-10-09 at 5 13 10 PM

Code Sample

No response

Setup

  • Mermaid version: v10.5.0
  • Browser and Version: Chrome

Suggested Solutions

Preferred solution would be a new flowchart config option that allows for custom padding around subgraph titles.

An alternate solution would be to apply titleTopMargin to subgraph titles as well as the current functionality of applying to the general flowchart title.

Additional Context

No response

@zoeyTM zoeyTM added Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect labels Oct 9, 2023
@VishalMCF
Copy link

Hi everyone, which solution suggested by @zoeyTM is suitable?

@nirname nirname added Type: Enhancement New feature or request Contributor needed Status: Approved Is ready to be worked on Graph: Flow Area: Development and removed Type: Bug / Error Something isn't working or is incorrect Status: Triage Needs to be verified, categorized, etc labels Oct 10, 2023
@nirname
Copy link
Contributor

nirname commented Oct 10, 2023

@VishalMCF I think we need a configuration option for margins. You can extend schema, update types generated from it with with

pnpm --filter=mermaid types:build-config

and then fix Flowchart renderer.

@mathbraga
Copy link
Contributor

@nirname Is adding 2 separate config options (1 for top and 1 for bottom) an ideal solution for this? I figured that in some cases users might want to also add spacing between the subgraph title and its content.

@nirname
Copy link
Contributor

nirname commented Oct 30, 2023

@mathbraga I think that 2 configuration options in is enough. It will allow to adjust margins for all the subtitles. May be we should keep it as an object itself:

subgraphTitleMargin: {
  top: 10,
  bottom: 20
}

or we could use

titleMarting: {
  top: 10,
  bottom, 20
}

which would affect graph title too, but we should keep current titleTopMargin for backward compatibility anyway

@jgreywolf jgreywolf added include and removed include labels Nov 16, 2023
@mathbraga
Copy link
Contributor

mathbraga commented Nov 17, 2023

Hi @nirname, I solved the issue for the generic subgraph, but I'm having trouble when subgraphs have external connections. Was wondering if it would be possible to make a PR for only the general case and then create another issue for the external connections variation.

To clarify, this is what I mean with external connection:
image
So subcontainer has an external connection.

@nirname
Copy link
Contributor

nirname commented Nov 17, 2023

@mathbraga Hi! Open PR, let's have a live preview of the change. Your request will be deployed and everyone will be able to see what is going on.

@zoeyTM
Copy link
Author

zoeyTM commented Jan 22, 2024

@sidharthv96 Can we reopen this issue since the feature PR that closed it got reverted?

@nirname
Copy link
Contributor

nirname commented Jan 22, 2024

@zoeyTM
Copy link
Author

zoeyTM commented Jan 23, 2024

Ah! I missed that, thanks!

@zoeyTM
Copy link
Author

zoeyTM commented Jan 23, 2024

Any idea when the next release might be that would include the re-revert? @nirname

@nirname
Copy link
Contributor

nirname commented Jan 23, 2024

@zoeyTM Not really sure, I am not currently responsible for making releases, maybe @sidharthv96 can respond to this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants