Mercurial > hg > ugly-duckling
diff src/app/visualisations/FeatureUtilities.ts @ 404:6672496ff32e
Alter Plot types slightly, moving yDomain to top level.
author | Lucas Thompson <dev@lucas.im> |
---|---|
date | Sat, 03 Jun 2017 09:59:56 +0100 |
parents | 3eab26a629e1 |
children | 9251232b689e |
line wrap: on
line diff
--- 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] + }; }