Data Visualization
从层级数据生成交互式树状图,支持自定义样式
用三种语言从你的代码中调用此工具。
curl -X POST 'https://api.elysiatools.com/zh/api/tools/tree-diagram-generator' \
-H 'Content-Type: application/json' \
-d '{"treeData":"JSON: [{"name": "Root", "value": 100,\n "children": [\n {"name": "Branch 1", "value": 50},\n {"name": "Branch 2", "value": 30}\n ]\n}]\n\nor text:\nRoot:100\nRoot:Branch 1:50\nRoot:Branch 2:30","chartTitle":"输入图表标题...","nodeShape":"circle","nodeColor":"#3b82f6","nodeTextColor":"#ffffff","lineColor":"#6b7280","backgroundColor":"#ffffff","nodeSize":"40","fontSize":"12","lineWidth":"2","chartHeight":"600","showLabels":true,"showValues":true}'以 JSON 形式 POST 提交输入参数。文件类型参数需先单独上传。
POST https://api.elysiatools.com/zh/api/tools/tree-diagram-generator| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| treeData | textarea | 是 | 树的层级数据。支持JSON对象或父子关系文本格式 |
| chartTitle | text | 否 | 显示在图表上方的标题 |
| nodeShape | select | 否 | — |
| nodeColor | color | 否 | 树节点的颜色 |
| nodeTextColor | color | 否 | 节点文字的颜色 |
| lineColor | color | 否 | 连接线的颜色 |
| backgroundColor | color | 否 | 图表容器的背景颜色 |
| nodeSize | number | 否 | 节点的像素大小 |
| fontSize | number | 否 | 节点文字的字体大小 |
| lineWidth | number | 否 | 连接线的宽度 |
| chartHeight | number | 否 | 图表的像素高度 |
| showLabels | checkbox | 否 | 在节点上显示文字标签 |
| showValues | checkbox | 否 | 在节点上显示数值 |
HTML 结果
{
"result": "<div>Processed HTML content</div>",
"error": "Error message (optional)",
"message": "Notification message (optional)",
"metadata": {
"key": "value"
}
}将此工具加入你的 Model Context Protocol 服务,让 AI 智能体可以列出并调用它。
将以下内容加入你的 MCP 客户端配置:
{
"mcpServers": {
"elysiatools-tree-diagram-generator": {
"name": "tree-diagram-generator",
"description": "从层级数据生成交互式树状图,支持自定义样式",
"baseUrl": "https://api.elysiatools.com/mcp/sse?toolId=tree-diagram-generator",
"command": "",
"args": [],
"env": {},
"isActive": true,
"type": "sse"
}
}
}连接到 SSE 端点后,列出已开放的工具:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list"
}通过工具 id 调用,参数由其参数表构建:
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "tree-diagram-generator",
"arguments": {
"treeData": "JSON: [{"name": "Root", "value": 100,\n "children": [\n {"name": "Branch 1", "value": 50},\n {"name": "Branch 2", "value": 30}\n ]\n}]\n\nor text:\nRoot:100\nRoot:Branch 1:50\nRoot:Branch 2:30",
"chartTitle": "输入图表标题...",
"nodeShape": "circle",
"nodeColor": "#3b82f6",
"nodeTextColor": "#ffffff",
"lineColor": "#6b7280",
"backgroundColor": "#ffffff",
"nodeSize": "40",
"fontSize": "12",
"lineWidth": "2",
"chartHeight": "600",
"showLabels": true,
"showValues": true
}
}
}有问题或反馈?请联系 [email protected]