Mercurial > hg > ugly-duckling
comparison src/app/waveform/waveform.component.ts @ 68:f94a9bb319e3
Bail out of rendering if there are no features.
author | Lucas Thompson <dev@lucas.im> |
---|---|
date | Mon, 19 Dec 2016 14:18:09 +0000 |
parents | 7c34938470fb |
children | 13955649f5af |
comparison
equal
deleted
inserted
replaced
67:7c34938470fb | 68:f94a9bb319e3 |
---|---|
174 // TODO refactor all of this | 174 // TODO refactor all of this |
175 switch (features.shape) { | 175 switch (features.shape) { |
176 case 'vector': { | 176 case 'vector': { |
177 const stepDuration = (features as FixedSpacedFeatures).stepDuration; | 177 const stepDuration = (features as FixedSpacedFeatures).stepDuration; |
178 const featureData = (features.data as Float32Array); | 178 const featureData = (features.data as Float32Array); |
179 if (featureData.length === 0) return; | |
179 const normalisationFactor = 1.0 / | 180 const normalisationFactor = 1.0 / |
180 featureData.reduce( | 181 featureData.reduce( |
181 (currentMax, feature) => Math.max(currentMax, feature), | 182 (currentMax, feature) => Math.max(currentMax, feature), |
182 -Infinity | 183 -Infinity |
183 ); | 184 ); |
200 ), colour); | 201 ), colour); |
201 break; | 202 break; |
202 } | 203 } |
203 case 'list': { | 204 case 'list': { |
204 const featureData = (features.data as FeatureList); | 205 const featureData = (features.data as FeatureList); |
206 if (featureData.length === 0) return; | |
205 // TODO look at output descriptor instead of directly inspecting features | 207 // TODO look at output descriptor instead of directly inspecting features |
206 const hasDuration = outputDescriptor.configured.hasDuration; | 208 const hasDuration = outputDescriptor.configured.hasDuration; |
207 const isMarker = !hasDuration | 209 const isMarker = !hasDuration |
208 && outputDescriptor.configured.binCount === 0 | 210 && outputDescriptor.configured.binCount === 0 |
209 && featureData[0].featureValues == null; | 211 && featureData[0].featureValues == null; |