moodSendView.jsx 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /*
  2. * @Author: dayan_hjm 月度产量/发货量
  3. * @Date: 2023-10-23 09:32:12
  4. * @Last Modified by: dayan_hjm
  5. * @Last Modified time: 2024-10-24 11:03:08
  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. twoService,
  13. } from "../api";
  14. import { getThousandNum } from "@utils/util";
  15. @withRouter
  16. class MoodSendView extends Component {
  17. // 构造函数,组件的实例创建时,最先执行
  18. constructor(props, context) {
  19. super(props, context);
  20. this.store = mod;
  21. this.state = {
  22. proQty:[],
  23. year:[],
  24. deliveryQty:[],
  25. };
  26. }
  27. componentDidMount() {
  28. this.getUrl()
  29. }
  30. async getUrl() {
  31. await twoService().then(({ data = [], resultCode }) => {
  32. if (+resultCode === 0) {
  33. let year = [], proQty = [], deliveryQty = [];
  34. data.map((x, i) => {
  35. year.push(x.bMonth);
  36. // proQty.push(x.proQty)
  37. deliveryQty.push(x?.DeliveryQty ? x?.DeliveryQty.toFixed(1) : 0)
  38. });
  39. this.setState({ year, deliveryQty });
  40. this.setData();
  41. }
  42. });
  43. }
  44. setData() {
  45. setTimeout(() => {
  46. var data = [220, 182, 191, 234, 290, 330, 310, 123, 442, 321, 90, 149, 210, 122, 200];
  47. var yMax = 500;
  48. var dataShadow = [];
  49. for (var i = 0; i < data.length; i++) {
  50. dataShadow.push(yMax);
  51. }
  52. var option = {
  53. grid: {
  54. left: '2%',
  55. top: '18%',
  56. right: '0%',
  57. bottom: '8%',
  58. containLabel: true
  59. },
  60. tooltip: {
  61. trigger: 'axis',
  62. axisPointer: {
  63. type: 'shadow'
  64. },
  65. borderColor:"rgba(105, 255, 222, 0.5)",
  66. borderWidth:2,
  67. padding:5,
  68. textStyle:{
  69. fontSize:10,
  70. color:"#ededed"
  71. },
  72. valueFormatter: (value) => {
  73. return getThousandNum(Number(value))
  74. },
  75. backgroundColor:"#0000008a"
  76. },
  77. xAxis: [
  78. {
  79. type: 'category',
  80. axisTick: { show: false },
  81. data: this.state.year,
  82. axisLabel: {
  83. /*inside: true,*/
  84. color: "rgba(255,255,255,.6)",
  85. interval: 0,
  86. textStyle: {
  87. color: '#7d7d7d',
  88. fontSize: 10
  89. },
  90. },
  91. axisLine: {
  92. lineStyle: {
  93. color: 'rgba(255,255,255,.1)',
  94. type: 'dashed',
  95. }
  96. },
  97. splitLine:{
  98. show:true,
  99. lineStyle:{
  100. color: '#3b3b3b',
  101. type: 'dashed',
  102. }
  103. }
  104. }
  105. ],
  106. yAxis: [
  107. {
  108. type: 'value',
  109. axisLine: {
  110. lineStyle: {
  111. color: '#7d7d7d',
  112. type: 'dashed',
  113. },
  114. },
  115. axisTick: { show: false },
  116. axisLabel: {
  117. formatter: "{value}t",
  118. textStyle: {
  119. color: '#7d7d7d',
  120. fontSize: 11
  121. }
  122. },
  123. splitLine:{
  124. show:true,
  125. lineStyle:{
  126. color: '#3b3b3b',
  127. type: 'dashed',
  128. }
  129. }
  130. }
  131. ],
  132. series: [
  133. {
  134. name: '发货量(Shipment)',
  135. type: 'bar',
  136. animation:true,
  137. animationDuration:3000,
  138. "smooth": true,
  139. barGap: 0,
  140. barWidth: 10,
  141. emphasis: {
  142. focus: 'series'
  143. },
  144. itemStyle: {
  145. labelLine:{
  146. show:false
  147. },
  148. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  149. { offset: 0, color: 'rgba(105, 255, 222, 1)' },
  150. { offset: 0.7, color: 'rgba(105, 255, 222, 1)' },
  151. { offset: 1, color: 'rgba(105, 255, 222, 0.3)' },
  152. ])
  153. },
  154. data: this.state.deliveryQty
  155. }
  156. ]
  157. }
  158. var myChart = echarts.init(document.getElementById('chartmain2'));
  159. // 使用刚指定的配置项和数据显示图表。
  160. myChart.setOption(option);
  161. }, 3000)
  162. }
  163. render() {
  164. return (
  165. <div className={["eacharView cbMoodSendView"]}>
  166. <div id="chartmain2"></div>
  167. </div>
  168. )
  169. }
  170. }
  171. export default MoodSendView;