107 lines
2.7 KiB
Vue
107 lines
2.7 KiB
Vue
<template>
|
|
<div class="timeAnalysis">
|
|
<canvas :style="{width:width+'px'}" class="timeAnalysis" canvas-id="timeAnalysis" id="timeAnalysis"/>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import uCharts from '@/components/u-charts.js';
|
|
var uChartsInstance = {};
|
|
export default {
|
|
name: "timeAnalysis",
|
|
data() {
|
|
return {
|
|
width:0,
|
|
}
|
|
},
|
|
props: {
|
|
data: {
|
|
type: Array,
|
|
default: () => []
|
|
}
|
|
},
|
|
watch: {
|
|
data: {
|
|
handler(value) {
|
|
this.handleCarData(value)
|
|
}
|
|
}
|
|
},
|
|
methods: {
|
|
// 处理传入的数据
|
|
handleCarData(value) {
|
|
let res = {
|
|
series:value
|
|
}
|
|
this.drawCharts('timeAnalysis', res)
|
|
},
|
|
drawCharts(id, data) {
|
|
const ctx = uni.createCanvasContext(id, this);
|
|
let _this = this
|
|
let phoneInfo = uni.getStorageSync('phoneInfo')
|
|
this.width = phoneInfo.screenWidth - 16
|
|
uChartsInstance[id] = new uCharts({
|
|
type: "bubble",
|
|
context: ctx,
|
|
width: _this.width,
|
|
height: 170,
|
|
series: data.series,
|
|
animation: true,
|
|
rotate: false,
|
|
canvas2d: true,
|
|
rotateLock: false,
|
|
background: "#FFFFFF",
|
|
color: ["#CAD0DA", "#1E80FF"],
|
|
padding: [5, 30, 5, 5],
|
|
dataLabel: false,
|
|
enableScroll: false,
|
|
xAxis: {
|
|
disableGrid: true,
|
|
gridType: "dash",
|
|
splitNumber: 6,
|
|
boundaryGap: "justify",
|
|
min: 0,
|
|
max: 24
|
|
},
|
|
yAxis: {
|
|
disabled: false,
|
|
disableGrid: false,
|
|
gridType: "dash",
|
|
splitNumber: 4,
|
|
data: [
|
|
{
|
|
min: 0,
|
|
max: 4
|
|
}
|
|
]
|
|
},
|
|
legend: {
|
|
show: true,
|
|
position: "bottom",
|
|
lineHeight: 25,
|
|
float: 'center'
|
|
|
|
},
|
|
extra: {
|
|
bubble: {
|
|
border: 2,
|
|
opacity: 0.5
|
|
}
|
|
}
|
|
});
|
|
|
|
},
|
|
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
.timeAnalysis{
|
|
width: 100%;
|
|
.timeAnalysis{
|
|
width: 100%;
|
|
margin-top: 12px;
|
|
}
|
|
}
|
|
</style> |