oneQualified.jsx 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /*
  2. * @Author: dayan_hjm 一次合格率
  3. * @Date: 2023-10-23 09:32:12
  4. * @Last Modified by: dayan_hjm
  5. * @Last Modified time: 2023-12-19 16:02:23
  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": "10%",
  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. min:0.9,
  126. max:1,
  127. splitNumber:5,
  128. axisTick: { show: false },
  129. axisLabel: {
  130. formatter: (value)=>{
  131. return value*100 + '%'
  132. },
  133. textStyle: {
  134. color: '#7d7d7d',
  135. fontSize: 12
  136. }
  137. },
  138. splitLine: {
  139. show: true,
  140. lineStyle: {
  141. color: '#3b3b3b',
  142. type: 'dashed',
  143. }
  144. }
  145. },
  146. ],
  147. "series": [
  148. {
  149. "name": "目标一次合格率",
  150. "type": "line",
  151. data: this.state.targeRate,
  152. lineStyle: {
  153. normal: {
  154. width: 2
  155. },
  156. },
  157. "itemStyle": {
  158. "normal": {
  159. "color": "#69FFDE",
  160. }
  161. },
  162. "smooth": true
  163. },
  164. {
  165. "name": "实际一次合格率",
  166. "type": "line",
  167. data: this.state.qcRate,
  168. lineStyle: {
  169. normal: {
  170. width: 2
  171. },
  172. },
  173. "itemStyle": {
  174. "normal": {
  175. "color": "#FFCE00",
  176. }
  177. },
  178. "smooth": true
  179. }
  180. ]
  181. };
  182. // 使用刚指定的配置项和数据显示图表。
  183. myChart.setOption(option);
  184. window.addEventListener("resize", function () {
  185. myChart.resize();
  186. });
  187. }, 3000)
  188. }
  189. render() {
  190. return (
  191. <div className={["eacharView cbBottomLineForSend"]}>
  192. <div id="echarts5"></div>
  193. </div>
  194. )
  195. }
  196. }
  197. export default BottomLineForSend;