[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. 项 ...
随机推荐
- Windows应急响应-Auto病毒
目录 应急背景 分析样本 开启监控 感染病毒 查看监控 分析病毒行为 autorun.inf分析 2.异常连接 3.进程排查 4.启动项排查 查杀 1.先删掉autorun.inf文件 2.使用xue ...
- USB gadget configfs
概述 USB Linux Gadget是一种具有UDC (USB设备控制器)的设备,可以连接到USB主机,以扩展其附加功能,如串口或大容量存储能力. 一个gadget被它的主机视为一组配置,每个配置都 ...
- 深度学习卷积、全连接层、深度可分离层参数量和FLOPs计算公式
来源 卷积: 输入尺寸 ,卷积核的大小为 * ,输出的尺寸大小为 参数量 (1)不考虑bias:(2)考虑bias: FLOPs (1)不考虑bias 解释:先计算输出的中一个元素需要的计算量, ...
- synchronized锁的内容
synchronized锁的内容 import java.util.concurrent.TimeUnit; class Test1 { public static void main(String[ ...
- 初探python栈帧逃逸
前言 以前在一些大型比赛就遇到这种题,一直没时间去研究,现在康复训练下:) 生成器介绍 生成器(Generator)是Python中一种特殊的迭代器,它可以在迭代过程中动态生成值,而不需要一次性将所有 ...
- 指针进阶(数组指针 )(C语言)
1. 数组名的理解 在指针入门中我们在使用指针访问数组的内容时,有这样的代码: int arr[10] = {1,2,3,4,5,6,7,8,9,10}; int *p = &arr[0]; ...
- C# 入门深度学习:万字长文讲解微积分和梯度下降
教程名称:使用 C# 入门深度学习 作者:痴者工良 地址: https://torch.whuanle.cn 目录 微积分 极限 导数 求导公式 乘除求导例题 复合函数求导的链式法则 Sigmoid ...
- IPC最新发行了新标准:IPC-A-610J, IPC-J-STD-001J, IPC-7711/21D, IPC-2221C
IPC最新发行了新标准:IPC-A-610J, IPC-J-STD-001J, IPC-7711/21D, IPC-2221C 2024年伊始,IPC又更新了一些新的标准,大家可以及时去更新了 ...
- atcoder ABC237-E Skiing
atcoder ABC237-E Skiing 传送门 这题把一个点到另外一个点的开心值变为这条边的权值,就可以化为求最大路.因为有负边权,所以要用\(SPFA\),但\(SPFA\)这玄学的时间复杂 ...
- .NET周刊【11月第3期 2024-11-17】
国内文章 .NET 9使用Scalar替代Swagger https://www.cnblogs.com/netry/p/18543378/scalar-an-alternative-to-swagg ...