chart-server
introduction
由于项目要用到服务器生成图片的功能,但是由于后台图表的依赖库所能渲染的样式有限,故选择了业界最广泛使用的Echarts与HighCharts作为服务端渲染图片的库。使用了puppeteer作为headless浏览器来渲染图片,返回生成图片的 base64码。该功能需要使用nodejs来运行express服务,服务成功运行之后,可在java端或其他后台中通过本地(localhost)或者网络请求的方式,通过服务来得到base64码。
运行
yarn install
node server.js
接口
echarts
- request
POST (application/json)
{
"width":700,
"height":600,
"options":{
"title": {
"text": "ECharts 入门示例"
},
"tooltip": {},
"legend": {
"data":["销量"]
},
"xAxis": {
"data": ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"