组件
<template>
<div class="chart" :style="{height:height/75+'rem',width:width}">
</div>
</template>
<script>
import echarts from "echarts";
export default {
props: {
barObj: {
type: Object
},
width: {
type: String,
default: "100%"
},
height: {
type: String,
default: "400"
}
},
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;
let list = [{
name: "辅助",
type: "bar",
stack: "总量",
itemStyle: {
normal: {
barBorderColor: "rgba(0,0,0,0)",
color: "rgba(0,0,0,0)"
},
emphasis: {
barBorderColor: "rgba(0,0,0,0)",