282 lines
6.6 KiB
Vue
282 lines
6.6 KiB
Vue
|
<template>
|
||
|
<view class="content-box">
|
||
|
<view class="content d-e-c">
|
||
|
<picker :range="monthList" @change="changeMonth">
|
||
|
<view class="picker-small">
|
||
|
<text>{{monthIndex+1}}{{$t('ENU_SETTLE_P_3')}}</text>
|
||
|
<u-icon name="arrow-down-fill" size="28rpx" color="#333"></u-icon>
|
||
|
</view>
|
||
|
</picker>
|
||
|
</view>
|
||
|
|
||
|
<view class="d-c d-c-c ">
|
||
|
<canvas canvas-id="etgpRPnElDWyuZKiOQsRDExvUInxSCkZ" id="etgpRPnElDWyuZKiOQsRDExvUInxSCkZ" class="charts"
|
||
|
:style="'height: '+cHeight+'px;'" @touchend="tap" />
|
||
|
</view>
|
||
|
</view>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
import uCharts from '@/uni_modules/qiun-data-charts/js_sdk/u-charts/u-charts.js';
|
||
|
var uChartsInstance = {};
|
||
|
export default {
|
||
|
data() {
|
||
|
return {
|
||
|
now: 0,
|
||
|
monthList: [],
|
||
|
monthIndex: 0,
|
||
|
cWidth: 750,
|
||
|
cHeight: 700
|
||
|
};
|
||
|
},
|
||
|
onReady() {
|
||
|
this.initDate();
|
||
|
|
||
|
//这里的 750 对应 css .charts 的 width
|
||
|
//这里的 500 对应 css .charts 的 height
|
||
|
this.cWidth = uni.upx2px(750);
|
||
|
// this.cHeight = uni.upx2px(700);
|
||
|
// this.getServerData();
|
||
|
},
|
||
|
methods: {
|
||
|
changeMonth(e) {
|
||
|
this.monthIndex = e.detail.value;
|
||
|
this.getServerData();
|
||
|
},
|
||
|
initDate() {
|
||
|
let date = new Date();
|
||
|
let self = this;
|
||
|
self.now = date.getMonth();
|
||
|
for (var i = 1; i <= self.now + 1; i++) {
|
||
|
self.monthList.push(i+self.$t('ENU_SETTLE_P_3'));
|
||
|
}
|
||
|
this.monthIndex = self.now;
|
||
|
this.getServerData();
|
||
|
console.log(self.monthList)
|
||
|
},
|
||
|
getServerData() {
|
||
|
let self = this;
|
||
|
self._get('member/api/achieve/new-add-achieve-contrast', {
|
||
|
month: self.monthIndex + 1
|
||
|
}, res => {
|
||
|
let list = res.data;
|
||
|
let obj = {
|
||
|
categories: [],
|
||
|
series: [{
|
||
|
data: [],
|
||
|
name: self.$t('S_C_18')
|
||
|
},
|
||
|
{
|
||
|
data: [],
|
||
|
name: self.$t('S_C_19')
|
||
|
},
|
||
|
]
|
||
|
}
|
||
|
if (list && list.length > 0) {
|
||
|
list.forEach((item, index) => {
|
||
|
obj.categories.push(item.date);
|
||
|
obj.series[0].data.push(self.formatNum(item.anewPv*1)*1);
|
||
|
obj.series[1].data.push(self.formatNum(item.bnewPv*1)*1);
|
||
|
// obj.series[0].data.push(item.anewPv*1);
|
||
|
// obj.series[1].data.push(item.bnewPv*1);
|
||
|
})
|
||
|
}
|
||
|
self.cHeight = uni.upx2px(120 * obj.categories.length + 200);
|
||
|
self.chartsDataColumn = JSON.parse(JSON.stringify(obj));
|
||
|
self.drawCharts('etgpRPnElDWyuZKiOQsRDExvUInxSCkZ', self.chartsDataColumn);
|
||
|
})
|
||
|
},
|
||
|
drawCharts(id, data) {
|
||
|
const ctx = uni.createCanvasContext(id, this);
|
||
|
uChartsInstance[id] = new uCharts({
|
||
|
type: "bar",
|
||
|
context: ctx,
|
||
|
width: this.cWidth,
|
||
|
height: this.cHeight,
|
||
|
categories: data.categories,
|
||
|
series: data.series,
|
||
|
animation: true,
|
||
|
timing: "easeOut",
|
||
|
duration: 1000,
|
||
|
rotate: false,
|
||
|
rotateLock: false,
|
||
|
background: "#FFFFFF",
|
||
|
color: ["#fe4c4b", "#feb036", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4",
|
||
|
"#ea7ccc"
|
||
|
],
|
||
|
padding: [15, 30, 0, 5],
|
||
|
fontSize: 13,
|
||
|
fontColor: "#666666",
|
||
|
dataLabel: false,
|
||
|
dataPointShape: true,
|
||
|
dataPointShapeType: "solid",
|
||
|
touchMoveLimit: 60,
|
||
|
enableScroll: false,
|
||
|
enableMarkLine: false,
|
||
|
legend: {
|
||
|
show: true,
|
||
|
position: "top",
|
||
|
float: "center",
|
||
|
padding: 5,
|
||
|
margin: 5,
|
||
|
backgroundColor: "rgba(0,0,0,0)",
|
||
|
borderColor: "rgba(0,0,0,0)",
|
||
|
borderWidth: 0,
|
||
|
fontSize: 13,
|
||
|
fontColor: "#666666",
|
||
|
lineHeight: 11,
|
||
|
hiddenColor: "#CECECE",
|
||
|
itemGap: 10
|
||
|
},
|
||
|
xAxis: {
|
||
|
boundaryGap: "center",
|
||
|
disableGrid: false,
|
||
|
min: 0,
|
||
|
axisLine: false,
|
||
|
disabled: false,
|
||
|
axisLineColor: "#CCCCCC",
|
||
|
calibration: false,
|
||
|
fontColor: "#666666",
|
||
|
fontSize: 9,
|
||
|
lineHeight: 20,
|
||
|
marginTop: 0,
|
||
|
rotateLabel: false,
|
||
|
rotateAngle: 45,
|
||
|
itemCount: 5,
|
||
|
splitNumber: 5,
|
||
|
gridColor: "#CCCCCC",
|
||
|
gridType: "solid",
|
||
|
dashLength: 4,
|
||
|
gridEval: 1,
|
||
|
scrollShow: false,
|
||
|
scrollAlign: "left",
|
||
|
scrollColor: "#A6A6A6",
|
||
|
scrollBackgroundColor: "#EFEBEF",
|
||
|
title: this.$t('S_C_72'),
|
||
|
titleFontSize: 9,
|
||
|
titleOffsetY: 0,
|
||
|
titleOffsetX: 0,
|
||
|
titleFontColor: "#666666",
|
||
|
formatter: ""
|
||
|
},
|
||
|
yAxis: {
|
||
|
disabled: false,
|
||
|
disableGrid: false,
|
||
|
splitNumber: 5,
|
||
|
gridType: "solid",
|
||
|
dashLength: 8,
|
||
|
gridColor: "#CCCCCC",
|
||
|
padding: 10,
|
||
|
showTitle: false,
|
||
|
data: [{
|
||
|
type: "categories",
|
||
|
position: "left",
|
||
|
disabled: false,
|
||
|
axisLine: true,
|
||
|
axisLineColor: "#CCCCCC",
|
||
|
calibration: false,
|
||
|
fontColor: "#666666",
|
||
|
fontSize: 9,
|
||
|
textAlign: "right",
|
||
|
title: "",
|
||
|
titleFontSize: 11,
|
||
|
titleOffsetY: 0,
|
||
|
titleOffsetX: 0,
|
||
|
titleFontColor: "#666666",
|
||
|
min: null,
|
||
|
max: null,
|
||
|
tofix: null,
|
||
|
unit: "",
|
||
|
formatter: ""
|
||
|
}]
|
||
|
},
|
||
|
extra: {
|
||
|
bar: {
|
||
|
type: "group",
|
||
|
width: 60,
|
||
|
meterBorde: 1,
|
||
|
meterFillColor: "#FFFFFF",
|
||
|
activeBgColor: "#000000",
|
||
|
activeBgOpacity: 0.08,
|
||
|
seriesGap: 4,
|
||
|
categoryGap: 10,
|
||
|
barBorderCircle: false,
|
||
|
linearType: "none",
|
||
|
linearOpacity: 1,
|
||
|
colorStop: 0,
|
||
|
barBorderRadius: [25, 25, 0, 0]
|
||
|
},
|
||
|
tooltip: {
|
||
|
showBox: true,
|
||
|
showArrow: true,
|
||
|
showCategory: false,
|
||
|
borderWidth: 0,
|
||
|
borderRadius: 0,
|
||
|
borderColor: "#000000",
|
||
|
borderOpacity: 0.7,
|
||
|
bgColor: "#000000",
|
||
|
bgOpacity: 0.7,
|
||
|
gridType: "solid",
|
||
|
dashLength: 4,
|
||
|
gridColor: "#CCCCCC",
|
||
|
boxPadding: 3,
|
||
|
fontSize: 13,
|
||
|
lineHeight: 20,
|
||
|
fontColor: "#FFFFFF",
|
||
|
legendShow: true,
|
||
|
legendShape: "auto",
|
||
|
splitLine: true,
|
||
|
horizentalLine: false,
|
||
|
xAxisLabel: false,
|
||
|
yAxisLabel: false,
|
||
|
labelBgColor: "#FFFFFF",
|
||
|
labelBgOpacity: 0.7,
|
||
|
labelFontColor: "#666666"
|
||
|
},
|
||
|
markLine: {
|
||
|
type: "solid",
|
||
|
dashLength: 4,
|
||
|
data: []
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
},
|
||
|
tap(e) {
|
||
|
uChartsInstance[e.target.id].touchLegend(e);
|
||
|
uChartsInstance[e.target.id].showToolTip(e);
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
</script>
|
||
|
|
||
|
<style scoped>
|
||
|
page {
|
||
|
background-color: #fff;
|
||
|
}
|
||
|
.content-box{
|
||
|
background-color: #ffffff;
|
||
|
min-height: 100vh;
|
||
|
}
|
||
|
.content {
|
||
|
padding: 26rpx 22rpx 26rpx 23rpx;
|
||
|
}
|
||
|
|
||
|
.picker-small {
|
||
|
width: 232rpx;
|
||
|
height: 72rpx;
|
||
|
border: 1rpx solid #EEEEEE;
|
||
|
border-radius: 15rpx;
|
||
|
font-size: 28rpx;
|
||
|
padding: 0 28rpx 0 20rpx;
|
||
|
display: flex;
|
||
|
justify-content: space-between;
|
||
|
align-items: center;
|
||
|
box-sizing: border-box;
|
||
|
|
||
|
}
|
||
|
|
||
|
.charts {
|
||
|
width: 750rpx;
|
||
|
height: 500rpx;
|
||
|
}
|
||
|
</style>
|