fuchengshen
2022-07-09 3a25c05b5ab837714f30469cdcb1e2a77d8d7f6c
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
<template>
  <!-- 图例面板 -->
  <div class="divPanel">
    <img src="/img/legend/heatmap.png" />
  </div>
 
  <!-- 按钮 -->
  <mars-pannel :visible="true" left="10" top="10">
    <mars-button @click="btnUpdate">更新数据</mars-button>
  </mars-pannel>
 
  <!-- echarts图表 -->
  <div class="chart">
    <div class="chartOne">
      <h6>分类统计</h6>
      <ul class="chartList">
        <li :key="item" v-for="item in fltjData">
          <div class="title">{{ item.name }}</div>
          <div class="conter">
            <span>{{ item.xms }}</span
            >个, 投资<span>{{ item.zds }}</span
            >亿,占地<span>{{ item.zjl }}</span
            >亩
          </div>
        </li>
      </ul>
    </div>
    <div class="chartTwo" id="chartTwo">
      <h6>分资金来源统计</h6>
      <div id="ul_ZJLY" class="chartTwo_ulzjly"></div>
    </div>
 
    <div class="chartThree" id="chartThree">
      <h6>分年度统计</h6>
      <button @click="btnNDTJ_xms(chartsData.ndtj)">项目数</button>
      <button @click="btnNDTJ_zds(chartsData.ndtj)">占地数</button>
      <button @click="btnNDTJ_zjl(chartsData.ndtj)">资金量</button>
      <div id="ul_NDTJ" class="chartThree_ulndtj"></div>
    </div>
  </div>
</template>
 
<script setup lang="ts">
import { onMounted, ref } from "vue"
import * as echarts from "echarts"
import * as mapWork from "./map.js"
 
const fltjData = ref([])
let ZJLY
const NDTJ = ref()
 
onMounted(() => {
  ZJLY = document.getElementById("ul_ZJLY")
  NDTJ.value = document.getElementById("ul_NDTJ")
  // 分类统计
  fltjData.value = chartsData.fltj
  // 分资金来源统计
  initCharts_Two(chartsData.zjly, ZJLY)
  // 分年度统计
  initCharts_Three(chartsData.ndtj)
})
const btnUpdate = () => {
  mapWork.btnUpdate()
}
 
const chartsData = {
  fltj: [
    { name: "公共文化", xms: 160, zds: 10, zjl: 645 },
    { name: "公共教育", xms: 848, zds: 580, zjl: 10 },
    { name: "医疗卫生", xms: 370, zds: 10, zjl: 150560 },
    { name: "公共体育", xms: 91, zds: 0, zjl: 182 },
    { name: "社会保障", xms: 233, zds: 10, zjl: 808 },
    { name: "基层公共服务", xms: 20, zds: 10, zjl: 10 }
  ],
  zjly: [
    { name: "省级", value: 88 },
    { name: "市级", value: 127 },
    { name: "区县级", value: 175 },
    { name: "街道级", value: 270 },
    { name: "社会资本", value: 42 }
  ],
  ndtj: {
    xms: [
      { name: "2013", value: 1 },
      { name: "2014", value: 2 },
      { name: "2015", value: 6 },
      { name: "2016", value: 36 },
      { name: "2017", value: 85 },
      { name: "2018", value: 10 },
      { name: "2019年", value: 17 }
    ],
    zds: [
      { name: "2013", value: 10 },
      { name: "2014", value: 20 },
      { name: "2015", value: 30 },
      { name: "2016", value: 40 },
      { name: "2017", value: 50 },
      { name: "2018", value: 60 }
    ],
    zjl: [
      { name: "2013", value: 55600 },
      { name: "2014", value: 95600 },
      { name: "2015", value: 162896 },
      { name: "2016", value: 195761 },
      { name: "2017", value: 87068 },
      { name: "2018", value: 68393 }
    ]
  }
}
 
// chartTwo  Echart圆形  分类资金来源
function initCharts_Two(arr: any, ZJLY: any) {
  const data = []
  for (let i = 0; i < arr.length; i++) {
    const object: any = {}
    object.name = arr[i].name
    object.value = arr[i].value
    data[i] = object
  }
 
  const myChart = echarts.init(ZJLY)
  const option = {
    tooltip: {
      trigger: "item",
      formatter: "{b}<br/>{c}"
    },
    // 图例 的相关设置
    legend: {
      orient: "vertical",
      left: "right",
      textStyle: {
        color: "#ccc"
      }
    },
    // 图形的设置
    series: [
      {
        // name: '访问来源',
        type: "pie",
        radius: "80%",
        right: "20%",
        // 图形上文本标签的样式设置
        label: {
          show: false
        },
        color: [
          "#37A2DA",
          "#32C5E9",
          "#67E0E3",
          "#9FE6B8",
          "#FFDB5C",
          "#ff9f7f",
          "#fb7293",
          "#E062AE",
          "#E690D1",
          "#e7bcf3",
          "#9d96f5",
          "#8378EA",
          "#96BFFF"
        ],
        center: ["45%", "55%"],
        data: data, // 使用for循环添加
        emphasis: {
          itemStyle: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: "rgba(0, 0, 0, 0.5)"
          }
        }
      }
    ]
  }
  myChart.setOption(option)
 
  window.addEventListener("resize", function () {
    myChart.resize()
  })
}
 
