lineMarker.vue 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <div :class="className" :id="id" :style="{height:height,width:width}"></div>
  3. </template>
  4. <script>
  5. import echarts from 'echarts'
  6. import resize from './mixins/resize'
  7. export default {
  8. mixins: [resize],
  9. props: {
  10. className: {
  11. type: String,
  12. default: 'chart'
  13. },
  14. id: {
  15. type: String,
  16. default: 'chart'
  17. },
  18. width: {
  19. type: String,
  20. default: '200px'
  21. },
  22. height: {
  23. type: String,
  24. default: '200px'
  25. }
  26. },
  27. data() {
  28. return {
  29. chart: null
  30. }
  31. },
  32. mounted() {
  33. this.initChart()
  34. },
  35. beforeDestroy() {
  36. if (!this.chart) {
  37. return
  38. }
  39. this.chart.dispose()
  40. this.chart = null
  41. },
  42. methods: {
  43. initChart() {
  44. this.chart = echarts.init(document.getElementById(this.id))
  45. this.chart.setOption({
  46. backgroundColor: '#394056',
  47. title: {
  48. top: 20,
  49. text: 'Requests',
  50. textStyle: {
  51. fontWeight: 'normal',
  52. fontSize: 16,
  53. color: '#F1F1F3'
  54. },
  55. left: '1%'
  56. },
  57. tooltip: {
  58. trigger: 'axis',
  59. axisPointer: {
  60. lineStyle: {
  61. color: '#57617B'
  62. }
  63. }
  64. },
  65. legend: {
  66. top: 20,
  67. icon: 'rect',
  68. itemWidth: 14,
  69. itemHeight: 5,
  70. itemGap: 13,
  71. data: ['CMCC', 'CTCC', 'CUCC'],
  72. right: '4%',
  73. textStyle: {
  74. fontSize: 12,
  75. color: '#F1F1F3'
  76. }
  77. },
  78. grid: {
  79. top: 100,
  80. left: '3%',
  81. right: '4%',
  82. bottom: '2%',
  83. containLabel: true
  84. },
  85. xAxis: [{
  86. type: 'category',
  87. boundaryGap: false,
  88. axisLine: {
  89. lineStyle: {
  90. color: '#57617B'
  91. }
  92. },
  93. data: ['13:00', '13:05', '13:10', '13:15', '13:20', '13:25', '13:30', '13:35', '13:40', '13:45', '13:50', '13:55']
  94. }],
  95. yAxis: [{
  96. type: 'value',
  97. name: '(%)',
  98. axisTick: {
  99. show: false
  100. },
  101. axisLine: {
  102. lineStyle: {
  103. color: '#57617B'
  104. }
  105. },
  106. axisLabel: {
  107. margin: 10,
  108. textStyle: {
  109. fontSize: 14
  110. }
  111. },
  112. splitLine: {
  113. lineStyle: {
  114. color: '#57617B'
  115. }
  116. }
  117. }],
  118. series: [{
  119. name: 'CMCC',
  120. type: 'line',
  121. smooth: true,
  122. symbol: 'circle',
  123. symbolSize: 5,
  124. showSymbol: false,
  125. lineStyle: {
  126. normal: {
  127. width: 1
  128. }
  129. },
  130. areaStyle: {
  131. normal: {
  132. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  133. offset: 0,
  134. color: 'rgba(137, 189, 27, 0.3)'
  135. }, {
  136. offset: 0.8,
  137. color: 'rgba(137, 189, 27, 0)'
  138. }], false),
  139. shadowColor: 'rgba(0, 0, 0, 0.1)',
  140. shadowBlur: 10
  141. }
  142. },
  143. itemStyle: {
  144. normal: {
  145. color: 'rgb(137,189,27)',
  146. borderColor: 'rgba(137,189,2,0.27)',
  147. borderWidth: 12
  148. }
  149. },
  150. data: [220, 182, 191, 134, 150, 120, 110, 125, 145, 122, 165, 122]
  151. }, {
  152. name: 'CTCC',
  153. type: 'line',
  154. smooth: true,
  155. symbol: 'circle',
  156. symbolSize: 5,
  157. showSymbol: false,
  158. lineStyle: {
  159. normal: {
  160. width: 1
  161. }
  162. },
  163. areaStyle: {
  164. normal: {
  165. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  166. offset: 0,
  167. color: 'rgba(0, 136, 212, 0.3)'
  168. }, {
  169. offset: 0.8,
  170. color: 'rgba(0, 136, 212, 0)'
  171. }], false),
  172. shadowColor: 'rgba(0, 0, 0, 0.1)',
  173. shadowBlur: 10
  174. }
  175. },
  176. itemStyle: {
  177. normal: {
  178. color: 'rgb(0,136,212)',
  179. borderColor: 'rgba(0,136,212,0.2)',
  180. borderWidth: 12
  181. }
  182. },
  183. data: [120, 110, 125, 145, 122, 165, 122, 220, 182, 191, 134, 150]
  184. }, {
  185. name: 'CUCC',
  186. type: 'line',
  187. smooth: true,
  188. symbol: 'circle',
  189. symbolSize: 5,
  190. showSymbol: false,
  191. lineStyle: {
  192. normal: {
  193. width: 1
  194. }
  195. },
  196. areaStyle: {
  197. normal: {
  198. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  199. offset: 0,
  200. color: 'rgba(219, 50, 51, 0.3)'
  201. }, {
  202. offset: 0.8,
  203. color: 'rgba(219, 50, 51, 0)'
  204. }], false),
  205. shadowColor: 'rgba(0, 0, 0, 0.1)',
  206. shadowBlur: 10
  207. }
  208. },
  209. itemStyle: {
  210. normal: {
  211. color: 'rgb(219,50,51)',
  212. borderColor: 'rgba(219,50,51,0.2)',
  213. borderWidth: 12
  214. }
  215. },
  216. data: [220, 182, 125, 145, 122, 191, 134, 150, 120, 110, 165, 122]
  217. }]
  218. })
  219. }
  220. }
  221. }
  222. </script>