# HG changeset patch # User Lucas Thompson # Date 1496480396 -3600 # Node ID 6672496ff32eb0eca993b79c18cfcf56f00518df # Parent 40ea40ebc2b3ff86bfcb14ee8f75b5081f1d2d2c Alter Plot types slightly, moving yDomain to top level. diff -r 40ea40ebc2b3 -r 6672496ff32e src/app/visualisations/FeatureUtilities.ts --- a/src/app/visualisations/FeatureUtilities.ts Fri Jun 02 19:12:38 2017 +0100 +++ b/src/app/visualisations/FeatureUtilities.ts Sat Jun 03 09:59:56 2017 +0100 @@ -172,19 +172,23 @@ throwShapeError(); } -export interface PlotData { +export interface PlotDataPoint { cx: number; cy: number; } +export interface PlotData { + points: PlotDataPoint[]; + startTime: number; + duration; +} + export interface PlotLayerData { data: PlotData[]; yDomain: [number, number]; - startTime: number; - duration: number; } -export function generatePlotData(features: VectorFeature[]): PlotLayerData[] { +export function generatePlotData(features: VectorFeature[]): PlotLayerData { const winnowed = features.filter(feature => feature.data.length > 0); @@ -207,28 +211,30 @@ max = 1; } - return winnowed.map(feature => { - let duration = 0; + return { + data: winnowed.map(feature => { + let duration = 0; - // Give the plot items positions relative to the start of the - // line, rather than relative to absolute time 0. This is - // because we'll be setting the layer timeline start property - // later on and these will be positioned relative to that + // Give the plot items positions relative to the start of the + // line, rather than relative to absolute time 0. This is + // because we'll be setting the layer timeline start property + // later on and these will be positioned relative to that - const plotData = [...feature.data].map((val, i) => { - const t = i * feature.stepDuration; - duration = t + feature.stepDuration; + const plotData = [...feature.data].map((val, i) => { + const t = i * feature.stepDuration; + duration = t + feature.stepDuration; + return { + cx: t, + cy: val + }; + }); + return { - cx: t, - cy: val + points: plotData, + startTime: feature.startTime, + duration: duration }; - }); - - return { - data: plotData, - yDomain: [min, max] as [number, number], - startTime: feature.startTime, - duration: duration - }; - }); + }), + yDomain: [min, max] + }; } diff -r 40ea40ebc2b3 -r 6672496ff32e src/app/visualisations/tracks/tracks.components.ts --- a/src/app/visualisations/tracks/tracks.components.ts Fri Jun 02 19:12:38 2017 +0100 +++ b/src/app/visualisations/tracks/tracks.components.ts Sat Jun 03 09:59:56 2017 +0100 @@ -30,32 +30,32 @@ export class TracksComponent extends InspectableVerticallyBoundedComponent { - private currentState: PlotLayerData[]; + 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; + return this.currentState && this.currentState.data.length > 0 ? + this.currentState.yDomain : null; } protected get featureLayers(): Layer[] { this.currentState = generatePlotData(this.feature); - return this.currentState.map(feature => new Waves.helpers.LineLayer( - feature.data, { + return this.currentState.data.map(feature => new Waves.helpers.LineLayer( + feature.points, { color: this.colour, height: this.height, - yDomain: feature.yDomain + yDomain: this.currentState.yDomain }) ); } protected get postAddMap() { return (layer, index) => { - layer.start = this.currentState[index].startTime; - layer.duration = this.currentState[index].duration; + layer.start = this.currentState.data[index].startTime; + layer.duration = this.currentState.data[index].duration; layer.update(); }; }