fe-drone-ci/src/components/Charts/keyboard.vue

114 lines
2.3 KiB
Vue
Raw Normal View History

2017-04-18 07:09:13 +00:00
<template>
2017-07-06 09:56:17 +00:00
<div :class="className" :id="id" :style="{height:height,width:width}"></div>
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'
2017-04-18 07:09:13 +00:00
2017-08-22 07:43:34 +00:00
export default {
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 = []
for (let i = 0; i < 30; i++) {
xAxisData.push(i + '号')
data.push(Math.round(Math.random() * 2 + 3))
}
2017-04-18 07:09:13 +00:00
2017-08-22 07:43:34 +00:00
this.chart.setOption(
{
backgroundColor: '#08263a',
tooltip: {
trigger: 'axis'
},
xAxis: {
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: {}
},
series: [{
type: 'bar',
data,
name: '撸文数',
itemStyle: {
normal: {
barBorderRadius: 5,
shadowBlur: 10,
shadowColor: '#111'
}
},
animationEasing: 'elasticOut',
animationEasingUpdate: 'elasticOut',
animationDelay(idx) {
return idx * 20
},
animationDelayUpdate(idx) {
return idx * 20
}
}]
})
}
}
}
2017-04-18 07:09:13 +00:00
</script>