changeset 258:3018e8531840

Don't normalise the feature data to 0,1 here: instead set the yDomain of the layer to its actual extent
author Chris Cannam <cannam@all-day-breakfast.com>
date Fri, 28 Apr 2017 12:00:55 +0100
parents 7bd5152e2edb
children 4824acbf1a95
files src/app/waveform/waveform.component.ts
diffstat 1 files changed, 11 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/app/waveform/waveform.component.ts	Fri Apr 28 10:51:52 2017 +0100
+++ b/src/app/waveform/waveform.component.ts	Fri Apr 28 12:00:55 2017 +0100
@@ -626,23 +626,22 @@
         if (featureData.length === 0) {
           return;
         }
-        const normalisationFactor = 1.0 /
-          featureData.reduce(
-            (currentMax, feature) => Math.max(currentMax, feature),
-            -Infinity
-          );
-
         const plotData = [...featureData].map((feature, i) => {
           return {
             cx: i * stepDuration,
-            cy: feature * normalisationFactor,
-            value: feature
+            cy: feature
           };
         });
-
+        let min = featureData.reduce((m, f) => Math.min(m, f), Infinity);
+        let max = featureData.reduce((m, f) => Math.max(m, f), -Infinity);
+        if (min === Infinity) {
+          min = 0;
+          max = 1;
+        }
         const lineLayer = new wavesUI.helpers.LineLayer(plotData, {
           color: colour,
-          height: height
+          height: height,
+          yDomain: [ min, max ]
         });
         this.addLayer(
           lineLayer,
@@ -652,7 +651,8 @@
         this.highlightLayer = new wavesUI.helpers.HighlightLayer(lineLayer, {
           opacity: 0.7,
           height: height,
-          color: '#c33c54'
+          color: '#c33c54',
+          yDomain: [ min, max ]
         });
         this.addLayer(
           this.highlightLayer,