LineChart.vue
2.42 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<!--
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2022-10-25 10:43:46
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2022-10-28 14:53:22
* @FilePath: \dj-data-view\src\components\barChart.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
<div class="line-box">
<div :id="domId" class="line-chart" :style="{ height: boxHeight }"></div>
</div>
</template>
<script>
import datas from '@/utils/data'
import * as echarts from 'echarts'
import { getLineOptions } from './options'
export default {
name: 'lineChart',
props: {
domId: {
type: String,
default: 'line-chart'
},
revese: {
type: Boolean,
default: false
},
boxHeight: {
type: String,
default: '12.83vh'
},
storeOrBrandTxt: {
type: String,
default: '品牌'
},
privateList: {
type: [Object, Array],
default: () => {}
},
// 0-月表;1-日表
queryType: {
type: Number,
default: 0
},
tooltipFormatterObj: {
type: Array,
default: () => {
return [
{
label: '数量',
attrName: 'num'
},
{
label: '环比',
attrName: 'hrate',
addSymbol: '%'
},
{
label: '同比',
attrName: 'trate',
addSymbol: '%'
}
]
}
}
},
data() {
return {
directionTimer: datas.DefaultData.directionTimer,
delayTimer: datas.DefaultData.delayTimer,
rankFlag: 'top',
lineOptions: [],
rankList: [],
echartsLine: '',
moveAttr: {
// speed: 900,
seriesIndex: 0,
dataIndex: 0
},
timer: null
}
},
watch: {
privateList: {
handler() {
this.lineOptions = getLineOptions(this.privateList)
this.chartBindEvent()
},
deep: true
}
},
mounted() {
this.lineDom = document.getElementById(this.domId)
this[this.domId] = echarts.init(this.lineDom)
},
methods: {
chartBindEvent() {
this[this.domId].setOption(this.lineOptions)
}
}
}
</script>
<style lang="scss" scoped>
.line-box {
height: 100%;
color: #ffffff;
.txt-orange {
color: #eb6001;
}
.line-chart {
width: 100%;
}
}
</style>