HTML
<view class = "page">
<view style="width:350rpx;height:280rpx;border:1rpx solid #f40;">
<image wx:if="{
{imgUrl}}" src="{
{imgUrl}}" style="width:350rpx;height:280rpx;"></image>
<canvas wx:else canvas-id="annular-pie" ec="{
{pie}}" style="width:350rpx;height:280rpx;"></canvas>
</view>
</view>
JS
Component({
properties: {
setdata: {
type: Object,
value: {
totalItems: 600,
rightItems: [150, 200, 250],
text: ["一级", "二级", "三级"],
color: [
['#308347', '#00D3AC'],
['#F5AE8C', '#FFA600'],
['#FF4C6A', '#D42900']
],
}
}
},
data: {
width: '',
r: 80,
lineWidth: 40,
fontSize: "20"
},
ready: function () {
let that = this;
wx.getSystemInfo({
success: function (res) {
that.setData({
windowWidth: res.windowWidth,
})
}
})
let totalItems = that.data.setdata.totalItems;
let rightItems = that.data.setdata.rightItems;
that.showScoreAnimation(rightItems, totalItems);
},
methods: {
showScoreAnimation: function (rightItems, totalItems) {
let that = this;
let cxt_arc = wx.createCanvasContext('annular-pie', this