Mercurial > hg > ugly-duckling
comparison src/app/waveform/waveform.component.ts @ 313:a37fe99e1d9d
Add unit to highlight layer
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Fri, 12 May 2017 15:07:50 +0100 |
parents | e356409f4c45 |
children | 98490d0ceb77 |
comparison
equal
deleted
inserted
replaced
309:e356409f4c45 | 313:a37fe99e1d9d |
---|---|
608 | 608 |
609 this.timeline.tracks.update(); | 609 this.timeline.tracks.update(); |
610 } | 610 } |
611 | 611 |
612 private addLineLayers(features: VectorFeature[], | 612 private addLineLayers(features: VectorFeature[], |
613 unit: string, | |
613 colour: Colour) { | 614 colour: Colour) { |
614 | 615 |
615 // Winnow out empty features | 616 // Winnow out empty features |
616 features = features.filter(feature => (feature.data.length > 0)); | 617 features = features.filter(feature => (feature.data.length > 0)); |
617 | 618 |
676 | 677 |
677 return lineLayer; | 678 return lineLayer; |
678 }); | 679 }); |
679 | 680 |
680 // And a single scale layer at left | 681 // And a single scale layer at left |
682 //!!! todo: unit in scale layer | |
681 const scaleLayer = new wavesUI.helpers.ScaleLayer({ | 683 const scaleLayer = new wavesUI.helpers.ScaleLayer({ |
682 tickColor: colour, | 684 tickColor: colour, |
683 textColor: colour, | 685 textColor: colour, |
684 height: height, | 686 height: height, |
685 yDomain: [ min, max ] | 687 yDomain: [ min, max ] |
695 this.highlightLayer = new wavesUI.helpers.HighlightLayer(lineLayers, { | 697 this.highlightLayer = new wavesUI.helpers.HighlightLayer(lineLayers, { |
696 opacity: 0.7, | 698 opacity: 0.7, |
697 height: height, | 699 height: height, |
698 color: '#c33c54', | 700 color: '#c33c54', |
699 labelOffset: 38, | 701 labelOffset: 38, |
700 yDomain: [ min, max ] | 702 yDomain: [ min, max ], |
703 unit | |
701 }); | 704 }); |
702 this.addLayer( | 705 this.addLayer( |
703 this.highlightLayer, | 706 this.highlightLayer, |
704 waveTrack, | 707 waveTrack, |
705 this.timeline.timeContext | 708 this.timeline.timeContext |
724 const features: FeatureCollection = (extracted.features as FeatureCollection); | 727 const features: FeatureCollection = (extracted.features as FeatureCollection); |
725 const outputDescriptor = extracted.outputDescriptor; | 728 const outputDescriptor = extracted.outputDescriptor; |
726 const height = this.trackDiv.nativeElement.getBoundingClientRect().height; | 729 const height = this.trackDiv.nativeElement.getBoundingClientRect().height; |
727 const waveTrack = this.timeline.getTrackById(`wave-${this.trackIdPrefix}`); | 730 const waveTrack = this.timeline.getTrackById(`wave-${this.trackIdPrefix}`); |
728 | 731 |
732 let unit = ""; | |
733 if (outputDescriptor.configured.hasOwnProperty('unit')) { | |
734 unit = outputDescriptor.configured.unit; | |
735 } | |
736 | |
729 // TODO refactor all of this | 737 // TODO refactor all of this |
730 switch (features.shape) { | 738 switch (features.shape) { |
731 | 739 |
732 case 'vector': { | 740 case 'vector': { |
733 const collected = features.collected as VectorFeature; | 741 const collected = features.collected as VectorFeature; |
734 this.addLineLayers([collected], colour); | 742 this.addLineLayers([collected], unit, colour); |
735 break; | 743 break; |
736 } | 744 } |
737 | 745 |
738 case 'tracks': { | 746 case 'tracks': { |
739 const collected = features.collected as TracksFeature; | 747 const collected = features.collected as TracksFeature; |
740 this.addLineLayers(collected, colour); | 748 this.addLineLayers(collected, unit, colour); |
741 break; | 749 break; |
742 } | 750 } |
743 | 751 |
744 case 'list': { | 752 case 'list': { |
745 const featureData = features.collected as FeatureList; | 753 const featureData = features.collected as FeatureList; |