[O] Optimize in-between dates storing
This commit is contained in:
@@ -142,21 +142,21 @@ export default class OverallLine extends Vue
|
|||||||
|
|
||||||
// Find the dates in between
|
// Find the dates in between
|
||||||
let now = new Date(Math.min(new Date().getTime(), CourseUtils.getTermEndDate().getTime()));
|
let now = new Date(Math.min(new Date().getTime(), CourseUtils.getTermEndDate().getTime()));
|
||||||
let dates: number[] = [];
|
let times: number[] = [];
|
||||||
for (let date = minDate; date <= now; date.setDate(date.getDate() + 1))
|
for (let date = minDate; date <= now; date.setDate(date.getDate() + 1))
|
||||||
{
|
{
|
||||||
dates.push(new Date(date).getTime());
|
times.push(date.getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
let lastValue: any = null;
|
let lastValue: any = null;
|
||||||
return dates.map(date =>
|
return times.map(time =>
|
||||||
{
|
{
|
||||||
// Data point on this specific date
|
// Data point on this specific date
|
||||||
let thisValue = data.find(a => a[0] == date);
|
let thisValue = data.find(a => a[0] == time);
|
||||||
|
|
||||||
// None
|
// None
|
||||||
if (thisValue == null) return [date, lastValue == null ? null : lastValue[1]];
|
if (thisValue == null) return [time, lastValue == null ? null : lastValue[1]];
|
||||||
else return [date, (lastValue = thisValue)[1]];
|
else return [time, (lastValue = thisValue)[1]];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user