bottomLineForSend.jsx 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. /*
  2. * @Author: dayan_hjm 近30天产量
  3. * @Date: 2023-10-23 09:32:12
  4. * @Last Modified by: dayan_hjm
  5. * @Last Modified time: 2024-10-17 14:24:52
  6. */
  7. import React, { useState, useEffect, Component } from "react";
  8. import styles from "../style.less";
  9. import { useHistory, useLocation, withRouter } from "react-router-dom";
  10. import mod from '../mod';
  11. import {
  12. mondService,
  13. } from "../api";
  14. @withRouter
  15. class BottomLineForSend extends Component {
  16. // 构造函数,组件的实例创建时,最先执行
  17. constructor(props, context) {
  18. super(props, context);
  19. this.store = mod;
  20. this.state = {
  21. factoryProdcution_arr: [],
  22. missionsIntensity_arr: [],
  23. year: [],
  24. AvgQty:[],
  25. };
  26. }
  27. componentDidMount() {
  28. this.getUrl()
  29. }
  30. async getUrl() {
  31. await mondService().then(({ data = [], resultCode }) => {
  32. if (+resultCode === 0) {
  33. let year = [], missionsIntensity_arr = [],AvgQty = [], factoryProdcution_arr = [];
  34. data.map((x, i) => {
  35. const name_ = x.DateId.split('-')[1] + '-' + x.DateId.split('-')[2];
  36. year.push(name_);
  37. missionsIntensity_arr.push(x.ProdQty);
  38. AvgQty.push(x.AvgQty);
  39. factoryProdcution_arr.push(x.Avg5daysQty)
  40. });
  41. this.setState({ year, missionsIntensity_arr, AvgQty,factoryProdcution_arr });
  42. this.setData();
  43. }
  44. });
  45. }
  46. setData() {
  47. setTimeout(() => {
  48. // 基于准备好的dom,初始化echarts实例
  49. var myChart = echarts.init(document.getElementById('echarts21'));
  50. var option = {
  51. tooltip: {
  52. trigger: 'axis',
  53. axisPointer: { type: 'shadow' },
  54. borderColor: "rgba(105, 255, 222, 0.5)",
  55. borderWidth: 2,
  56. padding: 5,
  57. className: 'dyLeft',
  58. textStyle: {
  59. fontSize: 12,
  60. textAlign: "left",
  61. color: "#ededed"
  62. },
  63. backgroundColor: "#0000008a",
  64. },
  65. // formatter: `日期: {b0}<br />{a0}: {c0}吨<br />{a1}: {c1}吨`,
  66. grid: {
  67. left: '5%',
  68. top: '15%',
  69. right: '4%',
  70. bottom: '10%',
  71. containLabel: true
  72. },
  73. legend: {
  74. data: ['日产量(Daily Net Prodution)', '日产量趋势( Daily Net Production Trends)', "平均产量(Average Net Production)"],
  75. fontFamily: 'DingTalkJinBuTi',
  76. padding: [5, 0, 40, 0],
  77. textStyle: {
  78. color: "#CDF1FF",
  79. fontSize: 10
  80. },
  81. itemWidth: 8,
  82. itemHeight: 8,
  83. },
  84. xAxis: [{
  85. type: 'category',
  86. // boundaryGap: ['20%', '20%'],
  87. axisLabel: {
  88. // interval: 0,//设置是否展示全部数据在x轴
  89. rotate: -60,
  90. textStyle: {
  91. color: '#7d7d7d',
  92. fontSize: 11,
  93. },
  94. showMaxLabel: true,//关键部分,显示最后一个label
  95. },
  96. axisLine: {
  97. lineStyle: {
  98. color: 'rgba(255,255,255,.1)',
  99. type: 'dashed',
  100. }
  101. },
  102. splitLine: {
  103. show: true,
  104. lineStyle: {
  105. color: '#3b3b3b',
  106. type: 'dashed',
  107. }
  108. },
  109. data: this.state.year
  110. }, {
  111. axisPointer: { show: false },
  112. axisLine: { show: false },
  113. position: 'bottom',
  114. offset: 20,
  115. }],
  116. yAxis: [{
  117. type: 'value',
  118. axisTick: { show: false },
  119. // splitNumber: 6,
  120. axisLine: {
  121. lineStyle: {
  122. color: 'rgba(255,255,255,.1)'
  123. },
  124. },
  125. axisLabel: {
  126. formatter: "{value}t",
  127. textStyle: {
  128. color: '#7d7d7d',
  129. fontSize: 11
  130. },
  131. },
  132. splitLine: {
  133. lineStyle: {
  134. color: 'rgba(255,255,255,.1)'
  135. }
  136. }
  137. }],
  138. series: [
  139. {
  140. name: '日产量(Daily Net Prodution)',
  141. type: 'line',
  142. smooth: true,
  143. symbol: 'circle',
  144. symbolSize: 5,
  145. showSymbol: false,
  146. lineStyle: {
  147. normal: {
  148. color: '#69FFDE',
  149. width: 2
  150. }
  151. },
  152. areaStyle: {
  153. normal: {
  154. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  155. offset: 0,
  156. color: 'rgba(0, 255, 182, 0.5)'
  157. }, {
  158. offset: 1,
  159. color: 'rgba(0, 255, 182, 0)'
  160. }], false),
  161. shadowColor: 'rgba(0, 0, 0, 0.1)',
  162. }
  163. },
  164. itemStyle: {
  165. normal: {
  166. color: 'rgba(0, 255, 182, 0.3)',
  167. borderWidth: 12
  168. }
  169. },
  170. data: this.state.missionsIntensity_arr,
  171. "smooth": true
  172. },
  173. {
  174. name: '日产量趋势( Daily Net Production Trends)',
  175. type: 'line',
  176. smooth: true,
  177. showSymbol: false,
  178. itemStyle: {
  179. color: '#FFCE00'
  180. },
  181. lineStyle: {
  182. normal: {
  183. color: '#FFCE00',
  184. width: 2
  185. }
  186. },
  187. data: this.state.factoryProdcution_arr,
  188. },
  189. {
  190. name: '平均产量(Average Net Production)',
  191. type: 'line',
  192. smooth: true,
  193. symbol: 'circle',
  194. symbolSize: 5,
  195. showSymbol: false,
  196. lineStyle: {
  197. normal: {
  198. color: '#8D93FF',
  199. width: 2
  200. }
  201. },
  202. itemStyle: {
  203. normal: {
  204. color: '#8D93FF',
  205. borderColor: '#8D93FF',
  206. borderWidth: 12
  207. }
  208. },
  209. data: this.state.AvgQty,
  210. "smooth": true
  211. },
  212. ]
  213. };
  214. // 使用刚指定的配置项和数据显示图表。
  215. myChart.setOption(option);
  216. window.addEventListener("resize", function () {
  217. myChart.resize();
  218. });
  219. }, 3000)
  220. }
  221. render() {
  222. return (
  223. <div className={["eacharView cbBottomLineForSend"]}>
  224. <div id="echarts21"></div>
  225. </div>
  226. )
  227. }
  228. }
  229. export default BottomLineForSend;