rightBottomView.jsx 6.6 KB

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