dev@359: /** dev@359: * Created by lucas on 30/05/2017. dev@359: */ dev@359: import {WavesComponent} from "../waves-base.component"; dev@366: import { dev@366: AfterViewInit, dev@366: ChangeDetectionStrategy, dev@366: Component, dev@366: ElementRef, dev@366: Input, dev@366: ViewChild dev@366: } from "@angular/core"; dev@366: import {VectorFeature} from "piper/HigherLevelUtilities"; dev@366: import Waves from 'waves-ui-piper'; dev@368: import {generatePlotData, PlotLayerData} from "../FeatureUtilities"; dev@359: dev@359: @Component({ dev@359: selector: 'ugly-curve', dev@366: templateUrl: '../waves-template.html', dev@359: styleUrls: ['../waves-template.css'], dev@359: changeDetection: ChangeDetectionStrategy.OnPush dev@359: }) dev@366: export class CurveComponent extends WavesComponent implements AfterViewInit { dev@359: dev@366: @ViewChild('track') trackDiv: ElementRef; dev@366: dev@366: private mFeature: VectorFeature; dev@366: private currentState: PlotLayerData[]; dev@368: private height: number; // As it stands, height is fixed. Store once onInit. dev@366: dev@366: @Input() set feature(input: VectorFeature) { dev@366: this.mFeature = input; dev@368: this.currentState = generatePlotData([input]); dev@366: this.update(); dev@366: } dev@368: @Input() colour: string; dev@366: dev@366: get feature(): VectorFeature { dev@366: return this.mFeature; dev@366: } dev@366: dev@366: ngAfterViewInit(): void { dev@368: this.height = this.trackDiv.nativeElement.getBoundingClientRect().height; dev@366: this.renderTimeline(this.trackDiv); dev@366: this.update(); dev@366: } dev@366: dev@366: update(): void { dev@366: if (this.waveTrack) { dev@367: this.clearTimeline(this.trackDiv); dev@366: for (const feature of this.currentState) { dev@366: const lineLayer = new Waves.helpers.LineLayer(feature.data, { dev@368: color: this.colour, dev@368: height: this.height, dev@366: yDomain: feature.yDomain dev@366: }); dev@366: this.addLayer( dev@366: lineLayer, dev@366: this.waveTrack, dev@366: this.timeline.timeContext dev@366: ); dev@366: dev@366: // Set start and duration so that the highlight layer can use dev@366: // them to determine which line to draw values from dev@366: lineLayer.start = feature.startTime; dev@366: lineLayer.duration = feature.duration; dev@366: } dev@366: } dev@366: } dev@359: }