Files
mes-ui-d2/src/mock/chart/G2Line.js
李杨 472a95be6a no message
Former-commit-id: 5874fc28b778fc88a172c6bf686cd90a260f28ea
Former-commit-id: 17b3344bb7c99b93ced5d1cf8cad81deda0a7b7d
Former-commit-id: bfecc607c2f9dcd9078cee0a71bd3b2bb10b4730
2018-02-18 18:20:28 +08:00

29 lines
720 B
JavaScript

import Mock from 'mockjs'
import * as fn from './_fn'
Mock.mock('/api/chart/G2Line', 'post', ({body, type, url}) => {
const _body = JSON.parse(body)
switch (_body.type) {
// 基础折线图
case 'base': {
let last = 0
const data = ['2010', '2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018'].map(x => ({
x,
y: 0
})).map(e => {
e.y = last + fn.r()
last = e.y
return e
})
last = 0
return fn.returnMaker(data)
}
// 阶梯折线图
case 'step': {
return fn.returnMaker(['3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月'].map(x => ({x, y: fn.r()})))
}
default:
return {}
}
})