diff --git a/src/components/charts/G2/components/Column/base.vue b/src/components/charts/G2/components/Column/base.vue
new file mode 100644
index 00000000..3283eb4d
--- /dev/null
+++ b/src/components/charts/G2/components/Column/base.vue
@@ -0,0 +1,32 @@
+
+
+
+
+
+
diff --git a/src/components/charts/index.js b/src/components/charts/index.js
index 7ec65c47..8d363576 100644
--- a/src/components/charts/index.js
+++ b/src/components/charts/index.js
@@ -2,3 +2,4 @@ import Vue from 'vue'
Vue.component('G2LineBase', resolve => { require(['@/components/charts/G2/components/Line/base.vue'], resolve) })
Vue.component('G2LineStep', resolve => { require(['@/components/charts/G2/components/Line/step.vue'], resolve) })
+Vue.component('G2ColumnBase', resolve => { require(['@/components/charts/G2/components/Column/base.vue'], resolve) })
diff --git a/src/mock/chart/G2Column.js b/src/mock/chart/G2Column.js
new file mode 100644
index 00000000..f0a11681
--- /dev/null
+++ b/src/mock/chart/G2Column.js
@@ -0,0 +1,33 @@
+import Mock from 'mockjs'
+
+const r = (add = 0) => {
+ return Math.round(Math.random() * 100) + add
+}
+
+const returnMaker = (data = []) => {
+ return {
+ code: 0,
+ msg: '请求成功',
+ data
+ }
+}
+
+Mock.mock('/api/chart/G2Column', 'post', ({body, type, url}) => {
+ const _body = JSON.parse(body)
+ switch (_body.type) {
+ // 基础折线图
+ case 'base': {
+ const year = ['3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月']
+ const data = year.map(e => ({
+ year: e,
+ value: r()
+ })).map(e => ({
+ x: e.year,
+ y: e.value
+ }))
+ return returnMaker(data)
+ }
+ default:
+ return {}
+ }
+})
diff --git a/src/mock/chart/G2Line.js b/src/mock/chart/G2Line.js
index af6911b6..a459cb2c 100644
--- a/src/mock/chart/G2Line.js
+++ b/src/mock/chart/G2Line.js
@@ -15,6 +15,7 @@ const returnMaker = (data = []) => {
Mock.mock('/api/chart/G2Line', 'post', ({body, type, url}) => {
const _body = JSON.parse(body)
switch (_body.type) {
+ // 基础折线图
case 'base': {
let last = 0
const year = ['1991', '1992', '1993', '1994', '1995', '1996', '1997', '1998', '1999']
@@ -32,6 +33,7 @@ Mock.mock('/api/chart/G2Line', 'post', ({body, type, url}) => {
last = 0
return returnMaker(data)
}
+ // 阶梯折线图
case 'step': {
const month = ['3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月']
const data = month.map(e => ({
diff --git a/src/mock/chart/index.js b/src/mock/chart/index.js
index 24f0d417..da63eff5 100644
--- a/src/mock/chart/index.js
+++ b/src/mock/chart/index.js
@@ -1 +1,2 @@
+import './G2Column'
import './G2Line'
diff --git a/src/pages/demo/chart/index/index.vue b/src/pages/demo/chart/index/index.vue
index 3994cae6..66e49644 100644
--- a/src/pages/demo/chart/index/index.vue
+++ b/src/pages/demo/chart/index/index.vue
@@ -2,17 +2,24 @@
-
+
-
+
+
+
+
+
@@ -37,6 +44,11 @@ export default {
api: {url: '/api/chart/G2Line', data: {type: 'step'}},
data: [],
padding: [30, 40, 50, 50]
+ },
+ {
+ api: {url: '/api/chart/G2Column', data: {type: 'base'}},
+ data: [],
+ padding: [30, 40, 50, 50]
}
],
layout: {