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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
| <template>
| <div style="width: 100%">
| <el-card class="box-card">
| <div slot="header" class="clearfix">
| <span class="font-18 font-bold">资产增长/报废统计图(数量)</span>
| </div>
| <div id="ZCZZ" />
| </el-card>
| </div>
| </template>
| <script>
| import {getGoodsNumByMonth} from '@/api/dashboard'
| import * as echarts from 'echarts';
|
| export default {
| name: 'XYZC',
| props: {
| activeId: {
| type: String,
| default: '',
| },
| },
| data() {
| return {
| myChart: null,
| options: {},
| };
| },
| mounted() {
| this.getCenterLine();
| },
| methods: {
| getCenterLine() {
| var chartDom = document.getElementById('ZCZZ');
| this.myChart = echarts.init(chartDom);
| window.addEventListener('resize', () => {
| this.changeWidth();
| });
| this.options = {
| color: ['#5BE1FD', '#FFD15C'],
| tooltip: {
| trigger: 'axis',
| axisPointer: {
| type: 'shadow',
| },
| },
| legend: {
| data: ['资产增长', '资产报废'],
| },
| toolbox: {
| show: false
| },
| grid: {
| left: '30',
| right: '30',
| bottom: '30px'
| },
| xAxis: [
| {
| type: 'category',
| axisTick: { show: false },
| data: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
| },
| ],
| yAxis: [
| {
| type: 'value',
| },
| ],
| series: [
| {
| name: '资产增长',
| type: 'line',
| barGap: 0,
| smooth: true,
| emphasis: {
| focus: 'series',
| },
| data: [],
| lineStyle: {
| width: 2, // 外边线宽度
| color: '#5BE1FD'// 外边线颜色
| },
| areaStyle: {// 区域填充渐变颜色
| color: {
| type: 'linear',
| x: 0,
| y: 0,
| x2: 0,
| y2: 1,
| colorStops: [{
| offset: 0, color: 'rgba(91, 225, 253, .6)' // 0% 处的颜色
| }, {
| offset: 1, color: 'rgba(91, 225, 253, 0)' // 100% 处的颜色
| }],
| global: false // 缺省为 false
| }
| }
| },
| {
| name: '资产报废',
| type: 'line',
| smooth: true,
| emphasis: {
| focus: 'series',
| },
| data: [],
| lineStyle: {
| width: 2, // 外边线宽度
| color: '#FFD15C'// 外边线颜色
| },
| areaStyle: {// 区域填充渐变颜色
| color: {
| type: 'linear',
| x: 0,
| y: 0,
| x2: 0,
| y2: 1,
| colorStops: [{
| offset: 0, color: 'rgba(255, 209, 92, .6)' // 0% 处的颜色
| }, {
| offset: 1, color: 'rgba(255, 209, 92, 0)' // 100% 处的颜色
| }],
| global: false // 缺省为 false
| }
| }
| },
| ],
| };
| this.options && this.myChart.setOption(this.options);
| getGoodsNumByMonth().then(res=>{
| let xAxis0 = []
| let xAxis1 = []
| res.map(item=>{
| xAxis0.push(item.addTotalNum)
| xAxis1.push(item.reduceTotalNum)
| })
| this.options.series[0].data = xAxis0
| this.options.series[1].data = xAxis1
| this.myChart.setOption(this.options);
| })
| },
| changeWidth() {
| this.myChart.resize();
| },
| },
| };
| </script>
| <style lang="scss" scoped>
| #ZCZZ {
| width: 100%;
| height: 400px;
| }
|
| .box-card {
| margin-top: 10px;
| width: 100%;
| border-radius: 10px;
| border: none;
| .card-title-right {
| display: flex;
| align-items: center;
| align-self: flex-end;
| float: right;
| }
| }
| </style>
|
|