Mercurial > hg > ugly-duckling
comparison src/app/waveform/waveform.component.ts @ 316:98490d0ceb77
Lint.
author | Lucas Thompson <dev@lucas.im> |
---|---|
date | Fri, 12 May 2017 17:14:59 +0100 |
parents | a37fe99e1d9d |
children | 64dee0c156b1 |
comparison
equal
deleted
inserted
replaced
315:78a38043b634 | 316:98490d0ceb77 |
---|---|
613 unit: string, | 613 unit: string, |
614 colour: Colour) { | 614 colour: Colour) { |
615 | 615 |
616 // Winnow out empty features | 616 // Winnow out empty features |
617 features = features.filter(feature => (feature.data.length > 0)); | 617 features = features.filter(feature => (feature.data.length > 0)); |
618 | 618 |
619 // First establish a [min,max] range across all of the features | 619 // First establish a [min,max] range across all of the features |
620 let [min, max] = features.reduce((acc, feature) => { | 620 let [min, max] = features.reduce((acc, feature) => { |
621 return feature.data.reduce((acc, val) => { | 621 return feature.data.reduce((acc, val) => { |
622 const [min, max] = acc; | 622 const [min, max] = acc; |
623 return [Math.min (min, val), Math.max (max, val)]; | 623 return [Math.min (min, val), Math.max (max, val)]; |
624 }, acc); | 624 }, acc); |
625 }, [Infinity, -Infinity]); | 625 }, [Infinity, -Infinity]); |
626 | 626 |
627 console.log("addLineLayers: " + features.length + " non-empty features, overall min = " + min + ", max = " + max); | 627 console.log('addLineLayers: ' + features.length + ' non-empty features, overall min = ' + min + ', max = ' + max); |
628 | 628 |
629 if (min === Infinity) { | 629 if (min === Infinity) { |
630 min = 0; | 630 min = 0; |
631 max = 1; | 631 max = 1; |
632 } | 632 } |
633 | 633 |
634 if (min !== min || max !== max) { | 634 if (min !== min || max !== max) { |
635 console.log("WARNING: min or max is NaN"); | 635 console.log('WARNING: min or max is NaN'); |
636 min = 0; | 636 min = 0; |
637 max = 1; | 637 max = 1; |
638 } | 638 } |
639 | 639 |
640 const height = this.trackDiv.nativeElement.getBoundingClientRect().height; | 640 const height = this.trackDiv.nativeElement.getBoundingClientRect().height; |
647 | 647 |
648 // Give the plot items positions relative to the start of the | 648 // Give the plot items positions relative to the start of the |
649 // line, rather than relative to absolute time 0. This is | 649 // line, rather than relative to absolute time 0. This is |
650 // because we'll be setting the layer timeline start property | 650 // because we'll be setting the layer timeline start property |
651 // later on and these will be positioned relative to that | 651 // later on and these will be positioned relative to that |
652 | 652 |
653 const plotData = [...feature.data].map((val, i) => { | 653 const plotData = [...feature.data].map((val, i) => { |
654 const t = i * feature.stepDuration; | 654 const t = i * feature.stepDuration; |
655 duration = t + feature.stepDuration; | 655 duration = t + feature.stepDuration; |
656 return { | 656 return { |
657 cx: t, | 657 cx: t, |
658 cy: val | 658 cy: val |
659 }; | 659 }; |
660 }); | 660 }); |
661 | 661 |
662 const lineLayer = new wavesUI.helpers.LineLayer(plotData, { | 662 const lineLayer = new wavesUI.helpers.LineLayer(plotData, { |
663 color: colour, | 663 color: colour, |
664 height: height, | 664 height: height, |
665 yDomain: [ min, max ] | 665 yDomain: [ min, max ] |
666 }); | 666 }); |
672 | 672 |
673 // Set start and duration so that the highlight layer can use | 673 // Set start and duration so that the highlight layer can use |
674 // them to determine which line to draw values from | 674 // them to determine which line to draw values from |
675 lineLayer.start = feature.startTime; | 675 lineLayer.start = feature.startTime; |
676 lineLayer.duration = duration; | 676 lineLayer.duration = duration; |
677 | 677 |
678 return lineLayer; | 678 return lineLayer; |
679 }); | 679 }); |
680 | 680 |
681 // And a single scale layer at left | 681 // And a single scale layer at left |
682 //!!! todo: unit in scale layer | 682 // !!! todo: unit in scale layer |
683 const scaleLayer = new wavesUI.helpers.ScaleLayer({ | 683 const scaleLayer = new wavesUI.helpers.ScaleLayer({ |
684 tickColor: colour, | 684 tickColor: colour, |
685 textColor: colour, | 685 textColor: colour, |
686 height: height, | 686 height: height, |
687 yDomain: [ min, max ] | 687 yDomain: [ min, max ] |
727 const features: FeatureCollection = (extracted.features as FeatureCollection); | 727 const features: FeatureCollection = (extracted.features as FeatureCollection); |
728 const outputDescriptor = extracted.outputDescriptor; | 728 const outputDescriptor = extracted.outputDescriptor; |
729 const height = this.trackDiv.nativeElement.getBoundingClientRect().height; | 729 const height = this.trackDiv.nativeElement.getBoundingClientRect().height; |
730 const waveTrack = this.timeline.getTrackById(`wave-${this.trackIdPrefix}`); | 730 const waveTrack = this.timeline.getTrackById(`wave-${this.trackIdPrefix}`); |
731 | 731 |
732 let unit = ""; | 732 let unit = ''; |
733 if (outputDescriptor.configured.hasOwnProperty('unit')) { | 733 if (outputDescriptor.configured.hasOwnProperty('unit')) { |
734 unit = outputDescriptor.configured.unit; | 734 unit = outputDescriptor.configured.unit; |
735 } | 735 } |
736 | 736 |
737 // TODO refactor all of this | 737 // TODO refactor all of this |
746 case 'tracks': { | 746 case 'tracks': { |
747 const collected = features.collected as TracksFeature; | 747 const collected = features.collected as TracksFeature; |
748 this.addLineLayers(collected, unit, colour); | 748 this.addLineLayers(collected, unit, colour); |
749 break; | 749 break; |
750 } | 750 } |
751 | 751 |
752 case 'list': { | 752 case 'list': { |
753 const featureData = features.collected as FeatureList; | 753 const featureData = features.collected as FeatureList; |
754 if (featureData.length === 0) { | 754 if (featureData.length === 0) { |
755 return; | 755 return; |
756 } | 756 } |
851 } | 851 } |
852 break; | 852 break; |
853 } | 853 } |
854 case 'matrix': { | 854 case 'matrix': { |
855 const collected = features.collected as MatrixFeature; | 855 const collected = features.collected as MatrixFeature; |
856 const startTime = collected.startTime; //!!! + make use of | 856 const startTime = collected.startTime; // !!! + make use of |
857 const stepDuration = collected.stepDuration; | 857 const stepDuration = collected.stepDuration; |
858 const matrixData = collected.data; | 858 const matrixData = collected.data; |
859 | 859 |
860 if (matrixData.length === 0) { | 860 if (matrixData.length === 0) { |
861 return; | 861 return; |