diff --git a/src/components/charts/G2/mixins/G2.js b/src/components/charts/G2/mixins/G2.js index bd00a5f6..e0147a67 100644 --- a/src/components/charts/G2/mixins/G2.js +++ b/src/components/charts/G2/mixins/G2.js @@ -35,6 +35,7 @@ export default { if (this.autoInit) { this.startInit() } + this.$emit('ready') }, watch: { // 数据改变 diff --git a/src/pages/demo/chart/index/index.vue b/src/pages/demo/chart/index/index.vue index c1ab3813..59fcea76 100644 --- a/src/pages/demo/chart/index/index.vue +++ b/src/pages/demo/chart/index/index.vue @@ -4,49 +4,49 @@ - + - + - + - + - + - + - + - + @@ -65,51 +65,65 @@ export default { { api: {url: '/api/chart/G2Line', data: {type: 'base'}}, refName: 'G2LineBase', + ready: false, data: [] }, { api: {url: '/api/chart/G2Line', data: {type: 'step'}}, refName: 'G2LineStep', + ready: false, data: [] }, { api: {url: '/api/chart/G2Column', data: {type: 'base'}}, refName: 'G2ColumnBase', + ready: false, data: [] }, { api: {url: '/api/chart/G2Bar', data: {type: 'base'}}, refName: 'G2BarBase', + ready: false, data: [] }, { api: {url: '/api/chart/G2Pie', data: {type: 'base'}}, refName: 'G2PieBase', + ready: false, data: [] }, { api: {url: '/api/chart/G2NightingaleRose', data: {type: 'base'}}, refName: 'G2NightingaleRoseBase', + ready: false, data: [] }, { api: {url: '/api/chart/G2Radar', data: {type: 'base'}}, refName: 'G2RadarBase', + ready: false, data: [] }, { api: {url: '/api/chart/G2Area', data: {type: 'base'}}, refName: 'G2AreaBase', + ready: false, data: [] } ] } }, - mounted () { - // 请求图表数据 - setTimeout(() => { - this.syncData() - }, 1000) + computed: { + ready () { + return !this.chart.find(e => !e.ready) + } + }, + watch: { + ready (ready) { + if (ready) { + this.syncData() + } + } }, methods: { // 请求图表数据