Keyboard.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <div :id="id" :class="className" :style="{height:height,width:width}" />
  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. const xAxisData = []
  46. const data = []
  47. const data2 = []
  48. for (let i = 0; i < 50; i++) {
  49. xAxisData.push(i)
  50. data.push((Math.sin(i / 5) * (i / 5 - 10) + i / 6) * 5)
  51. data2.push((Math.sin(i / 5) * (i / 5 + 10) + i / 6) * 3)
  52. }
  53. this.chart.setOption({
  54. backgroundColor: '#08263a',
  55. grid: {
  56. left: '5%',
  57. right: '5%'
  58. },
  59. xAxis: [{
  60. show: false,
  61. data: xAxisData
  62. }, {
  63. show: false,
  64. data: xAxisData
  65. }],
  66. visualMap: {
  67. show: false,
  68. min: 0,
  69. max: 50,
  70. dimension: 0,
  71. inRange: {
  72. color: ['#4a657a', '#308e92', '#b1cfa5', '#f5d69f', '#f5898b', '#ef5055']
  73. }
  74. },
  75. yAxis: {
  76. axisLine: {
  77. show: false
  78. },
  79. axisLabel: {
  80. textStyle: {
  81. color: '#4a657a'
  82. }
  83. },
  84. splitLine: {
  85. show: true,
  86. lineStyle: {
  87. color: '#08263f'
  88. }
  89. },
  90. axisTick: {
  91. show: false
  92. }
  93. },
  94. series: [{
  95. name: 'back',
  96. type: 'bar',
  97. data: data2,
  98. z: 1,
  99. itemStyle: {
  100. normal: {
  101. opacity: 0.4,
  102. barBorderRadius: 5,
  103. shadowBlur: 3,
  104. shadowColor: '#111'
  105. }
  106. }
  107. }, {
  108. name: 'Simulate Shadow',
  109. type: 'line',
  110. data,
  111. z: 2,
  112. showSymbol: false,
  113. animationDelay: 0,
  114. animationEasing: 'linear',
  115. animationDuration: 1200,
  116. lineStyle: {
  117. normal: {
  118. color: 'transparent'
  119. }
  120. },
  121. areaStyle: {
  122. normal: {
  123. color: '#08263a',
  124. shadowBlur: 50,
  125. shadowColor: '#000'
  126. }
  127. }
  128. }, {
  129. name: 'front',
  130. type: 'bar',
  131. data,
  132. xAxisIndex: 1,
  133. z: 3,
  134. itemStyle: {
  135. normal: {
  136. barBorderRadius: 5
  137. }
  138. }
  139. }],
  140. animationEasing: 'elasticOut',
  141. animationEasingUpdate: 'elasticOut',
  142. animationDelay(idx) {
  143. return idx * 20
  144. },
  145. animationDelayUpdate(idx) {
  146. return idx * 20
  147. }
  148. })
  149. }
  150. }
  151. }
  152. </script>