组件
<template>
<div class="chart" :style="{height:height,width:width}">
</div>
</template>
<script>
import echarts from "echarts";
export default {
props: {
barObj: {
type: Object
},
width: {
type: String,
default: "100%"
},
height: {
type: String,
default: "150px"
}
},
data() {
return {
myChart: null
};
},
mounted() {
let _this = this;
_this.init();
window.addEventListener("resize", function() {
_this.myChart.resize();
});
},
beforeDestroy() {
if (!this.myChart) {
return;
}
this.myChart.dispose();
this.myChart = null;
},
methods: {
init() {
this.drawLine();
},
drawLine() {
let self = this;
self.myChart = echarts.init(this.$el);
self.myChart.clear();
let data = self.barObj;
// 绘制图表
s