121 lines
3.5 KiB
Vue
121 lines
3.5 KiB
Vue
<template>
|
|
<div class="businessFormat">
|
|
<canvas v-if="!formatPath" class="format" canvas-id="businessFormat" id="businessFormat"/>
|
|
<image v-if="formatPath" class="format" :src="formatPath"></image>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import uCharts from '@/components/u-charts.js';
|
|
var uChartsInstance = {};
|
|
export default {
|
|
name: "businessFormat",
|
|
data() {
|
|
return {
|
|
width:0,
|
|
formatPath:''
|
|
}
|
|
},
|
|
props: {
|
|
data: {
|
|
type: Object,
|
|
default: () => {}
|
|
}
|
|
},
|
|
watch: {
|
|
data: {
|
|
handler(value) {
|
|
console.log('businessFormat', value)
|
|
this.handleCarData(value)
|
|
}
|
|
}
|
|
},
|
|
methods: {
|
|
// 处理传入的数据
|
|
handleCarData(value) {
|
|
let res = value
|
|
this.drawCharts('businessFormat', res)
|
|
},
|
|
drawCharts(id, data) {
|
|
const ctx = uni.createCanvasContext(id, this);
|
|
let _this = this
|
|
let phoneInfo = uni.getStorageSync('phoneInfo')
|
|
this.width = phoneInfo.screenWidth - 32
|
|
uChartsInstance[id] = new uCharts({
|
|
type: "ring",
|
|
context: ctx,
|
|
width: _this.width,
|
|
height: 250,
|
|
series: data.series,
|
|
animation: true,
|
|
rotate: false,
|
|
rotateLock: false,
|
|
background: "#FFFFFF",
|
|
color: ["#1E80FF", "#456497","#6B85AE","#8095B8","#97A9C6","#ACB9CD","#B8C7DE","#D5DFF0"],
|
|
padding: [5, 5, 5, 5],
|
|
dataLabel: true,
|
|
enableScroll: false,
|
|
title: {
|
|
name: '刚需型',
|
|
fontSize: 16,
|
|
color: "#341D00"
|
|
},
|
|
subtitle: {
|
|
name: "理想业态布局",
|
|
fontSize: 12,
|
|
color: "#786B6C",
|
|
},
|
|
legend: {
|
|
show: true,
|
|
position: "bottom",
|
|
lineHeight: 25,
|
|
float: 'center'
|
|
|
|
},
|
|
extra: {
|
|
ring: {
|
|
ringWidth: 12,
|
|
activeOpacity: 0.5,
|
|
activeRadius: 10,
|
|
offsetAngle: 0,
|
|
labelWidth: 15,
|
|
border: false,
|
|
borderWidth: 3,
|
|
borderColor: "#FFFFFF"
|
|
}
|
|
}
|
|
});
|
|
setTimeout( ()=>{
|
|
this.canvasToTempImage('businessFormat')
|
|
},2000)
|
|
},
|
|
canvasToTempImage(id){
|
|
uni.canvasToTempFilePath({
|
|
canvasId:id,
|
|
complete:(res)=>{
|
|
if (res.tempFilePath){
|
|
uni.getFileSystemManager().readFile({
|
|
filePath: res.tempFilePath,
|
|
encoding: 'base64',
|
|
success: res => {
|
|
let base64 = 'data:image/png;base64,' + res.data;
|
|
this.formatPath = base64
|
|
}
|
|
})
|
|
}
|
|
}
|
|
},this)
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
.businessFormat{
|
|
width: 100%;
|
|
.format{
|
|
width: 100%;
|
|
height: 250px;
|
|
}
|
|
}
|
|
</style> |