park_easy.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <template>
  2. <div>
  3. <div style="color: #d5d3d3" class="middle-map">
  4. <div align="center" style="color: #3498db;font-size: 23px;margin-bottom: 20px">停车难易指数</div>
  5. <el-select clearable v-model="value" filterable remote reserve-keyword placeholder="请选择时段">
  6. <el-option
  7. v-for="item in options"
  8. :key="item.value"
  9. :label="item.label"
  10. :value="item.value">
  11. </el-option>
  12. </el-select>
  13. <div style="height: 450px">
  14. <div class="bottom" id="map"></div>
  15. </div>
  16. </div>
  17. <div class="body-wrapper" style="height: 300px">
  18. <div align="center" style="color: #3498db;font-size: 23px;margin-bottom: 20px">停车难易指数变化趋势</div>
  19. <linechart
  20. :autoStop="false"
  21. :top="30"
  22. :bottom="30"
  23. :left="40"
  24. :legendTop="0"
  25. :dataset="linedata"
  26. :tooltipFormat="lineTooltipFormat"
  27. :encode="[
  28. { x: 'mouth', y: 'lastAmount', seriesName: '难易指数',bool:'true' },
  29. ]"
  30. id="sxcyfzqk"
  31. />
  32. </div>
  33. </div>
  34. </template>
  35. <script>
  36. import * as echarts from 'echarts'
  37. import * as geoJson from '../../../util/411100.json'
  38. import linechart from "@/components/lineChart";
  39. import api from '@/api/audit'
  40. export default {
  41. components: {
  42. linechart,
  43. },
  44. data() {
  45. return {
  46. linedata: [],
  47. options: [{
  48. value: '日间时段',
  49. label: '日间时段'
  50. }, {
  51. value: '夜间时段',
  52. label: '夜间时段'
  53. }],
  54. value: '',
  55. dqIndex: -1,
  56. timer: null,
  57. option: {
  58. visualMap: {
  59. show: true,
  60. type: "continuous",
  61. left: "0%",
  62. bottom: "0%",
  63. calculable: true,
  64. textStyle: {
  65. color: "white",
  66. },
  67. text: ["(%)"],
  68. min: 0,
  69. max: 100,
  70. inRange: {
  71. color: ["#4FC9FB","#36ADFC","#1788D1","#0E6BAE","#1871A2","#0D4D7D"],
  72. },
  73. },
  74. geo: {
  75. map: "luohe",
  76. // aspectScale: 1,
  77. roam: false,
  78. itemStyle: {
  79. normal: {
  80. borderColor: "#2ab8ff",
  81. borderWidth: 2.5,
  82. areaColor: "#12235c",
  83. },
  84. emphasis: {
  85. areaColor: "#2AB8FF",
  86. shadowColor: "rgba(42,184,255, 0.7)",
  87. shadowOffsetY: 5,
  88. shadowOffsetX: 5,
  89. shadowBlur: 5,
  90. },
  91. },
  92. },
  93. tooltip: {
  94. confine: true,
  95. formatter: this.mapTooltip,
  96. position: "inside",
  97. backgroundColor: "transparent",
  98. },
  99. series: [
  100. {
  101. type: "map",
  102. // roam: true,
  103. label: {
  104. normal: {
  105. textStyle: {
  106. color: "#fff",
  107. },
  108. },
  109. emphasis: {
  110. show: false,
  111. textStyle: {
  112. color: "#fff",
  113. },
  114. },
  115. },
  116. itemStyle: {
  117. normal: {
  118. borderColor: "#76bef5",
  119. borderWidth: 1.5,
  120. areaColor: "#4282de",
  121. },
  122. emphasis: {
  123. areaColor: "#002aff",
  124. borderWidth: 0,
  125. color: "green",
  126. },
  127. },
  128. roam: false,
  129. map: "luohe", //使用
  130. data: [],
  131. },
  132. ],
  133. },
  134. };
  135. },
  136. mounted() {
  137. this.zxt()
  138. api.dtnyzs().then(res => {
  139. let arr = []
  140. let dataSoure = res.data
  141. for (const key in dataSoure) {
  142. if (key !== 411100) {
  143. arr.push({
  144. name: dataSoure[key].quyuName,
  145. value: Number(dataSoure[key].zb),
  146. });
  147. }
  148. }
  149. let mapMax = Math.max(...arr.map(item => item.value))
  150. let mapMin = Math.min(...arr.map(item => item.value))
  151. let chart = echarts.init(document.getElementById("map"));
  152. echarts.registerMap("luohe", geoJson);
  153. this.option.series[0].data = arr;
  154. this.option.visualMap.min = mapMin;
  155. this.option.visualMap.max = mapMax;
  156. chart.setOption(this.option);
  157. this.dqIndex = -1;
  158. this.setIntervalMap(chart);
  159. //鼠标移入静止播放
  160. chart.on("mouseover", (e) => {
  161. clearInterval(this.timer);
  162. chart.dispatchAction({
  163. type: "showTip",
  164. seriesIndex: 0,
  165. dataIndex: e.dataIndex,
  166. });
  167. });
  168. chart.on("mouseout", (e) => {
  169. clearInterval(this.timer);
  170. //鼠标移出后先把上次的高亮取消
  171. chart.dispatchAction({
  172. type: "downplay",
  173. seriesIndex: 0,
  174. dataIndex: e.dataIndex,
  175. });
  176. this.setIntervalMap(chart);
  177. });
  178. })
  179. },
  180. methods: {
  181. zxt() {
  182. api.zxt().then(res => {
  183. this.linedata = res.data || []
  184. })
  185. },
  186. lineTooltipFormat(params) {
  187. const data = params[0].data;
  188. return `<div class="line-tooltip">
  189. <div style="color: ${params[0].color}">${params[0].seriesName}: ${
  190. params[0].data.lastAmount || "--"
  191. }</div>
  192. </div>`;
  193. },
  194. setIntervalMap(chart) {
  195. this.timer = setInterval(() => {
  196. chart.dispatchAction({
  197. type: "showTip",
  198. seriesIndex: 0,
  199. dataIndex: this.dqIndex + 1,
  200. });
  201. this.dqIndex++;
  202. if (this.dqIndex > 4) {
  203. this.dqIndex = -1;
  204. }
  205. }, 3000);
  206. },
  207. mapTooltip(data) {
  208. return `<div class="map-tooltip">
  209. <div class="map-tooltip-name">${data.name}:<span class="map-tooltip-value">${data.value}%</span></div>
  210. </div>`;
  211. },
  212. },
  213. };
  214. </script>
  215. <style lang="scss" scoped>
  216. .form-wrapper {
  217. margin-bottom: 20px;
  218. }
  219. /deep/ .el-input__inner {
  220. background: #2d3744;
  221. border: none;
  222. border-radius: 0;
  223. }
  224. /deep/ .el-select {
  225. height: 40px;
  226. .el-input__inner {
  227. height: 40px;
  228. }
  229. .el-input__prefix, .el-input__suffix {
  230. height: 40px;
  231. }
  232. /* 下面设置右侧按钮居中 */
  233. .el-input__suffix {
  234. top: 0px;
  235. display: flex;
  236. justify-content: center;
  237. align-items: center;
  238. flex-wrap: nowrap;
  239. flex-direction: row;
  240. align-content: flex-start;
  241. }
  242. /* 输入框加上上下边是 32px + 2px =34px */
  243. .el-input__icon {
  244. line-height: 0px;
  245. }
  246. }
  247. /deep/ .form-wrapper .el-button {
  248. background: linear-gradient(90deg,#0158d9,#3c97e4);
  249. width: 100px;
  250. height: 40px;
  251. }
  252. .body-wrapper {
  253. width: 100%;
  254. height: 100%;
  255. box-sizing: border-box;
  256. background: #0c0c0c;
  257. }
  258. </style>
  259. <style lang="less" scoped>
  260. .middle-map {
  261. width: 100%;
  262. height: 100%;
  263. .bottom {
  264. height: 90%;
  265. width: 100%;
  266. }
  267. /deep/.map-tooltip {
  268. font-size: 18px;
  269. padding: 10px 20px;
  270. background: url("../../../../static/img/u231.png");
  271. background-size: 100% 100%;
  272. .map-tooltip-name {
  273. color: #00e4ff;
  274. }
  275. .map-tooltip-value {
  276. color: white;
  277. margin-left: 20px;
  278. }
  279. }
  280. }
  281. </style>