DialWatch.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. <template>
  2. <div class="content_scjd">
  3. <div class="space">
  4. <div class="lt_box box">
  5. <div class="text">
  6. <p>{{ dial_watch_info.lt.key }}</p>
  7. <span>{{ dial_watch_info.lt.value }}</span>{{ dial_watch_info.lt.unit }}
  8. </div>
  9. </div>
  10. <div class="lb_box box">
  11. <div class="text">
  12. <p>{{ dial_watch_info.lb.key }}</p>
  13. <span>{{ dial_watch_info.lb.value }}</span>{{ dial_watch_info.lb.unit }}
  14. </div>
  15. </div>
  16. <div id="dial_watch_scjg" ref="dial_watch_scjg">
  17. </div>
  18. <div class="rt_box_tdsc_jd box">
  19. <div class="text">
  20. <p>{{ dial_watch_info.rt.key }}</p>
  21. <span>{{ dial_watch_info.rt.value }}</span>{{ dial_watch_info.rt.unit }}
  22. </div>
  23. </div>
  24. <div class="rb_box_tdsc_jd box">
  25. <div class="text">
  26. <p>{{ dial_watch_info.rb.key }}</p>
  27. <span>{{ dial_watch_info.rb.value }}</span>{{ dial_watch_info.rb.unit }}
  28. </div>
  29. </div>
  30. </div>
  31. </div>
  32. </template>
  33. <script>
  34. //这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  35. export default {
  36. components: {},
  37. data() {
  38. return {};
  39. },
  40. //监听属性 类似于data概念
  41. computed: {},
  42. //监控data中的数据变化
  43. watch: {},
  44. props: {
  45. dial_watch_info: {
  46. type: Object,
  47. default: {
  48. lt: {
  49. key: '计划收储',
  50. value: 0,
  51. unit: "公顷",
  52. }, lb: {
  53. key: "完成收储",
  54. value: 0,
  55. unit: "公顷",
  56. }, rt: {
  57. key: "计划收储项目",
  58. value: 0,
  59. unit: "个",
  60. }, rb: {
  61. key: "完成收储项目",
  62. value: 0,
  63. unit: "个",
  64. },
  65. }
  66. }
  67. },
  68. //方法集合
  69. methods: {
  70. init_dial_watch(echart_data) {
  71. var myChart = echarts.init(this.$refs.dial_watch_scjg);
  72. var demoData = {
  73. name: '城镇化率',
  74. value: echart_data,
  75. };
  76. let option = {
  77. backgroundColor: 'rgba(0,0,0,0)',
  78. title: {
  79. text: `{num|${demoData.value}%} ` + '\n' + `{label|完成率}`,
  80. x: '49%',
  81. y: '70%',
  82. textAlign: 'center',
  83. textStyle: {
  84. rich: {
  85. num: {
  86. fontWeight: '600',
  87. color: 'rgba(249, 180, 71, 1)',
  88. fontFamily: '微软雅黑',
  89. fontSize: 14,
  90. }, label: {
  91. color: "#fff",
  92. fontSize: 12,
  93. },
  94. },
  95. },
  96. },
  97. grid: { top: '0%', left: '0%' },
  98. series: [
  99. {
  100. type: 'gauge',
  101. radius: '90%', // 1行3个
  102. center: ['50%', '70%'],
  103. splitNumber: 10,
  104. // min: 0,
  105. max: 100,
  106. startAngle: 220,
  107. endAngle: -44,
  108. z: 99,
  109. // 线
  110. axisLine: {
  111. lineStyle: {
  112. width: 1,
  113. color: [[1, 'rgba(255,255,255,0)']],
  114. },
  115. detail: {
  116. formatter: '{value}',
  117. },
  118. data: [
  119. {
  120. value: 50,
  121. name: 'SCORE',
  122. },
  123. ],
  124. },
  125. //刻度标签。
  126. axisTick: {
  127. show: true,
  128. splitNumber: 6, //刻度的段落数
  129. lineStyle: {
  130. color: '#ccc',
  131. width: 1, //刻度的宽度
  132. shadowColor: 'RGBA(60, 139, 232, 0)',
  133. shadowBlur: 2,
  134. },
  135. length: 3, //刻度的长度
  136. },
  137. splitLine: {
  138. //文字和刻度的偏移量
  139. show: true,
  140. length: 1, //长度
  141. lineStyle: {
  142. color: '#ccc',
  143. width: 1,
  144. },
  145. },
  146. // //刻度线文字
  147. axisLabel: {
  148. show: false,
  149. color: '#ccc',
  150. fontSize: 1,
  151. distance: -30,
  152. },
  153. data: [
  154. {
  155. value: demoData.value,
  156. name: 'SCORE',
  157. itemStyle: {
  158. color: 'rgba(73, 148, 236, 1)',
  159. },
  160. },
  161. ],
  162. pointer: {
  163. show: true,
  164. length: '40%',
  165. radius: '50%',
  166. width: 5, //指针粗细
  167. offsetCenter: [0, -10]
  168. },
  169. detail: {
  170. show: false
  171. },
  172. title: {
  173. // 仪表盘标题。
  174. show: false,
  175. },
  176. },
  177. {
  178. name: demoData.name,
  179. type: 'pie',
  180. radius: ['65%', '50%'],
  181. center: ['50%', '70%'],
  182. startAngle: 220,
  183. endAngle: -10,
  184. color: [
  185. {
  186. type: 'linear',
  187. x: 1,
  188. y: 0,
  189. x2: 0,
  190. y2: 0,
  191. colorStops: [
  192. {
  193. offset: 0,
  194. color: 'rgba(62, 147, 244, 0.3)', // 0% 处的颜色
  195. },
  196. {
  197. offset: 1,
  198. color: 'rgba(62, 147, 244, 1)', // 100% 处的颜色
  199. },
  200. ],
  201. },
  202. 'transparent',
  203. ],
  204. hoverAnimation: true,
  205. legendHoverLink: false,
  206. z: 10,
  207. labelLine: {
  208. normal: {
  209. show: false,
  210. },
  211. },
  212. data: [
  213. {
  214. value: 60,
  215. },
  216. {
  217. value: 20,
  218. },
  219. ],
  220. },
  221. {
  222. type: 'pie',
  223. hoverAnimation: false,
  224. label: {
  225. show: false,
  226. },
  227. center: ['50%', '70%'],
  228. radius: ['0%', '60%'],
  229. startAngle: 230,
  230. data: [
  231. {
  232. value: 100,
  233. itemStyle: {
  234. normal: {
  235. color: {
  236. type: 'radial',
  237. x: 0.5,
  238. y: 0.5,
  239. r: 0.5,
  240. colorStops: [
  241. { offset: 0, color: 'rgba(0,0,0,0)' },
  242. { offset: 1, color: 'rgba(0,0,0,0)' },
  243. ],
  244. },
  245. opacity: 0.2,
  246. },
  247. },
  248. },
  249. {
  250. value: 100,
  251. color: 'transparent',
  252. },
  253. ],
  254. },
  255. ],
  256. };
  257. myChart.setOption(option);
  258. },
  259. },
  260. beforeCreate() { }, //生命周期 - 创建之前
  261. created() { }, //生命周期 - 创建完成(可以访问当前this实例)
  262. beforeMount() { }, //生命周期 - 挂载之前
  263. mounted() {
  264. // this.init_dial_watch_scjg();
  265. }, //生命周期 - 挂在完成
  266. beforeUpdate() { }, //生命周期 - 更新之前
  267. updated() { }, //生命周期 - 更新之后
  268. beforeDestroy() { }, //生命周期 - 销毁之前
  269. destroy() { },//生命周期 - 销毁完成
  270. activated() { }, //若组件实例是 <KeepAlive> 缓存树的一部分,当组件被插入到 DOM 中时调用。
  271. deactivated() { } //若组件实例是 <KeepAlive> 缓存树的一部分,当组件从 DOM 中被移除时调用。
  272. };
  273. </script>
  274. <style lang="scss" scoped>
  275. .content_scjd {
  276. #dial_watch_scjg {
  277. // border: 1px red solid;
  278. width: 26rem;
  279. height: 8.5rem;
  280. float: left;
  281. position: relative;
  282. bottom: 9rem;
  283. z-index: -1;
  284. }
  285. .box {
  286. width: 10rem;
  287. height: 5rem;
  288. position: absolute;
  289. }
  290. .lt_box {
  291. background: no-repeat;
  292. background-size: 101% 50%;
  293. background-image: url("/static/images/overview/ltback.png");
  294. position: relative;
  295. top: 3rem;
  296. }
  297. .lb_box {
  298. background: no-repeat;
  299. background-size: 101% 50%;
  300. background-image: url("/static/images/overview/lbback.png");
  301. position: relative;
  302. top: 3rem;
  303. }
  304. .rt_box_tdsc_jd {
  305. background: no-repeat;
  306. background-size: 101% 50%;
  307. background-image: url("/static/images/overview/rtback.png");
  308. position: relative;
  309. top: -7rem;
  310. left: 16rem;
  311. z-index: -1;
  312. .text {
  313. margin-left: 4rem;
  314. margin-left: 4rem;
  315. margin-top: -8.5rem;
  316. float: left;
  317. }
  318. }
  319. .rb_box_tdsc_jd {
  320. background: no-repeat;
  321. background-size: 101% 50%;
  322. background-image: url("/static/images/overview/rbback.png");
  323. position: relative;
  324. top: -7rem;
  325. left: 16rem;
  326. z-index: -1;
  327. .text {
  328. display: inline-block;
  329. position: relative;
  330. left: 3rem;
  331. top: -3.5rem;
  332. }
  333. }
  334. }
  335. .text {
  336. display: inline-block;
  337. width: 100px;
  338. // margin-top: 10px;
  339. margin-left: 15px;
  340. color: #ffffff;
  341. margin-top: 3px;
  342. p {
  343. font-kerning: normal;
  344. font-family: "Arial Negreta", "Arial Normal", "Arial";
  345. font-weight: 500;
  346. font-style: normal;
  347. font-size: 12px;
  348. color: #ffffff;
  349. }
  350. span {
  351. font-family: "Arial Negreta", "Arial Normal", "Arial";
  352. font-weight: 700;
  353. font-style: normal;
  354. color: #68f4fb;
  355. }
  356. }
  357. .hysy_box {
  358. margin: 1px;
  359. }
  360. </style>