no message
Former-commit-id: a686cbec6aa82ccf0a5a2f738602d72ff3fa00e5 Former-commit-id: 7e986278ddb45ad7f2373e759f923148f92a3981 Former-commit-id: 4efa4699c64d12049ead46e050e95d495364516b
This commit is contained in:
47
src/components/G2/charts/Column/1.vue
Normal file
47
src/components/G2/charts/Column/1.vue
Normal file
@@ -0,0 +1,47 @@
|
||||
<template>
|
||||
<div ref="chart" style="height: 100%;"></div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import G2Mixin from '@/components/G2/mixins/G2.js'
|
||||
export default {
|
||||
mixins: [
|
||||
G2Mixin
|
||||
],
|
||||
data () {
|
||||
return {
|
||||
// 在组件 mounted 后立即初始化图表
|
||||
// autoInit: false,
|
||||
// [图表设置项] padding
|
||||
padding: [30, 40, 50, 50]
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 初始化图表
|
||||
initHandler () {
|
||||
this.chart = new this.G2.Chart({
|
||||
container: this.$refs.chart,
|
||||
forceFit: this.forceFit,
|
||||
height: this.G2.DomUtil.getHeight(this.$refs.chart),
|
||||
padding: this.padding
|
||||
})
|
||||
this.chart.source(this.data)
|
||||
this.chart.scale('sales', {
|
||||
tickInterval: 20
|
||||
})
|
||||
this.chart.interval().position('year*sales')
|
||||
this.chart.render()
|
||||
},
|
||||
// 数据源改变 重新渲染新的数据
|
||||
changeData () {
|
||||
if (this.chart) {
|
||||
// 已经初始化过图表 更新数据
|
||||
this.chart.changeData(this.data)
|
||||
} else {
|
||||
// 没有图表 新创建一个实例
|
||||
this.initHandler()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -2,3 +2,4 @@ import Vue from 'vue'
|
||||
|
||||
Vue.component('G2Line1', resolve => { require(['@/components/G2/charts/Line/1.vue'], resolve) })
|
||||
Vue.component('G2Pie1', resolve => { require(['@/components/G2/charts/Pie/1.vue'], resolve) })
|
||||
Vue.component('G2Column1', resolve => { require(['@/components/G2/charts/Column/1.vue'], resolve) })
|
||||
|
||||
Reference in New Issue
Block a user