Mercurial > hg > ugly-duckling
view src/app/visualisations/tracks/tracks.components.ts @ 394:f45a916eb5b1
Use the cross hair layer for notes, tracks and curve. This involved bodging in unit to ShapedFeatureData, which isn't particularly easy to do because this isn't an encapsulated type. Need to come back to improving this, as I am monkey-patching a unit property onto Arrays etc.
author | Lucas Thompson <dev@lucas.im> |
---|---|
date | Thu, 01 Jun 2017 18:55:55 +0100 |
parents | 7ef6c8089801 |
children | 6672496ff32e |
line wrap: on
line source
/** * Created by lucas on 30/05/2017. */ import { InspectableVerticallyBoundedComponent, VerticallyBounded, VerticalScaleRenderer, VerticalValueInspectorRenderer, } from '../waves-base.component'; import { ChangeDetectionStrategy, Component, Input, } from '@angular/core'; import {TracksFeature} from 'piper/HigherLevelUtilities'; import Waves from 'waves-ui-piper'; import {generatePlotData, PlotLayerData} from '../FeatureUtilities'; @Component({ selector: 'ugly-tracks', templateUrl: '../waves-template.html', styleUrls: ['../waves-template.css'], changeDetection: ChangeDetectionStrategy.OnPush, providers: [ {provide: VerticallyBounded, useExisting: TracksComponent }, {provide: VerticalScaleRenderer, useExisting: TracksComponent}, {provide: VerticalValueInspectorRenderer, useExisting: TracksComponent}, ], }) export class TracksComponent extends InspectableVerticallyBoundedComponent<TracksFeature> { private currentState: PlotLayerData[]; @Input() set tracks(input: TracksFeature) { this.feature = input; } get range(): [number, number] { return this.currentState && this.currentState.length > 0 ? this.currentState[0].yDomain : null; } protected get featureLayers(): Layer[] { this.currentState = generatePlotData(this.feature); return this.currentState.map(feature => new Waves.helpers.LineLayer( feature.data, { color: this.colour, height: this.height, yDomain: feature.yDomain }) ); } protected get postAddMap() { return (layer, index) => { layer.start = this.currentState[index].startTime; layer.duration = this.currentState[index].duration; layer.update(); }; } }