Commit 82e285b4 authored by Nina Willems's avatar Nina Willems

[client/timeserie] param dates in stats

parent a980a076
......@@ -30,7 +30,7 @@ export interface IDimensions {
width: number;
height: number;
}
export const graphsize: IDimensions = { width: 500, height: 200 };
export const graphsize: IDimensions = { width: 600, height: 200 };
export const YAXISDISTANCE = 27;
export const LABELFONTSIZE = '0.4em';
export const MAXLENGTH = 800;
......@@ -639,7 +639,7 @@ const chartNorms = (
text(
xWidth,
getYInPixel(n.value, chartInfo.yUnit, chartInfo.yMin),
`${n.name}`,
`${n.name}: ${n.value}`,
'end',
{
fill: `${chartInfo.color}`,
......
......@@ -6,10 +6,20 @@ import {
getMaxInDataElem,
getAverage,
getMedian,
getTimeserieBetweenDates
getTimeserieBetweenDates,
getTimeserieAsPlotData
} from '../queries/timeserie';
import { Option, fromNullable } from 'fp-ts/lib/Option';
import { Parameter } from '../remote/timeserie';
import { remoteToOption } from 'sdi/source';
import { PlotDataElement } from './plot';
const renderParamDates = (start: Date, end: Date) =>
DIV(
{ className: 'stat__label' },
DIV({ className: 'stat__dates' }, `du ${toSimpleDate(start)} au ${toSimpleDate(end)}`),
);
const renderValue = (key: TimeserieMessageKey, value: Option<number>) =>
DIV(
......@@ -35,6 +45,25 @@ const getDateOfValue = (param: Parameter, val: number) => {
return elem.chain(e => fromNullable(e).map(p => p.date));
}
const getMinDateInDataElem = (dataElem: PlotDataElement) =>
dataElem.ts.map(point => point.date).reduce((acc, val) => (val < acc ? val : acc));
const getMaxDateInDataElem = (dataElem: PlotDataElement) =>
dataElem.ts.map(point => point.date).reduce((acc, val) => (val > acc ? val : acc));
const valueWindow = (param: Parameter) => {
const s = remoteToOption(getTimeserieAsPlotData(param.id)).map(dataElem => getMinDateInDataElem(dataElem));
const e = remoteToOption(getTimeserieAsPlotData(param.id)).map(dataElem => getMaxDateInDataElem(dataElem));
return s.chain(start =>
e.map(end => renderParamDates(start, end))
);
}
const renderUnit = (param: Parameter) =>
DIV(
{ className: 'stat__item' },
DIV({ className: 'stat__label' }, `en ${param.unit}`) //TODO Translations
)
const valueMin = (param: Parameter) => {
const minOpt = getTimeserieBetweenDates(param.id).chain(dataElem => getMinInDataElem(dataElem));
......@@ -72,6 +101,8 @@ const valueCount = (param: Parameter) =>
const render = (param: Parameter) =>
DIV(
{ className: 'legend-item__stat' },
renderUnit(param),
valueWindow(param),
valueCount(param),
valueMin(param),
valueMax(param),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment