Skip to content

Commit 67c4a3b

Browse files
committed
fix case-sensitive bug
1 parent c339b62 commit 67c4a3b

File tree

1 file changed

+268
-0
lines changed

1 file changed

+268
-0
lines changed

src/components/Charts/mixChart.vue

Lines changed: 268 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,268 @@
1+
<template>
2+
<div :class="className" :id="id" :style="{height:height,width:width}"></div>
3+
</template>
4+
5+
<script>
6+
import echarts from 'echarts';
7+
8+
export default {
9+
props: {
10+
className: {
11+
type: String,
12+
default: 'chart'
13+
},
14+
id: {
15+
type: String,
16+
default: 'chart'
17+
},
18+
width: {
19+
type: String,
20+
default: '200px'
21+
},
22+
height: {
23+
type: String,
24+
default: '200px'
25+
}
26+
},
27+
data() {
28+
return {
29+
chart: null
30+
};
31+
},
32+
mounted() {
33+
this.initChart();
34+
this.chart = null;
35+
},
36+
beforeDestroy() {
37+
if (!this.chart) {
38+
return
39+
}
40+
this.chart.dispose();
41+
this.chart = null;
42+
},
43+
methods: {
44+
initChart() {
45+
this.chart = echarts.init(document.getElementById(this.id));
46+
const xData = (function() {
47+
const data = [];
48+
for (let i = 1; i < 13; i++) {
49+
data.push(i + '月份');
50+
}
51+
return data;
52+
}());
53+
this.chart.setOption({
54+
backgroundColor: '#344b58',
55+
title: {
56+
text: '统计',
57+
x: '4%',
58+
textStyle: {
59+
color: '#fff',
60+
fontSize: '22'
61+
},
62+
subtextStyle: {
63+
color: '#90979c',
64+
fontSize: '16'
65+
}
66+
},
67+
tooltip: {
68+
trigger: 'axis',
69+
axisPointer: {
70+
textStyle: {
71+
color: '#fff'
72+
}
73+
}
74+
},
75+
grid: {
76+
borderWidth: 0,
77+
top: 110,
78+
bottom: 95,
79+
textStyle: {
80+
color: '#fff'
81+
}
82+
},
83+
legend: {
84+
x: '15%',
85+
top: '10%',
86+
textStyle: {
87+
color: '#90979c'
88+
},
89+
data: ['', '', '平均']
90+
},
91+
calculable: true,
92+
xAxis: [{
93+
type: 'category',
94+
axisLine: {
95+
lineStyle: {
96+
color: '#90979c'
97+
}
98+
},
99+
splitLine: {
100+
show: false
101+
},
102+
axisTick: {
103+
show: false
104+
},
105+
splitArea: {
106+
show: false
107+
},
108+
axisLabel: {
109+
interval: 0
110+
111+
},
112+
data: xData
113+
}],
114+
yAxis: [{
115+
type: 'value',
116+
splitLine: {
117+
show: false
118+
},
119+
axisLine: {
120+
lineStyle: {
121+
color: '#90979c'
122+
}
123+
},
124+
axisTick: {
125+
show: false
126+
},
127+
axisLabel: {
128+
interval: 0
129+
},
130+
splitArea: {
131+
show: false
132+
}
133+
}],
134+
dataZoom: [{
135+
show: true,
136+
height: 30,
137+
xAxisIndex: [
138+
0
139+
],
140+
bottom: 30,
141+
start: 10,
142+
end: 80,
143+
handleIcon: 'path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h59.8c2.2,0,4,1.8,4,4V413z',
144+
handleSize: '110%',
145+
handleStyle: {
146+
color: '#d3dee5'
147+
148+
},
149+
textStyle: {
150+
color: '#fff' },
151+
borderColor: '#90979c'
152+
153+
154+
}, {
155+
type: 'inside',
156+
show: true,
157+
height: 15,
158+
start: 1,
159+
end: 35
160+
}],
161+
series: [{
162+
name: '',
163+
type: 'bar',
164+
stack: '总量',
165+
barMaxWidth: 35,
166+
barGap: '10%',
167+
itemStyle: {
168+
normal: {
169+
color: 'rgba(255,144,128,1)',
170+
label: {
171+
show: true,
172+
textStyle: {
173+
color: '#fff'
174+
},
175+
position: 'insideTop',
176+
formatter(p) {
177+
return p.value > 0 ? p.value : '';
178+
}
179+
}
180+
}
181+
},
182+
data: [
183+
709,
184+
1917,
185+
2455,
186+
2610,
187+
1719,
188+
1433,
189+
1544,
190+
3285,
191+
5208,
192+
3372,
193+
2484,
194+
4078
195+
]
196+
},
197+
198+
{
199+
name: '',
200+
type: 'bar',
201+
stack: '总量',
202+
itemStyle: {
203+
normal: {
204+
color: 'rgba(0,191,183,1)',
205+
barBorderRadius: 0,
206+
label: {
207+
show: true,
208+
position: 'top',
209+
formatter(p) {
210+
return p.value > 0 ? p.value : '';
211+
}
212+
}
213+
}
214+
},
215+
data: [
216+
327,
217+
1776,
218+
507,
219+
1200,
220+
800,
221+
482,
222+
204,
223+
1390,
224+
1001,
225+
951,
226+
381,
227+
220
228+
]
229+
}, {
230+
name: '平均',
231+
type: 'line',
232+
stack: '总量',
233+
symbolSize: 10,
234+
symbol: 'circle',
235+
itemStyle: {
236+
normal: {
237+
color: 'rgba(252,230,48,1)',
238+
barBorderRadius: 0,
239+
label: {
240+
show: true,
241+
position: 'top',
242+
formatter(p) {
243+
return p.value > 0 ? p.value : '';
244+
}
245+
}
246+
}
247+
},
248+
data: [
249+
1036,
250+
3693,
251+
2962,
252+
3810,
253+
2519,
254+
1915,
255+
1748,
256+
4675,
257+
6209,
258+
4323,
259+
2865,
260+
4298
261+
]
262+
}
263+
]
264+
})
265+
}
266+
}
267+
}
268+
</script>

0 commit comments

Comments
 (0)