| | |
| | | 子组件有基本的样式 |
| | | 使用同一个图形实例,接受父组件传入的折线图option |
| | | **父组件 |
| | | |
| | | <ExceptionTypeLineChart |
| | | :option="option" |
| | | :is-open-dialog="centerDialogVisible" |
| | | v-loading="chartLoading" |
| | | ></ExceptionTypeLineChart> |
| | | --> |
| | | <template> |
| | | <div id="main" class="line-chart"></div> |
| | |
| | | }, |
| | | isOpenDialog:{ |
| | | type:Boolean |
| | | } |
| | | }, |
| | | |
| | | }, |
| | | data() { |
| | | return { |
| | |
| | | }; |
| | | }, |
| | | mounted() { |
| | | // 获取页面宽度的一半 |
| | | |
| | | this.initChart(); |
| | | this.chart.clear |
| | | this.chart.setOption(this.option,true) |
| | |
| | | }, |
| | | isOpenDialog(){ |
| | | window.addEventListener('resize', this.resizeChart); |
| | | console.log('调用了'); |
| | | } |
| | | }, |
| | | }, |
| | | beforeUnmount() { |
| | | if (this.chart) { |
| | |
| | | |
| | | // 跟页面响应式变化 |
| | | resizeChart() { |
| | | this.chart.resize(); |
| | | this.$nextTick(() => { |
| | | if (this.chart) { |
| | | this.chart.resize(); |
| | | } |
| | | }); |
| | | // this.chart.resize(); |
| | | } |
| | | } |
| | | }; |
| | |
| | | |
| | | <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> |