zmc
2023-10-12 f3acb8ce787f3df0eda633031473be4e6a9ff448
src/sfc/ExceptionTypeLineChart.vue
@@ -2,7 +2,11 @@
子组件有基本的样式 
使用同一个图形实例,接受父组件传入的折线图option
**父组件
 <ExceptionTypeLineChart
        :option="option"
        :is-open-dialog="centerDialogVisible"
        v-loading="chartLoading"
      ></ExceptionTypeLineChart>
 -->
<template>
  <div  id="main" class="line-chart"></div>
@@ -21,7 +25,8 @@
    },
    isOpenDialog:{
      type:Boolean
    }
    },
  },
  data() {
    return {
@@ -29,6 +34,8 @@
    };
  },
  mounted() {
     // 获取页面宽度的一半
    this.initChart();
    this.chart.clear
    this.chart.setOption(this.option,true)
@@ -44,8 +51,7 @@
    },
    isOpenDialog(){
      window.addEventListener('resize', this.resizeChart);
      console.log('调用了');
    }
    },
  },
  beforeUnmount() {
    if (this.chart) {
@@ -97,7 +103,12 @@
    // 跟页面响应式变化
    resizeChart() {
      this.chart.resize();
      this.$nextTick(() => {
        if (this.chart) {
          this.chart.resize();
        }
      });
      // this.chart.resize();
    }
  }
};
@@ -106,10 +117,10 @@
<style>
.line-chart {
  width: 100%;
  width:920px;
  height: 300px;
  margin-bottom: 20px;
  margin-left: 10px;
  min-width: 350px;
  /* margin-left: 10px; */
  min-width: 600px;
}
</style>