2018-01-27 22:38:39 +08:00
|
|
|
<template>
|
2018-01-28 14:58:34 +08:00
|
|
|
<Container type="ghost" :responsive="true" class="demo-chart-index">
|
2018-01-28 22:45:54 +08:00
|
|
|
<GridLayout v-bind="layout">
|
2018-01-28 14:58:34 +08:00
|
|
|
<GridItem v-bind="layout.layout[0]" @resize="resizeHandler('G2Line1')" @resized="resizedHandler('G2Line1')">
|
2018-01-28 23:22:25 +08:00
|
|
|
<el-card><G2Line1 ref="G2Line1" :data="G2Line1"></G2Line1></el-card>
|
2018-01-27 22:52:45 +08:00
|
|
|
</GridItem>
|
|
|
|
|
</GridLayout>
|
2018-01-27 22:38:39 +08:00
|
|
|
</Container>
|
|
|
|
|
</template>
|
2018-01-27 22:52:45 +08:00
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
data () {
|
|
|
|
|
return {
|
|
|
|
|
layout: {
|
|
|
|
|
layout: [
|
|
|
|
|
{'x': 0, 'y': 0, 'w': 8, 'h': 9, 'i': '0'},
|
|
|
|
|
{'x': 8, 'y': 9, 'w': 4, 'h': 7, 'i': '1'},
|
|
|
|
|
{'x': 0, 'y': 9, 'w': 4, 'h': 7, 'i': '2'},
|
|
|
|
|
{'x': 8, 'y': 0, 'w': 4, 'h': 9, 'i': '3'},
|
|
|
|
|
{'x': 4, 'y': 9, 'w': 4, 'h': 7, 'i': '4'}
|
|
|
|
|
],
|
|
|
|
|
colNum: 12,
|
|
|
|
|
rowHeight: 30,
|
|
|
|
|
isDraggable: true,
|
|
|
|
|
isResizable: true,
|
|
|
|
|
isMirrored: false,
|
|
|
|
|
verticalCompact: true,
|
|
|
|
|
margin: [10, 10],
|
|
|
|
|
useCssTransforms: true
|
2018-01-28 22:45:54 +08:00
|
|
|
},
|
2018-01-28 23:22:25 +08:00
|
|
|
// 数据
|
|
|
|
|
G2Line1: []
|
2018-01-27 22:52:45 +08:00
|
|
|
}
|
|
|
|
|
},
|
2018-01-28 22:45:54 +08:00
|
|
|
mounted () {
|
2018-01-28 23:52:37 +08:00
|
|
|
this.syncData()
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
// 请求图表数据
|
|
|
|
|
syncData () {
|
2018-01-28 23:22:25 +08:00
|
|
|
const api = [
|
2018-01-28 23:52:37 +08:00
|
|
|
{url: '/api/chart/G2Line', data: {code: 1}}
|
2018-01-28 22:45:54 +08:00
|
|
|
]
|
2018-01-28 23:52:37 +08:00
|
|
|
this.$axios.all(api.map(e => this.$axios.post(e.url, e.data)))
|
2018-01-28 23:22:25 +08:00
|
|
|
.then(this.$axios.spread((G2Line1) => {
|
|
|
|
|
this.G2Line1 = G2Line1
|
|
|
|
|
}))
|
2018-01-28 23:52:37 +08:00
|
|
|
},
|
2018-01-28 22:45:54 +08:00
|
|
|
// 改变尺寸
|
2018-01-28 14:58:34 +08:00
|
|
|
resizeHandler (name) {
|
|
|
|
|
this.$nextTick(() => {
|
2018-01-28 22:45:54 +08:00
|
|
|
this.$refs[name].resize()
|
2018-01-27 22:52:45 +08:00
|
|
|
})
|
|
|
|
|
},
|
2018-01-28 22:45:54 +08:00
|
|
|
// 改变尺寸完成
|
2018-01-28 14:58:34 +08:00
|
|
|
resizedHandler (name) {
|
|
|
|
|
this.$nextTick(() => {
|
2018-01-28 22:45:54 +08:00
|
|
|
this.$refs[name].resize()
|
2018-01-28 14:58:34 +08:00
|
|
|
})
|
2018-01-27 22:52:45 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
@import '~@/assets/style/public.scss';
|
|
|
|
|
.demo-chart-index {
|
|
|
|
|
.vue-grid-layout {
|
|
|
|
|
margin: -10px;
|
|
|
|
|
.el-card {
|
|
|
|
|
@extend %unable-select;
|
|
|
|
|
height: 100%;
|
|
|
|
|
.el-card__body {
|
|
|
|
|
height: 100%;
|
|
|
|
|
padding: 0px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.vue-resizable-handle {
|
2018-01-28 22:45:54 +08:00
|
|
|
bottom: 6px;
|
|
|
|
|
right: 6px;
|
2018-01-27 22:52:45 +08:00
|
|
|
opacity: .3;
|
|
|
|
|
&:hover{
|
|
|
|
|
opacity: 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|