Blame view
src/components/Charts/Keyboard.vue
3.17 KB
d7d9c38c2 auto commit the c... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
<template> <div :id="id" :class="className" :style="{height:height,width:width}" /> </template> <script> import echarts from 'echarts' import resize from './mixins/resize' export default { mixins: [resize], props: { className: { type: String, default: 'chart' }, id: { type: String, default: 'chart' }, width: { type: String, default: '200px' }, height: { type: String, default: '200px' } }, data() { return { chart: null } }, mounted() { this.initChart() }, beforeDestroy() { if (!this.chart) { return } this.chart.dispose() this.chart = null }, methods: { initChart() { this.chart = echarts.init(document.getElementById(this.id)) const xAxisData = [] const data = [] const data2 = [] for (let i = 0; i < 50; i++) { xAxisData.push(i) data.push((Math.sin(i / 5) * (i / 5 - 10) + i / 6) * 5) data2.push((Math.sin(i / 5) * (i / 5 + 10) + i / 6) * 3) } this.chart.setOption({ backgroundColor: '#08263a', grid: { left: '5%', right: '5%' }, xAxis: [{ show: false, data: xAxisData }, { show: false, data: xAxisData }], visualMap: { show: false, min: 0, max: 50, dimension: 0, inRange: { color: ['#4a657a', '#308e92', '#b1cfa5', '#f5d69f', '#f5898b', '#ef5055'] } }, yAxis: { axisLine: { show: false }, axisLabel: { textStyle: { color: '#4a657a' } }, splitLine: { show: true, lineStyle: { color: '#08263f' } }, axisTick: { show: false } }, series: [{ name: 'back', type: 'bar', data: data2, z: 1, itemStyle: { normal: { opacity: 0.4, barBorderRadius: 5, shadowBlur: 3, shadowColor: '#111' } } }, { name: 'Simulate Shadow', type: 'line', data, z: 2, showSymbol: false, animationDelay: 0, animationEasing: 'linear', animationDuration: 1200, lineStyle: { normal: { color: 'transparent' } }, areaStyle: { normal: { color: '#08263a', shadowBlur: 50, shadowColor: '#000' } } }, { name: 'front', type: 'bar', data, xAxisIndex: 1, z: 3, itemStyle: { normal: { barBorderRadius: 5 } } }], animationEasing: 'elasticOut', animationEasingUpdate: 'elasticOut', animationDelay(idx) { return idx * 20 }, animationDelayUpdate(idx) { return idx * 20 } }) } } } </script> |