diff --git a/web/src/components/measure-details/simple-details.ts b/web/src/components/measure-details/simple-details.ts index 87c241b..ef28330 100644 --- a/web/src/components/measure-details/simple-details.ts +++ b/web/src/components/measure-details/simple-details.ts @@ -4,6 +4,7 @@ import moment from 'moment'; import assign from 'lodash.assign'; import { library } from '@fortawesome/fontawesome-svg-core'; import { faPencilAlt } from '@fortawesome/free-solid-svg-icons'; +import { byTimestampComparator } from '@/util'; library.add(faPencilAlt); @@ -28,7 +29,7 @@ export class SimpleDetails extends Vue { return [{ name: this.measure.name, data: measurementData - .sort((a, b) => a.timestamp.getTime() - b.timestamp.getTime()) + .sort(byTimestampComparator) .map((m) => ({ x: m.timestamp.toISOString(), y: m.value })) }]; } diff --git a/web/src/util.ts b/web/src/util.ts new file mode 100644 index 0000000..c51f4b9 --- /dev/null +++ b/web/src/util.ts @@ -0,0 +1,7 @@ +import { Measurement, MeasurementMeta } from '@/models'; + +export function byTimestampComparator( + a: Measurement, + b: Measurement): number { + return a.timestamp.getTime() - b.timestamp.getTime(); +}