rightBottomView.jsx 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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-01 15:01:37
  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. dataengineCenterOneservice,
  13. } from "../api";
  14. @withRouter
  15. class RightBottomView extends Component {
  16. // 构造函数,组件的实例创建时,最先执行
  17. constructor(props, context) {
  18. super(props, context);
  19. this.store = mod;
  20. this.state = {
  21. };
  22. }
  23. componentDidMount() {
  24. this.getUrl()
  25. this.setData();
  26. this.setData2();
  27. }
  28. getUrl(){
  29. dataengineCenterOneservice().then(({ data, resultCode }) => {
  30. if (+resultCode === 0) {
  31. }
  32. });
  33. }
  34. setData() {
  35. setTimeout(() => {
  36. // 基于准备好的dom,初始化echarts实例
  37. var myChart = echarts.init(document.getElementById('echarts8'));
  38. var myColor = ['#eb2100', '#eb3600', '#d0570e', '#d0a00e', '#34da62', '#00e9db', '#00c0e9', '#0096f3'];
  39. var option = {
  40. grid: {
  41. left: '5%',
  42. top: '15%',
  43. right: '5%',
  44. bottom: '0%',
  45. containLabel: true
  46. },
  47. xAxis: [{
  48. show: false,
  49. }],
  50. yAxis: [{
  51. axisTick: 'none',
  52. axisLine: 'none',
  53. axisLabel: {
  54. padding:[0,25,0,0],
  55. textStyle: {
  56. color: '#69FFDE',
  57. fontSize: '16',
  58. fontWeight: 700,
  59. fontFamily: 'DingTalkJinBuTi',
  60. }
  61. },
  62. data: ['2020', '2021', '2022']
  63. },
  64. {
  65. name: '单位:件',
  66. nameGap: '50',
  67. nameTextStyle: {
  68. color: 'rgba(255,255,255,.6)',
  69. fontSize: '16',
  70. },
  71. axisLine: {
  72. lineStyle: {
  73. color: 'rgba(0,0,0,0)'
  74. }
  75. },
  76. data: [],
  77. }],
  78. legend: {
  79. data: '碳排放强度',
  80. // right: 'center',
  81. // top: 0,
  82. textStyle: {
  83. color: "#fff",
  84. fontSize: 12
  85. },
  86. itemWidth: 12,
  87. itemHeight: 10,
  88. },
  89. series: [{
  90. name: '条',
  91. type: 'bar',
  92. yAxisIndex: 0,
  93. data: [88, 73, 34],
  94. label: {
  95. normal: {
  96. show: true,
  97. position: 'insideBottomLeft',
  98. formatter: function (param) {
  99. return param.value;
  100. },
  101. textStyle: {
  102. color: 'rgba(255,255,255,1)',
  103. fontSize: '15',
  104. padding:[5,0,0,5]
  105. }
  106. }
  107. },
  108. barWidth: 23,
  109. itemStyle: {
  110. normal: {
  111. color: new echarts.graphic.LinearGradient(1, 0, 0, 0, [
  112. { offset: 0, color: 'rgba(255, 206, 0, 1)' },
  113. { offset: 0.7, color: '#ffd01d94' },
  114. { offset: 1, color: '#ffd01d94' },
  115. ]),
  116. barBorderRadius: 15,
  117. borderColor: "rgba(255, 206, 0, 1)",
  118. borderWidth: 1
  119. },
  120. },
  121. z: 2
  122. }, {
  123. name: '白框',
  124. type: 'bar',
  125. yAxisIndex: 1,
  126. barGap: '-100%',
  127. data: [99.5, 99.5, 99.5],
  128. barWidth: 23,
  129. itemStyle: {
  130. normal: {
  131. color: '#ffffff24',
  132. barBorderRadius: 15,
  133. }
  134. },
  135. z: 1
  136. }]
  137. };
  138. // 使用刚指定的配置项和数据显示图表。
  139. myChart.setOption(option);
  140. window.addEventListener("resize", function () {
  141. myChart.resize();
  142. });
  143. }, 3000)
  144. }
  145. setData2() {
  146. setTimeout(() => {
  147. // 基于准备好的dom,初始化echarts实例
  148. var myChart = echarts.init(document.getElementById('echarts9'));
  149. var myColor = ['#eb2100', '#eb3600', '#d0570e', '#d0a00e', '#34da62', '#00e9db', '#00c0e9', '#0096f3'];
  150. var option = {
  151. grid: {
  152. left: '0%',
  153. top: '15%',
  154. right: '5%',
  155. bottom: '0%',
  156. containLabel: true
  157. },
  158. xAxis: [{
  159. show: false,
  160. inverse: true,
  161. }],
  162. yAxis: [{
  163. axisTick: 'none',
  164. axisLine: 'none',
  165. offset: '15',
  166. axisLine: {
  167. onZero: false
  168. },
  169. axisLabel: {
  170. textStyle: {
  171. color: 'rgba(255,255,255,.6)',
  172. fontSize: '0',
  173. }
  174. },
  175. data: ['字段1', '字段2', '字段3']
  176. },
  177. {
  178. name: '单位:件',
  179. nameGap: '50',
  180. nameTextStyle: {
  181. color: 'rgba(255,255,255,.6)',
  182. fontSize: '16',
  183. },
  184. axisLine: {
  185. lineStyle: {
  186. color: 'rgba(0,0,0,0)'
  187. }
  188. },
  189. data: [],
  190. }],
  191. series: [{
  192. name: '条',
  193. type: 'bar',
  194. yAxisIndex: 0,
  195. data: [25, 55, 88],
  196. animation:true,
  197. animationDuration:3000,
  198. smooth: true,
  199. label: {
  200. normal: {
  201. show: true,
  202. position: 'insideRight',
  203. formatter: function (param) {
  204. return param.value;
  205. },
  206. textStyle: {
  207. color: 'rgba(255,255,255,1)',
  208. fontSize: '15',
  209. padding:[5,5,0,0]
  210. }
  211. }
  212. },
  213. barWidth: 23,
  214. itemStyle: {
  215. normal: {
  216. color: new echarts.graphic.LinearGradient(1, 0, 0, 0, [
  217. { offset: 1, color: '#69FFDE' },
  218. { offset: 0.75, color: '#69FFDE' },
  219. { offset: 0, color: 'rgb(83 211 183 / 15%)' },
  220. ]),
  221. barBorderRadius: 15,
  222. borderColor: "#69FFDE",
  223. borderWidth: 1
  224. }
  225. },
  226. z: 2
  227. }, {
  228. name: '白框',
  229. type: 'bar',
  230. yAxisIndex: 1,
  231. barGap: '-100%',
  232. data: [99.5, 99.5, 99.5],
  233. animation:true,
  234. animationDuration:3000,
  235. smooth: true,
  236. barWidth: 23,
  237. itemStyle: {
  238. normal: {
  239. color: '#ffffff24',
  240. barBorderRadius: 15,
  241. }
  242. },
  243. z: 1
  244. }]
  245. };
  246. // 使用刚指定的配置项和数据显示图表。
  247. myChart.setOption(option);
  248. window.addEventListener("resize", function () {
  249. myChart.resize();
  250. });
  251. }, 3000)
  252. }
  253. render() {
  254. return (
  255. <div className={["eacharView cbRightBottomView"]}>
  256. <span className="right_b_tip1">碳排放强度</span>
  257. <div id="echarts9"></div>
  258. {/* <div className="fonts">
  259. </div> */}
  260. <span className="right_b_tip2">碳排放总量/万吨</span>
  261. <div id="echarts8"></div>
  262. </div>
  263. )
  264. }
  265. }
  266. export default RightBottomView;