diff --git a/src/pages/demo/chart/dynamicSize/index.vue b/src/pages/demo/chart/dynamicSize/index.vue index 8c007185..7309bb01 100644 --- a/src/pages/demo/chart/dynamicSize/index.vue +++ b/src/pages/demo/chart/dynamicSize/index.vue @@ -5,56 +5,56 @@ - + - + - + - + - + - + - + - + @@ -73,41 +73,49 @@ 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: [] } ], @@ -134,11 +142,23 @@ export default { } } }, - mounted () { - // 请求图表数据 - this.syncData() + computed: { + ready () { + return !this.chart.find(e => !e.ready) + } + }, + watch: { + ready (ready) { + if (ready) { + this.syncData() + } + } }, methods: { + // 图表 mounted + isReady (index) { + this.chart[index].ready = true + }, // 请求图表数据 syncData () { this.$axios.all(this.chart.map(e => this.$axios.post(e.api.url, e.api.data)))