// chartThree   Echart柱状   年度统计
function initCharts_Three(arr: any) {
  histogram(arr.xms, "个")
}
// 分年度统计,按钮事件
function btnNDTJ_xms(arr: any) {
  histogram(arr.xms, "个")
}
function btnNDTJ_zds(arr: any) {
  histogram(arr.zds, "亩")
}
function btnNDTJ_zjl(arr: any) {
  histogram(arr.zjl, "亿")
}
 
// 项目、占地、资金    按钮点击切换
function histogram(arr: any, Word: string) {
  const arrName = []
  const arrValue = []
  for (let i = 0; i < arr.length; i++) {
    arrName[i] = arr[i].name
    arrValue[i] = arr[i].value
  }
 
  const myChart = echarts.init(NDTJ.value)
  const option = {
    // xAxis和yAxis的nameTextStyle不起作用
    // 因此设置了字体的全局样式
    textStyle: {
      color: "#ccc"
    },
    title: {
      text: "单位:" + Word,
      // 全局样式对此不生效,
      textStyle: {
        color: "#ccc"
      }
    },
    // 移入柱子时的阴影
    tooltip: {
      trigger: "axis",
      formatter: "{b}<br/>{c}" + Word,
      axisPointer: {
        type: "shadow"
      }
    },
    grid: {
      left: "5px",
      right: "0",
      bottom: "5px",
      containLabel: true
    },
    xAxis: {
      type: "category",
      data: arrName
    },
    yAxis: {
      type: "value"
    },
    series: [
      {
        // 柱子的相关设置
        itemStyle: {
          color: "rgb(0, 174, 255)"
        },
        barWidth: "20px",
        type: "bar",
        emphasis: {
          focus: "series"
        },
        data: arrValue
      }
    ]
  }
  myChart.setOption(option)
 
  window.addEventListener("resize", function () {
    myChart.resize()
  })
}
</script>
<style scoped lang="less">
.divPanel {
  position: absolute;
  bottom: 40px;
  left: 55px;
}
.divPanel img {
  width: 40px;
  height: 180px;
}
.infoView {
  left: 10px;
  width: 100px;
}
 
/* m10右侧统计图表1 */
.chart {
  position: absolute;
  right: 10px;
  top: 10px;
  height: 100%;
  font-size: 15px;
  border: none;
  color: #ffffff;
  background: none;
}
.chartOne,
.chartTwo,
.chartThree {
  width: 393px;
  height: 30%;
  margin-bottom: 6px;
  position: relative;
  border: 1px solid #17366c;
  background: linear-gradient(to left, #3897cf, #3897cf) left top no-repeat, linear-gradient(to bottom, #3897cf, #3897cf) left top no-repeat,
    linear-gradient(to left, #3897cf, #3897cf) right top no-repeat, linear-gradient(to bottom, #3897cf, #3897cf) right top no-repeat,
    linear-gradient(to left, #3897cf, #3897cf) left bottom no-repeat, linear-gradient(to bottom, #3897cf, #3897cf) left bottom no-repeat,
    linear-gradient(to left, #3897cf, #3897cf) right bottom no-repeat, linear-gradient(to left, #3897cf, #3897cf) right bottom no-repeat;
  background-size: 1px 20px, 20px 1px, 1px 20px, 20px 1px;
  background-color: rgba(0, 0, 0, 0.1);
  overflow-y: scroll;
  h6 {
    color: #ffffff;
  }
}
.chart h6 {
  padding: 4px;
  width: 10px;
  margin-left: 5%;
  float: left;
  margin-top: 3%;
  font-size: 16px;
  line-height: 16px;
  text-align: center;
}
.chartOne h6::before {
  position: absolute;
  top: 10px;
  left: 6%;
  width: 20px;
  height: 2px;
  background: red;
  content: " ";
}
.chartTwo h6::before {
  position: absolute;
  top: 10px;
  left: 6%;
  width: 20px;
  height: 2px;
  background: red;
  content: " ";
}
.chartThree h6::before {
  position: absolute;
  top: 10px;
  left: 6%;
  width: 20px;
  height: 2px;
  background: red;
  content: " ";
}
.chartOne .chartList {
  height: 30%;
  width: 91%;
  float: left;
  margin-top: 15px;
  font-size: 15px;
}
.chartOne .title {
  float: left;
}
.chartOne .conter {
  float: right;
}
.chartOne .title {
  margin-right: 10px;
}
.chartOne .chartList li {
  height: 40px;
  width: 95%;
  margin-left: 23px;
  border-bottom: white 0.5px dashed;
  line-height: 50%;
  padding: 13px;
}
.chartOne .chartList li:hover {
  padding: 10px;
  background-color: rgba(0, 0, 0, 0.4);
}
.chartOne .chartList span {
  color: rgb(0, 174, 255);
}
 
/*chartTwo ul_ZJLY */
.chartTwo_ulzjly,
.chartThree_ulndtj {
  width: 84%;
  height: 90%;
  position: absolute;
  left: 13%;
  bottom: 5px;
}
 
/* chartThree ul_NDTJ */
.chartThree button {
  background: none;
  border: 0.06px solid rgb(0, 174, 255);
  z-index: 1000;
  font-size: 1rem;
}
.chartThree button:nth-child(2) {
  position: absolute;
  top: 10px;
  right: 160px;
}
.chartThree button:nth-child(3) {
  position: absolute;
  top: 10px;
  right: 90px;
}
.chartThree button:nth-child(4) {
  position: absolute;
  top: 10px;
  right: 15px;
  margin-right: 5px;
}
 
.chartThree button:active {
  background-color: rgb(19, 166, 224);
}
.chartThree button:visited {
  background-color: rgb(19, 166, 224);
}
</style>