Commit e32737d0 authored by lvtz's avatar lvtz

fix chart

parent b5450b8e
...@@ -54,27 +54,25 @@ Page({ ...@@ -54,27 +54,25 @@ Page({
this.analyzeclasshourGet(1); this.analyzeclasshourGet(1);
this.analyzeclasshourGet(2); this.analyzeclasshourGet(2);
this.analyzeclasscourseGet(); this.analyzeclasscourseGet();
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
const {
chartData,
allcount,
count1,
count2,
count3
} = this.data;
try { try {
var res = wx.getSystemInfoSync(); var res = wx.getSystemInfoSync();
this.data.windowWidth = res.windowWidth; this.data.windowWidth = res.windowWidth;
this.setData({
windowWidth: res.windowWidth
})
} catch (e) { } catch (e) {
console.error('getSystemInfoSync failed!'); console.error('getSystemInfoSync failed!');
} }
}, },
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
...@@ -185,7 +183,6 @@ Page({ ...@@ -185,7 +183,6 @@ Page({
}).then((res)=>{ }).then((res)=>{
const {code, data} = res; const {code, data} = res;
if(code == 200){ if(code == 200){
console.log(data,'data')
this.setData({ this.setData({
classCours:data.list classCours:data.list
}) })
...@@ -236,6 +233,7 @@ Page({ ...@@ -236,6 +233,7 @@ Page({
}); });
}, },
initRingChart(index,data){ initRingChart(index,data){
let canvasWidth = this.data.windowWidth/3 || 125;
this.data.ringChart[index] = new wxCharts({ this.data.ringChart[index] = new wxCharts({
animation: true, animation: true,
canvasId: `ringCanvas${index}`, canvasId: `ringCanvas${index}`,
...@@ -243,31 +241,30 @@ Page({ ...@@ -243,31 +241,30 @@ Page({
extra: { extra: {
ringWidth: 14, ringWidth: 14,
pie: { pie: {
offsetAngle: -90
} }
}, },
title: { title: {
name: `${data.course_time_rate}%`, name: `${(data.course_time_rate*100).toFixed(2)}%`,
color: '#000000', color: '#000000',
fontSize: 12 fontSize: 12
}, },
series: [{ series: [{
name: '成交量1', name: '已完成',
data: data.course_time_rate, data: data.course_time_rate*100,
stroke: false, stroke: false,
color: '#FFB97A', color: '#FFB97A',
}, { }, {
name: '成交量2', name: '除去已完成',
data: 100 - data.course_time_rate, data: 100 - data.course_time_rate*100,
stroke: false, stroke: false,
color: '#FFEBD9', color: '#FFEBD9',
}], }],
disablePieStroke: true, disablePieStroke: true,
width: 140, width: canvasWidth,
height: 140, height: canvasWidth,
dataLabel: false, dataLabel: false,
legend: false, legend: false,
background: '#f5f5f5',
padding: 0 padding: 0
}); });
} }
......
...@@ -28,21 +28,21 @@ ...@@ -28,21 +28,21 @@
<view class="chart-box" wx:if="{{classCours.length>0}}"> <view class="chart-box" wx:if="{{classCours.length>0}}">
<view class="chart-item" wx:if="{{classCours[0]}}"> <view class="chart-item" wx:if="{{classCours[0]}}">
<view class="canvas-box" > <view class="canvas-box" >
<canvas canvas-id="ringCanvas1" class="ringcanvas"></canvas> <canvas canvas-id="ringCanvas1" class="ringcanvas" style="width: {{windowWidth? windowWidth/3: 125}}px;height: {{windowWidth? windowWidth/3: 125}}px;"></canvas>
</view> </view>
<view class="name" >{{classCours[0].title}}</view> <view class="name" >{{classCours[0].title}}</view>
<view class="count" >{{classCours[0].course_time}}课时</view> <view class="count" >{{classCours[0].course_time}}课时</view>
</view> </view>
<view class="chart-item" wx:if="{{classCours[1]}}"> <view class="chart-item" wx:if="{{classCours[1]}}">
<view class="canvas-box" > <view class="canvas-box" >
<canvas canvas-id="ringCanvas2" class="ringcanvas"></canvas> <canvas canvas-id="ringCanvas2" class="ringcanvas" style="width: {{windowWidth? windowWidth/3: 125}}px;height: {{windowWidth? windowWidth/3: 125}}px;"></canvas>
</view> </view>
<view class="name" >{{classCours[1].title}}</view> <view class="name" >{{classCours[1].title}}</view>
<view class="count" >{{classCours[1].course_time}}课时</view> <view class="count" >{{classCours[1].course_time}}课时</view>
</view> </view>
<view class="chart-item" wx:if="{{classCours[2]}}"> <view class="chart-item" wx:if="{{classCours[2]}}">
<view class="canvas-box" > <view class="canvas-box" >
<canvas canvas-id="ringCanvas3" class="ringcanvas"></canvas> <canvas canvas-id="ringCanvas3" class="ringcanvas" style="width: {{windowWidth? windowWidth/3: 125}}px;height: {{windowWidth? windowWidth/3: 125}}px;" ></canvas>
</view> </view>
<view class="name" >{{classCours[2].title}}</view> <view class="name" >{{classCours[2].title}}</view>
<view class="count" >{{classCours[2].course_time}}课时</view> <view class="count" >{{classCours[2].course_time}}课时</view>
......
...@@ -4,10 +4,12 @@ ...@@ -4,10 +4,12 @@
height: 200px; height: 200px;
} }
.ringcanvas{ .ringcanvas{
width:100%; width: 250rpx;
height: 140px; height: 250rpx;
}
.container{
padding-bottom: 120rpx;
} }
.container{}
.column-chart-box{ .column-chart-box{
padding: 0 24rpx; padding: 0 24rpx;
} }
...@@ -93,10 +95,25 @@ ...@@ -93,10 +95,25 @@
.ring-chart-box .chart-box{ .ring-chart-box .chart-box{
display: flex; display: flex;
position: relative; position: relative;
left: -18rpx;
} }
.ring-chart-box .chart-box .chart-item{ .ring-chart-box .chart-box .chart-item{
width: 33%; flex: 1;
overflow: hidden;
max-width: 33.33%;
}
.ring-chart-box .chart-box .chart-item .canvas-box{
position: relative;
}
.ring-chart-box .chart-box .chart-item .canvas-box::after{
content: '';
width: 180rpx;
height: 180rpx;
border: 1px solid rgba(255,185,122,1);
border-radius: 50%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
} }
.ring-chart-box .chart-box .chart-item .name{ .ring-chart-box .chart-box .chart-item .name{
font-size:24rpx; font-size:24rpx;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment