interactiveLine.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <div :id="id" style="height: 100%;width:100%;"></div>
  3. </template>
  4. <script>
  5. export default {
  6. data () {
  7. return {}
  8. },
  9. props:{
  10. id:{
  11. type: String
  12. }
  13. },
  14. mounted(){
  15. this.drawLine();
  16. },
  17. methods:{
  18. drawLine(){
  19. let _this = this
  20. // 基于准备好的dom,初始化echarts实例
  21. let myChart = this.$echarts.init(document.getElementById(this.id));
  22. let arrlabel = ["2017-11","2017-12","2018-01","2018-02","2018-03","2018-04","2018-05","2018-06","2018-07","2018-08","2018-09","2018-10","2018-11","2018-12","2019-01","2019-02","2019-03","2019-04"];
  23. let arrTotal1 = [29,245,94,0,310,301,481,207,1,27,713,1053,1312,1064,365,441,720,369];
  24. let arrTotal2 = ["26", "20", "2", "18", "27", "22", "26", "33", "9", "0", "40"];
  25. myChart.setOption({
  26. // backgroundColor: 'rgba(17, 17, 17, 0.14)',
  27. tooltip: {
  28. trigger: 'axis',
  29. borderRadius: 0,
  30. },
  31. grid: {
  32. left: '0',
  33. right: '0',
  34. bottom: '5%',
  35. top: '5%',
  36. containLabel: true,
  37. },
  38. xAxis: [{
  39. axisTick: {
  40. show: false,
  41. },
  42. type: 'category',
  43. axisLabel: {
  44. margin: 10,
  45. textStyle: {
  46. fontSize: 11,
  47. color: '#fafafa'
  48. },
  49. // interval:0,
  50. // formatter:function(val){
  51. // let firstOne = arrlabel[0];
  52. // let labellength = arrlabel.length
  53. // let lastOne = arrlabel[labellength-1];
  54. // if(firstOne != val && lastOne != val){
  55. // return val
  56. // }
  57. // }
  58. },
  59. boundaryGap: false,
  60. splitLine: {
  61. lineStyle: {
  62. color: 'rgba(185, 193, 173, 0.63)',
  63. },
  64. show: true
  65. },
  66. axisLine: {
  67. lineStyle: {
  68. color: 'rgba(185, 193, 173, 0.63)',
  69. width: 1,
  70. }
  71. },
  72. data: arrlabel
  73. }],
  74. yAxis: [{
  75. type: 'value',
  76. // name: '单 位(%)',
  77. axisTick: {
  78. show: false
  79. },
  80. axisLine: {
  81. show: true,
  82. lineStyle: {
  83. color: 'rgba(185, 193, 173, 0.63)',
  84. }
  85. },
  86. axisLabel: {
  87. margin: 10,
  88. textStyle: {
  89. fontSize: 11,
  90. color:'#fafafa'
  91. }
  92. },
  93. splitLine: {
  94. show: true,
  95. lineStyle: {
  96. color: 'rgba(185, 193, 173, 0.63)',
  97. }
  98. }
  99. }],
  100. series: [{
  101. // name: '实名率',
  102. type: 'line',
  103. // symbol: 'circle',
  104. //symbolSize: 5,
  105. // showSymbol: false,
  106. // markPoint: { // markLine 也是同理
  107. // data: [{
  108. // coord: [0,1,2,3,4], // 其中 5 表示 xAxis.data[5],即 '33' 这个元素。
  109. // // coord: ['5', 33.4] // 其中 '5' 表示 xAxis.data中的 '5' 这个元素。
  110. // // 注意,使用这种方式时,xAxis.data 不能写成 [number, number, ...]
  111. // // 而只能写成 [string, string, ...]
  112. // }]
  113. // },
  114. lineStyle: {
  115. normal: {
  116. width: 2
  117. }
  118. },
  119. areaStyle: {
  120. normal: {
  121. // 渐变色
  122. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  123. offset: 0,
  124. color: "rgba(28, 208, 161, 1)" // 0% 处的颜色
  125. },{
  126. offset: 1,
  127. color: "rgba(28, 208, 161, 0.5)" // 100% 处的颜色
  128. }], false)
  129. },
  130. },
  131. itemStyle: {
  132. normal: {
  133. areaStyle: {
  134. type: 'default'
  135. },
  136. color: '#1CD0A1',
  137. },
  138. emphasis: {
  139. // color: 'rgb(0,196,132)',
  140. borderColor: 'rgba(0,196,132,0.2)',
  141. extraCssText: 'box-shadow: 8px 8px 8px rgba(0, 0, 0, 1);',
  142. // borderWidth: 10
  143. }
  144. },
  145. data: arrTotal1
  146. },
  147. // {
  148. // type: 'line',
  149. // lineStyle: {
  150. // normal: {
  151. // width: 2
  152. // }
  153. // },
  154. // areaStyle: {
  155. // normal: {
  156. // // 渐变色
  157. // color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  158. // offset: 0,
  159. // color: "rgba(72, 219, 252, 1)" // 0% 处的颜色
  160. // },{
  161. // offset: 1,
  162. // color: "rgba(72, 219, 252, 0.5)" // 100% 处的颜色
  163. // }], false)
  164. // },
  165. // },
  166. // itemStyle: {
  167. // normal: {
  168. // areaStyle: {
  169. // type: 'default'
  170. // },
  171. // color: '#48DBFC',
  172. // },
  173. // emphasis: {
  174. // // color: 'rgb(0,196,132)',
  175. // borderColor: 'rgba(0,196,132,0.2)',
  176. // extraCssText: 'box-shadow: 8px 8px 8px rgba(0, 0, 0, 1);',
  177. // // borderWidth: 10
  178. // }
  179. // },
  180. // data: arrTotal2
  181. // }
  182. ]
  183. });
  184. }
  185. }
  186. }
  187. </script>
  188. <style>
  189. </style>