Data Visualization
生成桑基图来可视化不同节点之间的流量分布和能量转移
用三种语言从你的代码中调用此工具。
curl -X POST 'https://api.elysiatools.com/zh/api/tools/sankey-diagram-generator' \
-H 'Content-Type: application/json' \
-d '{"chartData":"简单示例(2个节点):\n{\n "nodes": [{"id": "source", "name": "来源", "value": 100}, {"id": "target", "name": "目标", "value": 100}],\n "links": [{"source": "source", "target": "target", "value": 100}]\n}\n\n或者3个节点:\n{\n "nodes": [{"id": "input", "name": "输入", "value": 100}, {"id": "process", "name": "处理", "value": 75}, {"id": "output", "name": "输出", "value": 75}],\n "links": [{"source": "input", "target": "process", "value": 75}, {"source": "process", "target": "output", "value": 75}]\n}","chartTitle":"输入图表标题...","nodeColors":"#1e40af,#dc2626,#16a34a,#ca8a04,#7c3aed,#0891b2","linkColors":"#3b82f6,#ef4444,#22c55e,#eab308,#a855f7,#06b6d4","chartWidth":"800","chartHeight":"500","nodeWidth":"30","nodePadding":"30","backgroundColor":"#ffffff","showValues":true,"showLabels":true,"animated":true}'以 JSON 形式 POST 提交输入参数。文件类型参数需先单独上传。
POST https://api.elysiatools.com/zh/api/tools/sankey-diagram-generator| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| chartData | textarea | 是 | 桑基图数据,需要包含nodes和links数组的JSON格式 |
| chartTitle | text | 否 | 显示在图表上方的标题 |
| nodeColors | text | 否 | 节点的颜色(逗号分隔的十六进制颜色) |
| linkColors | text | 否 | 流量连接线的颜色(逗号分隔的十六进制颜色) |
| chartWidth | number | 否 | 图表的像素宽度 |
| chartHeight | number | 否 | 图表的像素高度 |
| nodeWidth | number | 否 | 每个节点的像素宽度 |
| nodePadding | number | 否 | 节点之间的垂直间距(像素) |
| backgroundColor | color | 否 | 图表容器的背景颜色 |
| showValues | checkbox | 否 | 在图表上显示流量数值 |
| showLabels | checkbox | 否 | 在图表上显示节点名称 |
| animated | 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-sankey-diagram-generator": {
"name": "sankey-diagram-generator",
"description": "生成桑基图来可视化不同节点之间的流量分布和能量转移",
"baseUrl": "https://api.elysiatools.com/mcp/sse?toolId=sankey-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": "sankey-diagram-generator",
"arguments": {
"chartData": "简单示例(2个节点):\n{\n "nodes": [{"id": "source", "name": "来源", "value": 100}, {"id": "target", "name": "目标", "value": 100}],\n "links": [{"source": "source", "target": "target", "value": 100}]\n}\n\n或者3个节点:\n{\n "nodes": [{"id": "input", "name": "输入", "value": 100}, {"id": "process", "name": "处理", "value": 75}, {"id": "output", "name": "输出", "value": 75}],\n "links": [{"source": "input", "target": "process", "value": 75}, {"source": "process", "target": "output", "value": 75}]\n}",
"chartTitle": "输入图表标题...",
"nodeColors": "#1e40af,#dc2626,#16a34a,#ca8a04,#7c3aed,#0891b2",
"linkColors": "#3b82f6,#ef4444,#22c55e,#eab308,#a855f7,#06b6d4",
"chartWidth": "800",
"chartHeight": "500",
"nodeWidth": "30",
"nodePadding": "30",
"backgroundColor": "#ffffff",
"showValues": true,
"showLabels": true,
"animated": true
}
}
}有问题或反馈?请联系 [email protected]