no message

Former-commit-id: dd09d6b1c896f1ed594f452ba29c47421e827dd1
Former-commit-id: 00c0180c258f09256e70d19f33e3db0ef5da58d2
Former-commit-id: 4cda50a2b215586ea6696c2d91627acae23164f5
This commit is contained in:
李杨
2018-02-18 13:06:51 +08:00
parent cf7907f866
commit dee30fb7b5
6 changed files with 85 additions and 4 deletions

View File

@@ -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 {}
}
})

View File

@@ -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 => ({

View File

@@ -1 +1,2 @@
import './G2Column'
import './G2Line'