当前位置:   article > 正文

大屏可视化(VUE2 + DataV)_vue 大屏可视化

vue 大屏可视化

准备:安装vue脚手架(vue/cli),创建vue2项目,安装dataV,在main.js入口文件中引入dataV。

dataV地址:DataV

一、dataV安装

npm install @jiaminghi/data-view

二、main.js

  1. import Vue from 'vue'
  2. import App from './App.vue'
  3. import router from './router'
  4. import store from './store'
  5. import dataV from '@jiaminghi/data-view'
  6. import '@/assets/css/index.css'
  7. Vue.use(dataV)
  8. Vue.config.productionTip = false
  9. new Vue({
  10. router,
  11. store,
  12. render: h => h(App)
  13. }).$mount('#app')

三、app.vue

  1. <template>
  2. <div id="app">
  3. <router-view/>
  4. </div>
  5. </template>

四、route => index.js

  1. import Vue from 'vue'
  2. import VueRouter from 'vue-router'
  3. Vue.use(VueRouter)
  4. const routes = [
  5. {
  6. path: '/',
  7. name: 'home',
  8. component: () => import('../views/HomeView.vue')
  9. }
  10. ]
  11. const router = new VueRouter({
  12. routes
  13. })
  14. export default router

五、views => HomeView.vue

  1. <template>
  2. <div class="content bg">
  3. <!-- 全屏容器 -->
  4. <dv-full-screen-container>
  5. <!-- 第一行 -->
  6. <div class="module_box" style="height: 10vh;">
  7. <div style="flex: 0 1 30%;">
  8. <dv-decoration-10 style="width:100%;height:50px;" />
  9. </div>
  10. <div style="flex: 0 1 40%;">
  11. <div style="display: flex;width: 100%;">
  12. <dv-decoration-8 style="width:300px;height:50px;flex:1;transform: rotateY(180deg);" />
  13. <dv-decoration-11 style="width:200px;height:60px;flex:1">数据中心</dv-decoration-11>
  14. <dv-decoration-8 style="width:300px;height:50px;flex:1" />
  15. </div>
  16. </div>
  17. <div style="flex: 0 1 30%;">
  18. <dv-decoration-10 style="width: 100%;height:50px;transform: rotateY(180deg);" />
  19. </div>
  20. </div>
  21. <!-- 第二行 -->
  22. <div class="module_box" style="height: 60vh;">
  23. <!-- flex布局 一行四个 各占25% -->
  24. <!-- 左 -->
  25. <div style="flex: 0 1 25%;">
  26. <dv-border-box-13 style="width: 100%;height: 33.33%;">
  27. <dv-capsule-chart :config="config1" style="width:95%;height:95%" />
  28. </dv-border-box-13>
  29. <dv-border-box-1 style="width: 100%;height: 33.33%;">
  30. <dv-water-level-pond :config="config3" style="width:90%;height:86%" />
  31. </dv-border-box-1>
  32. <dv-border-box-2 style="width: 100%;height: 33.33%;">
  33. <dv-conical-column-chart :config="config5" style="width:90%;height:90%;" />
  34. </dv-border-box-2>
  35. </div>
  36. <!-- 中 -->
  37. <div style="flex: 0 1 50%;">
  38. <dv-border-box-12 style="width: 100%;height: 100%">
  39. <dv-flyline-chart-enhanced :config="config4" style="width:95%;height:95%" />
  40. </dv-border-box-12>
  41. </div>
  42. <!-- 右 -->
  43. <div style="flex: 0 1 25%;">
  44. <dv-border-box-1 style="width: 100%;height: 33.33%">
  45. <dv-scroll-board :config="config6" style="width:90%;height:80%" />
  46. </dv-border-box-1>
  47. <dv-border-box-8 style="width: 100%;height: 66.66%">
  48. <dv-capsule-chart :config="config2" style="width:100%;height:90%" />
  49. </dv-border-box-8>
  50. </div>
  51. </div>
  52. <!-- 第三行 -->
  53. <div class="module_box" style="height: 30vh;">
  54. <!-- flex布局 一行四个 各占25% -->
  55. <!-- 左 -->
  56. <div style="flex: 0 1 50%;">
  57. <dv-border-box-8 style="width: 100%;height: 200px;">
  58. <dv-scroll-ranking-board :config="config7" style="width:90%;height:100%" />
  59. </dv-border-box-8>
  60. </div>
  61. <!-- 中 -->
  62. <div style="flex: 0 1 25%;">
  63. <dv-border-box-13 style="width: 100%;height: 200px;">
  64. <dv-active-ring-chart :config="config8" style="width:100%;height:100%" />
  65. </dv-border-box-13>
  66. </div>
  67. <!-- 右 -->
  68. <div style="flex: 0 1 25%;">
  69. <dv-border-box-8 style="width: 100%;height: 200px;">
  70. <dv-charts :option="option" />
  71. </dv-border-box-8>
  72. </div>
  73. </div>
  74. </dv-full-screen-container>
  75. </div>
  76. </template>
  77. <script>
  78. export default {
  79. name: 'HomeView',
  80. data() {
  81. return {
  82. config1: {
  83. data: [
  84. {
  85. name: '南阳',
  86. value: 167
  87. },
  88. {
  89. name: '周口',
  90. value: 67
  91. },
  92. {
  93. name: '漯河',
  94. value: 123
  95. },
  96. {
  97. name: '郑州',
  98. value: 55
  99. },
  100. {
  101. name: '西峡',
  102. value: 98
  103. },
  104. ],
  105. },
  106. config2: {
  107. data: [
  108. {
  109. name: '南阳',
  110. value: 167
  111. },
  112. {
  113. name: '周口',
  114. value: 123
  115. },
  116. {
  117. name: '漯河',
  118. value: 98
  119. },
  120. {
  121. name: '郑州',
  122. value: 75
  123. },
  124. {
  125. name: '西峡',
  126. value: 66
  127. },
  128. ],
  129. colors: ['#e062ae', '#fb7293', '#e690d1', '#32c5e9', '#96bfff'],
  130. unit: '单位',
  131. showValue: true
  132. },
  133. config3: {
  134. data: [66, 45],
  135. shape: 'roundRect'
  136. },
  137. config4: {
  138. points: [
  139. {
  140. name: '郑州',
  141. coordinate: [0.48, 0.35],
  142. halo: {
  143. show: true,
  144. },
  145. icon: {
  146. src: 'http://datav.jiaminghi.com/img/flylineChart/mapCenterPoint.png',
  147. width: 30,
  148. height: 30
  149. },
  150. text: {
  151. show: false
  152. }
  153. },
  154. {
  155. name: '新乡',
  156. coordinate: [0.52, 0.23]
  157. },
  158. {
  159. name: '焦作',
  160. coordinate: [0.43, 0.29]
  161. },
  162. {
  163. name: '开封',
  164. coordinate: [0.59, 0.35]
  165. },
  166. {
  167. name: '许昌',
  168. coordinate: [0.53, 0.47]
  169. },
  170. {
  171. name: '平顶山',
  172. coordinate: [0.45, 0.54]
  173. },
  174. {
  175. name: '洛阳',
  176. coordinate: [0.36, 0.38]
  177. },
  178. {
  179. name: '周口',
  180. coordinate: [0.62, 0.55],
  181. halo: {
  182. show: true,
  183. color: '#8378ea'
  184. }
  185. },
  186. {
  187. name: '漯河',
  188. coordinate: [0.56, 0.56]
  189. },
  190. {
  191. name: '南阳',
  192. coordinate: [0.37, 0.66],
  193. halo: {
  194. show: true,
  195. color: '#37a2da'
  196. }
  197. },
  198. {
  199. name: '信阳',
  200. coordinate: [0.55, 0.81]
  201. },
  202. {
  203. name: '驻马店',
  204. coordinate: [0.55, 0.67]
  205. },
  206. {
  207. name: '济源',
  208. coordinate: [0.37, 0.29]
  209. },
  210. {
  211. name: '三门峡',
  212. coordinate: [0.20, 0.36]
  213. },
  214. {
  215. name: '商丘',
  216. coordinate: [0.76, 0.41]
  217. },
  218. {
  219. name: '鹤壁',
  220. coordinate: [0.59, 0.18]
  221. },
  222. {
  223. name: '濮阳',
  224. coordinate: [0.68, 0.17]
  225. },
  226. {
  227. name: '安阳',
  228. coordinate: [0.59, 0.10]
  229. }
  230. ],
  231. lines: [
  232. {
  233. source: '新乡',
  234. target: '郑州'
  235. },
  236. {
  237. source: '焦作',
  238. target: '郑州'
  239. },
  240. {
  241. source: '开封',
  242. target: '郑州'
  243. },
  244. {
  245. source: '周口',
  246. target: '郑州',
  247. color: '#fb7293',
  248. width: 2
  249. },
  250. {
  251. source: '南阳',
  252. target: '郑州',
  253. color: '#fb7293',
  254. width: 2
  255. },
  256. {
  257. source: '济源',
  258. target: '郑州'
  259. },
  260. {
  261. source: '三门峡',
  262. target: '郑州'
  263. },
  264. {
  265. source: '商丘',
  266. target: '郑州'
  267. },
  268. {
  269. source: '鹤壁',
  270. target: '郑州'
  271. },
  272. {
  273. source: '濮阳',
  274. target: '郑州'
  275. },
  276. {
  277. source: '安阳',
  278. target: '郑州'
  279. },
  280. {
  281. source: '许昌',
  282. target: '南阳',
  283. color: '#37a2da'
  284. },
  285. {
  286. source: '平顶山',
  287. target: '南阳',
  288. color: '#37a2da'
  289. },
  290. {
  291. source: '洛阳',
  292. target: '南阳',
  293. color: '#37a2da'
  294. },
  295. {
  296. source: '驻马店',
  297. target: '周口',
  298. color: '#8378ea'
  299. },
  300. {
  301. source: '信阳',
  302. target: '周口',
  303. color: '#8378ea'
  304. },
  305. {
  306. source: '漯河',
  307. target: '周口',
  308. color: '#8378ea'
  309. }
  310. ],
  311. icon: {
  312. show: true,
  313. src: 'http://datav.jiaminghi.com/img/flylineChart/mapPoint.png'
  314. },
  315. text: {
  316. show: true,
  317. },
  318. k: 0.5,
  319. bgImgSrc: 'http://datav.jiaminghi.com/img/flylineChart/map.jpg'
  320. },
  321. config5: {
  322. data: [
  323. {
  324. name: '周口',
  325. value: 55
  326. },
  327. {
  328. name: '南阳',
  329. value: 120
  330. },
  331. {
  332. name: '西峡',
  333. value: 71
  334. },
  335. {
  336. name: '驻马店',
  337. value: 66
  338. },
  339. {
  340. name: '新乡',
  341. value: 80
  342. },
  343. {
  344. name: '信阳',
  345. value: 35
  346. },
  347. {
  348. name: '漯河',
  349. value: 15
  350. }
  351. ],
  352. img: [
  353. 'http://datav.jiaminghi.com/img/conicalColumnChart/1st.png',
  354. 'http://datav.jiaminghi.com/img/conicalColumnChart/2st.png',
  355. 'http://datav.jiaminghi.com/img/conicalColumnChart/3st.png',
  356. 'http://datav.jiaminghi.com/img/conicalColumnChart/4st.png',
  357. 'http://datav.jiaminghi.com/img/conicalColumnChart/5st.png',
  358. 'http://datav.jiaminghi.com/img/conicalColumnChart/6st.png',
  359. 'http://datav.jiaminghi.com/img/conicalColumnChart/7st.png'
  360. ],
  361. showValue: true
  362. },
  363. config6: {
  364. header: ['列1', '列2', '列3'],
  365. data: [
  366. ['<span style="color:#37a2da;">行1列1</span>', '行1列2', '行1列3'],
  367. ['行2列1', '<span style="color:#32c5e9;">行2列2</span>', '行2列3'],
  368. ['行3列1', '行3列2', '<span style="color:#67e0e3;">行3列3</span>'],
  369. ['行4列1', '<span style="color:#9fe6b8;">行4列2</span>', '行4列3'],
  370. ['<span style="color:#ffdb5c;">行5列1</span>', '行5列2', '行5列3'],
  371. ['行6列1', '<span style="color:#ff9f7f;">行6列2</span>', '行6列3'],
  372. ['行7列1', '行7列2', '<span style="color:#fb7293;">行7列3</span>'],
  373. ['行8列1', '<span style="color:#e062ae;">行8列2</span>', '行8列3'],
  374. ['<span style="color:#e690d1;">行9列1</span>', '行9列2', '行9列3'],
  375. ['行10列1', '<span style="color:#e7bcf3;">行10列2</span>', '行10列3']
  376. ],
  377. index: true,
  378. columnWidth: [50],
  379. align: ['center']
  380. },
  381. config7: {
  382. data: [
  383. {
  384. name: '周口',
  385. value: 55123
  386. },
  387. {
  388. name: '南阳',
  389. value: 12022
  390. },
  391. {
  392. name: '西峡',
  393. value: 78932
  394. },
  395. {
  396. name: '驻马店',
  397. value: 63411
  398. },
  399. {
  400. name: '新乡',
  401. value: 44231
  402. }
  403. ],
  404. unit: '单位',
  405. valueFormatter({ value }) {
  406. console.warn(arguments)
  407. const reverseNumber = (value + '').split('').reverse()
  408. let valueStr = ''
  409. while (reverseNumber.length) {
  410. const seg = reverseNumber.splice(0, 3).join('')
  411. valueStr += seg
  412. if (seg.length === 3) valueStr += ','
  413. }
  414. return valueStr.split('').reverse().join('')
  415. }
  416. },
  417. config8: {
  418. radius: '40%',
  419. activeRadius: '45%',
  420. data: [
  421. {
  422. name: '周口',
  423. value: 55
  424. },
  425. {
  426. name: '郑州',
  427. value: 120
  428. },
  429. {
  430. name: '濮阳',
  431. value: 78
  432. },
  433. {
  434. name: '商丘',
  435. value: 66
  436. },
  437. {
  438. name: '苏州',
  439. value: 80
  440. }
  441. ],
  442. digitalFlopStyle: {
  443. fontSize: 20
  444. },
  445. showOriginValue: true
  446. },
  447. option: {
  448. title: {
  449. text: '表盘',
  450. style: {
  451. fill: '#fff'
  452. }
  453. },
  454. series: [
  455. {
  456. type: 'gauge',
  457. data: [{ name: 'itemA', value: 55 }],
  458. center: ['50%', '55%'],
  459. axisLabel: {
  460. formatter: '{value}%',
  461. style: {
  462. fill: '#fff'
  463. }
  464. },
  465. axisTick: {
  466. style: {
  467. stroke: '#fff'
  468. }
  469. },
  470. animationCurve: 'easeInOutBack'
  471. }
  472. ]
  473. }
  474. }
  475. }
  476. }
  477. </script>
  478. <style>
  479. .container {
  480. width: 100vw;
  481. height: 100vh;
  482. box-sizing: border-box;
  483. }
  484. #dv-full-screen-container {
  485. height: 100vh !important;
  486. }
  487. </style>

六、index.css

  1. * {
  2. margin: 0;
  3. padding: 0;
  4. }
  5. /* 主体 */
  6. .content {
  7. color: #fff;
  8. background: #000;
  9. width: 100vw;
  10. height: 100vh;
  11. }
  12. .bg {
  13. background: url(../image/bg.jpg) no-repeat center center;
  14. background-size: cover;
  15. }
  16. .module_box {
  17. display: flex;
  18. justify-content: space-between;
  19. margin: 5px;
  20. }
  21. .border-box-content {
  22. display: flex;
  23. justify-content: center;
  24. align-items: center;
  25. }

七、效果展示

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/木道寻08/article/detail/903958
推荐阅读
相关标签
  

闽ICP备14008679号