东西湖大屏
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

165 lines
3.7 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <div id="main" :style="{height:height,width:width}" />
  3. </template>
  4. <script>
  5. import echarts from 'echarts'
  6. import resize from '@/utils/resizeMixins.js'
  7. export default {
  8. name: 'AcrossEcharts',
  9. mixins: [resize],
  10. props: {
  11. chartData: {
  12. type: Object,
  13. require: true,
  14. default: function() {
  15. return {}
  16. }
  17. },
  18. width: {
  19. type: String,
  20. default: '100%'
  21. },
  22. height: {
  23. type: String,
  24. default: '100%'
  25. }
  26. },
  27. data() {
  28. return {
  29. chart: null
  30. }
  31. },
  32. watch: {
  33. 'chartData': {
  34. handler(val) {
  35. setTimeout(() => {
  36. this.drawChart()
  37. }, 100)
  38. },
  39. immediate: true,
  40. deep: true
  41. }
  42. },
  43. mounted() {
  44. this.drawChart()
  45. window.addEventListener('resize', this.__resizeHandler)
  46. },
  47. methods: {
  48. drawChart() {
  49. const chartDom = document.getElementById('main')
  50. this.chart = echarts.init(chartDom)
  51. let option = null
  52. option = {
  53. grid: { // 边距
  54. left: '2%',
  55. right: '2%',
  56. bottom: '5%',
  57. top: '8%',
  58. containLabel: true
  59. },
  60. tooltip: {
  61. trigger: 'axis',
  62. axisPointer: {
  63. type: 'cross',
  64. label: {
  65. backgroundColor: '#339cff'
  66. }
  67. }
  68. },
  69. xAxis: {
  70. type: 'category',
  71. data: this.chartData.totalLendMonth,
  72. axisLine: { // 轴线的颜色以及宽度
  73. lineStyle: {
  74. color: 'rgba(17, 61, 114,0.5)'
  75. }
  76. },
  77. axisTick: { show: false },
  78. axisLabel: { // x轴文字的配置
  79. show: true,
  80. textStyle: {
  81. color: '#fff'
  82. }
  83. }
  84. },
  85. yAxis: {
  86. type: 'value',
  87. min: 0,
  88. max: 1000,
  89. splitNumber: 5,
  90. axisLine: {
  91. show: false
  92. },
  93. axisLabel: { // x轴文字的配置
  94. show: true,
  95. textStyle: {
  96. color: '#fff'
  97. }
  98. },
  99. axisTick: { // 刻度线隐藏
  100. show: false
  101. },
  102. splitLine: { // 分割线配置
  103. lineStyle: {
  104. color: 'rgba(17, 61, 114,0.5)',
  105. type: 'solid'
  106. }
  107. }
  108. },
  109. series: [
  110. {
  111. name: '借阅量',
  112. data: this.chartData.totalLendData,
  113. type: 'line',
  114. areaStyle: {
  115. normal: {
  116. color: {
  117. x: 0,
  118. y: 0,
  119. x2: 0,
  120. y2: 1,
  121. colorStops: [
  122. {
  123. offset: 0.1,
  124. color: 'rgba(26, 201, 255, 0.5)' // 0% 处的颜色
  125. },
  126. {
  127. offset: 0.5,
  128. color: 'rgba(26, 201, 255, 0.3)' // 0% 处的颜色
  129. },
  130. {
  131. offset: 0.7,
  132. color: 'rgba(26, 201, 255, 0.2)' // 0% 处的颜色
  133. },
  134. {
  135. offset: 0.9,
  136. color: 'rgba(26, 201, 255, 0.1)' // 100% 处的颜色
  137. }
  138. ]
  139. }
  140. }
  141. },
  142. itemStyle: {
  143. normal: {
  144. color: '#339CFF', // 改变折线点的颜色
  145. lineStyle: {
  146. color: 'rgba(26, 201, 255,0.5)' // 改变折线颜色
  147. }
  148. }
  149. }
  150. }
  151. ]
  152. }
  153. option && this.chart.setOption(option)
  154. }
  155. }
  156. }
  157. </script>
  158. <style lang="scss" scoped>
  159. .h{
  160. color: rgb(26, 201, 255);
  161. }
  162. </style>