diff --git a/src/views/dashboard/admin/barChart.vue b/src/views/dashboard/admin/barChart.vue index a09bd8d9f5fdb612ec6cad9fc5cb1c2e70062e4d..4d151f602ea03ff62f75376d470fa23000919750 100644 --- a/src/views/dashboard/admin/barChart.vue +++ b/src/views/dashboard/admin/barChart.vue @@ -5,6 +5,7 @@ <script> import echarts from 'echarts' require('echarts/theme/macarons') // echarts 主题 +import { debounce } from '@/utils' const animationDuration = 3000 export default { @@ -29,11 +30,18 @@ export default { }, mounted() { this.initChart() + this.__resizeHanlder = debounce(() => { + if (this.chart) { + this.chart.resize() + } + }, 100) + window.addEventListener('resize', this.__resizeHanlder) }, beforeDestroy() { if (!this.chart) { return } + window.removeEventListener('resize', this.__resizeHanlder) this.chart.dispose() this.chart = null }, diff --git a/src/views/dashboard/admin/pieChart.vue b/src/views/dashboard/admin/pieChart.vue index 728fba8fb76159cb52af295bd864bd6f646b46af..51be373af4cc1cd7f42455556f9b67efc9edf498 100644 --- a/src/views/dashboard/admin/pieChart.vue +++ b/src/views/dashboard/admin/pieChart.vue @@ -5,6 +5,7 @@ <script> import echarts from 'echarts' require('echarts/theme/macarons') // echarts 主题 +import { debounce } from '@/utils' export default { props: { @@ -28,11 +29,18 @@ export default { }, mounted() { this.initChart() + this.__resizeHanlder = debounce(() => { + if (this.chart) { + this.chart.resize() + } + }, 100) + window.addEventListener('resize', this.__resizeHanlder) }, beforeDestroy() { if (!this.chart) { return } + window.removeEventListener('resize', this.__resizeHanlder) this.chart.dispose() this.chart = null }, @@ -60,6 +68,7 @@ export default { name: 'WEEKLY WRITE ARTICLES', type: 'pie', roseType: 'radius', + radius: [10, 90], data: [ { value: 320, name: 'industries' }, { value: 240, name: 'technology' },