优化
This commit is contained in:
parent
7dfd38215b
commit
3ea7becaa6
@ -70,6 +70,7 @@ import moment from "moment";
|
|||||||
import {auth} from "matrix-middle-service-web/src/api/auth/index";
|
import {auth} from "matrix-middle-service-web/src/api/auth/index";
|
||||||
import {locationRecord} from "matrix-middle-service-web/src/api/location/record/index";
|
import {locationRecord} from "matrix-middle-service-web/src/api/location/record/index";
|
||||||
import {createCanvasDir} from "matrix-middle-service-web/src/views/record/logic/icon";
|
import {createCanvasDir} from "matrix-middle-service-web/src/views/record/logic/icon";
|
||||||
|
import {getAvgSpeed, getMaxSpeed} from "matrix-middle-service-web/src/views/record/logic/speed";
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
const COLOR = [
|
const COLOR = [
|
||||||
'#6090e0', '#30c030', '#d070d0', '#80c0f0', '#f07050', '#ffb900',
|
'#6090e0', '#30c030', '#d070d0', '#80c0f0', '#f07050', '#ffb900',
|
||||||
@ -281,16 +282,9 @@ function drawMap(){
|
|||||||
})
|
})
|
||||||
|
|
||||||
view.filterData = _data;
|
view.filterData = _data;
|
||||||
let sortSpeedData = JSON.parse(JSON.stringify(view.filterData)).sort((a,b)=>{return b.speed - a.speed})
|
|
||||||
view.speed.max = ((sortSpeedData[0]||{}).speed*3.6 || 0).toFixed(2);
|
|
||||||
|
|
||||||
if(view.filterData.length === 0){
|
view.speed.max = (getMaxSpeed(view.filterData) * 3.6).toFixed(2);
|
||||||
view.speed.avg = 0
|
view.speed.avg = (getAvgSpeed(view.filterData) * 3.6).toFixed(2);
|
||||||
} else {
|
|
||||||
view.speed.avg = ((view.filterData.map(item=>item.speed || 0).reduce((prev,cur)=>{
|
|
||||||
return prev + cur
|
|
||||||
},0) / view.filterData.length) * 3.6).toFixed(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log("data", _data)
|
console.log("data", _data)
|
||||||
|
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
export function getMaxSpeed(data:any[]){
|
||||||
|
let sortSpeedData = JSON.parse(JSON.stringify(data)).sort((a,b)=>{return (b.speed || 0) - (a.speed||0)})
|
||||||
|
return ((sortSpeedData[0]||{}).speed || 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getAvgSpeed(data:any[]){
|
||||||
|
if(data.length === 0){
|
||||||
|
return 0
|
||||||
|
} else {
|
||||||
|
return ((data.map(item=>item.speed || 0).reduce((prev,cur)=>{
|
||||||
|
return prev + cur
|
||||||
|
},0) / data.length))
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user