一、wxml
<canvas canvas-id="lineCanvas" disable-scroll="true" class="canvas" hidden='{{canvaShow}}'></canvas>
二、js
var wxCharts = require('../../utils/wxcharts.js');
var seriesArr = [];//数据数组
for (var i = 0; i < Datas.length; i++) {
var objs = new Object();
objs.name = Datas[i].Name;
objs.format = function (val) {
return val.toFixed(2);
}
var dataArr = [];
for (var j = 0; j < Datas[i].ObjChild.length; j++) {
dataArr.push(Datas[i].ObjChild[j].StaffScorePoint);
}
objs.data = dataArr;
seriesArr.push(objs);
}
new wxCharts({
canvasId: 'lineCanvas', // canvas-id
type: 'line', // 图表类型,可选值为pie, line, column, area, ring
categories: ['', '', '', '', ''],
series: seriesArr,
yAxis: {
format: function (val) {
return val.toFixed(2);
},
min: 0 // Y轴起始值
},
width: 300,
height: 160,
legend: true, // 是否显示图表下方各类别的标识
xAxis: {
disableGrid: true
}
});