Mercurial > hg > ugly-duckling
changeset 58:bb2bbb192e2b
Normalise time series values.
author | Lucas Thompson <dev@lucas.im> |
---|---|
date | Thu, 08 Dec 2016 16:45:30 +0000 |
parents | 6ece58c96868 |
children | 010871a771d3 |
files | src/app/waveform/waveform.component.ts |
diffstat | 1 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/app/waveform/waveform.component.ts Thu Dec 08 16:23:22 2016 +0000 +++ b/src/app/waveform/waveform.component.ts Thu Dec 08 16:45:30 2016 +0000 @@ -137,10 +137,16 @@ // TODO refactor - this doesn't belong here private renderFeatures(features: FeatureList): void { + const normalisationFactor = 1.0 / + features.reduce((currentMax, feature) => { + return (feature.featureValues) + ? Math.max(currentMax, feature.featureValues[0]) + : currentMax; + }, -Infinity); const plotData = features.map(feature => { return { cx: toSeconds(feature.timestamp), - cy: feature.featureValues[0] + cy: feature.featureValues[0] * normalisationFactor }; }); this.addLayer(