[BootstrapBlazor] Blazor 使用 Mermaid 渲染详细图表
BootstrapBlazor 是一套基于 Bootstrap 和 Blazor 的企业级组件库,无缝整合了 Bootstrap 框架与 Blazor 技术。它提供了一整套强大的工具,使开发者能够轻松创建响应式和交互式的 Web 应用程序。
项目地址
Gitee:https://gitee.com/LongbowEnterprise/BootstrapBlazor
GitHub:https://github.com/dotnetcore/BootstrapBlazor
Nuget:https://www.nuget.org/packages/BootstrapBlazor
Blazor 使用 Mermaid 渲染详细图表
安装项目模板
dotnet new install Bootstrap.Blazor.Templates::*
新建项目,使用任意渲染模式模板,如果要在已有项目中使用Mermaid组件,则需要添加BootstrapBlazor包引用
安装可选包
Mermaid组件不包括在核心组件库BootstrapBlazor.Components中,需要使用Nuget安装BootstrapBlazor.Mermaid包
dotnet add package BootstrapBlazor.Mermaid
编写UI代码
<Mermaid DiagramString="@CustomStyleString"></Mermaid>
private string CustomStyleString { get; } = """
flowchart LR
A[start] -->
B{Whether the conditions are met?}
B -- yes --> C[Perform tasks 1]
B -- no --> D[Perform tasks 2]
C --> E{Condition checks}
D --> E
E -- The conditions are established --> F[Sub-processes]
F --> G[Complete the subprocess]
E -- The condition failed --> H[Error handling]
H --> I[Keep a log]
G --> J[end]
I --> J
style A fill:#ffe0b3,stroke:#ff9900,stroke-width:2px;
style B fill:#ffcccc,stroke:#ff0000,stroke-width:2px;
style C fill:#e6ffcc,stroke:#009933,stroke-width:2px;
style D fill:#cce6ff,stroke:#0033cc,stroke-width:2px;
style E fill:#ffccff,stroke:#9900cc,stroke-width:2px;
style F fill:#ccccff,stroke:#3300cc,stroke-width:2px;
style G fill:#b3ffff,stroke:#00cccc,stroke-width:2px;
style H fill:#ffd9b3,stroke:#ff6600,stroke-width:2px;
style I fill:#d9d9d9,stroke:#808080,stroke-width:2px;
style J fill:#ccffcc,stroke:#009900,stroke-width:2px;
linkStyle 0 stroke:#00cc00,stroke-width:2px;
linkStyle 1 fill:#006600,stroke:#009933,stroke-width:2px,font-size:12px;
linkStyle 2 fill:#990000,stroke:#ff3300,stroke-width:2px,font-size:12px;
linkStyle 3 stroke:#ff33cc,stroke-width:2px;
linkStyle 4 stroke:#cc33ff,stroke-width:2px;
linkStyle 5 stroke:#33ccff,stroke-width:2px;
linkStyle 6 stroke:#ff6600,stroke-width:2px,stroke-dasharray: 10,10;
linkStyle 7 stroke:#999999,stroke-width:2px;
linkStyle 8 stroke:#009900,stroke-width:2px;
linkStyle 9 stroke:#ff6600,stroke-width:2px;
""";
效果图
#bb_64469555-svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#bb_64469555-svg .error-icon{fill:#552222;}#bb_64469555-svg .error-text{fill:#552222;stroke:#552222;}#bb_64469555-svg .edge-thickness-normal{stroke-width:1px;}#bb_64469555-svg .edge-thickness-thick{stroke-width:3.5px;}#bb_64469555-svg .edge-pattern-solid{stroke-dasharray:0;}#bb_64469555-svg .edge-thickness-invisible{stroke-width:0;fill:none;}#bb_64469555-svg .edge-pattern-dashed{stroke-dasharray:3;}#bb_64469555-svg .edge-pattern-dotted{stroke-dasharray:2;}#bb_64469555-svg .marker{fill:#333333;stroke:#333333;}#bb_64469555-svg .marker.cross{stroke:#333333;}#bb_64469555-svg svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#bb_64469555-svg p{margin:0;}#bb_64469555-svg .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#bb_64469555-svg .cluster-label text{fill:#333;}#bb_64469555-svg .cluster-label span{color:#333;}#bb_64469555-svg .cluster-label span p{background-color:transparent;}#bb_64469555-svg .label text,#bb_64469555-svg span{fill:#333;color:#333;}#bb_64469555-svg .node rect,#bb_64469555-svg .node circle,#bb_64469555-svg .node ellipse,#bb_64469555-svg .node polygon,#bb_64469555-svg .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#bb_64469555-svg .rough-node .label text,#bb_64469555-svg .node .label text,#bb_64469555-svg .image-shape .label,#bb_64469555-svg .icon-shape .label{text-anchor:middle;}#bb_64469555-svg .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#bb_64469555-svg .rough-node .label,#bb_64469555-svg .node .label,#bb_64469555-svg .image-shape .label,#bb_64469555-svg .icon-shape .label{text-align:center;}#bb_64469555-svg .node.clickable{cursor:pointer;}#bb_64469555-svg .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#bb_64469555-svg .arrowheadPath{fill:#333333;}#bb_64469555-svg .edgePath .path{stroke:#333333;stroke-width:2.0px;}#bb_64469555-svg .flowchart-link{stroke:#333333;fill:none;}#bb_64469555-svg .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#bb_64469555-svg .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#bb_64469555-svg .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#bb_64469555-svg .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#bb_64469555-svg .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#bb_64469555-svg .cluster text{fill:#333;}#bb_64469555-svg .cluster span{color:#333;}#bb_64469555-svg div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#bb_64469555-svg .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#bb_64469555-svg rect.text{fill:none;stroke-width:0;}#bb_64469555-svg .icon-shape,#bb_64469555-svg .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#bb_64469555-svg .icon-shape p,#bb_64469555-svg .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#bb_64469555-svg .icon-shape rect,#bb_64469555-svg .image-shape rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#bb_64469555-svg :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;}
yes
no
The conditions are established
The condition failed
start
Whether the conditions are met?
Perform tasks 1
Perform tasks 2
Condition checks
Sub-processes
Complete the subprocess
Error handling
Keep a log
end
JohnBobAliceJohnBobAlice#bb_50804827-svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#bb_50804827-svg .error-icon{fill:#552222;}#bb_50804827-svg .error-text{fill:#552222;stroke:#552222;}#bb_50804827-svg .edge-thickness-normal{stroke-width:1px;}#bb_50804827-svg .edge-thickness-thick{stroke-width:3.5px;}#bb_50804827-svg .edge-pattern-solid{stroke-dasharray:0;}#bb_50804827-svg .edge-thickness-invisible{stroke-width:0;fill:none;}#bb_50804827-svg .edge-pattern-dashed{stroke-dasharray:3;}#bb_50804827-svg .edge-pattern-dotted{stroke-dasharray:2;}#bb_50804827-svg .marker{fill:#333333;stroke:#333333;}#bb_50804827-svg .marker.cross{stroke:#333333;}#bb_50804827-svg svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#bb_50804827-svg p{margin:0;}#bb_50804827-svg .actor{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#bb_50804827-svg text.actor>tspan{fill:black;stroke:none;}#bb_50804827-svg .actor-line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);}#bb_50804827-svg .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333;}#bb_50804827-svg .messageLine1{stroke-width:1.5;stroke-dasharray:2,2;stroke:#333;}#bb_50804827-svg #arrowhead path{fill:#333;stroke:#333;}#bb_50804827-svg .sequenceNumber{fill:white;}#bb_50804827-svg #sequencenumber{fill:#333;}#bb_50804827-svg #crosshead path{fill:#333;stroke:#333;}#bb_50804827-svg .messageText{fill:#333;stroke:none;}#bb_50804827-svg .labelBox{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#bb_50804827-svg .labelText,#bb_50804827-svg .labelText>tspan{fill:black;stroke:none;}#bb_50804827-svg .loopText,#bb_50804827-svg .loopText>tspan{fill:black;stroke:none;}#bb_50804827-svg .loopLine{stroke-width:2px;stroke-dasharray:2,2;stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);}#bb_50804827-svg .note{stroke:#aaaa33;fill:#fff5ad;}#bb_50804827-svg .noteText,#bb_50804827-svg .noteText>tspan{fill:black;stroke:none;}#bb_50804827-svg .activation0{fill:#f4f4f4;stroke:#666;}#bb_50804827-svg .activation1{fill:#f4f4f4;stroke:#666;}#bb_50804827-svg .activation2{fill:#f4f4f4;stroke:#666;}#bb_50804827-svg .actorPopupMenu{position:absolute;}#bb_50804827-svg .actorPopupMenuPanel{position:absolute;fill:#ECECFF;box-shadow:0px 8px 16px 0px rgba(0,0,0,0.2);filter:drop-shadow(3px 5px 2px rgb(0 0 0 / 0.4));}#bb_50804827-svg .actor-man line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#bb_50804827-svg .actor-man circle,#bb_50804827-svg line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;stroke-width:2px;}#bb_50804827-svg :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;}loop[HealthCheck]Rational thoughts prevail!Hello John, how are you?Fight against hypochondriaGreat!How about you?Jolly good!Title SequenceDiagram
结语
组件支持导出Base64数据(ExportBase64MermaidAsync),后续会实现双绑事件
更多Mermaid语法,参考:https://mermaid.nodejs.cn/intro/
[BootstrapBlazor] Blazor 使用 Mermaid 渲染详细图表的更多相关文章
- Vue自定义标签页,并且在其中渲染Echarts图表
目录 一.需求说明 二.标签页功能实现 一.需求说明 1.点击标签按钮切换不同的echarts图表,考虑用Ant Design Vue,但是其样式无法自定义 2.div的整体布局样式使用tailwin ...
- mpvue——动态渲染echarts图表
前言 使用mpvue-echarts来写图表,那个F2再提醒自己下要踩坑不能忘记.遇到了一个问题就是数据不能动态的去渲染,这个其实官方给了我们对应的方法 懒加载 代码 修改了调用initChart() ...
- 关于在bootstrap的tab栏中渲染echats图表,切换tab时echats不显示问题
在开发过程中遇到这样个问题: 利用bootstrap中的tab栏,每当点击tab栏的导航时,echats仅仅只渲染第一个tab的内容,切换tab时,echats图表不显示. 其html代码为: < ...
- v-if和updated钩子结合使用 渲染echart图表
项目需求是这样的,用户可以自定选择echart 曲线图 是横向还是竖向显示.我的做法是 写了一个横向的echart图表,也写了一个竖向的echart图表,然后两者共用存在store里的图表数据,就能实 ...
- 浏览器渲染详细过程:重绘、重排和 composite 只是冰山一角
https://juejin.im/entry/590801780ce46300617c89b8 渲染 这张很经典的图许多人都看过,其中的概念大家应该都很熟悉,也就是这么几个步骤:js修改dom结构或 ...
- jQuery插件jqplot的详细配置说明和渲染器
jQuery插件jqplot的详细配置说明和渲染器 (2012-08-23 08:57:42) 转载▼ 标签: jqplot 详细配置 渲染器 it 分类: 技术类 jQuery.jqplot插件的官 ...
- FusionCharts可使用JavaScript渲染iPhone/iPod/iPad图表
FusionCharts使用JavaScript: FusionCharts允许用户创建建立JavaScript图表(也就是web上的HTML5 /Canvas图表).这个特性允许用户在不支持Flas ...
- 11个很棒的 jQuery 图表库
如果你曾经使用过任何类型的数据,你应该知道阅读一排排数据的痛苦.通过所有这些数据弄清楚他们的意思是非常不容易的.可视化对于解决这个问题起到了重要的作用.可视化降低了数据阅读的难度,帮助决策者获得可操作 ...
- Android 图表绘制 achartengine 示例解析
一. AChartEngine 简介 1. 项目地址 AChartEngine 简介 : AChartEngine 是 Android 平台的图表开发库, 能绘制 折线图, 饼图, 气泡图, 柱状图, ...
- 【Android 应用开发】Android 图表绘制 achartengine 示例解析
作者 : 韩曙亮 转载请注明出处 : http://blog.csdn.net/shulianghan/article/details/38420197 一. AChartEngine 简介 1. 项 ...
随机推荐
- CMake 属性之目标属性
[写在前面] CMake 可以通过属性来存储信息.它就像是一个变量,但它被附加到一些其他的实体上,像是一个目录或者是一个目标.例如一个全局的属性可以是一个有用的非缓存的全局变量. 在 CMake 的众 ...
- 墨天轮访谈 | Pika数据库陈磊:云时代下,键值数据库是否会被替代?
分享嘉宾:陈磊 开源数据库Pika项目PMC核心人员 整理:墨天轮社区 导读 大家好,今天我分享的主题是:KV数据库,云时代的文件存储. 随着AI和机器学习等技术的发展,数据演变为了十分宝贵的资源,数 ...
- 大数据技术之Shell
1. shell概述 示意图: Shell是一个命令行解释器,它为用户提供了一个向Linux内核发送请求以便运行程序的界面系统级程序,用户可以用Shell来启动.挂起.停止甚至是编写一些程序. ● L ...
- P3472 [POI2008]MAF-Mafia
P3472 [POI2008]MAF-Mafia 解法 不难发现,这个题目建图后出现的是一个基环树森林+一堆环,因为每个点仅有一条出边. 大概长这样: 对于最大,最小值,我们分开考虑. 最大值 可以看 ...
- ROS入门21讲(4)
八.客户端Client的编程实现 1.话题模型 服务模型(客户端/服务器) 2.创建功能包 命令: $ cd ~/catkin_ws/src $ catkin_create_pkg learning_ ...
- .NET 9 中没有 wasi 实验性支持
2023年10月份写个一篇<本计划在 .NET 8 中推出的 WASI 推迟到 .NET 9>[1],根据此问题,在 .NET 9 RTM 中似乎不会有wasi-experimental, ...
- js 数字计算的精度问题
〇.js 的数值计算存在结果不精确的情况 最近接触财务相关系统,页面上会有一些简单的计算,就发现其实是非常简单的计算,但 js 计算出来的结果却不是预期值,可能带上一大串 0 或 9,导致计算结果错误 ...
- .NET 8.0 通用管理平台,支持模块化、WinForms 和 WPF
前言 领导要求做一个小项目,要求独立运行,用以最少的依赖,此时不想集成到主项目中,但是又想用HzyAdmin中如此好用的自动注入,还有操作简单的仓储模式,话不多说,直接开干. HzyAdmin 是一个 ...
- 成为Java GC专家系列(3) — 如何优化Java垃圾回收机制
本文是成为Java GC专家系列文章的第三篇.在第一篇<成为JavaGC专家Part I - 深入浅出Java垃圾回收机制>中我们学习了不同GC算法的执行过程,GC是如何工作的,什么是新生 ...
- 反编译工具之Jadx
jadx 是一款功能强大的反编译工具,使用起来简单方便(拖拽式操作),不光提供了命令行程序,还提供了 GUI 程序.一般情况下,我们直接使用 GUI 程序就可以了. jadx 支持 Windows.L ...