|
@@ -3,8 +3,10 @@
|
|
|
-->
|
|
|
<!-- https://blog.csdn.net/zyz13883658166/article/details/124430938 -->
|
|
|
<template>
|
|
|
- <div>
|
|
|
+ <div ref="wrap">
|
|
|
<!-- <div>{{mid}}</div> -->
|
|
|
+ <div class="ntitle">{{option.title.text}}</div>
|
|
|
+ <div class="addr">{{$store.state.addr.selectAddr}}</div>
|
|
|
<div :id="mid" class="echarts" :style="style"></div>
|
|
|
</div>
|
|
|
|
|
@@ -19,7 +21,7 @@ export default {
|
|
|
props: {
|
|
|
height: {
|
|
|
type: String,
|
|
|
- default: "30vh",
|
|
|
+ default: null,
|
|
|
},
|
|
|
width: {
|
|
|
type: String,
|
|
@@ -38,13 +40,22 @@ export default {
|
|
|
return {
|
|
|
uuid: null,
|
|
|
myChart: null,
|
|
|
+ domHeight:null,
|
|
|
};
|
|
|
},
|
|
|
created() {
|
|
|
this.uuid = idGen();
|
|
|
- // console.log('this.uuid',this.uuid);
|
|
|
+ // console.log('this.option',this.option);
|
|
|
+
|
|
|
},
|
|
|
watch: {
|
|
|
+ // '$store.state.addr.mapLevel': {
|
|
|
+ // handler:function (newVal, oldVal) {
|
|
|
+ // console.log('newVal',newVal);
|
|
|
+ // console.log('oldVal',oldVal);
|
|
|
+ // },
|
|
|
+ // immediate: true
|
|
|
+ // },
|
|
|
width() {
|
|
|
//如果实例可用
|
|
|
if (this.myChart) {
|
|
@@ -69,7 +80,7 @@ export default {
|
|
|
computed: {
|
|
|
style() {
|
|
|
return {
|
|
|
- height: this.height,
|
|
|
+ height: this.height?this.height:this.domHeight-57 +'px',
|
|
|
width: this.width,
|
|
|
};
|
|
|
},
|
|
@@ -86,10 +97,28 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
+ console.log('height',this.height);
|
|
|
+ let obj = this.$refs.wrap;
|
|
|
+ let h = window.getComputedStyle(obj).height;
|
|
|
+ console.log('h',h);
|
|
|
+ this.domHeight = h.slice(0, -2);
|
|
|
+ console.log('domHeight',this.domHeight);
|
|
|
+ console.log('style',this.style);
|
|
|
console.log('echarts mounted');
|
|
|
// echarts.init(document.getElementById('echarts')).dispose();//销毁前一个实例
|
|
|
- this.myChart = echarts.init(document.getElementById(this.mid));
|
|
|
- this.myChart.setOption(this.option);
|
|
|
+ this.$nextTick(()=>{
|
|
|
+ this.myChart = echarts.init(document.getElementById(this.mid));
|
|
|
+ this.myChart.setOption(this.option);
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
},
|
|
|
};
|
|
|
-</script>
|
|
|
+</script>
|
|
|
+<style lang='scss' scoped>
|
|
|
+.addr{
|
|
|
+ text-align: right;
|
|
|
+ padding-right: 24px;
|
|
|
+ font-size: 14px;
|
|
|
+}
|
|
|
+</style>
|