parking.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <template>
  2. <div class="middle-map">
  3. <div class="top">
  4. <div class="title">停车热度时空分布</div>
  5. </div>
  6. <div class="bottom" id="map"></div>
  7. </div>
  8. </template>
  9. <script>
  10. import * as echarts from 'echarts'
  11. import * as geoJson from '../../../util/411100.json'
  12. export default {
  13. data() {
  14. return {
  15. dqIndex: -1,
  16. timer: null,
  17. option: {
  18. visualMap: {
  19. show: true,
  20. type: "continuous",
  21. left: "0%",
  22. bottom: "0%",
  23. calculable: true,
  24. textStyle: {
  25. color: "white",
  26. },
  27. text: ["(辆)"],
  28. min: 0,
  29. max: 100,
  30. inRange: {
  31. color: ["#4FC9FB","#36ADFC","#1788D1","#0E6BAE","#1871A2","#0D4D7D"],
  32. },
  33. },
  34. geo: {
  35. map: "luohe",
  36. // aspectScale: 1,
  37. roam: false,
  38. itemStyle: {
  39. normal: {
  40. borderColor: "#2ab8ff",
  41. borderWidth: 2.5,
  42. areaColor: "#12235c",
  43. },
  44. emphasis: {
  45. areaColor: "#2AB8FF",
  46. shadowColor: "rgba(42,184,255, 0.7)",
  47. shadowOffsetY: 5,
  48. shadowOffsetX: 5,
  49. shadowBlur: 5,
  50. },
  51. },
  52. },
  53. tooltip: {
  54. confine: true,
  55. formatter: this.mapTooltip,
  56. position: "inside",
  57. backgroundColor: "transparent",
  58. },
  59. series: [
  60. {
  61. type: "map",
  62. // roam: true,
  63. label: {
  64. normal: {
  65. textStyle: {
  66. color: "#fff",
  67. },
  68. },
  69. emphasis: {
  70. show: false,
  71. textStyle: {
  72. color: "#fff",
  73. },
  74. },
  75. },
  76. itemStyle: {
  77. normal: {
  78. borderColor: "#76bef5",
  79. borderWidth: 1.5,
  80. areaColor: "#4282de",
  81. },
  82. emphasis: {
  83. areaColor: "#002aff",
  84. borderWidth: 0,
  85. color: "green",
  86. },
  87. },
  88. roam: false,
  89. map: "luohe", //使用
  90. data: [],
  91. },
  92. ],
  93. },
  94. curData: {},
  95. dataSource: null,
  96. totalAll: '0',
  97. };
  98. },
  99. methods: {
  100. setIntervalMap(chart) {
  101. this.timer = setInterval(() => {
  102. chart.dispatchAction({
  103. type: "showTip",
  104. seriesIndex: 0,
  105. dataIndex: this.dqIndex + 1,
  106. });
  107. this.dqIndex++;
  108. if (this.dqIndex > 4) {
  109. this.dqIndex = -1;
  110. }
  111. }, 3000);
  112. },
  113. mapTooltip(data) {
  114. return `<div class="map-tooltip">
  115. <div class="map-tooltip-name">${data.name}:<span class="map-tooltip-value">${data.value}%</span></div>
  116. </div>`;
  117. },
  118. },
  119. mounted() {
  120. let arr = []
  121. let dataSoure = {
  122. '411102': {quyuName: '源汇区', zb: 40},
  123. '411103': {quyuName: '郾城区', zb: 60},
  124. '411104': {quyuName: '召陵区', zb: 40},
  125. '411121': {quyuName: '舞阳县', zb: 50},
  126. '411122': {quyuName: '临颍县', zb: 30}}
  127. for (const key in dataSoure) {
  128. if (key !== '411100') {
  129. arr.push({
  130. name: dataSoure[key].quyuName,
  131. value: Number(dataSoure[key].zb),
  132. });
  133. }
  134. }
  135. let mapMax = Math.max(...arr.map(item => item.value))
  136. let mapMin = Math.min(...arr.map(item => item.value))
  137. let chart = echarts.init(document.getElementById("map"));
  138. echarts.registerMap("luohe", geoJson);
  139. this.option.series[0].data = arr;
  140. this.option.visualMap.min = mapMin;
  141. this.option.visualMap.max = mapMax;
  142. chart.setOption(this.option);
  143. this.dqIndex = -1;
  144. this.setIntervalMap(chart);
  145. //鼠标移入静止播放
  146. chart.on("mouseover", (e) => {
  147. clearInterval(this.timer);
  148. chart.dispatchAction({
  149. type: "showTip",
  150. seriesIndex: 0,
  151. dataIndex: e.dataIndex,
  152. });
  153. });
  154. chart.on("mouseout", (e) => {
  155. clearInterval(this.timer);
  156. //鼠标移出后先把上次的高亮取消
  157. chart.dispatchAction({
  158. type: "downplay",
  159. seriesIndex: 0,
  160. dataIndex: e.dataIndex,
  161. });
  162. this.setIntervalMap(chart);
  163. });
  164. },
  165. };
  166. </script>
  167. <style lang="less" scoped>
  168. .middle-map {
  169. width: 100%;
  170. height: 100%;
  171. .top {
  172. height: 10%;
  173. // padding: 50px 50px 0 50px;
  174. display: flex;
  175. flex-direction: column;
  176. justify-content: space-between;
  177. font-family: "PingFangSC-Semibold", "PingFang SC Semibold", "PingFang SC";
  178. .total-detail {
  179. display: flex;
  180. margin-top: 10px;
  181. align-items: center;
  182. justify-content: center;
  183. .total-value {
  184. font-size: 41px;
  185. }
  186. .total-unit {
  187. margin-left: 20px;
  188. font-size: 20px;
  189. }
  190. }
  191. .title {
  192. font-weight: 650;
  193. font-style: normal;
  194. color: #ffffff;
  195. font-size: 18px;
  196. }
  197. .dq {
  198. font-weight: 650;
  199. color: #ffcc00;
  200. font-size: 24px;
  201. text-align: center;
  202. }
  203. .num-container {
  204. height: 180px;
  205. margin-top: 20px;
  206. display: flex;
  207. justify-content: space-between;
  208. width: 100%;
  209. padding: 0 20px;
  210. .num-item {
  211. display: flex;
  212. flex-direction: column;
  213. justify-content: space-around;
  214. // width: 28%;
  215. .label-box {
  216. display: flex;
  217. align-items: center;
  218. // justify-content: space-between;
  219. .label {
  220. font-weight: 650;
  221. color: #ffcc00;
  222. font-size: 28px;
  223. }
  224. .rate {
  225. margin-left: 30px;
  226. font-weight: 650;
  227. color: #ffcc00;
  228. font-size: 18px;
  229. }
  230. }
  231. .num-box {
  232. display: flex;
  233. justify-content: space-between;
  234. justify-content: left;
  235. font-family: "Arial-BoldMT", "Arial Bold", "Arial";
  236. font-weight: 700;
  237. .money {
  238. color: #fff;
  239. font-size: 22px;
  240. .num {
  241. color: #ffcc00;
  242. }
  243. }
  244. .rate {
  245. color: #008000;
  246. font-size: 32px;
  247. }
  248. }
  249. }
  250. }
  251. }
  252. .bottom {
  253. height: 90%;
  254. width: 100%;
  255. }
  256. /deep/.map-tooltip {
  257. font-size: 18px;
  258. padding: 10px 20px;
  259. background: url("../../../../static/img/u231.png");
  260. background-size: 100% 100%;
  261. .map-tooltip-name {
  262. color: #00e4ff;
  263. }
  264. .map-tooltip-value {
  265. color: white;
  266. margin-left: 20px;
  267. }
  268. }
  269. }
  270. </style>