2021-06-02 14:35:51 +08:00

46 lines
1.1 KiB
JavaScript

import Moment from 'com/utils/moment.zh_cn'
export function processWater(water, label){
const waters = []
water.forEach( w => {
let n = {}
label.forEach( key => {
if(!!w.data) {
n[key] = w.data[key]
}
} )
n['key'] = w._id.$oid
n['time_str'] = Moment(w.timestamp).format('lll')
n['time'] = Moment(w.timestamp).toDate()
waters.push(n)
} )
return waters
}
export function processTimeData(dataArr=[], start=new Date(), end=new Date(), step=1) {
const data_re = []
for(let i=start.getTime(); i<=end.getTime(); i+=step)
{
data_re.push({
})
}
}
export function generateWaterData(label, count) {
let data = []
for(let _ = 0; _< count; _ ++) {
let d = {}
label.forEach(key => {
d[key] = Math.random()
})
d.key = Math.round( Math.random() * 10000000 ).toString()
d['time_str'] = Moment().format('lll')
d['time'] = Moment().toDate()
data.push(d)
}
return data;
}