chart.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. <template>
  2. <div>
  3. <Echart
  4. :options="options"
  5. id="bottom1Chart"
  6. height="195px"
  7. width="1100px"
  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.lastw + ',历史:' + newData.hisd,
  111. // subtext: newData.year + '/' + newData.nowdate,
  112. subtextStyle: {
  113. color: '#fff',
  114. fontSize: 13
  115. },
  116. top: 90,
  117. left: 60
  118. },
  119. legend: {
  120. top: 10,
  121. left: 60,
  122. orient: 'vertical',
  123. itemGap: 15,
  124. itemWidth: 12,
  125. itemHeight: 12,
  126. data: ['本周','上周','历史'],
  127. textStyle: {
  128. color: '#fff',
  129. fontSize: 13
  130. }
  131. },
  132. tooltip: {
  133. trigger: 'item'
  134. },
  135. radar: {
  136. center: ['68%', '27%'],
  137. radius: '30%',
  138. name: {
  139. color: '#fff'
  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: 85
  168. },
  169. {
  170. name: '制程不良',
  171. max: 85
  172. },
  173. {
  174. name: '设计不良',
  175. max: 85
  176. },
  177. {
  178. name: '其他',
  179. max: 85
  180. }
  181. ],
  182. axisName: {
  183. fontSize: 5
  184. },
  185. nameGap: 8
  186. },*/
  187. grid: {
  188. /* left: 50,
  189. right: 80,
  190. bottom: 30,
  191. top: '60%'*/
  192. left: '5%',
  193. right: '4%',
  194. bottom: 25,
  195. },
  196. xAxis: {
  197. type: 'category',
  198. position: 'bottom',
  199. axisLine: true,
  200. axisLabel: {
  201. color: 'rgba(255,255,255,.8)',
  202. fontSize: 12
  203. },
  204. data: newData.weekCategory
  205. },
  206. // 下方Y轴
  207. yAxis: {
  208. name: '',
  209. nameLocation: 'end',
  210. nameGap: 24,
  211. nameTextStyle: {
  212. color: 'rgba(255,255,255,.5)',
  213. fontSize: 14
  214. },
  215. max:newData.maxData,
  216. splitNumber: 4,
  217. min:newData.minData,
  218. axisLine: {
  219. lineStyle: {
  220. opacity: 0
  221. }
  222. },
  223. splitLine: {
  224. show: true,
  225. lineStyle: {
  226. color: '#fff',
  227. opacity: 0.1
  228. }
  229. },
  230. axisLabel: {
  231. color: 'rgba(255,255,255,.8)',
  232. fontSize: 12
  233. }
  234. },
  235. series: [
  236. /* {
  237. name: '',
  238. type: 'radar',
  239. symbolSize: 0,
  240. data: [
  241. {
  242. value: newData.radarDataAvg,
  243. name: '本周',
  244. itemStyle: {
  245. normal: {
  246. color: '#f8d351'
  247. }
  248. },
  249. lineStyle: {
  250. normal: {
  251. opacity: 0
  252. }
  253. },
  254. areaStyle: {
  255. normal: {
  256. color: '#f8d351',
  257. shadowBlur: 25,
  258. shadowColor: 'rgba(248,211,81,.3)',
  259. shadowOffsetX: 0,
  260. shadowOffsetY: -10,
  261. opacity: 1
  262. }
  263. }
  264. },
  265. {
  266. value: newData.radarData,
  267. name: '上周',
  268. itemStyle: {
  269. normal: {
  270. color: '#43dfa2'
  271. }
  272. },
  273. lineStyle: {
  274. normal: {
  275. opacity: 0
  276. }
  277. },
  278. areaStyle: {
  279. normal: {
  280. color: this.colorList.linearGtoB,
  281. shadowBlur: 15,
  282. shadowColor: 'rgba(0,0,0,.2)',
  283. shadowOffsetX: 0,
  284. shadowOffsetY: 5,
  285. opacity: 0.8
  286. }
  287. }
  288. }
  289. , {
  290. value: newData.radarHisData,
  291. name: '历史',
  292. itemStyle: {
  293. normal: {
  294. color: '#137af4'
  295. }
  296. },
  297. lineStyle: {
  298. normal: {
  299. opacity: 0
  300. }
  301. },
  302. areaStyle: {
  303. normal: {
  304. color: '#137af4',
  305. shadowBlur: 25,
  306. shadowColor: 'rgba(159,229,245,0.3)',
  307. shadowOffsetX: 0,
  308. shadowOffsetY: -10,
  309. opacity: 1
  310. }
  311. }
  312. }
  313. ]
  314. },*/
  315. {
  316. name: '',
  317. type: 'line',
  318. smooth: true,
  319. symbol: 'emptyCircle',
  320. symbolSize: 8,
  321. itemStyle: {
  322. normal: {
  323. color: '#fff'
  324. }
  325. },
  326. lineStyle: {
  327. normal: {
  328. color: this.colorList.linearBtoG,
  329. width: 3
  330. }
  331. },
  332. areaStyle: {
  333. normal: {
  334. color: this.colorList.areaBtoG
  335. }
  336. },
  337. data: newData.weekLineData,
  338. label: {
  339. show: true,
  340. position: 'top'
  341. },
  342. lineSmooth: true,
  343. markLine: {
  344. silent: true,
  345. data: [
  346. {
  347. type: 'average',
  348. name: '平均值'
  349. }
  350. ],
  351. precision: 0,
  352. label: {
  353. normal: {
  354. formatter: '平均值: \n {c}'
  355. }
  356. },
  357. lineStyle: {
  358. normal: {
  359. color: 'rgba(248,211,81,.7)'
  360. }
  361. }
  362. },
  363. tooltip: {
  364. position: 'top',
  365. formatter: '{c} %',
  366. backgroundColor: 'rgba(28,152,232,.2)',
  367. padding: 6
  368. }
  369. },
  370. {
  371. name: '占位背景',
  372. type: 'bar',
  373. itemStyle: {
  374. normal: {
  375. show: true,
  376. color: '#000',
  377. opacity: 0
  378. }
  379. },
  380. silent: true,
  381. barWidth: '50%',
  382. data: newData.weekMaxData,
  383. animation: false
  384. }
  385. ]
  386. }
  387. },
  388. immediate: true,
  389. deep: true
  390. }
  391. }
  392. }
  393. </script>