2017-04-18 07:09:13 +00:00
|
|
|
<template>
|
2019-03-17 09:40:51 +00:00
|
|
|
<div :id="id" :class="className" :style="{height:height,width:width}" />
|
2017-04-18 07:09:13 +00:00
|
|
|
</template>
|
2017-07-06 09:56:17 +00:00
|
|
|
|
2017-04-18 07:09:13 +00:00
|
|
|
<script>
|
2017-08-22 07:43:34 +00:00
|
|
|
import echarts from 'echarts'
|
2018-03-13 10:36:11 +00:00
|
|
|
import resize from './mixins/resize'
|
2017-04-18 07:09:13 +00:00
|
|
|
|
2017-08-22 07:43:34 +00:00
|
|
|
export default {
|
2018-03-13 10:36:11 +00:00
|
|
|
mixins: [resize],
|
2017-08-22 07:43:34 +00:00
|
|
|
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))
|
2017-04-18 07:09:13 +00:00
|
|
|
|
2017-08-22 07:43:34 +00:00
|
|
|
const xAxisData = []
|
|
|
|
const data = []
|
2017-11-17 07:07:21 +00:00
|
|
|
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)
|
2017-08-22 07:43:34 +00:00
|
|
|
}
|
|
|
|
this.chart.setOption(
|
|
|
|
{
|
|
|
|
backgroundColor: '#08263a',
|
2018-09-04 07:03:47 +00:00
|
|
|
grid: {
|
|
|
|
left: '5%',
|
|
|
|
right: '5%'
|
|
|
|
},
|
2017-11-17 07:07:21 +00:00
|
|
|
xAxis: [{
|
2017-08-22 07:43:34 +00:00
|
|
|
show: false,
|
|
|
|
data: xAxisData
|
2017-11-17 07:07:21 +00:00
|
|
|
}, {
|
|
|
|
show: false,
|
|
|
|
data: xAxisData
|
|
|
|
}],
|
2017-08-22 07:43:34 +00:00
|
|
|
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'
|
|
|
|
}
|
|
|
|
},
|
2017-11-17 07:07:21 +00:00
|
|
|
axisTick: {
|
|
|
|
show: false
|
|
|
|
}
|
2017-08-22 07:43:34 +00:00
|
|
|
},
|
|
|
|
series: [{
|
2017-11-17 07:07:21 +00:00
|
|
|
name: 'back',
|
2017-08-22 07:43:34 +00:00
|
|
|
type: 'bar',
|
2017-11-17 07:07:21 +00:00
|
|
|
data: data2,
|
|
|
|
z: 1,
|
2017-08-22 07:43:34 +00:00
|
|
|
itemStyle: {
|
|
|
|
normal: {
|
2017-11-17 07:07:21 +00:00
|
|
|
opacity: 0.4,
|
2017-08-22 07:43:34 +00:00
|
|
|
barBorderRadius: 5,
|
2017-11-17 07:07:21 +00:00
|
|
|
shadowBlur: 3,
|
2017-08-22 07:43:34 +00:00
|
|
|
shadowColor: '#111'
|
|
|
|
}
|
2017-11-17 07:07:21 +00:00
|
|
|
}
|
|
|
|
}, {
|
|
|
|
name: 'Simulate Shadow',
|
|
|
|
type: 'line',
|
|
|
|
data,
|
|
|
|
z: 2,
|
|
|
|
showSymbol: false,
|
|
|
|
animationDelay: 0,
|
|
|
|
animationEasing: 'linear',
|
|
|
|
animationDuration: 1200,
|
|
|
|
lineStyle: {
|
|
|
|
normal: {
|
|
|
|
color: 'transparent'
|
|
|
|
}
|
2017-08-22 07:43:34 +00:00
|
|
|
},
|
2017-11-17 07:07:21 +00:00
|
|
|
areaStyle: {
|
|
|
|
normal: {
|
|
|
|
color: '#08263a',
|
|
|
|
shadowBlur: 50,
|
|
|
|
shadowColor: '#000'
|
|
|
|
}
|
2017-08-22 07:43:34 +00:00
|
|
|
}
|
2017-11-17 07:07:21 +00:00
|
|
|
}, {
|
|
|
|
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
|
|
|
|
}
|
2017-08-22 07:43:34 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-04-18 07:09:13 +00:00
|
|
|
</script>
|