no message
Former-commit-id: 0f4dec9260afd64158506873442954bdf58d20c4 Former-commit-id: 160dbe94357a4fa21765c1671d1783bab4282fd9 Former-commit-id: 2dbe3d4c8e3c7e25ef5be1739a11c0b51c131155
This commit is contained in:
@@ -1,5 +1,42 @@
|
||||
<template>
|
||||
<Container type="ghost" :responsive="true">
|
||||
demo
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="6">
|
||||
<ChartDemoControl
|
||||
@sync="syncData"
|
||||
:height.sync="height">
|
||||
</ChartDemoControl>
|
||||
</el-col>
|
||||
<el-col :span="18">
|
||||
<el-card>
|
||||
<div :style="style">
|
||||
<G2AreaBase ref="chart" v-bind="chart"></G2AreaBase>
|
||||
</div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</Container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import publicMixin from './mixins/public'
|
||||
export default {
|
||||
mixins: [
|
||||
publicMixin
|
||||
],
|
||||
data () {
|
||||
return {
|
||||
api: {
|
||||
url: '/api/chart/G2Area',
|
||||
data: {
|
||||
type: 'base'
|
||||
}
|
||||
},
|
||||
chart: {
|
||||
data: []
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
41
src/pages/demo/chart/demo/components/ChartDemoControl.vue
Normal file
41
src/pages/demo/chart/demo/components/ChartDemoControl.vue
Normal file
@@ -0,0 +1,41 @@
|
||||
<template>
|
||||
<el-card>
|
||||
<el-button @click="$emit('sync')">
|
||||
<Icon name="refresh"></Icon>
|
||||
重新载入数据
|
||||
</el-button>
|
||||
<p>改变容器高度</p>
|
||||
<el-radio-group v-model="currentHeight" size="small">
|
||||
<el-radio-button v-for="(item, index) in heightOptions" :key="index" :label="item">{{item}}</el-radio-button>
|
||||
</el-radio-group>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
height: {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: 0
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
heightOptions: [300, 400, 500, 600],
|
||||
currentHeight: 0
|
||||
}
|
||||
},
|
||||
created () {
|
||||
this.currentHeight = this.height
|
||||
},
|
||||
watch: {
|
||||
currentHeight (value) {
|
||||
if (value !== this.height) {
|
||||
this.$emit('update:height', value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
41
src/pages/demo/chart/demo/mixins/public.js
Normal file
41
src/pages/demo/chart/demo/mixins/public.js
Normal file
@@ -0,0 +1,41 @@
|
||||
import ChartDemoControl from '../components/ChartDemoControl.vue'
|
||||
export default {
|
||||
components: {
|
||||
ChartDemoControl
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
height: 300
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
this.syncData()
|
||||
},
|
||||
computed: {
|
||||
style () {
|
||||
return {
|
||||
height: this.height + 'px'
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
style () {
|
||||
this.$nextTick(() => {
|
||||
this.resize()
|
||||
})
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 请求数据
|
||||
syncData () {
|
||||
this.$axios.post(this.api.url, this.api.data)
|
||||
.then(res => {
|
||||
this.chart.data = res
|
||||
})
|
||||
},
|
||||
// 重新适应大小
|
||||
resize () {
|
||||
this.$refs.chart.resize()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,9 +7,6 @@ export const menu = {
|
||||
requiresAuth: true
|
||||
},
|
||||
component: resolve => { require(['@/components/core/MainLayout/index.vue'], resolve) },
|
||||
redirect: {
|
||||
name: 'demo-chart-index'
|
||||
},
|
||||
children: [
|
||||
// 所有
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user