no message

Former-commit-id: e42b1ce57f595759636bc8e4e42b1eab6bc4e70f
Former-commit-id: 91009871838e2c143836c0baec9c6eeda84ad145
Former-commit-id: 471c0f984124c70409b7ad73e105999fa9e04b8d
This commit is contained in:
李杨
2018-02-17 11:26:36 +08:00
parent f1d7e49da3
commit 815a97a002
15 changed files with 43 additions and 66 deletions

View File

@@ -0,0 +1,3 @@
// import Vue from 'vue'
// Vue.component('G2Line1', resolve => { require(['@/components/G2/charts/Line/1.vue'], resolve) })

View File

@@ -2,5 +2,5 @@
import './core' import './core'
// 非核心组件 只是在很多演示页面中用到的组件 // 非核心组件 只是在很多演示页面中用到的组件
import './demo' import './demo'
// 图表组件 // 图表组件 G2
import './G2' import './charts/G2'

View File

@@ -4,19 +4,19 @@
<GridItem v-bind="layout.layout[0]" @resize="resizeHandler('G2Line1')" @resized="resizedHandler('G2Line1')"> <GridItem v-bind="layout.layout[0]" @resize="resizeHandler('G2Line1')" @resized="resizedHandler('G2Line1')">
<el-card class="header-in"> <el-card class="header-in">
<div slot="header">近年趋势</div> <div slot="header">近年趋势</div>
1 <G2Line1 ref="G2Line1" :data="chartData.G2Line1"></G2Line1>
</el-card> </el-card>
</GridItem> </GridItem>
<GridItem v-bind="layout.layout[1]" @resize="resizeHandler('G2Pie1')" @resized="resizedHandler('G2Pie1')"> <GridItem v-bind="layout.layout[1]" @resize="resizeHandler('G2Pie1')" @resized="resizedHandler('G2Pie1')">
<el-card class="header-in"> <el-card class="header-in">
<div slot="header">人员分布</div> <div slot="header">人员分布</div>
2 <G2Pie1 ref="G2Pie1" :data="chartData.G2Pie1"></G2Pie1>
</el-card> </el-card>
</GridItem> </GridItem>
<GridItem v-bind="layout.layout[2]" @resize="resizeHandler('G2Column1')" @resized="resizedHandler('G2Column1')"> <GridItem v-bind="layout.layout[2]" @resize="resizeHandler('G2Column1')" @resized="resizedHandler('G2Column1')">
<el-card class="header-in"> <el-card class="header-in">
<div slot="header">人员分布</div> <div slot="header">人员分布</div>
3 <G2Column1 ref="G2Column1" :data="chartData.G2Column1"></G2Column1>
</el-card> </el-card>
</GridItem> </GridItem>
</GridLayout> </GridLayout>
@@ -37,3 +37,4 @@ export default {
<style lang="scss"> <style lang="scss">
@import './style.scss'; @import './style.scss';
</style> </style>

View File

@@ -2,7 +2,6 @@ export default {
data () { data () {
return { return {
layout: { layout: {
// 调整布局时 复制 layoutUpdatedHandler() 输出的日志到这里
layout: [ layout: [
{'x': 0, 'y': 0, 'w': 8, 'h': 9, 'i': '0'}, {'x': 0, 'y': 0, 'w': 8, 'h': 9, 'i': '0'},
{'x': 8, 'y': 0, 'w': 4, 'h': 9, 'i': '1'}, {'x': 8, 'y': 0, 'w': 4, 'h': 9, 'i': '1'},
@@ -20,11 +19,6 @@ export default {
} }
}, },
methods: { methods: {
// 更新指定的图表
chartResize () {
this.$log('chartResize')
},
// 布局组件发生变化
layoutUpdatedHandler (newLayout) { layoutUpdatedHandler (newLayout) {
console.group('layoutUpdatedHandler') console.group('layoutUpdatedHandler')
newLayout.forEach(e => { newLayout.forEach(e => {
@@ -34,11 +28,15 @@ export default {
}, },
// 改变尺寸 // 改变尺寸
resizeHandler (name) { resizeHandler (name) {
this.chartResize() this.$nextTick(() => {
this.$refs[name].resize()
})
}, },
// 改变尺寸完成 // 改变尺寸完成
resizedHandler (name) { resizedHandler (name) {
this.chartResize() this.$nextTick(() => {
this.$refs[name].resize()
})
} }
} }
} }

View File

@@ -1,22 +1,13 @@
<template> <template>
<Container type="ghost" :responsive="true" class="demo-chart-index"> <Container type="ghost" :responsive="true" class="demo-chart-index">
<GridLayout v-bind="layout" @layout-updated="layoutUpdatedHandler"> <GridLayout v-bind="layout" @layout-updated="layoutUpdatedHandler">
<GridItem v-bind="layout.layout[0]" @resize="resizeHandler('G2Line1')" @resized="resizedHandler('G2Line1')"> <GridItem
v-bind="layout.layout[0]"
@resize="resizeHandler('G2Line1')"
@resized="resizedHandler('G2Line1')">
<el-card class="header-in"> <el-card class="header-in">
<div slot="header">近年趋势</div> <div slot="header">近年趋势</div>
<G2Line1 ref="G2Line1" :data="chartData.G2Line1"></G2Line1> 1
</el-card>
</GridItem>
<GridItem v-bind="layout.layout[1]" @resize="resizeHandler('G2Pie1')" @resized="resizedHandler('G2Pie1')">
<el-card class="header-in">
<div slot="header">人员分布</div>
<G2Pie1 ref="G2Pie1" :data="chartData.G2Pie1"></G2Pie1>
</el-card>
</GridItem>
<GridItem v-bind="layout.layout[2]" @resize="resizeHandler('G2Column1')" @resized="resizedHandler('G2Column1')">
<el-card class="header-in">
<div slot="header">人员分布</div>
<G2Column1 ref="G2Column1" :data="chartData.G2Column1"></G2Column1>
</el-card> </el-card>
</GridItem> </GridItem>
</GridLayout> </GridLayout>
@@ -37,4 +28,3 @@ export default {
<style lang="scss"> <style lang="scss">
@import './style.scss'; @import './style.scss';
</style> </style>

View File

@@ -1,34 +1,27 @@
export default { export default {
data () { data () {
return { return {}
// 数据
chartData: {
G2Line1: [],
G2Pie1: [],
G2Column1: []
}
}
}, },
mounted () { mounted () {
// 请求图表数据 // 请求图表数据
this.syncData() // this.syncData()
}, },
methods: { methods: {
// 请求图表数据 // 请求图表数据
syncData () { syncData () {
const api = [ // const api = [
{url: '/api/chart/G2Line', data: {code: 1}}, // {url: '/api/chart/G2Line', data: {code: 1}},
{url: '/api/chart/G2Pie', data: {code: 1}}, // {url: '/api/chart/G2Pie', data: {code: 1}},
{url: '/api/chart/G2Column', data: {code: 1}} // {url: '/api/chart/G2Column', data: {code: 1}}
] // ]
this.$axios.all(api.map(e => this.$axios.post(e.url, e.data))) // this.$axios.all(api.map(e => this.$axios.post(e.url, e.data)))
.then(this.$axios.spread((G2Line1, G2Pie1, G2Column1) => { // .then(this.$axios.spread((G2Line1, G2Pie1, G2Column1) => {
this.chartData = { // this.chartData = {
G2Line1, // G2Line1,
G2Pie1, // G2Pie1,
G2Column1 // G2Column1
} // }
})) // }))
} }
} }
} }

View File

@@ -2,6 +2,7 @@ export default {
data () { data () {
return { return {
layout: { layout: {
// 调整布局时 复制 layoutUpdatedHandler() 输出的日志到这里
layout: [ layout: [
{'x': 0, 'y': 0, 'w': 8, 'h': 9, 'i': '0'}, {'x': 0, 'y': 0, 'w': 8, 'h': 9, 'i': '0'},
{'x': 8, 'y': 0, 'w': 4, 'h': 9, 'i': '1'}, {'x': 8, 'y': 0, 'w': 4, 'h': 9, 'i': '1'},
@@ -19,6 +20,11 @@ export default {
} }
}, },
methods: { methods: {
// 更新指定的图表
chartResize () {
this.$log('chartResize')
},
// 布局组件发生变化
layoutUpdatedHandler (newLayout) { layoutUpdatedHandler (newLayout) {
console.group('layoutUpdatedHandler') console.group('layoutUpdatedHandler')
newLayout.forEach(e => { newLayout.forEach(e => {
@@ -28,15 +34,11 @@ export default {
}, },
// 改变尺寸 // 改变尺寸
resizeHandler (name) { resizeHandler (name) {
this.$nextTick(() => { this.chartResize()
this.$refs[name].resize()
})
}, },
// 改变尺寸完成 // 改变尺寸完成
resizedHandler (name) { resizedHandler (name) {
this.$nextTick(() => { this.chartResize()
this.$refs[name].resize()
})
} }
} }
} }

View File

@@ -21,16 +21,6 @@ export const menu = {
requiresAuth: true requiresAuth: true
}, },
component: resolve => { require(['@/pages/demo/chart/index/index.vue'], resolve) } component: resolve => { require(['@/pages/demo/chart/index/index.vue'], resolve) }
},
{
title: '图表演示2',
icon: 'file-o',
path: 'index2',
name: 'demo-chart-index2',
meta: {
requiresAuth: true
},
component: resolve => { require(['@/pages/demo/chart/index2/index.vue'], resolve) }
} }
] ]
} }