node后台生成echarts图表
Posted vichang
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了node后台生成echarts图表相关的知识,希望对你有一定的参考价值。
1 //2,生成图片数据 2 var option = { 3 tooltip: { 4 trigger: ‘item‘, 5 formatter: "{a} <br/>{b} : {c} ({d}%)" 6 }, 7 8 series: [{ 9 name: ‘访问来源‘, 10 type: ‘pie‘, 11 radius: ‘55%‘, 12 center: [‘50%‘, ‘60%‘], 13 data: [ 14 { value: 335, name: ‘直接访问‘ }, 15 { value: 310, name: ‘邮件营销‘ }, 16 { value: 234, name: ‘联盟广告‘ }, 17 { value: 135, name: ‘视频广告‘ }, 18 { value: 1548, name: ‘搜索引擎‘ } 19 ], 20 itemStyle: { 21 emphasis: { 22 shadowBlur: 10, 23 shadowOffsetX: 0, 24 shadowColor: ‘rgba(0, 0, 0, 0.5)‘ 25 } 26 } 27 }] 28 }; 29 //模块引入 30 var node_echarts = require(‘node-echarts‘); 31 var path = require(‘path‘); 32 33 node_echarts({ 34 width: 500, // Image width, type is number. 35 height: 500, // Image height, type is number. 36 option: option, // Echarts configuration, type is Object. 37 //If the path is not set, return the Buffer of image. 38 path: path.join(__dirname, ‘../data/image1.png‘), // Path is filepath of the image which will be created. 39 enableAutoDispose: true //Enable auto-dispose echarts after the image is created. 40 })
以上是关于node后台生成echarts图表的主要内容,如果未能解决你的问题,请参考以下文章
vue2+echarts:使用后台传输的json数据去动态渲染echarts图表
前端Vue+Element UI案例:通用后台管理系统-Echarts图表:折线图柱状图饼状图