cake.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <!-- 地图 -->
  2. <template>
  3. <div class="wrap-container sn-container">
  4. <div class="sn-content">
  5. <div class="sn-title title">
  6. <div class="titleZn">{{ title }}</div>
  7. <div class="titleEn">{{ titleEn }}</div>
  8. </div>
  9. <div class="sn-body">
  10. <div class="wrap-container flex">
  11. <div class="chartsdom" id="cake"></div>
  12. <div class="panel">
  13. <div class="panelitem flex space_around">
  14. <div>
  15. <div class="number">{{ data.年移栽数量 }}</div>
  16. <div class="text">
  17. <img
  18. class="img1"
  19. src="../../assets/img/rectangle.png"
  20. alt=""
  21. />
  22. 年移栽数量
  23. </div>
  24. </div>
  25. <div>
  26. <div class="number">{{ data.年移栽面积 }}</div>
  27. <div class="text">
  28. <img
  29. class="img1"
  30. src="../../assets/img/rectangle.png"
  31. alt=""
  32. />年移栽面积
  33. </div>
  34. </div>
  35. </div>
  36. <div class="panelitem">
  37. <div class="flex space_between secondItem">
  38. <img class="img" src="../../assets/img/tree.png" alt="" />
  39. <div>移栽区域数</div>
  40. <div>{{ data.移栽区域数 }}</div>
  41. </div>
  42. <div class="flex space_between secondItem">
  43. <img class="img" src="../../assets/img/head.png" alt="" />
  44. <div>烟农数量</div>
  45. <div>{{ data.烟农数量 }}</div>
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. </div>
  53. </template>
  54. <script>
  55. export default {
  56. data() {
  57. return {
  58. option: null,
  59. information: {},
  60. }
  61. },
  62. props: {
  63. data: {
  64. type: Object,
  65. },
  66. title: {
  67. type: String,
  68. default: ``,
  69. },
  70. titleEn: {
  71. type: String,
  72. default: `Tongren Tobacco Planting Digital Management Platform`,
  73. },
  74. },
  75. async mounted() {
  76. this.getEchart()
  77. },
  78. watch: {
  79. data() {
  80. this.getEchart()
  81. },
  82. },
  83. methods: {
  84. getEchart() {
  85. let myChart = echarts.init(document.getElementById(`cake`))
  86. const title = `目标完成率`
  87. const value = this.data.目标完成率
  88. const splitLineLength = `19%`
  89. const splitLineDistance = -5
  90. const splitLineWidth = 2
  91. const int = value.toFixed(1).split(`.`)[0]
  92. const float = value.toFixed(1).split(`.`)[1]
  93. this.option = {
  94. title: {
  95. text: `{a|` + int + `}{b|.` + float + `%}\n{c|` + title + `}`,
  96. x: `center`,
  97. y: `center`,
  98. textStyle: {
  99. rich: {
  100. a: {
  101. fontSize: 42,
  102. color: `#fff`,
  103. },
  104. b: {
  105. fontSize: 20,
  106. color: `#96A2BC`,
  107. padding: [2, 0, 0, 0],
  108. },
  109. c: {
  110. fontSize: 16,
  111. color: `#96A2BC`,
  112. padding: [2, 0, 0, 0],
  113. },
  114. },
  115. },
  116. },
  117. series: [
  118. {
  119. type: `pie`,
  120. radius: [`84%`, `70%`],
  121. silent: true,
  122. clockwise: true,
  123. startAngle: -35,
  124. z: 0,
  125. zlevel: 0,
  126. data: [
  127. {
  128. value: value,
  129. itemStyle: {
  130. color: {
  131. type: `linear`,
  132. x: 1,
  133. y: 0,
  134. x2: 0,
  135. y2: 1,
  136. colorStops: [
  137. {
  138. offset: 0,
  139. color: `#DFFFFF`, // 0% 处的颜色
  140. },
  141. {
  142. offset: 1,
  143. color: `#0E7E7D`, // 100% 处的颜色
  144. },
  145. ],
  146. global: false, // 缺省为 false
  147. },
  148. },
  149. label: {
  150. show: false,
  151. },
  152. },
  153. {
  154. value: 100 - value,
  155. label: {
  156. show: false,
  157. },
  158. itemStyle: {
  159. normal: {
  160. color: `rgba(15, 31, 52,1)`,
  161. },
  162. },
  163. },
  164. ],
  165. },
  166. {
  167. name: ``,
  168. type: `gauge`,
  169. radius: `88%`,
  170. center: [`50%`, `50%`],
  171. startAngle: 0,
  172. endAngle: 360,
  173. splitNumber: 100,
  174. hoverAnimation: true,
  175. axisTick: {
  176. show: false,
  177. },
  178. splitLine: {
  179. length: splitLineLength,
  180. distance: splitLineDistance,
  181. lineStyle: {
  182. width: splitLineWidth,
  183. color: `#000`,
  184. },
  185. },
  186. axisLabel: {
  187. show: false,
  188. },
  189. pointer: {
  190. show: false,
  191. },
  192. axisLine: {
  193. show: false,
  194. },
  195. },
  196. {
  197. name: `外边框`,
  198. type: `pie`,
  199. clockwise: false, // 顺时加载
  200. emphasis: {
  201. scale: false, // 鼠标移入变大
  202. },
  203. center: [`50%`, `50%`],
  204. radius: [`88%`, `88%`],
  205. label: {
  206. show: false,
  207. },
  208. data: [
  209. {
  210. value: 0,
  211. name: ``,
  212. itemStyle: {
  213. borderWidth: 2,
  214. borderColor: `#24FFFD`,
  215. },
  216. },
  217. ],
  218. },
  219. ],
  220. }
  221. myChart.setOption(this.option)
  222. },
  223. },
  224. }
  225. </script>
  226. <style lang="scss" scoped>
  227. .sn-container {
  228. width: 401px;
  229. height: 300px;
  230. .title {
  231. display: flex;
  232. justify-content: space-between;
  233. .titleEn {
  234. width: 120px;
  235. font-size: 8px;
  236. text-align: right;
  237. word-break: break-all;
  238. line-height: 1;
  239. }
  240. }
  241. .chartsdom {
  242. width: 80%;
  243. height: 80%;
  244. }
  245. .flex {
  246. display: flex;
  247. .panel {
  248. width: 80%;
  249. height: 80%;
  250. .panelitem {
  251. border-top: 2px solid #646464;
  252. box-sizing: border-box;
  253. height: 50%;
  254. margin: 0 10px;
  255. .secondItem {
  256. margin: 21px 0;
  257. }
  258. }
  259. }
  260. }
  261. .img {
  262. height: 25px;
  263. margin-right: 3px;
  264. }
  265. .img1 {
  266. height: 17px;
  267. width: 3px;
  268. margin-right: 3px;
  269. }
  270. .l-height {
  271. line-height: 100%;
  272. }
  273. .space_around {
  274. justify-content: space-around;
  275. align-items: center;
  276. }
  277. .space_between {
  278. justify-content: space-between;
  279. align-items: center;
  280. }
  281. .number {
  282. font-size: 22px;
  283. padding: 4px 0;
  284. margin: 3px 0;
  285. }
  286. .text {
  287. font-size: 14px;
  288. color: #888888;
  289. display: flex;
  290. justify-content: center;
  291. align-items: center;
  292. }
  293. .column_reverse {
  294. flex-direction: column-reverse;
  295. }
  296. }
  297. </style>