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
| <template>
|
| <div class="menuBox1">
| <div class="serachContent">
| <el-select v-model="linesName" @change="setEchartChange" placeholder="请选择">
| <el-option v-for="(item, key) in linesOption" :key="key" :label="item.line" :value="item.line">
| </el-option>
| </el-select>
| </div>
| <div class="echartContent">
| <div id="myEchart" class="myChart"> </div>
| </div>
| </div>
| </template>
|
| <script>
| import Popup from '@/components/Tool/Popup.vue';
| import { zhangzitou_selectInfos } from "@/api/mapView/map.js"
| import mapData from '@/assets/js/mapSdk/mapData';
| import * as echarts from 'echarts';
| export default {
| name: 'dataAnalysis',
| components: { Popup },
| data() {
| return {
| title: '数据统计',
| allLines: [],
| linesOption: [],
| linesName: '',
| myChart: null,
| };
| },
| mounted(){
| this.getAllLines();
| },
| methods: {
|
| getAllLines() {
| zhangzitou_selectInfos().then(response => {
| if (response.data.code != 200) {
| return this.close();
| }
| this.setAllLinses(response.data.result)
| })
| },
| setAllLinses(res) {
| this.allLines = res;
| this.linesOption = this.allLines.filter((item, index, self) =>
| index === self.findIndex((t) => t.line === item.line)
| );
| this.linesName = this.linesOption[0].line;
| this.setEchartChange();
| },
| setEchartChange() {
| zhangzitou_selectInfos({
| line: this.linesName
| }).then(response => {
| if (response.data.code != 200) return
| const result = response.data.result;
|
| const objData = []
| result.filter(item => {
| const type = mapData.dataStatistics[item.type];
| if (type) {
| item.type = type
| }
| objData.push({
| value: item.count, name: item.type
| })
| })
| this.setEchartShow(objData)
| })
|
| },
|
| setEchartShow(res) {
|
| let option = {
| title: {
|
| left: 'center'
| },
| tooltip: {
| trigger: 'item'
| },
| legend: {
| orient: 'vertical',
| left: 'left'
| },
| series: [
| {
| name: this.linesName,
| type: 'pie',
| radius: '50%',
| data: res,
| emphasis: {
| itemStyle: {
| shadowBlur: 10,
| shadowOffsetX: 0,
| shadowColor: 'rgba(0, 0, 0, 0.5)'
| }
| }
| }
| ]
| };
| if (!this.myChart) {
|
| this.myChart = echarts.init(document.getElementById("myEchart"));
| }
|
|
| this.myChart.setOption(option);
| window.addEventListener("resize", () => {
| this.myChart.resize();
| });
| },
| },
| };
| </script>
|
| <style lang="scss" scoped>
| .menuBox1 {
| position: relative;
| height: 100%;
| width: calc(100% - 0px);
| padding: 10px;
| display: flex;
| flex-direction: column;
|
| .serachContent {
| display: flex;
| }
|
| .echartContent {
| flex: 1;
|
|
| .myChart {
| margin-top: 10px;
| width: 100%;
| height: calc(100% - 10px);
| }
| }
|
| }
| </style>
|
|