right-middle.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <template>
  2. <div class="right_middle">
  3. <Echart
  4. :options="options"
  5. id="rightMiddleChart"
  6. class="echarts_top"
  7. ></Echart>
  8. </div>
  9. </template>
  10. <script>
  11. import { graphic } from "echarts";
  12. export default {
  13. data() {
  14. return {
  15. options: {},
  16. };
  17. },
  18. props: {},
  19. mounted() {
  20. this.getData();
  21. },
  22. methods: {
  23. getData() {
  24. this.init({
  25. "timePoints": ['00:00', '01:00', '02:00', '03:00', '04:00', '05:00',
  26. '06:00', '07:00', '08:00', '09:00', '10:00', '11:00',
  27. '12:00', '13:00', '14:00', '15:00', '16:00', '17:00',
  28. '18:00', '19:00', '20:00', '21:00', '22:00', '23:00'],
  29. "jhData": [
  30. 1060,
  31. 1020,
  32. 1000,
  33. 970,
  34. 950,
  35. 980,
  36. 995,
  37. 1020,
  38. 1050,
  39. 1080,
  40. 1140,
  41. 1200,
  42. 1160,
  43. 1100,
  44. 1180,
  45. 1200,
  46. 1240,
  47. 1280,
  48. 1255,
  49. 1240,
  50. 1250,
  51. 1260,
  52. 1140,
  53. 1050
  54. ],
  55. "sfData": [
  56. 1100,
  57. 1085,
  58. 1060,
  59. 1032,
  60. 980,
  61. 1020,
  62. 1045,
  63. 1030,
  64. 1095,
  65. 1120,
  66. 1180,
  67. 1220,
  68. 1235
  69. ],
  70. "ycData": [
  71. 1160,
  72. 1120,
  73. 1100,
  74. 1070,
  75. 1050,
  76. 1080,
  77. 1095,
  78. 1120,
  79. 1150,
  80. 1180,
  81. 1240,
  82. 1300,
  83. 1330,
  84. 1200,
  85. 1280,
  86. 1300,
  87. 1340,
  88. 1380,
  89. 1355,
  90. 1340,
  91. 1350,
  92. 1360,
  93. 1240,
  94. 1150
  95. ]
  96. })
  97. },
  98. init(newData) {
  99. this.options = {
  100. title: {
  101. subtext: "MW",
  102. left: '5%',
  103. top: '5px',
  104. // left: 15,// 距离左边位置
  105. // top: -10,// 距离上面位置
  106. subtextStyle: { // 设置二级标题的样式
  107. color: "#efefef"
  108. }
  109. },
  110. tooltip: {
  111. trigger: "axis",
  112. backgroundColor: "rgba(0,0,0,.6)",
  113. borderColor: "rgba(147, 235, 248, .8)",
  114. textStyle: {
  115. color: "#efefef",
  116. },
  117. },
  118. legend: {
  119. textStyle: {
  120. color: "#efefef",
  121. },
  122. itemStyle: {
  123. // 去掉图例上的圆圈
  124. opacity: 0
  125. },
  126. top: "20",
  127. },
  128. grid: {
  129. top: '20%',
  130. left: '6%',
  131. right: '2%',
  132. bottom: '3%',
  133. containLabel: true
  134. },
  135. xAxis: {
  136. data: newData.timePoints,
  137. axisLine: {
  138. lineStyle: {
  139. color: "#efefef",
  140. },
  141. },
  142. axisTick: {
  143. show: false,
  144. },
  145. },
  146. yAxis: {
  147. scale: true,//yAxis 刻度 自适应 最大值/最小值
  148. splitLine: {
  149. show: true,
  150. lineStyle: {
  151. color: "#efefef",
  152. type: 'dashed'
  153. }
  154. },
  155. axisLine: {
  156. lineStyle: {
  157. color: "#efefef",
  158. },
  159. },
  160. // // y轴横线
  161. // axisTick: {
  162. // show: true
  163. // }
  164. },
  165. series: [
  166. {
  167. name: "计划值",
  168. type: "line",
  169. smooth: true,
  170. // showAllSymbol: true,
  171. // symbol: "emptyCircle",
  172. symbolSize: 0,
  173. itemStyle: {
  174. color: "#f0e62f",
  175. },
  176. data: newData.jhData.sort(function () {
  177. return Math.random() - 0.5
  178. }),
  179. },
  180. {
  181. name: "实发值",
  182. type: "line",
  183. smooth: true,
  184. // showAllSymbol: true,
  185. // symbol: "emptyCircle",
  186. symbolSize: 0,
  187. itemStyle: {
  188. color: "#2ff1e7",
  189. },
  190. label: {
  191. show: true,
  192. position: 'right',
  193. textStyle: {
  194. fontSize: 16,
  195. fontWeight: 1000,
  196. color: "#2ff0bd"
  197. },
  198. formatter: (params) => {
  199. if (newData.sfData.length - 1 == params.dataIndex) {
  200. return params.value
  201. } else {
  202. return ""
  203. }
  204. },
  205. },
  206. markLine: {
  207. // 锁定最后一个元素展示纵向虚线
  208. symbol: ['none', 'none'],
  209. label: { show: false },
  210. data: [{ xAxis: newData.sfData.length - 1 }],
  211. },
  212. areaStyle: {
  213. //右,下,左,上
  214. color: new graphic.LinearGradient(
  215. 0, 0, 0, 1,
  216. [
  217. {
  218. offset: 0,
  219. color: "rgba(58,249,224,0.85)",
  220. },
  221. {
  222. offset: 1,
  223. color: "rgba(9,202,243,.0)",
  224. },
  225. ],
  226. false
  227. ),
  228. },
  229. data: newData.sfData.sort(function () {
  230. return Math.random() - 0.5
  231. }),
  232. },
  233. {
  234. name: "预测值",
  235. type: "line",
  236. smooth: true,
  237. // showAllSymbol: true,
  238. // symbol: "emptyCircle",
  239. symbolSize: 0,
  240. lineStyle: {
  241. color: "#f0692f",
  242. type: 'dashed'
  243. },
  244. data: newData.ycData.sort(function () {
  245. return Math.random() - 0.5
  246. }),
  247. },
  248. ],
  249. };
  250. },
  251. },
  252. };
  253. </script>
  254. <style lang="scss" scoped>
  255. .right_middle {
  256. width: 100%;
  257. height: 100%;
  258. .echarts_top {
  259. width: 100%;
  260. height: 100%;
  261. }
  262. }
  263. </style>