1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
| <template>
| <div class="install" ref="chartBox"></div>
| </template>
|
| <script>
| import { findInstallInfo } from '@/api/dataAnalysis'
|
| export default {
| props: {
| chartData: {
| type: Object,
| default: function () {
| return {}
| }
| }
| },
| watch: {
| chartData: {
| handler (newValue, oldValue) {
| this.$nextTick(() => {
| this.findInstallInfo(this.chartData)
| })
| },
| deep: true, // true 深度监听
| immediate: true
| }
| },
| methods: {
| // 查询安装次数
| async findInstallInfo (item) {
| const myChart = this.$echarts.init(this.$refs.chartBox)
| myChart.showLoading()
| try {
| const res = await findInstallInfo({
| startTime: item.time[0],
| endTime: item.time[1]
| })
| if (res.code === '0') {
| myChart.setOption(item.option)
| myChart.setOption({ // 加载数据图表
| series: [{
| data: res.data.map(item => {
| return {
| name: item.equipment,
| value: item.number
| }
| })
| }]
| })
| window.addEventListener('resize', () => {
| myChart.resize()
| })
| myChart.hideLoading()
| } else {
| myChart.hideLoading()
| }
| } catch (error) {
| myChart.hideLoading()
| }
| }
| }
| }
| </script>
|
| <style>
| /* .install{
| width: 100%;
| height: 100%;
| } */
| </style>
|
|