docs: update API response structure in README
A TypeScript-based service for exporting VChart charts to images or HTML files using Koa2 and Puppeteer.
npm install
npm run dev
npm run build npm start
Export a chart based on the provided specification.
Request Body:
{ spec: any; // VChart specification type?: 'image' | 'html'; // Export type (default: 'image') option?: { width?: string; // Chart width (default: '800px') height?: string; // Chart height (default: '600px') } }
Response:
{ success: boolean; data: { imageUrl: string; // URL to access the exported image file htmlUrl: string; // URL to access the exported HTML file (only for HTML export) } }
Access exported files directly.
# Export as image curl -X POST http://localhost:3000/export \ -H "Content-Type: application/json" \ -d '{ "spec": { "type": "bar", "data": [{ "id": "barData", "values": [ {"month": "Jan", "sales": 120}, {"month": "Feb", "sales": 200}, {"month": "Mar", "sales": 150} ] }], "xField": "month", "yField": "sales" }, "type": "image", "option": { "width": "800px", "height": "600px" } }' # Export as HTML curl -X POST http://localhost:3000/export \ -H "Content-Type: application/json" \ -d '{ "spec": { ... }, "type": "html" }'
├── src/ │ ├── index.ts # Server entry point │ ├── types.ts # TypeScript type definitions │ ├── chartService.ts # Chart export service │ └── routes.ts # API routes ├── output/ # Exported files directory ├── test-export.js # Test script └── package.json
MIT
版权所有:中国计算机学会技术支持:开源发展技术委员会 京ICP备13000930号-9 京公网安备 11010802032778号
VChart MCP Server Export
A TypeScript-based service for exporting VChart charts to images or HTML files using Koa2 and Puppeteer.
Features
Installation
Usage
Development Mode
Production Mode
API Endpoints
POST /export
Export a chart based on the provided specification.
Request Body:
Response:
GET /output/:filename
Access exported files directly.
Example
Project Structure
Dependencies
License
MIT