oneQualified.jsx 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /*
  2. * @Author: dayan_hjm 一次合格率
  3. * @Date: 2023-10-23 09:32:12
  4. * @Last Modified by: dayan_hjm
  5. * @Last Modified time: 2023-11-29 10:53:47
  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. @withRouter
  15. class BottomLineForSend extends Component {
  16. // 构造函数,组件的实例创建时,最先执行
  17. constructor(props, context) {
  18. super(props, context);
  19. this.store = mod;
  20. this.state = {
  21. targeRate: [],
  22. year: [],
  23. qcRate: [],
  24. };
  25. }
  26. componentDidMount() {
  27. this.getUrl()
  28. }
  29. async getUrl() {
  30. await twoService().then(({ data = [], resultCode }) => {
  31. if (+resultCode === 0) {
  32. let year = [], qcRate = [], targeRate = [];
  33. data.map((x, i) => {
  34. year.push(x.bMonth);
  35. qcRate.push(x.qcRate)
  36. targeRate.push(x.targeRate)
  37. });
  38. this.setState({ year, targeRate, qcRate });
  39. this.setData();
  40. }
  41. });
  42. }
  43. roundFun(value=0) {
  44. value = value * 100;
  45. var str = parseFloat(value).toFixed(10);
  46. var num = str.substring(0,str.lastIndexOf('.')+3);
  47. return num
  48. }
  49. setData() {
  50. setTimeout(() => {
  51. // 基于准备好的dom,初始化echarts实例
  52. var myChart = echarts.init(document.getElementById('echarts5'));
  53. var option = {
  54. tooltip: {
  55. trigger: 'axis',
  56. axisPointer: { type: 'shadow' },
  57. borderColor: "rgba(105, 255, 222, 0.5)",
  58. borderWidth: 2,
  59. padding: 2,
  60. textStyle: {
  61. fontSize: 12,
  62. color: "#ededed"
  63. },
  64. formatter: (param)=> {
  65. return (param[0] && param[0].seriesName ? param[0].seriesName + ":" : "") + (param[0] && param[0].value ? this.roundFun(param[0].value) + "%<br />" : "") + (param[1] && param[1].seriesName ? param[1].seriesName + ":" : "") + (param[1] && param[1].value ? this.roundFun(param[1].value) + "%" : "")
  66. // return (
  67. // <div>
  68. // <p>
  69. // <span>{param[0] && param[0].seriesName ? param[0].seriesName + ":" : ""}</span>
  70. // <span>{param[0] && param[0].value ? param[0].value.toFixed(2) + "%<br />" : ""}</span>
  71. // </p>
  72. // <p>
  73. // <span>{param[1] && param[1].seriesName ? param[1].seriesName + ":" : ""}</span>
  74. // <span>{param[1] && param[1].value ? param[1].value.toFixed(2) + "%" : ""}</span>
  75. // </p>
  76. // </div>
  77. // )
  78. },
  79. // `{a0}: {c0}<br />{a1}: {c1}`,
  80. backgroundColor: "#0000008a"
  81. }, "grid": {
  82. "top": "20%",
  83. "right": "5%",
  84. "bottom": "20",
  85. "left": "7%",
  86. },
  87. legend: {
  88. data: ['目标一次及格率', '实际一次及格率'],
  89. right: 'center',
  90. padding: [10, 0, 0, 5],
  91. top: 0,
  92. textStyle: {
  93. color: "#fff",
  94. fontSize: 10,
  95. },
  96. itemWidth: 12,
  97. itemHeight: 5,
  98. },
  99. "xAxis": [
  100. {
  101. "type": "category",
  102. data: this.state.year,
  103. axisLine: { lineStyle: { color: "rgba(255,255,255,.1)" } },
  104. axisLabel: {
  105. textStyle: { color: "'#7d7d7d'", fontSize: '12', },
  106. },
  107. splitLine: {
  108. show: true,
  109. lineStyle: {
  110. color: '#3b3b3b',
  111. type: 'dashed',
  112. }
  113. }
  114. },
  115. ],
  116. "yAxis": [
  117. {
  118. type: 'value',
  119. axisLine: {
  120. lineStyle: {
  121. color: '#7d7d7d',
  122. type: 'dashed',
  123. },
  124. },
  125. axisTick: { show: false },
  126. axisLabel: {
  127. formatter: "{value}",
  128. textStyle: {
  129. color: '#7d7d7d',
  130. fontSize: 12
  131. }
  132. },
  133. splitLine: {
  134. show: true,
  135. lineStyle: {
  136. color: '#3b3b3b',
  137. type: 'dashed',
  138. }
  139. }
  140. },
  141. ],
  142. "series": [
  143. {
  144. "name": "目标一次及格率",
  145. "type": "line",
  146. data: this.state.targeRate,
  147. lineStyle: {
  148. normal: {
  149. width: 2
  150. },
  151. },
  152. "itemStyle": {
  153. "normal": {
  154. "color": "#69FFDE",
  155. }
  156. },
  157. "smooth": true
  158. },
  159. {
  160. "name": "实际一次及格率",
  161. "type": "line",
  162. data: this.state.qcRate,
  163. lineStyle: {
  164. normal: {
  165. width: 2
  166. },
  167. },
  168. "itemStyle": {
  169. "normal": {
  170. "color": "#FFCE00",
  171. }
  172. },
  173. "smooth": true
  174. }
  175. ]
  176. };
  177. // 使用刚指定的配置项和数据显示图表。
  178. myChart.setOption(option);
  179. window.addEventListener("resize", function () {
  180. myChart.resize();
  181. });
  182. }, 3000)
  183. }
  184. render() {
  185. return (
  186. <div className={["eacharView cbBottomLineForSend"]}>
  187. <div id="echarts5"></div>
  188. </div>
  189. )
  190. }
  191. }
  192. export default BottomLineForSend;