Mercurial > hg > ugly-duckling
view src/app/visualisations/tracks/tracks.components.ts @ 493:7f9fb84816b9
Introduce a singleton / service for communicating errors / or other notifications (there aren't any yet) - using MdSnackBar internally.
author | Lucas Thompson <dev@lucas.im> |
---|---|
date | Thu, 06 Jul 2017 19:47:18 +0100 |
parents | ab43880f1cd5 |
children | c39df81c4dae |
line wrap: on
line source
/** * Created by lucas on 30/05/2017. */ import { InspectableVerticallyBoundedComponent, PlayheadRenderer, VerticallyLabelled, VerticalScaleRenderer, VerticalValueInspectorRenderer, WavesComponent } 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: VerticallyLabelled, useExisting: TracksComponent }, {provide: VerticalScaleRenderer, useExisting: TracksComponent}, {provide: VerticalValueInspectorRenderer, useExisting: TracksComponent}, {provide: PlayheadRenderer, useExisting: TracksComponent }, {provide: WavesComponent, useExisting: TracksComponent} ], }) export class TracksComponent extends InspectableVerticallyBoundedComponent<TracksFeature> { private currentState: PlotLayerData; @Input() set tracks(input: TracksFeature) { this.feature = input; } get labels(): [number, number] { return this.currentState && this.currentState.data.length > 0 ? this.currentState.yDomain : null; } protected get featureLayers(): Layer[] { this.currentState = generatePlotData(this.feature); return this.currentState.data.map(feature => new Waves.helpers.LineLayer( feature.points, { color: this.colour, height: this.height, yDomain: this.currentState.yDomain }) ); } protected get postAddMap() { return (layer, index) => { layer.start = this.currentState.data[index].startTime; layer.duration = this.currentState.data[index].duration; layer.update(); }; } }