mermaid-js / mermaid

Generation of diagrams like flowcharts or sequence diagrams from text in a similar manner as markdown
https://mermaid.js.org
MIT License
72.07k stars 6.54k forks source link

changing default node shape to circle does not work #4765

Open gonzalobg opened 1 year ago

gonzalobg commented 1 year ago

Description

When I do:

graph TD;
classDef node shape:circle;
  subgraph thread1
    D-->E-->F;
  end
  subgraph thread10
    A-->B-->C;
  end
  F-->C

the default shape of the nodes in the graph is rectangles, not circles.

Steps to reproduce

See above.

Screenshots

No response

Code Sample

graph TD;
classDef node shape:circle;
  subgraph thread1
    D-->E-->F;
  end
  subgraph thread10
    A-->B-->C;
  end
  F-->C

Setup

Suggested Solutions

Fix this so that the default shape changes.

Additional Context

No response

tomperr commented 1 year ago

Is this supposed to work? I am not aware of all the flowchart features, but I can't find anything about this in the documentation

gonzalobg commented 1 year ago

Hard to tell. Is flowchart used for these graphs?

My understanding from skimming from some of the source code is that there is a default shape that can be overriden, but I could not find anything in the documentation about how to do that.

I couldn't find much documentation about graph either, so I'm not sure if this not being documented is a "bug", or whether this is not documented because it is not supported yet, or whether the bug is on my side because I am trying to change the default in the wrong way.

tomperr commented 1 year ago

graph and flowchart identify the same type of diagram, but I guess graph was the old identifier. By default, nodes are rendered with rect tag, so I don't think using classDef to modify its shape is really appropriated

ssgosh commented 8 months ago

How does one make all nodes circular by default in Mermaid?

nirname commented 4 months ago

classDef is not for modifying shapes.

Shape can have some special meaning in a diagram. There is no way to configure which shape corresponds to a type of node/vertex at the moment. By default they are square https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/diagrams/flowchart/parser/flow.jison#L381

e.g.

Label Shape
A square
A( ) rounded square
A(( )) circle

etc.

So it is in the grammar and all the matching between syntax & shapes are here

So I believe this is an enhancement.

Consider adding a configuration option for default shape.