[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. 项 ...
随机推荐
- 大模型应用开发初探 : 基于Coze创建Agent
大家好,我是Edison. 最近学习了一门课程<AI Agent入门实战>,了解了如何在Coze平台上创建AI Agent,发现它对我们个人(C端用户)而言十分有用,分享给你一下. Coz ...
- 分类问题的评价指标AUC
- 活动预告 | 中国数据库联盟(ACDU)中国行第四站定档西安,邀您探讨数据库前沿技术
作为墨天轮社区与中国数据库联盟的品牌活动之一,[ACDU 中国行]已走过深圳.杭州.成都三大城市,在线下汇集数据库领域的行业知名人士,共同探讨数据库前沿技术及其应用,促进行业发展和创新,同时也为开发者 ...
- js 中必须加分号的位置集合
1. 匿名函数(自执行函数)(function (){}()) 2. 解析赋值 2 个变量交换位置
- 云原生的 WebAssembly 能取代 Docker 吗?
WebAssembly 是一个可移植.体积小.加载快并且兼容 Web 的全新格式.由于 WebAssembly 具有很高的安全性,可移植性,效率和轻量级功能,因此它是应用程序安全沙箱方案的理想选择.现 ...
- 云原生周刊:Grafana Beyla 发布 | 2023.9.18
开源项目推荐 Komiser Komiser 是一个与云无关的开源资源管理器.它与多个云提供商(包括 AWS.Azure.Civo.Digital Ocean.OCI.Linode.腾讯和 Scale ...
- C++容器概览
容器 容器是用来存储数据的序列,它们提供了不同的存储方式和访问模式. STL 中的容器可以分为三类: 1.序列容器:存储元素的序列,允许双向遍历. vector:动态数组,支持快速随机访问. dequ ...
- 工作中的技术总结 _Thymeleaf限制字符串的展示长度 _20210910
工作中的技术总结 _Thymeleaf限制字符串的展示长度 _20210910 比较简单就这一行代码 #strings.abbreviate 应该是调用了 thymeleaf 的内置函数 这一个方法的 ...
- Multi-Patch Prediction Adapting LLMs for Time Series Representation Learning
这篇论文是出自2024ICML的一篇论文,作者成功将大语言模型应用到时序模型之中,并在时序领域取得了很好的效果,不仅如此,作者还设置了多种下游任务,从论文结果得知,作者的模型在下游任务处都取得了很好的 ...
- ATC:多快好省,无参数token reduction方法 | ECCV'24
来源:晓飞的算法工程笔记 公众号,转载请注明出处 论文: Agglomerative Token Clustering 论文地址:https://arxiv.org/abs/2409.11923 论文 ...