parent
de64853cc2
commit
4db8e935d1
@ -0,0 +1,71 @@
|
|||||||
|
<template>
|
||||||
|
<div class="chartline">
|
||||||
|
<div ref="dom" class="chartline1"></div>
|
||||||
|
<slot></slot>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
echartdata: {},
|
||||||
|
notMerge: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
dom: null,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
resize() {
|
||||||
|
this.dom.resize();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
// this.dom = echarts.init(this.$refs.dom, "dark");
|
||||||
|
|
||||||
|
window.addEventListener("resize", this.resize, false);
|
||||||
|
setTimeout(() => {
|
||||||
|
this.dom = this.$echarts.init(this.$refs.dom);
|
||||||
|
this.dom.setOption(this.echartdata, this.notMerge);
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
this.dom.dispose();
|
||||||
|
window.removeEventListener("resize", () => {}, false);
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
echartdata: {
|
||||||
|
handler(newval) {
|
||||||
|
// setTimeout(() => {
|
||||||
|
if (this.dom) {
|
||||||
|
this.dom.setOption(this.echartdata, this.notMerge);
|
||||||
|
}
|
||||||
|
|
||||||
|
// }, 1000);
|
||||||
|
},
|
||||||
|
deep: true,
|
||||||
|
// immediate: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="less">
|
||||||
|
.chartline {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
.chartline1 {
|
||||||
|
position: absolute;
|
||||||
|
z-index: 10;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
Loading…
Reference in new issue