-
-
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
Layered Blocks Layout #3358
Comments
Here's a modified series of suggestions inspired by the above and some of my thoughts. Some of these are looking to tackle more layout control (a bit more generalized than the initial issue - which I think is a subset of broader control and also tackling #2509). These are just suggestions. I'm not sure how perfectly this is driving on what people want, but it's maybe a few things to think about. Ultimately targeting something like this: The following syntax could be used.
Walking through it step by step.
or
Each new block is essentially a positioning element, and with 1 column by default which is vertically orienting the components within it. The number of columns can be overridden by blocks within blocks (nested) or nodes which individually override the layout, more on this below. Also, I think padding by default should be zero with a need to be explicit through styling by each node (driving impact in closest nested block) or setting up a new default.
yields Arrow/connection directionality is explicit: between middle of the bottom of the node preceding and the middle of the top of the node following it (or middle of the left and middle of the right for sideways arrows). Thinking it should be similar to flowchart default syntax and styling mostly, no need for thick arrows unless specified. The single direction downwards (or upwards) oriented arrows could be --v (or --^). The directionally upward/downward arrow-less connection could be -v- (with --- being left/right oriented). Arrows with a default at 0.5 (or similar) of default block height in size with changing length similar to flowchart (maybe 0.125 block height per additional -, like ---->). Connections act as their own nodes essentially (may want to overlay connections on nodes which might be used only for positioning, touch on this later).
Blocks by default should act as nodes unless there is at least one node inside it, then blocks provide structuring of layout. Can be titled or not - when there is a title (text associated beyond variable name), add something like 0.5 node height to the block for the title (nodes at same level shouldn’t increase height though). If unnamed no title should be added. The overarching blockDiagram itself acts somewhat like a block with a 1 column vertical orientation. Styling blocks without associated variable can only be done with with :::className inline and blocks without titles can not have direct connections with the overarching group (only variable associated blocks or nodes within them).
New nodes fall in line with layout of block (here, default of 1 column).
Here columns H recognizes a number of columns defined by the nodes within the block, default sizing (of each 1 column) should be determined by the greater of a standard size or max width of default of text or wrapped text (or max width with new lines given markdown-like). This can be explicitly defined as well, see below.
yields The explicit definition of the number of columns in a block defines its layout and the explicit definition of nodes taking up those columns can help define layout more precisely. columns H should have the same result, but if was instead mc:1, columns 3 would have an empty space equivalent to an additional column (with nodes/ blocks left aligned within block), whereas H is more dynamic.
Nodes and blocks should be able to be styled in a similar manner to nodes and subgraphs in a flowchart.
Because the columns are dynamically determined horizontally (by columns H), there are two columns in the unnamed block.
A new unnamed block with one column adding a new node, has it centered, because this is a new block it is below the block nested above it. Both are within a block with a default of one column with a preference for vertical orientation.
Explicitly defining the node to have two columns will override the default of one column (while maintaining a vertical orientation of the block), but the block will overall take up two columns.
yields
yields
yields
yields
Using this framework, there are a few things which could be more addressable. This diagram does not render as expected because the renderer makes decisions which are not perfectly aligned with what the editor may want. This is an instance of the same problem as #2509. Utilizing this proposed syntax, the intent of an editor could be expressed through the following:
This would yield the following. Utilizing this proposed syntax, the intent of an editor looking to produce something similar to the first example in this could be something reflected through something like the following.
I've not added the padding here, but this should yield the following. Utilizing this proposed syntax, the intent of an editor looking to produce something similar to the third example in this could be something reflected through something like the following.
This could yield something like the following. Here the rot class variable could recognize text rotation to align with the block height, this is maybe a bit clunky, but also keeps the organization of the blocks aligned with the rest of the diagram. These are all just a bunch of suggestions. I'm not sure how other people might feel or how the challenges associated with how these might be implemented. |
Great work @jordanroga! I like the addition of the auto column count where you don't have the need to set it automatically Good that you included the vertical layout. Instead of a class this should probably be a part of the syntax directly as a specific feature as it will affect the rendering more that a rotations. If you have internal blocks in the vertical block for instance. I also approve of keeping the syntax close to Mermaid flowcharts as you have it in your examples. Another area that should be defined is block arrows vs edges. Edges chould be defined as in flowcharts: block arrows are probable something else:
Likewise, the padding between blocks and alignment of sibling blocks as for instance on the same row needs a simple mechanism. You could opt for:
Padding: blocks can either have a space around them or not... |
Should we rename our diagram to |
While I understand the usefulness of these types of diagrams, I don't think they should be added to Mermaid unless a syntax is devised that is consistent with Mermaid's fundamental ethos:
Perhaps the problem is simply that my brain has grown stiff with age. Perhaps ya'll can read2 the various syntax examples above and the meaning is evident. If that's the case, please disregard this comment. 😊🙃🤪 But otherwise, if one has to render the Mermaid source to see the meaning, what is the advantage over just using SVG? If one is looking at the a diff before a git commit or when examining git history to understand changes to a diagram, and one ends up needing to render both versions to comprehend the change, there is no advantage over SVG, only disadvantages (SVG is far more flexible. You can draw exactly the diagram you want). You can see minor changes like spelling or label changes in the git diff for SVG just as well as you can for the above syntaxes. I don't know if an "easy to comprehend textual description translatable to a graphic" is possible for these types of diagrams, but for starters, nix the keywords 'block' and 'column'. Those are layout instructions, not semantics. If no such syntax is possible, just say no. 😉 Footnotes
|
@vassudanagunta Please, propose the syntax you think is correct |
@vassudanagunta I agree with your sentiment. The point is that the diagram should be readable as text as well. Saying that we could just as easy use svgs seems a little exaggerated though. I believe we will find a better syntax then that. Syntax summaryThe format of this thread is not working anymore with different versions of the proposed syntax. I will collect the latest. syntax here: https://github.com/mermaid-js/mermaid/wiki/Block-Diagram-(WIP) The we can discuss in around that. |
@nirname Thanks for your input. I have updated the wiki page with most of your suggestions.
|
@nirname Perhaps a call to work this out. |
What should we do if we add an edge between block and its content?
|
@Yokozuna59 I think we can give it a shot |
* develop: (124 commits) chore(deps): update all patch dependencies fix typo cutomers => customers chore(deps): update all minor dependencies Fix macOS onboarding issues Bump @zenuml/core and update render options in mermaid-zenuml (#5257) Fixed Typo in ErrorRenderer.ts (#5256) #3358 Removing redundant file #3358 Fix after review Fix selector #3358 Renaming of IOperation to ActionFun chore: Add interface naming build(deps-dev): bump vite from 4.4.12 to 4.5.2 Update container Update container Remove pnpm cache 3358 Adding types for blockArrowHelper #3358n Updated lockfile Update docs #3358 Another set of review changes Use `.node-version` file in workflows ...
* next: (118 commits) Update Deps chore(deps): update all patch dependencies fix typo cutomers => customers chore(deps): update all minor dependencies Fix macOS onboarding issues Bump @zenuml/core and update render options in mermaid-zenuml (mermaid-js#5257) Fixed Typo in ErrorRenderer.ts (mermaid-js#5256) mermaid-js#3358 Removing redundant file mermaid-js#3358 Fix after review Fix selector mermaid-js#3358 Renaming of IOperation to ActionFun chore: Add interface naming build(deps-dev): bump vite from 4.4.12 to 4.5.2 Update container Update container Remove pnpm cache 3358 Adding types for blockArrowHelper #3358n Updated lockfile Update docs mermaid-js#3358 Another set of review changes ...
* develop: Fix lint Use Yarn Add COREPACK_ENABLE_STRICT Updated chrome extension url's to new store add name only when present in rectData make name optional feat: add name field to the actors Changes to intro.md 1. Removed the Slack link 2. Updated the Discord invite link Changes to intro.md 1. Removed the Slack invite and left only the Discord invite Changes to intro.md 1. Added a link to the Discord server Updated contributions file #3358 Layoutfix for growing parent when children spans new rows due to updated columns widths Update docs Mermaid version 10.8.0
Trying this out, can't see how to name a composite block - no matter what I try it renders the parent block name as a child block |
Is your feature request related to a problem? Please describe.
I would prefer to describe APIs and such in terms of layered rectangles, rather than have a scattered array of boxes and curvy arrows.
It makes diagrams easier for me to read, plus this would be very useful for an API Layer diagram, to make it obvious that entity X is part of the foundational layer, where it consumes no other types. Then something at the top layer could all below it.
E.g. something like this, without the description bubbles on the left column. But with the connecting arrows, if desired.
Describe the solution you'd like
When working with (say) a class diagram. It would be nice if there was a way to apply an attribute to say that it was part of layer N.
This might require an attribute of
classDiagram
that would be similar todirection
such aslayout LAYERS
or something.The renderer would then create an encompassing rectangle around all classes of the same layer, and the encompassing rectangle would be stacked according to its relative number.
Describe alternatives you've considered
Presently, I think the class diagram is useful for describing dependencies, and the c4 diagram are the closest for providing encompassing rectangles, but neither seem to offer the ability to use a stacked rendering method instead of a graph solver with arrows.
** Additional Context **
Additional examples:
The text was updated successfully, but these errors were encountered: