web: Sort data in simple measure graphs.

This commit is contained in:
Jonathan Bernard 2019-09-27 11:45:01 -05:00
parent 8af6c65c9b
commit 74b8a42d29
2 changed files with 8 additions and 4 deletions

View File

@ -22,11 +22,13 @@ export class SimpleDetails extends Vue {
};
private get measurementChartData(): ApexAxisChartSeries {
const measurementData = this.measurements || [];
const measurementData = this.measurements.slice() || [];
return [{
name: this.measure.name,
data: measurementData.map((m) => ({ x: m.timestamp.toISOString(), y: m.value }))
data: measurementData
.sort((a, b) => a.timestamp.getTime() - b.timestamp.getTime())
.map((m) => ({ x: m.timestamp.toISOString(), y: m.value }))
}];
}

View File

@ -16,11 +16,13 @@ export class SimpleSummaryGraph extends Vue {
};
private get measurementData(): ApexAxisChartSeries {
const measurementData = this.measurements || [];
let measurementData = this.measurements.slice() || [];
return [{
name: this.measure.name,
data: measurementData.map((m) => ({ x: m.timestamp.toISOString(), y: m.value }))
data: measurementData
.sort((a, b) => a.timestamp.getTime() - b.timestamp.getTime())
.map((m) => ({ x: m.timestamp.toISOString(), y: m.value }))
}];
}
}