test.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. <template>
  2. <div class="box">
  3. <div class="speedOption">
  4. <!-- 仪表盘 -->
  5. <svg
  6. viewBox="0,0,560,570"
  7. xmlns="http://www.w3.org/2000/svg"
  8. xmlns:xlink="http://www.w3.org/1999/xlink"
  9. style="
  10. position: absolute;
  11. width: 560px;
  12. height: 570px;
  13. z-index: 0;
  14. top: 0;
  15. left: 0;
  16. "
  17. >
  18. <g>
  19. <image :href="require('../assets/img/cs.png')" />
  20. </g>
  21. </svg>
  22. <chart
  23. :options="speedOption"
  24. :autoResize="true"
  25. class="chartstyle"
  26. ></chart>
  27. </div>
  28. <div class="pressureOption">
  29. <!-- 仪表盘 -->
  30. <svg
  31. viewBox="0,0,560,570"
  32. xmlns="http://www.w3.org/2000/svg"
  33. xmlns:xlink="http://www.w3.org/1999/xlink"
  34. style="
  35. position: absolute;
  36. width: 560px;
  37. height: 570px;
  38. z-index: 0;
  39. top: 0;
  40. left: 0;
  41. "
  42. >
  43. <g>
  44. <image :href="require('../assets/img/css.png')" />
  45. </g>
  46. </svg>
  47. <chart
  48. :options="pressureOption"
  49. :autoResize="true"
  50. class="chartstyle"
  51. ></chart>
  52. </div>
  53. </div>
  54. </template>
  55. <script>
  56. export default {
  57. data() {
  58. return {
  59. // 车速表 圆盘value+阴影axisLine-color
  60. speedOption: {
  61. series: [
  62. // 内圆盘
  63. {
  64. type: "pie",
  65. radius: ["0", "25%"],
  66. center: ["50%", "50%"],
  67. z: 2,
  68. tooltip: {
  69. show: false,
  70. },
  71. avoidLabelOverlap: false,
  72. label: {
  73. normal: {
  74. show: false,
  75. },
  76. emphasis: {
  77. show: false,
  78. },
  79. },
  80. labelLine: {
  81. normal: {
  82. show: false,
  83. },
  84. },
  85. data: [
  86. {
  87. value: 600,
  88. itemStyle: {
  89. normal: {
  90. color: "rgba(21,31,36,1)",
  91. },
  92. },
  93. label: {
  94. rich: {
  95. a: {
  96. color: "#fff",
  97. align: "center",
  98. fontSize: 50,
  99. padding: [0, 0, 0, 0],
  100. fontWeight: "bold",
  101. shadowColor: "#063c92",
  102. fontFamily: "LCD",
  103. },
  104. b: {
  105. color: "#fff",
  106. align: "center",
  107. fontSize: 30,
  108. fontWeight: "bold",
  109. fontFamily: "微软雅黑",
  110. },
  111. },
  112. formatter: function (params) {
  113. return (
  114. "{a|" + params.value + "}\n\n" + "{b|" + "km/h" + "}"
  115. );
  116. },
  117. position: "center",
  118. show: true,
  119. },
  120. labelLine: {
  121. show: false,
  122. },
  123. },
  124. ],
  125. },
  126. // 内部阴影
  127. {
  128. type: "gauge",
  129. radius: "81%",
  130. z: 2,
  131. center: ["50%", "50%"],
  132. tooltip: {
  133. show: false,
  134. },
  135. axisLine: {
  136. lineStyle: {
  137. color: [
  138. [
  139. 600 / 1500,
  140. {
  141. x: 1,
  142. y: 1,
  143. x2: 0,
  144. y2: 0,
  145. colorStops: [
  146. {
  147. offset: 1,
  148. color: "rgba(24,100,128,0.8)",
  149. },
  150. {
  151. offset: 0,
  152. color: "rgba(24,100,128,0.1)",
  153. },
  154. ],
  155. },
  156. ],
  157. ],
  158. width: 200,
  159. },
  160. },
  161. axisLabel: {
  162. show: false,
  163. },
  164. axisTick: {
  165. show: false,
  166. },
  167. splitLine: {
  168. show: false,
  169. },
  170. detail: {
  171. show: false,
  172. },
  173. pointer: {
  174. // 指针
  175. show: true,
  176. length: "70%",
  177. },
  178. itemStyle: {
  179. color: "#fff",
  180. },
  181. data: [6000],
  182. },
  183. // 上层刻度数阴影
  184. {
  185. type: "gauge",
  186. min: 0,
  187. max: 1500,
  188. splitNumber: 12,
  189. radius: "80%",
  190. z: 2,
  191. startAngle: 225,
  192. endAngle: -45,
  193. axisLine: {
  194. show: false,
  195. },
  196. axisLabel: {
  197. fontSize: 28,
  198. fontWeight: "bolder",
  199. color: "white",
  200. fontFamily: "LCD",
  201. rich: {
  202. a: {
  203. fontSize: 28,
  204. fontWeight: "bolder",
  205. color: "white",
  206. fontFamily: "LCD",
  207. textShadowColor: "#22e4fb",
  208. textShadowBlur: 15,
  209. },
  210. },
  211. formatter: function (value) {
  212. const d = "{a|" + value + "}";
  213. return d;
  214. },
  215. },
  216. axisTick: {
  217. // 坐标轴小标记
  218. show: false,
  219. },
  220. splitLine: {
  221. // 分隔线
  222. show: false,
  223. },
  224. detail: {
  225. show: false,
  226. },
  227. },
  228. ],
  229. },
  230. // 车压表
  231. pressureOption: {
  232. series: [
  233. // 内圆盘
  234. {
  235. type: "pie",
  236. radius: ["0", "25%"],
  237. center: ["50%", "50%"],
  238. z: 3,
  239. hoverAnimation: false,
  240. data: [
  241. {
  242. value: 2,
  243. itemStyle: {
  244. normal: {
  245. color: "rgba(21,31,36,1)",
  246. },
  247. },
  248. label: {
  249. rich: {
  250. a: {
  251. color: "#fff",
  252. align: "center",
  253. fontSize: 50,
  254. padding: [0, 0, 0, 0],
  255. fontWeight: "bold",
  256. shadowColor: "#063c92",
  257. fontFamily: "LCD",
  258. },
  259. b: {
  260. color: "#fff",
  261. align: "center",
  262. fontSize: 30,
  263. fontWeight: "bold",
  264. },
  265. },
  266. formatter: function (params) {
  267. return (
  268. "{a|" + params.value + "}\n\n" + "{b|" + "m/s²" + "}"
  269. );
  270. },
  271. position: "center",
  272. show: true,
  273. },
  274. labelLine: {
  275. show: false,
  276. },
  277. },
  278. ],
  279. },
  280. // 阴影
  281. {
  282. type: "gauge",
  283. radius: "81%",
  284. z: 2,
  285. min: 0,
  286. max: 2,
  287. startAngle: 90,
  288. endAngle: -45,
  289. clockwise: true,
  290. center: ["50%", "50%"],
  291. tooltip: {
  292. show: false,
  293. },
  294. axisLine: {
  295. lineStyle: {
  296. color: [
  297. [
  298. 2 / 2,
  299. {
  300. x: 1,
  301. y: 1,
  302. x2: 0,
  303. y2: 0,
  304. colorStops: [
  305. {
  306. offset: 1,
  307. color: "rgba(24,100,128,0.8)",
  308. },
  309. {
  310. offset: 0,
  311. color: "rgba(24,100,128,0.1)",
  312. },
  313. ],
  314. },
  315. ],
  316. ],
  317. width: 200,
  318. },
  319. },
  320. axisLabel: {
  321. show: false,
  322. },
  323. axisTick: {
  324. show: false,
  325. },
  326. splitLine: {
  327. show: false,
  328. },
  329. detail: {
  330. show: false,
  331. },
  332. pointer: {
  333. show: false,
  334. },
  335. data: [4],
  336. },
  337. // 指针
  338. {
  339. type: "gauge",
  340. radius: "81%",
  341. z: 2,
  342. min: 0,
  343. max: 4,
  344. center: ["50%", "50%"],
  345. tooltip: {
  346. show: false,
  347. },
  348. axisLine: {
  349. lineStyle: {
  350. color: [
  351. [
  352. 4 / 4,
  353. {
  354. x: 0,
  355. y: 0,
  356. x2: 0,
  357. y2: 0,
  358. colorStops: [
  359. {
  360. offset: 1,
  361. color: "rgba(24,100,128,0.8)",
  362. },
  363. {
  364. offset: 0,
  365. color: "rgba(24,100,128,0.1)",
  366. },
  367. ],
  368. },
  369. ],
  370. ],
  371. width: 200,
  372. },
  373. },
  374. axisLabel: {
  375. show: false,
  376. },
  377. axisTick: {
  378. show: false,
  379. },
  380. splitLine: {
  381. show: false,
  382. },
  383. detail: {
  384. show: false,
  385. },
  386. pointer: {
  387. // 指针
  388. show: true,
  389. length: "70%",
  390. },
  391. itemStyle: {
  392. color: "#fff",
  393. },
  394. data: [4],
  395. },
  396. // 刻度数
  397. {
  398. type: "gauge",
  399. min: 0,
  400. max: 2,
  401. splitNumber: 2,
  402. radius: "80%",
  403. z: 2,
  404. startAngle: 90,
  405. endAngle: -45,
  406. axisLine: {
  407. show: false,
  408. },
  409. axisLabel: {
  410. fontSize: 28,
  411. fontWeight: "bolder",
  412. color: "white",
  413. fontFamily: "LCD",
  414. rich: {
  415. a: {
  416. fontSize: 28,
  417. fontWeight: "bolder",
  418. color: "white",
  419. fontFamily: "LCD",
  420. textShadowColor: "#22e4fb",
  421. textShadowBlur: 15,
  422. },
  423. },
  424. formatter: function (value) {
  425. const d = "{a|" + value + "}";
  426. return d;
  427. },
  428. },
  429. axisTick: {
  430. // 坐标轴小标记
  431. show: false,
  432. },
  433. splitLine: {
  434. // 分隔线
  435. show: false,
  436. },
  437. detail: {
  438. show: false,
  439. },
  440. },
  441. ],
  442. },
  443. };
  444. },
  445. };
  446. </script>
  447. <style>
  448. @font-face {
  449. font-family: "LCD";
  450. src: url("../assets/font/LCD.ttf") format("truetype");
  451. font-weight: normal;
  452. font-style: normal;
  453. }
  454. </style>
  455. <style scoped>
  456. .box {
  457. display: flex;
  458. }
  459. .speedOption,
  460. .pressureOption {
  461. width: 560px;
  462. height: 570px;
  463. position: relative;
  464. }
  465. .chartstyle {
  466. width: 100%;
  467. height: 100%;
  468. }
  469. </style>