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
71
| <template>
| <div ref="chartBox"></div>
| </template>
|
| <script>
| import { findRegOrLoginInfo } from '@/api/dataAnalysis'
| import { echartsEnlarge } from '@/utils/echartsEnlarge'
|
| export default {
| props: {
| chartData: {
| type: Object,
| default: function () {
| return {}
| }
| }
| },
| watch: {
| chartData: {
| handler (newValue, oldValue) {
| this.$nextTick(() => {
| this.findRegOrLoginInfo(this.chartData)
| })
| },
| deep: true, // true 深度监听
| immediate: true
| }
| },
| methods: {
| // 查询登录注册人数
| async findRegOrLoginInfo (item) {
| const myChart = this.$echarts.init(this.$refs.chartBox)
| myChart.showLoading()
| try {
| const res = await findRegOrLoginInfo({
| type: '2',
| timeType: item.timeType,
| startTime: item.time[0],
| endTime: item.time[1]
| })
| if (res.code === '0') {
| myChart.setOption(item.option)
| const dataAxis = res.data.map(item => { return item.time })
| const data = res.data.map(item => { return item.num })
| myChart.setOption({ // 加载数据图表
| series: [{
| data
| }],
| xAxis: {
| data: dataAxis
| }
| })
| myChart.hideLoading()
| window.addEventListener('resize', () => {
| myChart.resize()
| })
| echartsEnlarge(myChart, dataAxis, data) // 用户单击条形图时启用数据缩放
| } else {
| myChart.hideLoading()
| }
| } catch (error) {
| myChart.hideLoading()
| }
| }
| }
| }
| </script>
|
| <style>
|
| </style>
|
|