parking.vue 6.4 KB

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