comparison src/app/visualisations/grid/grid.component.ts @ 471:b69a223166b5

Add vertical scale to matrix, but just using matrix bin count to begin with
author Chris Cannam <cannam@all-day-breakfast.com>
date Thu, 29 Jun 2017 15:06:16 +0100
parents 3ace7672638b
children 9251232b689e
comparison
equal deleted inserted replaced
450:5fbecd666002 471:b69a223166b5
1 /** 1 /**
2 * Created by lucast on 31/05/2017. 2 * Created by lucast on 31/05/2017.
3 */ 3 */
4 import {WavesComponent} from '../waves-base.component'; 4 import {
5 InspectableVerticallyBoundedComponent,
6 VerticallyBounded,
7 VerticallyBoundedWavesComponent,
8 VerticalScaleRenderer,
9 VerticalValueInspectorRenderer,
10 WavesComponent
11 } from '../waves-base.component';
5 import { 12 import {
6 ChangeDetectionStrategy, 13 ChangeDetectionStrategy,
7 Component, 14 Component,
8 Input, 15 Input,
9 } from '@angular/core'; 16 } from '@angular/core';
16 selector: 'ugly-grid', 23 selector: 'ugly-grid',
17 templateUrl: '../waves-template.html', 24 templateUrl: '../waves-template.html',
18 styleUrls: ['../waves-template.css'], 25 styleUrls: ['../waves-template.css'],
19 changeDetection: ChangeDetectionStrategy.OnPush, 26 changeDetection: ChangeDetectionStrategy.OnPush,
20 providers: [ 27 providers: [
28 {provide: VerticallyBounded, useExisting: GridComponent },
29 {provide: VerticalScaleRenderer, useExisting: GridComponent },
30 {provide: VerticalValueInspectorRenderer, useExisting: GridComponent },
21 {provide: WavesComponent, useExisting: GridComponent} 31 {provide: WavesComponent, useExisting: GridComponent}
22 ] 32 ]
23 }) 33 })
24 export class GridComponent extends WavesComponent<MatrixFeature> { 34 export class GridComponent extends VerticallyBoundedWavesComponent<MatrixFeature> {
25 35
26 @Input() set grid(grid: MatrixFeature) { 36 @Input() set grid(grid: MatrixFeature) {
27 this.feature = grid; 37 this.feature = grid;
28 } 38 }
29 39
30 protected get featureLayers(): Layer[] { 40 protected get featureLayers(): Layer[] {
31 const startTime = this.feature.startTime; // !!! + make use of 41 const startTime = this.feature.startTime;
32 const stepDuration = this.feature.stepDuration; 42 const stepDuration = this.feature.stepDuration;
33 const matrixData = this.feature.data; 43 const matrixData = this.feature.data;
34 44
35 if (matrixData.length === 0) { 45 if (matrixData.length === 0) {
36 return []; 46 return [];
38 48
39 const targetValue = estimatePercentile(matrixData, 95); 49 const targetValue = estimatePercentile(matrixData, 95);
40 const gain = (targetValue > 0.0 ? (1.0 / targetValue) : 1.0); 50 const gain = (targetValue > 0.0 ? (1.0 / targetValue) : 1.0);
41 const matrixEntity = new Waves.utils.PrefilledMatrixEntity( 51 const matrixEntity = new Waves.utils.PrefilledMatrixEntity(
42 matrixData, 52 matrixData,
43 0, // startTime 53 startTime,
44 stepDuration 54 stepDuration
45 ); 55 );
46 56
47 return [ 57 return [
48 new Waves.helpers.MatrixLayer( 58 new Waves.helpers.MatrixLayer(
54 mapper: iceMapper() 64 mapper: iceMapper()
55 } 65 }
56 ) 66 )
57 ]; 67 ];
58 } 68 }
69
70 get range(): [number, number] {
71 return [0, this.feature.data.length > 0 ? this.feature.data[0].length : 0];
72 }
59 } 73 }