效果
?? 此圖并非折線圖餅圖聯(lián)動 折線圖餅圖聯(lián)動組件飛機(jī)票
??餅圖點擊事件再餅圖組件中 餅圖組件飛機(jī)票
??主要看折線圖部分,動態(tài)變化折現(xiàn)條數(shù)
錄制1.gif
折線圖組件 mutiLine.vue
<template>
<div :class="className" :id="id" :style="{height:height,width:width}"></div>
</template>
<script>
import echarts from 'echarts'
import { debounce } from '@/utils'
require('echarts/theme/macarons') // echarts theme
export default {
props: {
lineData: {
type: Object,
default: {}
},
className: {
type: String,
default: 'chart'
},
id: {
type: String,
default: 'chart'
},
width: {
type: String,
default: '100%'
},
height: {
type: String,
default: '420px'
},
autoResize: {
type: Boolean,
default: true
},
},
data() {
return {
chart: null
}
},
mounted() {
this.$nextTick(function () {
setTimeout(this.initChart(), 200);
})
},
methods: {
initChart() {
this.chart = echarts.init(document.getElementById(this.id), 'macarons')
this.chart.clear();//清除畫布內(nèi)容
this.chart.setOption({
backgroundColor: '#ffffff',
title: {
text: '', //標(biāo)題
},
tooltip: {
trigger: 'axis'
},
legend: {
top: 0,
icon: 'rect',
itemWidth: 14,
itemHeight: 5,
itemGap: 13,
data: this.lineData.yData, //導(dǎo)航數(shù)據(jù)
right: '50%',
textStyle: {
fontSize: 12,
color: '#000000'
}
},
grid: {
top: 100,
left: '3%',
right: '4%',
bottom: '2%',
containLabel: true
},
xAxis: [{
type: 'category',
boundaryGap: false,
axisLine: {
lineStyle: {
color: '#008acd'
}
},
data: this.lineData.yData,
}],
yAxis: [{
type: 'value',
name: '',
axisTick: {
show: false
},
axisLine: {
lineStyle: {
color: '#008acd'
}
},
axisLabel: {
margin: 10,
textStyle: {
fontSize: 14
}
},
splitLine: {
lineStyle: {
color: '#eeeeee'
}
}
}],
series: this.lineData.series
})
}
},
//折現(xiàn)數(shù)據(jù)通過變量傳遞
watch: {
lineData: {
deep: true,
handler(val) {
console.log('折線圖監(jiān)聽', val)
if (val) {
setTimeout(this.initChart(), 100);
}
}
},
}
}
</script>
父組件引用
<muti-line :lineData="lineData"></muti-line>
import mutiLine from "@/components/Charts/mutiLine";
export default{
components:{ mutiLine }
}
data(){
return{ lineData:{} }
}