<!--扇形图-->
<view class="shanxing">
<view class="sx" style="transform: rotate({{satisfactionDegInfo.percentDeg}}deg)"/>
</view>
.shanxing {
position: relative;
width: 40rpx;
height: 40rpx;
margin-right: 16rpx;
border-radius: 50%;
background-color: #F8B8C9;
background-image: linear-gradient(to left, transparent 50%, #fcd8e1 0);
.sx {
position: absolute;
width: 40rpx;
height: 40rpx;
border-radius: 50%;
background-color: #F8B8C9;
clip: rect(0, 20rpx, 40rpx, 0); /*clip用来绘制半圆,rect范围内的内容显示出来,clip必须是absolute*/
}
}
let satisfactionDegInfo = {};
if (data.satisfactionDegree && data.satisfaction) {
// 计算百分比
let percent = parseInt(data.satisfaction, 10) || 0;
if (percent >= 90) {
satisfactionDegInfo.title = data.satisfactionDegree;
let deg = -3.6 * (100 - percent); // 一个%占3.6度;
// 0是100% && 限制最小角度,角度太小android绘制扇形有点问题
if (deg != 0 && deg > -10) {
deg = -10;
}
satisfactionDegInfo.percentDeg = deg; // 一个%占3.6度
}
}
网友评论