先来看一下效果图
微信小程序里面用canvas画圆心进度条
页面给容器
<view class='weui'>
<canvas class='oneCan' canvas-id='one' ></canvas>
<canvas class='oneCan' canvas-id='two' ></canvas>
</view>
js:
data: {
yuan:{height:110}
},
onLoad: function (options) {
var windowidth = 700;
var colw=windowidth / 3;
this.setData({
yuan:{
height:colw
}
})
this.createCanvas('one',colw /2,'red','第一','80',100);
this.createCanvas('two', colw / 2, 'red', '第一', '50',100);
},
createCanvas:function(id,xy,color,txt,val,total){
var ctx=wx.createCanvasContext(id);
ctx.setLineWidth(8);
ctx.setStrokeStyle('#ffffff');
ctx.setLineCap('round');
ctx.beginPath();
ctx.arc(xy,xy,0.75*xy,0,2*Math.PI,false);