line-chart.vue
1.29 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
<template>
<div class="chart-box">
<CutomChart :options="options"/>
</div>
</template>
<script setup lang="ts">
//数据
const props = defineProps(['data','average'])
// 公共设置
const setting = {
symbol: 'circle',
type: 'line',
showSymbol: false,
smooth: true,
}
// 处理后的数据
const seriesData = []
for (const dataKey in props.data) {
seriesData.push({name: dataKey, data: props.data[dataKey], ...setting})
}
const options = {
tooltip: {
trigger: 'axis'
},
legend: {
icon: 'roundRect',
itemWidth: 8,
itemHeight: 8,
bottom: 0
},
grid: {
top: 20,
left: 40,
bottom: 70,
right: 30
},
xAxis: {
type: 'category',
boundaryGap: false,
data: ['00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00'],
axisTick: {
// 轴刻度
show: false,
}
},
yAxis: {
type: 'value'
},
dataZoom: [
{
type: "inside",
},
{
backgroundColor: '#7BCFA3',
height: 10,
opacity: 0,
moveHandleSize: 0
}
],
series: seriesData
}
</script>
<style scoped lang="less">
.chart-box {
width: 100%;
height: 350px;
}
</style>