2018-01-28 23:52:37 +08:00
|
|
|
import Mock from 'mockjs'
|
2018-02-18 18:04:45 +08:00
|
|
|
import * as fn from './_publicFunction'
|
2018-02-18 11:29:09 +08:00
|
|
|
|
2018-01-28 23:52:37 +08:00
|
|
|
Mock.mock('/api/chart/G2Line', 'post', ({body, type, url}) => {
|
|
|
|
|
const _body = JSON.parse(body)
|
2018-02-18 11:29:09 +08:00
|
|
|
switch (_body.type) {
|
2018-02-18 13:06:51 +08:00
|
|
|
// 基础折线图
|
2018-02-18 11:29:09 +08:00
|
|
|
case 'base': {
|
2018-02-18 11:59:43 +08:00
|
|
|
let last = 0
|
2018-02-18 11:25:24 +08:00
|
|
|
const year = ['1991', '1992', '1993', '1994', '1995', '1996', '1997', '1998', '1999']
|
2018-02-18 11:46:15 +08:00
|
|
|
const data = year.map(e => ({
|
|
|
|
|
year: e,
|
2018-02-18 11:25:24 +08:00
|
|
|
value: 0
|
|
|
|
|
})).map(e => {
|
2018-02-18 18:04:45 +08:00
|
|
|
e.value = last + fn.r()
|
2018-02-18 11:59:43 +08:00
|
|
|
last = e.value
|
2018-02-17 20:25:11 +08:00
|
|
|
return e
|
2018-02-18 11:59:43 +08:00
|
|
|
}).map(e => ({
|
|
|
|
|
x: e.year,
|
|
|
|
|
y: e.value
|
|
|
|
|
}))
|
|
|
|
|
last = 0
|
2018-02-18 18:04:45 +08:00
|
|
|
return fn.returnMaker(data)
|
2018-02-18 11:25:24 +08:00
|
|
|
}
|
2018-02-18 13:06:51 +08:00
|
|
|
// 阶梯折线图
|
2018-02-18 11:29:09 +08:00
|
|
|
case 'step': {
|
2018-02-18 12:40:17 +08:00
|
|
|
const month = ['3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月']
|
2018-02-18 11:46:15 +08:00
|
|
|
const data = month.map(e => ({
|
|
|
|
|
month: e,
|
2018-02-18 18:04:45 +08:00
|
|
|
value: fn.r()
|
2018-02-18 12:00:55 +08:00
|
|
|
})).map(e => ({
|
2018-02-18 11:59:43 +08:00
|
|
|
x: e.month,
|
|
|
|
|
y: e.value
|
|
|
|
|
}))
|
2018-02-18 18:04:45 +08:00
|
|
|
return fn.returnMaker(data)
|
2018-02-18 11:25:24 +08:00
|
|
|
}
|
2018-01-28 23:52:37 +08:00
|
|
|
default:
|
|
|
|
|
return {}
|
|
|
|
|
}
|
|
|
|
|
})
|