Data Visualization
生成背对背条形图,用于正负值对比展示,非常适合数据集对比分析
用三种语言从你的代码中调用此工具。
curl -X POST 'https://api.elysiatools.com/zh/api/tools/comparison-bar-chart' \
-H 'Content-Type: application/json' \
-d '{"chartData":"JSON format:\n[{"label": "Product A", "leftValue": 65, "rightValue": 85},\n{"label": "Product B", "leftValue": 45, "rightValue": 75},\n{"label": "Product C", "leftValue": 80, "rightValue": 60}]\n\nor text format:\nProduct A|65|85\nProduct B|45|75\nProduct C|80|60","chartTitle":"输入图表标题...","colorScheme":"default","barColor":"#3b82f6","leftLabel":"Left Values","rightLabel":"Right Values","chartHeight":"500","barWidth":"30","maxValue":0,"minValue":"0","animationDuration":"1000","backgroundColor":"#ffffff","gridColor":"#e0e0e0","showGrid":true,"showValues":true,"showLegend":true}'以 JSON 形式 POST 提交输入参数。文件类型参数需先单独上传。
POST https://api.elysiatools.com/zh/api/tools/comparison-bar-chart| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| chartData | textarea | 是 | 对比图数据。支持JSON数组或简单的标签|左值|右值文本格式 |
| chartTitle | text | 否 | 显示在图表上方的标题 |
| colorScheme | select | 否 | — |
| barColor | color | 否 | 左侧条形的颜色(右侧条形颜色来自配色方案) |
| leftLabel | text | 否 | 图表左侧的标签 |
| rightLabel | text | 否 | 图表右侧的标签 |
| chartHeight | number | 否 | 图表的像素高度 |
| barWidth | number | 否 | 条形的最大像素宽度 |
| maxValue | number | 否 | 图表缩放的最大值(留空自动) |
| minValue | number | 否 | 图表缩放的最小值 |
| animationDuration | number | 否 | 条形动画的毫秒时长 |
| backgroundColor | color | 否 | 图表容器的背景颜色 |
| gridColor | color | 否 | 网格线的颜色 |
| showGrid | checkbox | 否 | 显示网格线以便更好阅读 |
| showValues | checkbox | 否 | 在条形上显示数值 |
| showLegend | 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-comparison-bar-chart": {
"name": "comparison-bar-chart",
"description": "生成背对背条形图,用于正负值对比展示,非常适合数据集对比分析",
"baseUrl": "https://api.elysiatools.com/mcp/sse?toolId=comparison-bar-chart",
"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": "comparison-bar-chart",
"arguments": {
"chartData": "JSON format:\n[{"label": "Product A", "leftValue": 65, "rightValue": 85},\n{"label": "Product B", "leftValue": 45, "rightValue": 75},\n{"label": "Product C", "leftValue": 80, "rightValue": 60}]\n\nor text format:\nProduct A|65|85\nProduct B|45|75\nProduct C|80|60",
"chartTitle": "输入图表标题...",
"colorScheme": "default",
"barColor": "#3b82f6",
"leftLabel": "Left Values",
"rightLabel": "Right Values",
"chartHeight": "500",
"barWidth": "30",
"maxValue": 0,
"minValue": "0",
"animationDuration": "1000",
"backgroundColor": "#ffffff",
"gridColor": "#e0e0e0",
"showGrid": true,
"showValues": true,
"showLegend": true
}
}
}有问题或反馈?请联系 [email protected]