bottomRightChart2.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <div @click="openSteamUsed">
  3. <div id="bottomRightChart2" style="width:100%;height:2.6rem;">
  4. </div>
  5. <el-dialog class="my-info-dialog" :visible.sync="openChart" title="瞬时值" @open="open" width="1600px" destroy-on-close append-to-body>
  6. <div id="bottomRightChart2Dialog" style="width:100%;height:600px;"></div>
  7. </el-dialog>
  8. </div>
  9. </template>
  10. <script>
  11. import echartMixins from "@/utils/resizeMixins";
  12. import echarts from "@/api/cpms/echarts.min";
  13. export default {
  14. data() {
  15. return {
  16. chart:null,
  17. openChart: false,
  18. };
  19. },
  20. mixins: [echartMixins],
  21. mounted() {
  22. this.draw();
  23. },
  24. methods: {
  25. openSteamUsed(){
  26. this.openChart = true
  27. },
  28. open(){
  29. this.$nextTick(() => {
  30. this.drawDialog()
  31. })
  32. },
  33. draw() {
  34. // 基于准备好的dom,初始化echarts实例
  35. this.chart = this.echarts.init(document.getElementById('bottomRightChart2'))
  36. // let lineData = [
  37. // 820, 932, 901, 934, 1290, 1330, 1320
  38. // ];
  39. let option={
  40. legend:{
  41. orient:'horizontal',
  42. x: 'left',
  43. y: 'top',
  44. },
  45. grid: {
  46. top: '16%', // 等价于 y: '16%'
  47. left: '3%',
  48. right: '8%',
  49. bottom: '3%',
  50. containLabel: true
  51. },
  52. xAxis: {
  53. axisLine: {
  54. lineStyle: {
  55. // 设置x轴颜色
  56. color: '#ffffff'
  57. }
  58. },
  59. axisLabel: {
  60. rotate: 0, // 旋转角度
  61. interval: 1 //设置X轴数据间隔几个显示一个,为0表示都显示
  62. },
  63. boundaryGap: false,
  64. type: 'category',
  65. data: [
  66. '00:00-03:00',
  67. '03:00-06:00',
  68. '06:00-09:00',
  69. '09:00-12:00',
  70. '12:00-15:00',
  71. '15:00-18:00',
  72. '18:00-21:00',
  73. '21:00-00:00'
  74. ]
  75. },
  76. yAxis: {
  77. type: 'value',
  78. axisLine: {
  79. lineStyle: {
  80. // 设置x轴颜色
  81. color: '#ffffff'
  82. }
  83. },
  84. },
  85. series: [
  86. {
  87. data: [500, 680, 733, 470, 1290, 980, 1320,1580],
  88. type: 'line',
  89. smooth: 0.5,
  90. symbolSize: 10,
  91. areaStyle:{
  92. color:new echarts.graphic.LinearGradient(0,0,0,1,[{
  93. offset:0,
  94. color:'#92bda6',
  95. },{
  96. offset: 1,
  97. color: '#2480bb'
  98. }
  99. ])
  100. },
  101. itemStyle: {
  102. normal: {
  103. lineStyle:{
  104. width:1,
  105. type:'solid'
  106. },
  107. borderColor:'red',
  108. color: "#92bda6"
  109. }
  110. },
  111. },
  112. // {
  113. // name: 'HP',
  114. // type: "bar",
  115. // barGap: "-100%",
  116. // stack: 'Ad',
  117. // barWidth: 10,
  118. // itemStyle: {
  119. // normal: {
  120. // barBorderRadius: 5,
  121. // color: new this.echarts.graphic.LinearGradient(0, 0, 0, 1, [
  122. // { offset: 0, color: "#956FD4" },
  123. // { offset: 1, color: "#3EACE5" }
  124. // ])
  125. // }
  126. // },
  127. // z: -12,
  128. // data: lineData
  129. // },
  130. ]
  131. }
  132. this.chart.setOption(option);
  133. },
  134. drawDialog() {
  135. // 基于准备好的dom,初始化echarts实例
  136. this.chart1 = this.echarts.init(document.getElementById('bottomRightChart2Dialog'))
  137. // let lineData = [
  138. // 820, 932, 901, 934, 1290, 1330, 1320
  139. // ];
  140. let option={
  141. legend:{
  142. orient:'horizontal',
  143. x: 'left',
  144. y: 'top',
  145. },
  146. grid: {
  147. top: '16%', // 等价于 y: '16%'
  148. left: '3%',
  149. right: '8%',
  150. bottom: '3%',
  151. containLabel: true
  152. },
  153. xAxis: {
  154. axisLine: {
  155. lineStyle: {
  156. }
  157. },
  158. type: 'category',
  159. data: [
  160. '00:00-03:00',
  161. '03:00-06:00',
  162. '06:00-09:00',
  163. '09:00-12:00',
  164. '12:00-15:00',
  165. '15:00-18:00',
  166. '18:00-21:00',
  167. '21:00-00:00'
  168. ]
  169. },
  170. yAxis: {
  171. type: 'value',
  172. axisLine: {
  173. lineStyle: {
  174. }
  175. },
  176. },
  177. series: [
  178. {
  179. data: [500, 680, 733, 470, 1290, 980, 1320,1580],
  180. type: 'line',
  181. smooth: 0.5,
  182. symbolSize: 10,
  183. label: {
  184. show: true,
  185. position: 'top'
  186. },
  187. areaStyle:{
  188. color:new echarts.graphic.LinearGradient(0,0,0,1,[{
  189. offset:0,
  190. color:'#92bda6',
  191. },{
  192. offset: 1,
  193. color: '#2480bb'
  194. }
  195. ])
  196. },
  197. itemStyle: {
  198. normal: {
  199. lineStyle:{
  200. width:1,
  201. type:'solid'
  202. },
  203. borderColor:'red',
  204. color: "#92bda6"
  205. }
  206. },
  207. },
  208. ]
  209. }
  210. this.chart1.setOption(option);
  211. }
  212. },
  213. }
  214. </script>
  215. <style scoped>
  216. </style>