Draw.io Diagram Generator
Generate interactive draw.io diagrams that users can open and edit in their browser.
Supported Diagram Types
Draw.io supports virtually any diagram type:
- - Standard: Flowcharts, org charts, mind maps, timelines, Venn diagrams
- Software: UML (class, sequence, activity, use case), ERD, architecture diagrams
- Cloud/Infrastructure: AWS, Azure, GCP, Kubernetes, network topology
- Engineering: Electrical circuits, digital logic, P&ID, floor plans
- Business: BPMN, value streams, customer journeys, SWOT
- UI/UX: Wireframes, mockups, sitemaps
- And more: Infographics, data flows, decision trees, etc.
Format Selection Guide
| Format | Best For |
|---|
| Mermaid | Flowcharts, sequences, ERD, Gantt, state diagrams, class diagrams |
| CSV |
Hierarchical data (org charts), bulk import from spreadsheets |
|
XML | Complex layouts, precise positioning, custom styling, icons, shapes |
How to Use
Step 1: Determine the best format for the diagram
- - Use Mermaid for most standard diagrams (flowcharts, sequence diagrams, ERD)
- Use CSV for hierarchical data like org charts
- Use XML when you need precise control over positioning or custom shapes
Step 2: Generate the diagram code
Write the diagram code in the chosen format (see examples below).
Step 3: Execute the Python script
Run the script scripts/generate_drawio_url.py (relative to this SKILL.md file) to create the markdown link.
Format Templates
Mermaid
CODEBLOCK0
XML (draw.io native)
CODEBLOCK1
CSV (hierarchical data)
CODEBLOCK2
CRITICAL: XML Well-Formedness
When generating draw.io XML, the output must be well-formed XML:
- - NEVER use double hyphens (
--) inside XML comments. Use single hyphens or rephrase (e.g., <!-- Order 1 to OrderItem --> not <!-- Order 1 --- OrderItem -->) - Escape special characters in attribute values (
&, <, >, ")
Script Usage
The script generate_drawio_url.py is located in the scripts/ subdirectory relative to this SKILL.md file. Execute it with command-line arguments:
CODEBLOCK3
Arguments:
- -
-t, --type: Diagram type (required), choices: mermaid, xml, INLINECODE13 - INLINECODE14 : Diagram code content (required)
The script outputs a markdown link: INLINECODE15
Present the markdown link directly to the user.
Draw.io 图表生成器
生成用户可在浏览器中打开和编辑的交互式 draw.io 图表。
支持的图表类型
Draw.io 几乎支持所有图表类型:
- - 标准型:流程图、组织结构图、思维导图、时间线、维恩图
- 软件类:UML(类图、时序图、活动图、用例图)、ER图、架构图
- 云/基础设施:AWS、Azure、GCP、Kubernetes、网络拓扑图
- 工程类:电路图、数字逻辑图、P&ID、平面图
- 商业类:BPMN、价值流图、客户旅程图、SWOT分析图
- UI/UX类:线框图、原型图、站点地图
- 更多类型:信息图、数据流图、决策树等
格式选择指南
| 格式 | 最佳用途 |
|---|
| Mermaid | 流程图、时序图、ER图、甘特图、状态图、类图 |
| CSV |
层级数据(组织结构图)、从电子表格批量导入 |
|
XML | 复杂布局、精确定位、自定义样式、图标、形状 |
使用方法
步骤 1:确定图表的最佳格式
- - 大多数标准图表(流程图、时序图、ER图)使用 Mermaid
- 层级数据(如组织结构图)使用 CSV
- 需要精确定位或自定义形状时使用 XML
步骤 2:生成图表代码
以所选格式编写图表代码(参见下方示例)。
步骤 3:执行 Python 脚本
运行脚本 scripts/generatedrawiourl.py(相对于此 SKILL.md 文件)以创建 Markdown 链接。
格式模板
Mermaid
graph TD
A[开始] --> B{决策}
B -->|是| C[执行]
B -->|否| D[结束]
XML(draw.io 原生格式)
xml
CSV(层级数据)
label: %name%
style: rounded=1;whiteSpace=wrap;html=1;
connect: {from:manager,to:name,invert:true}
layout: auto
name,manager
CEO,
CTO,CEO
CFO,CEO
关键要求:XML 格式规范性
生成 draw.io XML 时,输出必须是格式规范的 XML:
- - 切勿在 XML 注释中使用双连字符(--)。 请使用单连字符或重新措辞(例如,使用 而非 )
- 对属性值中的特殊字符进行转义(&、<、>、")
脚本使用说明
脚本 generatedrawiourl.py 位于此 SKILL.md 文件所在目录的 scripts/ 子目录中。通过命令行参数执行:
bash
python scripts/generatedrawiourl.py -t mermaid -c graph TD\n A --> B
python scripts/generatedrawiourl.py --type xml --code ...
python scripts/generatedrawiourl.py -t csv -c name,manager\nCEO,\nCTO,CEO
参数说明:
- - -t, --type:图表类型(必填),可选值:mermaid、xml、csv
- -c, --code:图表代码内容(必填)
脚本输出一个 Markdown 链接:点击查看图表
将 Markdown 链接直接呈现给用户。