<template>
<div ref="charts" class="canvas"></div>
</template>
<script>
import echarts from 'echarts';
import { getLineOption } from './echart.line.config.js';
export default {
props: {
dataRes: {
type: Object,
default: () => {}
}
},
data() {
return {
myChart: null,
dataList: []
}
},
watch: {
dataRes() {
this.echartRender();
}
},
mounted() {
this.myChart = echarts.init(this.$refs.charts);
this.echartRender();
},
beforeDestroy() {
this.myChart.dispose();
},
methods: {
echartRender() {
const option = getLineOption(this.dataList);
this.myChart.setOption(option);
}
}
};
</script>
<style lang="scss" scoped>
.canvas{
width: 948px;
height: 364px;
}
</style>