leftMenoyView.jsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. /*
  2. * @Author: dayan_hjm 库存金额
  3. * @Date: 2023-10-23 09:32:12
  4. * @Last Modified by: dayan_hjm
  5. * @Last Modified time: 2023-10-30 11:24:04
  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. @withRouter
  12. class LeftMenoyView extends Component {
  13. // 构造函数,组件的实例创建时,最先执行
  14. constructor(props, context) {
  15. super(props, context);
  16. this.store = mod;
  17. this.state = {
  18. };
  19. }
  20. componentDidMount() {
  21. this.setData();
  22. this.setData2();
  23. }
  24. setData() {
  25. setTimeout(() => {
  26. // 基于准备好的dom,初始化echarts实例
  27. var myChart = echarts.init(document.getElementById('echarts4'));
  28. var myColor = ['#eb2100', '#eb3600', '#d0570e', '#d0a00e', '#34da62', '#00e9db', '#00c0e9', '#0096f3'];
  29. var option = {
  30. grid: {
  31. left: '0%',
  32. top: '1%',
  33. right: '5%',
  34. bottom: '0%',
  35. containLabel: true
  36. },
  37. xAxis: [{
  38. show: false,
  39. }],
  40. yAxis: [{
  41. axisTick: 'none',
  42. axisLine: 'none',
  43. offset: '7',
  44. axisLabel: {
  45. textStyle: {
  46. color: 'rgba(255,255,255,.9)',
  47. fontSize: '0',
  48. }
  49. },
  50. data: ['碳酸锂', '氧化纳', '金属锂', '氢氧化钠']
  51. },
  52. {
  53. name: '单位:件',
  54. nameGap: '50',
  55. nameTextStyle: {
  56. color: 'rgba(255,255,255,.6)',
  57. fontSize: '16',
  58. },
  59. axisLine: {
  60. lineStyle: {
  61. color: 'rgba(0,0,0,0)'
  62. }
  63. },
  64. data: [],
  65. }],
  66. series: [{
  67. name: '条',
  68. type: 'bar',
  69. yAxisIndex: 0,
  70. data: [{
  71. value: 25, name: '碳酸锂', itemStyle: {
  72. normal: {
  73. // barBorderRadius: 15,
  74. // borderColor: "rgba(141, 147, 255, 1)",
  75. // borderWidth: 1,
  76. color: {
  77. // 完成的圆环的颜色
  78. colorStops: [
  79. {
  80. offset: 0,
  81. color: 'rgba(141, 147, 255, 0.3)', // 0% 处的颜色
  82. },
  83. {
  84. offset: 1,
  85. color: 'rgba(141, 147, 255, 1)', // 100% 处的颜色
  86. },
  87. ],
  88. },
  89. },
  90. },
  91. }, {
  92. value: 33, name: '氧化纳', itemStyle: {
  93. normal: {
  94. // barBorderRadius: 15,
  95. // borderColor: "rgba(105, 255, 222, 1)",
  96. // borderWidth: 1,
  97. color: {
  98. // 完成的圆环的颜色
  99. colorStops: [
  100. {
  101. offset: 0,
  102. color: 'rgba(105, 255, 222, 0.3)', // 0% 处的颜色
  103. },
  104. {
  105. offset: 1,
  106. color: 'rgba(105, 255, 222, 1)', // 100% 处的颜色
  107. },
  108. ],
  109. },
  110. },
  111. },
  112. }, {
  113. value: 35, name: '金属锂', itemStyle: {
  114. normal: {
  115. // barBorderRadius: 15,
  116. // borderColor: "rgba(47, 210, 255, 1)",
  117. // borderWidth: 1,
  118. color: {
  119. // 完成的圆环的颜色
  120. colorStops: [
  121. {
  122. offset: 0,
  123. color: 'rgba(47, 210, 255, 0.3)', // 0% 处的颜色
  124. },
  125. {
  126. offset: 1,
  127. color: 'rgba(47, 210, 255, 1)', // 100% 处的颜色
  128. },
  129. ],
  130. },
  131. },
  132. },
  133. }, {
  134. value: 40, name: '氢氧化钠', itemStyle: {
  135. normal: {
  136. // barBorderRadius: 15,
  137. // borderColor: "rgba(255, 206, 0, 1)",
  138. // borderWidth: 1,
  139. color: {
  140. // 完成的圆环的颜色
  141. colorStops: [
  142. {
  143. offset: 0,
  144. color: 'rgba(255, 206, 0, 0.3)', // 0% 处的颜色
  145. },
  146. {
  147. offset: 1,
  148. color: 'rgba(255, 206, 0, 1)', // 100% 处的颜色
  149. },
  150. ],
  151. },
  152. },
  153. },
  154. }],
  155. label: {
  156. normal: {
  157. show: true,
  158. position: 'right',
  159. formatter: function (param) {
  160. return param.value + '万元';
  161. // return param.name+":"+param.value + '万元';
  162. },
  163. textStyle: {
  164. color: 'rgba(255,255,255,1)',
  165. fontSize: '12',
  166. }
  167. }
  168. },
  169. barWidth: 15,
  170. itemStyle: {
  171. normal: {
  172. color: new echarts.graphic.LinearGradient(1, 0, 0, 0, [
  173. { offset: 0, color: 'rgba(255, 206, 0, 1)' },
  174. { offset: 0.7, color: '#ffd01d94' },
  175. { offset: 1, color: '#ffd01d94' },
  176. ]),
  177. barBorderRadius: 15,
  178. // borderColor: "rgba(255, 206, 0, 1)",
  179. // borderWidth: 1
  180. }
  181. },
  182. labelLine: {
  183. length: 10,
  184. length2: 50,
  185. },
  186. labelLayout: {
  187. x: "20%",
  188. y: "20%",
  189. verticalAlign: "bottom",
  190. dy: -10,
  191. },
  192. z: 2
  193. }, {
  194. name: '白框',
  195. type: 'bar',
  196. yAxisIndex: 1,
  197. barGap: '-100%',
  198. data: [99.5, 99.5, 99.5, 99.5],
  199. barWidth: 15,
  200. itemStyle: {
  201. normal: {
  202. color: '#ffffff24',
  203. barBorderRadius: 15,
  204. }
  205. },
  206. z: 1
  207. }]
  208. };
  209. // 使用刚指定的配置项和数据显示图表。
  210. myChart.setOption(option);
  211. window.addEventListener("resize", function () {
  212. myChart.resize();
  213. });
  214. }, 200)
  215. }
  216. setData2() {
  217. setTimeout(() => {
  218. // 基于准备好的dom,初始化echarts实例
  219. var myChart = echarts.init(document.getElementById('echarts6'));
  220. var option = {
  221. title: {
  222. text: '16%',
  223. subtext: '氢氧化钠',
  224. x: 'center',
  225. y: '40%',
  226. textStyle: {
  227. color: '#fff',
  228. fontSize: 20,
  229. lineHeight: 10,
  230. },
  231. subtextStyle: {
  232. color: 'rgba(205, 241, 255, 1)',
  233. fontSize: 14,
  234. lineHeight: 10,
  235. marginTop: 15,
  236. },
  237. },
  238. tooltip: {
  239. trigger: 'item',
  240. formatter: "{b} : {c} ({d}%)"
  241. },
  242. visualMap: {
  243. show: false,
  244. min: 500,
  245. max: 600,
  246. inRange: {
  247. //colorLightness: [0, 1]
  248. }
  249. },
  250. series: [{
  251. name: '访问来源',
  252. type: 'pie',
  253. radius: ['50%', '70%'],
  254. center: ['50%', '50%'],
  255. color: ['rgb(131,249,103)', '#8D93FF', '#2FD2FF', '#FFCE00'], //'#FBFE27','rgb(11,228,96)','#FE5050'
  256. data: [{
  257. value: 205,
  258. name: '直接访问',
  259. itemStyle: {
  260. normal: {
  261. color: {
  262. // 完成的圆环的颜色
  263. colorStops: [
  264. {
  265. offset: 0,
  266. color: 'rgba(141, 147, 255, 0.3)', // 0% 处的颜色
  267. },
  268. {
  269. offset: 1,
  270. color: 'rgba(141, 147, 255, 1)', // 100% 处的颜色
  271. },
  272. ],
  273. },
  274. },
  275. },
  276. },
  277. {
  278. value: 310,
  279. name: '邮件营销',
  280. itemStyle: {
  281. normal: {
  282. color: {
  283. // 完成的圆环的颜色
  284. colorStops: [
  285. {
  286. offset: 0,
  287. color: 'rgba(105, 255, 222, 0.3)', // 0% 处的颜色
  288. },
  289. {
  290. offset: 1,
  291. color: 'rgba(105, 255, 222, 1)', // 100% 处的颜色
  292. },
  293. ],
  294. },
  295. },
  296. },
  297. },
  298. {
  299. value: 234,
  300. name: '联盟广告',
  301. itemStyle: {
  302. normal: {
  303. color: {
  304. // 完成的圆环的颜色
  305. colorStops: [
  306. {
  307. offset: 0,
  308. color: 'rgba(47, 210, 255, 0.3)', // 0% 处的颜色
  309. },
  310. {
  311. offset: 1,
  312. color: 'rgba(47, 210, 255, 1)', // 100% 处的颜色
  313. },
  314. ],
  315. },
  316. },
  317. },
  318. },
  319. {
  320. value: 135,
  321. name: '视频广告学习相',
  322. itemStyle: {
  323. normal: {
  324. barBorderRadius: 15,
  325. color: {
  326. // 完成的圆环的颜色
  327. colorStops: [
  328. {
  329. offset: 0,
  330. color: 'rgba(255, 206, 0, 0.3)', // 0% 处的颜色
  331. },
  332. {
  333. offset: 1,
  334. color: 'rgba(255, 206, 0, 1)', // 100% 处的颜色
  335. },
  336. ],
  337. },
  338. },
  339. },
  340. },
  341. ],
  342. roseType: 'radius',
  343. label: {
  344. show: false
  345. },
  346. labelLine: {
  347. show: false
  348. }
  349. }]
  350. };
  351. // 使用刚指定的配置项和数据显示图表。
  352. myChart.setOption(option);
  353. window.addEventListener("resize", function () {
  354. myChart.resize();
  355. });
  356. }, 200)
  357. }
  358. render() {
  359. return (
  360. <div className={["eacharView cbLeftMenoyView"]}>
  361. <div id="echarts6"></div>
  362. <ul className={"name_ul"}>
  363. <li>碳酸锂</li>
  364. <li>氧化纳</li>
  365. <li>金属锂</li>
  366. <li>氢氧化钠</li>
  367. </ul>
  368. <div id="echarts4"></div>
  369. </div>
  370. )
  371. }
  372. }
  373. export default LeftMenoyView;