美人鱼流程图传奇风格

发布于 2025-02-06 05:19:20 字数 1384 浏览 1 评论 0原文

这个问题有三个部分:在子图中格式化文本标签,以隐藏的对象为中心,并进行文件布局。

  • 如何从传奇组中删除标签文本背景? Mermaid如何设置标签样式的类似问题 - 对于流程图节点有一个答案,没有任何解释。

  • 流程图是自上而下的,但传说是左右,因此必须将传说放入一个子图中,右侧最终隐藏节点。这会导致输出右侧的空格,因此图像不在中心。可以在没有空格的情况下生成图像,以便它位于输出的中心?

  • 将样式和代码保存在一个文件中很方便,但欢迎对管理样式的任何注释。

“在此处输入图像说明”

<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>

<div class="mermaid">

%%{init: {'flowchart' : {'curve' : 'stepBefore'}}}%%

flowchart  TD
  A((A))
  A --- B
  A --- C
  A --- D
  A --- E
  B --- B1
  B --- B2

  %% Legend
  E --- legend
  subgraph legend
    direction LR
    Y --- |Type 1| Z
    Z --- |Type 2| null
  end
  linkStyle 6,7,8 stroke:#0000,stroke-width:0px;

  classDef Type1 fill:lime, font-weight: bolder;
  classDef Type2 fill:yellow, font-weight: bolder;
  class A,B,E,Z Type2;
  class C,D,B1,B2,Y Type1;

  classDef hide fill:#0000,stroke:#0000,stroke-width:0px,color:#0000;
  class legend,null hide;
  classDef hide-font color:#0000;
  class Y,Z hide-font;
  
  </div>

There are three parts to this question: formatting a text label in a subgraph, centering the output with hidden objects, and file layout.

  • How can the label text background be removed from within the legend group? A similar question at Mermaid - How to set the labels style for flowchart nodes has an answer without any explanation.

  • The flowchart is top-down but the legend is left-right, so the legend had to be put in a subgraph with a final hidden node on the right side. This causes whitespace on the right side of the output so the image is not centered. Can the image be generated without the whitespace so it sits in the center of the output?

  • It is convenient to keep the style and code in a single file but any comments on managing style are welcome.

enter image description here

<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>

<div class="mermaid">

%%{init: {'flowchart' : {'curve' : 'stepBefore'}}}%%

flowchart  TD
  A((A))
  A --- B
  A --- C
  A --- D
  A --- E
  B --- B1
  B --- B2

  %% Legend
  E --- legend
  subgraph legend
    direction LR
    Y --- |Type 1| Z
    Z --- |Type 2| null
  end
  linkStyle 6,7,8 stroke:#0000,stroke-width:0px;

  classDef Type1 fill:lime, font-weight: bolder;
  classDef Type2 fill:yellow, font-weight: bolder;
  class A,B,E,Z Type2;
  class C,D,B1,B2,Y Type1;

  classDef hide fill:#0000,stroke:#0000,stroke-width:0px,color:#0000;
  class legend,null hide;
  classDef hide-font color:#0000;
  class Y,Z hide-font;
  
  </div>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

天生の放荡 2025-02-13 05:19:20
{
  "theme": "neutral"
}

是最简单的解决方法。 (在线编辑中的“ config”下。)

https://github.com/github.com/mermeraid.com/mermeraid.com/mermeraid -JS/Mermaid/essume/3121 开放了一年。

{
  "theme": "neutral"
}

Is the easiest workaround for this. (Under "Config" in the online editor.)

https://github.com/mermaid-js/mermaid/issues/3121 has been open for a year.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文