chart.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. <template>
  2. <div>
  3. <Echart
  4. :options="options"
  5. id="bottomRightChart"
  6. height="480px"
  7. width="913px"
  8. ></Echart>
  9. </div>
  10. </template>
  11. <script>
  12. import Echart from '@/common/echart'
  13. export default {
  14. data() {
  15. return {
  16. options: {},
  17. // 定义颜色
  18. colorList: {
  19. linearYtoG: {
  20. type: 'linear',
  21. x: 0,
  22. y: 0,
  23. x2: 1,
  24. y2: 1,
  25. colorStops: [
  26. {
  27. offset: 0,
  28. color: '#f5b44d'
  29. },
  30. {
  31. offset: 1,
  32. color: '#28f8de'
  33. }
  34. ]
  35. },
  36. linearGtoB: {
  37. type: 'linear',
  38. x: 0,
  39. y: 0,
  40. x2: 1,
  41. y2: 0,
  42. colorStops: [
  43. {
  44. offset: 0,
  45. color: '#43dfa2'
  46. },
  47. {
  48. offset: 1,
  49. color: '#28f8de'
  50. }
  51. ]
  52. },
  53. linearBtoG: {
  54. type: 'linear',
  55. x: 0,
  56. y: 0,
  57. x2: 1,
  58. y2: 0,
  59. colorStops: [
  60. {
  61. offset: 0,
  62. color: '#1c98e8'
  63. },
  64. {
  65. offset: 1,
  66. color: '#28f8de'
  67. }
  68. ]
  69. },
  70. areaBtoG: {
  71. type: 'linear',
  72. x: 0,
  73. y: 0,
  74. x2: 0,
  75. y2: 1,
  76. colorStops: [
  77. {
  78. offset: 0,
  79. color: 'rgba(35,184,210,.2)'
  80. },
  81. {
  82. offset: 1,
  83. color: 'rgba(35,184,210,0)'
  84. }
  85. ]
  86. }
  87. }
  88. }
  89. },
  90. components: {
  91. Echart
  92. },
  93. props: {
  94. cdata: {
  95. type: Object,
  96. default: () => ({})
  97. }
  98. },
  99. watch: {
  100. cdata: {
  101. handler(newData) {
  102. this.options = {
  103. title: {
  104. text: '',
  105. textStyle: {
  106. color: '#D3D6DD',
  107. fontSize: 24,
  108. fontWeight: 'normal'
  109. },
  110. subtext: newData.year + '/' + newData.nowdate,
  111. subtextStyle: {
  112. color: '#fff',
  113. fontSize: 18
  114. },
  115. top: 50,
  116. left: 80
  117. },
  118. legend: {
  119. top: 120,
  120. left: 80,
  121. orient: 'vertical',
  122. itemGap: 15,
  123. itemWidth: 14,
  124. itemHeight: 14,
  125. data: ['实际','平均'],
  126. textStyle: {
  127. color: '#fff',
  128. fontSize: 16
  129. }
  130. },
  131. tooltip: {
  132. trigger: 'item'
  133. },
  134. radar: {
  135. center: ['68%', '27%'],
  136. radius: '40%',
  137. name: {
  138. color: '#fff',
  139. fontSize:16
  140. },
  141. splitNumber: 8,
  142. axisLine: {
  143. lineStyle: {
  144. color: this.colorList.linearYtoG,
  145. opacity: 0.6
  146. }
  147. },
  148. splitLine: {
  149. lineStyle: {
  150. color: this.colorList.linearYtoG,
  151. opacity: 0.6
  152. }
  153. },
  154. splitArea: {
  155. areaStyle: {
  156. color: '#fff',
  157. opacity: 0.1,
  158. shadowBlur: 25,
  159. shadowColor: '#000',
  160. shadowOffsetX: 0,
  161. shadowOffsetY: 5
  162. }
  163. },
  164. indicator: [
  165. {
  166. name: '来料不良',
  167. max: 100
  168. },
  169. {
  170. name: '制程不良',
  171. max: 100
  172. },
  173. {
  174. name: '设计不良',
  175. max: 100
  176. },
  177. {
  178. name: '其他',
  179. max: 100
  180. }
  181. ]
  182. },
  183. grid: {
  184. left: 90,
  185. right: 80,
  186. bottom: 40,
  187. top: '60%'
  188. },
  189. xAxis: {
  190. type: 'category',
  191. position: 'bottom',
  192. axisLine: true,
  193. axisLabel: {
  194. color: 'rgba(255,255,255,.8)',
  195. fontSize: 15
  196. },
  197. data: newData.weekCategory
  198. },
  199. // 下方Y轴
  200. yAxis: {
  201. name: '',
  202. nameLocation: 'end',
  203. nameGap: 24,
  204. nameTextStyle: {
  205. color: 'rgba(255,255,255,.5)',
  206. fontSize: 14
  207. },
  208. max:newData.maxData,
  209. //splitNumber: 4,
  210. min:newData.minData,
  211. axisLine: {
  212. lineStyle: {
  213. opacity: 0
  214. }
  215. },
  216. splitLine: {
  217. show: true,
  218. lineStyle: {
  219. color: '#fff',
  220. opacity: 0.1
  221. }
  222. },
  223. axisLabel: {
  224. color: 'rgba(255,255,255,.8)',
  225. fontSize: 14
  226. }
  227. },
  228. series: [
  229. {
  230. name: '',
  231. type: 'radar',
  232. symbolSize: 0,
  233. data: [
  234. {
  235. value: newData.radarDataAvg,
  236. name: '平均',
  237. itemStyle: {
  238. normal: {
  239. color: '#f8d351'
  240. }
  241. },
  242. lineStyle: {
  243. normal: {
  244. opacity: 0
  245. }
  246. },
  247. areaStyle: {
  248. normal: {
  249. color: '#f8d351',
  250. shadowBlur: 25,
  251. shadowColor: 'rgba(248,211,81,.3)',
  252. shadowOffsetX: 0,
  253. shadowOffsetY: -10,
  254. opacity: 1
  255. }
  256. }
  257. },
  258. {
  259. value: newData.radarData,
  260. name: '实际',
  261. itemStyle: {
  262. normal: {
  263. color: '#43dfa2'
  264. }
  265. },
  266. lineStyle: {
  267. normal: {
  268. opacity: 0
  269. }
  270. },
  271. areaStyle: {
  272. normal: {
  273. color: this.colorList.linearGtoB,
  274. shadowBlur: 15,
  275. shadowColor: 'rgba(0,0,0,.2)',
  276. shadowOffsetX: 0,
  277. shadowOffsetY: 5,
  278. opacity: 0.8
  279. }
  280. }
  281. }
  282. ]
  283. },
  284. {
  285. name: '',
  286. type: 'line',
  287. smooth: true,
  288. symbol: 'emptyCircle',
  289. symbolSize: 8,
  290. itemStyle: {
  291. normal: {
  292. color: '#fff'
  293. }
  294. },
  295. lineStyle: {
  296. normal: {
  297. color: this.colorList.linearBtoG,
  298. width: 3
  299. }
  300. },
  301. areaStyle: {
  302. normal: {
  303. color: this.colorList.areaBtoG
  304. }
  305. },
  306. data: newData.weekLineData,
  307. label: {
  308. show: true,
  309. position: 'top',
  310. fontSize:14,
  311. },
  312. lineSmooth: true,
  313. markLine: {
  314. silent: true,
  315. data: [
  316. {yAxis: newData.goalData}
  317. /*{
  318. type: 'average',
  319. value:80,
  320. name: '平均值'
  321. }*/
  322. ],
  323. precision: 0,
  324. label: {
  325. normal: {
  326. formatter: '目标线%: \n {c}'
  327. }
  328. },
  329. lineStyle: {
  330. normal: {
  331. fontSize: 16,
  332. color: 'rgba(248,211,81,.7)'
  333. }
  334. }
  335. },
  336. tooltip: {
  337. position: 'top',
  338. formatter: '{c} %',
  339. backgroundColor: 'rgba(28,152,232,.2)',
  340. padding: 6
  341. }
  342. },
  343. {
  344. name: '占位背景',
  345. type: 'bar',
  346. itemStyle: {
  347. normal: {
  348. show: true,
  349. color: '#000',
  350. opacity: 0
  351. }
  352. },
  353. silent: true,
  354. barWidth: '50%',
  355. data: newData.weekMaxData,
  356. animation: false
  357. }
  358. ]
  359. }
  360. },
  361. immediate: true,
  362. deep: true
  363. }
  364. }
  365. }
  366. </script>