From dee30fb7b51f0188a4557708e4fa9d4a04aea907 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E6=9D=A8?= <1711467488@qq.com>
Date: Sun, 18 Feb 2018 13:06:51 +0800
Subject: [PATCH] no message
Former-commit-id: dd09d6b1c896f1ed594f452ba29c47421e827dd1
Former-commit-id: 00c0180c258f09256e70d19f33e3db0ef5da58d2
Former-commit-id: 4cda50a2b215586ea6696c2d91627acae23164f5
---
.../charts/G2/components/Column/base.vue | 32 ++++++++++++++++++
src/components/charts/index.js | 1 +
src/mock/chart/G2Column.js | 33 +++++++++++++++++++
src/mock/chart/G2Line.js | 2 ++
src/mock/chart/index.js | 1 +
src/pages/demo/chart/index/index.vue | 20 ++++++++---
6 files changed, 85 insertions(+), 4 deletions(-)
create mode 100644 src/components/charts/G2/components/Column/base.vue
create mode 100644 src/mock/chart/G2Column.js
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: {