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
|
| <template>
| <div class="echarts-box" id="flowLineChart">
|
| </div>
| </template>
|
| <script>
| export default {
| data() {
| return {
| myChart: null
| }
| },
|
| mounted() {
| let stackBarData = {
| xAxisData: ["4-1", "4-2", "4-3", "4-4", "4-5", "4-6", "4-7"],
| seriesData: ["20", "30", "15", "14", "10", "8", "5", "18"],
| }
| this.$nextTick(() => {
| this.createStackBarChart(stackBarData)
| })
| },
| destroyed() {
|
| },
| methods: {
| createStackBarChart(chartData) {
| if(!this.myChart) {
| this.myChart = this.$echarts.init(
| document.getElementById('flowLineChart')
| );
| }
|
| // 指定图表的配置项和数据
| var option = {
| legend: {
| show: false,
| top: 5,
| itemWidth: 8,
| itemHeight: 8,
| itemGap: 20,
| left: "center",
| textStyle: {
| color: "#B5C5D4",
| fontSize: 14,
| },
| },
| tooltip: {
| trigger: "axis",
| axisPointer: {
| type: "shadow"
| },
| formatter: function (e) {
| if (e.length > 0) {
| var t = "".concat(e[0].name + " <br/>");
| e.forEach((item) => {
| t += item.marker + item.seriesName + ": " + item.value + " <br/>"
| })
| return t
| }
| }
| },
| xAxis: {
| data: chartData.xAxisData,
| name: "",
| axisLine: {
| onZero: true,
| lineStyle: {
| color: "rgba(186, 198, 208, .4)",
| },
| },
| axisTick: {
| show: false,
| },
| axisLabel: {
| interval: 0,
| fontSize: 14,
| color: "#B5C5D4",
| },
| },
| yAxis: {
| name: '数量',
| axisLabel: {
| fontSize: 13,
| color: "#B5C5D4",
| },
| nameTextStyle: {
| fontSize: 14,
| color: "#B5C5D4",
| },
| splitLine: {
| lineStyle: {
| color: ["#344B64"],
| type: "dashed",
| width: 2,
| },
| },
| },
| grid: {
| left: 20,
| right: 15,
| top: 40,
| bottom: 15,
| containLabel: true,
| },
| series: [
| {
| name: "流量",
| type: "line",
| data: chartData.seriesData,
| symbol: 'none',
| lineStyle: {
| color: '#63B7F9'
| }
| }
| ],
| };
|
| this.myChart.setOption(option);
| },
|
| },
| }
| </script>
|
| <style lang="scss" scoped>
| .echarts-box {
| width: 100%;
| height: 220px;
| }
| </style>
|
|