chart.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <div>
  3. <!-- 年度开工率 -->
  4. <Echart
  5. :options="options"
  6. id="bottomLeft2Chart"
  7. height="480px"
  8. width="100%"
  9. ref="column-board"
  10. ></Echart>
  11. </div>
  12. </template>
  13. <script>
  14. import Echart from '@/common/echart'
  15. //import { formatDate } from '../../../../utils/index.js'
  16. export default {
  17. data () {
  18. return {
  19. options:{
  20. tooltip: {
  21. trigger: 'axis',
  22. axisPointer: {
  23. type: 'shadow'
  24. }
  25. },
  26. legend: {},
  27. grid: {
  28. left: '3%',
  29. right: '4%',
  30. bottom: '3%',
  31. containLabel: true
  32. },
  33. xAxis: [
  34. {
  35. type: 'category',
  36. data:[]
  37. //data: ['插件-01', '插件-02', '插件-03', '插件-04', '插件-05', '插件-06', '插件-07'],
  38. }
  39. ],
  40. yAxis: [
  41. {
  42. type: 'value',
  43. },
  44. {
  45. type: 'value',
  46. name: 'rate',
  47. min: 0,
  48. max: 100,
  49. interval: 20,
  50. axisLabel: {
  51. formatter: '{value}%'
  52. }
  53. }
  54. ],
  55. series: [
  56. {
  57. name: '投入',
  58. type: 'bar',
  59. barWidth: 20,
  60. emphasis: {
  61. focus: 'series'
  62. },
  63. data:[]
  64. //data: [320, 332, 301, 334, 390, 330, 320]
  65. },
  66. {
  67. name: '产出',
  68. type: 'bar',
  69. barWidth: 20,
  70. stack: 'Ad',
  71. emphasis: {
  72. focus: 'series'
  73. },
  74. data:[]
  75. //data: [220, 232, 221, 234, 290, 230, 220]
  76. },
  77. {
  78. name: '不良',
  79. type: 'bar',
  80. stack: 'Ad',
  81. barWidth: 10,
  82. data:[],
  83. //data: [12, 22, 32, 12, 32, 12, 32],
  84. emphasis: {
  85. focus: 'series'
  86. }
  87. },
  88. {
  89. name: '良率%',
  90. type: 'line',
  91. data:[],
  92. yAxisIndex: 1,
  93. //data: [92, 92,92, 72, 82, 62, 62],
  94. tooltip: {
  95. valueFormatter: function (value) {
  96. return value + '%';
  97. }
  98. },
  99. itemStyle: {
  100. normal: {
  101. barBorderRadius: 5,
  102. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [
  103. { offset: 0, color: "rgba(156,107,211,0.8)" },
  104. { offset: 0.2, color: "rgba(156,107,211,0.5)" },
  105. { offset: 1, color: "rgba(156,107,211,0.2)" }
  106. ])
  107. }
  108. },
  109. emphasis: {
  110. focus: 'series'
  111. }
  112. }
  113. ]
  114. },
  115. };
  116. },
  117. components: {
  118. Echart, //子组件
  119. },
  120. props: {
  121. cdata: {
  122. type: Object,
  123. default: () => ({})
  124. },
  125. },
  126. mounted() {
  127. this.getdata();
  128. this.refreshdata();
  129. },
  130. methods: {
  131. refreshdata() {
  132. setInterval(() => {
  133. this.getdata(); //获取-数据
  134. }, 30000);
  135. },
  136. async getdata() {
  137. //20220211 -+formatDate(new Date()
  138. await this.$http.get("kanban/datalist.action?caller=WCDAYTURNOUT&_noc=1&page=1&pageSize=100&condition=1=1")
  139. .then((result)=>{
  140. let dataList = JSON.parse(result.data.data);
  141. let xAxis0 = new Array();
  142. let series0 = new Array();
  143. let series1 = new Array();
  144. let series2 = new Array();
  145. let series3 = new Array();
  146. for (let index = 0; index < dataList.length; index++) {
  147. const element = dataList[index];
  148. xAxis0.push(element.sp_wccode);
  149. //投入
  150. series0.push(element.v_inqty);
  151. //产出
  152. series1.push(element.v_outqty);
  153. //不良
  154. series2.push(element.v_ngqty);
  155. //良率
  156. series3.push(element.v_okrate);
  157. }
  158. this.options.xAxis[0].data = xAxis0;
  159. this.options.series[0].data = series0;
  160. this.options.series[1].data = series1;
  161. this.options.series[2].data = series2;
  162. this.options.series[3].data = series3;
  163. /*let myChart = this.$children[0].chart;
  164. myChart.setOption({
  165. xAxis: {
  166. data: xAxis0
  167. },
  168. series: [
  169. {
  170. // 根据名字对应到相应的系列
  171. name: '投入',
  172. data: series0
  173. },
  174. {
  175. name: '产出',
  176. data: series2
  177. }, {
  178. name: '不良',
  179. data: series3
  180. },
  181. {
  182. name: '不良率%',
  183. data: series4
  184. },
  185. ]
  186. });*/
  187. },(result)=>{
  188. console.error(result)
  189. }
  190. );
  191. }
  192. }
  193. }
  194. </script>