echarts-headless-render
v1.0.5
Published
echarts无头浏览器生成cli的工具
Maintainers
Readme
echarts-headless-render
A lightweight CLI tool to render ECharts charts to PNG or Base64 using Puppeteer
Features
- 🖼️ Render ECharts options to PNG images
- 📄 Output Base64-encoded images for embedding
- ⚙️ Support custom width, height, and renderer (canvas or svg)
- 🚫 No HTTP server required—pure CLI invocation
Installation
npm install -g echarts-headless-renderUsage
ec-cli [options]Options
| Flag | Description | Default |
| -------------- | ------------------------------------------------------ | ------------ |
| -i, --input | Path to JSON file or JSON string of the ECharts option | (required) |
| -o, --output | Output file path (PNG) | output.png |
| --width | Chart viewport width in pixels | 800 |
| --height | Chart viewport height in pixels | 600 |
| --base64 | Output Base64 string to stdout instead of file | false |
| --renderer | Rendering mode: canvas or svg | canvas |
| -h, --help | Show help | |
Examples
Render from JSON file
ec-cli -i option.json -o sales-chart.png --width 1024 --height 768Render and output Base64
ec-cli -i option.json --base64 > chart.base64.txtRender and output Svg
ec-cli -i option.json --renderer svg -o chart.svgInline JSON string
ec-cli -i '{"title":{"text":"Demo"},"xAxis":{"data":["A","B"]},"yAxis":{},"series":[{"type":"bar","data":[10,20]}]}' -o demo.png
