尝试使用wx-charts来使用图表显示各类数据,主要留意<canvas></canvas>中的id写法不是id="ringCanvas",而是canvas-id="ringCanvas"。
参考博客:https://blog.csdn.net/m0_37805167/article/details/75160063
wxcharts.js下载地址:https://github.com/xiaolin3303/wx-charts
1 ?<canvas canvas-id="ringCanvas" style="text-align:center;height:300px;width:375px;"></canvas> 2 ?3 <script> 4 import wxCharts from ‘.../utils/wxcharts‘ 5 ... 6 methods:{ 7 charts() { 8 ????????????new wxCharts({ 9 ????????????????animation: true,10 ????????????????canvasId: ‘ringCanvas‘,11 ????????????????type: ‘ring‘,12 ????????????????extra: {13 ????????????????????ringWidth: 15,14 ????????????????????pie: {15 ????????????????????????offsetAngle: -9016 ????????????????????},17 ????????????????},18 ????????????????subtitle: {19 ????????????????????fontSide: 1620 ????????????????},21 ????????????????series: [{22 ????????????????????name: ‘成交量1‘,23 ????????????????????data: 15,24 ????????????????????stroke:false25 ????????????????}, {26 ????????????????????name: ‘成交量2‘,27 ????????????????????data: 35,28 ????????????????}, {29 ????????????????????name: ‘成交量3‘,30 ????????????????????data: 78,31 ????????????????}],32 ????????????????width: 375,33 ????????????????height: 200,34 ????????????????dataLabel: false,35 ????????????});36 ????????}37 },38 ansyc onShow(){39 ????this.charts();}40 </script>
效果:
参数说明
数据列表每项结构定义
|
mpvue使用wxcharts.js显示各类图表
原文地址:https://www.cnblogs.com/wilsunson/p/9441850.html