Skip to content

Commit

Permalink
add size support
Browse files Browse the repository at this point in the history
  • Loading branch information
Bohan committed Dec 15, 2017
1 parent e7af31d commit 6163e7a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ ECharts图表接口,通过URL直接返回图像,方便发送邮件或机器

## API

通用参数

- width: 默认500px
- height: 默认500px

### 自定义样式
```
GET http://echarts.pipelinecraft.com/api?option={"title":{"text":"ECharts%20入门示例"},"tooltip":{},"legend":{"data":["销量"]},"xAxis":{"data":["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"]},"yAxis":{},"series":[{"name":"销量","type":"bar","data":[5,20,36,10,10,20]}]}
Expand Down
12 changes: 9 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ router.get('/api', async (ctx, next) => {
console.log('query:', ctx.query);
let option = JSON.parse(ctx.query.option)
let buffer = await node_echarts({
option: option
option: option,
width: ctx.query.width || 500,
height: ctx.query.height || 500
})
ctx.type = 'image/png'
ctx.body = buffer
Expand Down Expand Up @@ -46,7 +48,9 @@ router.get('/api/line', async (ctx, next) => {
}
ctx.type = 'image/png'
ctx.body = await node_echarts({
option: option
option: option,
width: ctx.query.width || 500,
height: ctx.query.height || 500
})
})

Expand Down Expand Up @@ -84,7 +88,9 @@ router.get('/api/pie', async (ctx, next) => {

ctx.type = 'image/png'
ctx.body = await node_echarts({
option: option
option: option,
width: ctx.query.width || 500,
height: ctx.query.height || 500
})
})

Expand Down

0 comments on commit 6163e7a

Please sign in to comment.