创建echarts的基本模板
<template>
<div class="com-container">
<div class="com-chart" ref="trend_ref"></div>
</div>
</template>
<script>
import axios from 'axios'
export default {
data(){
return{
chartInstance:null,
allData:null
}
},
mounted(){
this.initChart();
this.getData();
this.screenAdapter();
window.addEventListener('resize',this.screenAdapter);
},
destroyed(){
window.removeEventListener('resize',this.screenAdapter);
},
methods:{
initChart(){
const initOption ={};
this.chartInstance = window.echarts.init(this.$refs.trend_ref);
this.chartInstance.setOption(initOption);
},
async getData(){
//得到数据
this.updateChart();
},
updateChart(){
const dataOption ={};
this.chartInstance.setOption(dataOption);
},
screenAdapter(){
const adapterOption ={};
this.chartInstance.setOption(adapterOption);
this.chartInstance.resize();
}
}
}
</script>
<style>
</style>