安装模块
npm install node-echarts
图表配置
折线图
var LineChartOption = {
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value'
},
series: [{
data: [820, 932, 901, 934, 1290, 1330, 1320],
type: 'line'
}]
};
函数调用
生成base64
function draw(){
var buf= node_echarts({
width: 500,
height: 500,
option: HistogramOption,
//If the path is not set, return the Buffer of image.
//path: path.join(__dirname, '../public/image1.jpg'),
enableAutoDispose: true
});
var base64 = `data:image/png;base64,` + buf.toString('base64');