bottomLineForSend.jsx 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. /*
  2. * @Author: dayan_hjm 近30天产量
  3. * @Date: 2023-10-23 09:32:12
  4. * @Last Modified by: dayan_hjm
  5. * @Last Modified time: 2023-11-17 10:21:39
  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. missionsIntensity_arr:[],
  22. year:[],
  23. };
  24. }
  25. componentDidMount() {
  26. this.getUrl()
  27. }
  28. async getUrl() {
  29. await mondService().then(({ data = [], resultCode }) => {
  30. if (+resultCode === 0) {
  31. let year = [], missionsIntensity_arr = [];
  32. data.map((x, i) => {
  33. const name_ = x.indexDate.split('-')[1]+ '-'+x.indexDate.split('-')[2];
  34. year.push(name_);
  35. missionsIntensity_arr.push(x.indexValue)
  36. });
  37. this.setState({ year, missionsIntensity_arr });
  38. this.setData();
  39. }
  40. });
  41. }
  42. setData() {
  43. setTimeout(() => {
  44. // 基于准备好的dom,初始化echarts实例
  45. var myChart = echarts.init(document.getElementById('echarts2'));
  46. var option = {
  47. tooltip: {
  48. trigger: 'axis',
  49. axisPointer: { type: 'shadow' },
  50. borderColor:"rgba(105, 255, 222, 0.5)",
  51. borderWidth:2,
  52. padding:5,
  53. textStyle:{
  54. fontSize:12,
  55. color:"#ededed"
  56. },
  57. backgroundColor:"#0000008a"
  58. // formatter:'{c}' ,
  59. },
  60. grid: {
  61. left: '8%',
  62. top: '15%',
  63. right: '8%',
  64. bottom: '10',
  65. containLabel: true
  66. },
  67. // legend: {
  68. // data: ['字段1', '字段2'],
  69. // right: 'center',
  70. // top: 0,
  71. // textStyle: {
  72. // color: "#fff"
  73. // },
  74. // itemWidth: 12,
  75. // itemHeight: 10,
  76. // // itemGap: 35
  77. // },
  78. xAxis: [{
  79. type: 'category',
  80. boundaryGap: false,
  81. axisLabel: {
  82. textStyle: {
  83. color: '#7d7d7d',
  84. fontSize: 12
  85. },
  86. showMaxLabel: true,//关键部分,显示最后一个label
  87. },
  88. axisLine: {
  89. lineStyle: {
  90. color: 'rgba(255,255,255,.1)',
  91. type: 'dashed',
  92. }
  93. },
  94. splitLine: {
  95. show: true,
  96. lineStyle: {
  97. color: '#3b3b3b',
  98. type: 'dashed',
  99. }
  100. },
  101. data: this.state.year
  102. }, {
  103. axisPointer: { show: false },
  104. axisLine: { show: false },
  105. position: 'bottom',
  106. offset: 20,
  107. }],
  108. yAxis: [{
  109. type: 'value',
  110. axisTick: { show: false },
  111. // splitNumber: 6,
  112. axisLine: {
  113. lineStyle: {
  114. color: 'rgba(255,255,255,.1)'
  115. },
  116. },
  117. axisLabel: {
  118. formatter: "{value} 吨",
  119. textStyle: {
  120. color: '#7d7d7d',
  121. fontSize: 13
  122. },
  123. },
  124. splitLine: {
  125. lineStyle: {
  126. color: 'rgba(255,255,255,.1)'
  127. }
  128. }
  129. }],
  130. series: [
  131. {
  132. name: '吨数',
  133. type: 'line',
  134. smooth: true,
  135. symbol: 'circle',
  136. symbolSize: 5,
  137. showSymbol: false,
  138. lineStyle: {
  139. normal: {
  140. color: '#69FFDE',
  141. width: 2
  142. }
  143. },
  144. areaStyle: {
  145. normal: {
  146. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  147. offset: 0,
  148. color: '#69ffde5c'
  149. }, {
  150. offset: 1,
  151. color: 'rgba(228, 228, 126, 0)'
  152. }], false),
  153. shadowColor: 'rgba(0, 0, 0, 0.1)',
  154. }
  155. },
  156. itemStyle: {
  157. normal: {
  158. color: 'rgba(228, 228, 126, 1)',
  159. borderColor: 'rgba(228, 228, 126, .1)',
  160. borderWidth: 12
  161. }
  162. },
  163. data: this.state.missionsIntensity_arr,
  164. "smooth": true
  165. },
  166. // {
  167. // name: '字段2',
  168. // type: 'line',
  169. // smooth: true,
  170. // symbol: 'circle',
  171. // symbolSize: 5,
  172. // showSymbol: false,
  173. // lineStyle: {
  174. // normal: {
  175. // color: 'rgba(255, 128, 128, 1)',
  176. // width: 2
  177. // }
  178. // },
  179. // areaStyle: {
  180. // normal: {
  181. // color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  182. // offset: 0,
  183. // color: 'rgba(255, 128, 128,.2)'
  184. // }, {
  185. // offset: 1,
  186. // color: 'rgba(255, 128, 128, 0)'
  187. // }], false),
  188. // shadowColor: 'rgba(0, 0, 0, 0.1)',
  189. // }
  190. // },
  191. // itemStyle: {
  192. // normal: {
  193. // color: 'rgba(255, 128, 128, 1)',
  194. // borderColor: 'rgba(255, 128, 128, .1)',
  195. // borderWidth: 12
  196. // }
  197. // },
  198. // data: [-6.4, 0.1, 6.6, 11.2, 42.1, 26.0, 20.2, 18.31, 21.59, 24.42, 34.03, 32.9]
  199. // },
  200. ]
  201. };
  202. // 使用刚指定的配置项和数据显示图表。
  203. myChart.setOption(option);
  204. window.addEventListener("resize", function () {
  205. myChart.resize();
  206. });
  207. }, 3000)
  208. }
  209. render() {
  210. return (
  211. <div className={["eacharView cbBottomLineForSend"]}>
  212. <div id="echarts2"></div>
  213. </div>
  214. )
  215. }
  216. }
  217. export default BottomLineForSend;