Skip to content
Snippets Groups Projects
Commit 3a686727 authored by Bucknell, Mary S.'s avatar Bucknell, Mary S.
Browse files

Data table and median data now work

parent 979c8901
No related branches found
No related tags found
No related merge requests found
Showing
with 113 additions and 96 deletions
...@@ -4,8 +4,8 @@ import {createStructuredSelector} from 'reselect'; ...@@ -4,8 +4,8 @@ import {createStructuredSelector} from 'reselect';
import {link} from 'ui/lib/d3-redux'; import {link} from 'ui/lib/d3-redux';
import {getVisibleGroundwaterLevelsTableData} from './selectors/discrete-data'; import {getGroundwaterLevelsTableData} from './selectors/discrete-data';
import {getCurrentPointData} from './selectors/drawing-data'; import {getIVTableData} from './selectors/iv-data';
const TABLE_CAPTION = { const TABLE_CAPTION = {
iv: 'Instantaneous value data', iv: 'Instantaneous value data',
...@@ -94,12 +94,12 @@ export const drawDataTables = function(elem, store) { ...@@ -94,12 +94,12 @@ export const drawDataTables = function(elem, store) {
.attr('id', 'iv-hydrograph-data-table-container') .attr('id', 'iv-hydrograph-data-table-container')
.call(link(store, drawDataTable, createStructuredSelector({ .call(link(store, drawDataTable, createStructuredSelector({
dataKind: () => 'iv', dataKind: () => 'iv',
currentData: getCurrentPointData currentData: getIVTableData('primary')
}))); })));
elem.append('div') elem.append('div')
.attr('id', 'gw-hydrograph-data-table-container') .attr('id', 'gw-hydrograph-data-table-container')
.call(link(store, drawDataTable, createStructuredSelector({ .call(link(store, drawDataTable, createStructuredSelector({
dataKind: () => 'gw', dataKind: () => 'gw',
currentData: getVisibleGroundwaterLevelsTableData currentData: getGroundwaterLevelsTableData
}))); })));
}; };
\ No newline at end of file
import {link} from 'ui/lib/d3-redux'; import {link} from 'ui/lib/d3-redux';
import {getCurrentVariableMedianStatistics} from 'ml/selectors/median-statistics-selector'; import {getInputsForRetrieval} from 'ml/selectors/hydrograph-state-selector';
import {getCurrentVariableTimeSeries} from 'ml/selectors/time-series-selector';
import {Actions} from 'ml/store/instantaneous-value-time-series-state'; import {getSelectedParameterCode} from 'ml/selectors/hydrograph-state-selector';
import {getTimeRange} from 'ml/selectors/hydrograph-data-selector';
import {retrieveMedianStatistics, retrievePriorYearIVData} from 'ml/store/hydrograph-data';
import {setCompareDataVisibility, setMedianDataVisibility} from 'ml/store/hydrograph-state';
import {audibleUI} from './audible';
import {isVisible} from './selectors/time-series-data'; import {isVisible} from './selectors/time-series-data';
/* /*
* Create the show audible toggle, last year toggle, and median toggle for the time series graph. * Create the show audible toggle, last year toggle, and median toggle for the time series graph.
* @param {Object} elem - D3 selection * @param {Object} elem - D3 selection
*/ */
export const drawGraphControls = function(elem, store) { export const drawGraphControls = function(elem, store, siteno) {
const graphControlDiv = elem.append('ul') const graphControlDiv = elem.append('ul')
.classed('usa-fieldset', true) .classed('usa-fieldset', true)
.classed('usa-list--unstyled', true) .classed('usa-list--unstyled', true)
.classed('graph-controls-container', true); .classed('graph-controls-container', true);
graphControlDiv.append('li')
.call(audibleUI, store);
const compareControlDiv = graphControlDiv.append('li') const compareControlDiv = graphControlDiv.append('li')
.classed('usa-checkbox', true); .classed('usa-checkbox', true);
...@@ -34,14 +34,15 @@ export const drawGraphControls = function(elem, store) { ...@@ -34,14 +34,15 @@ export const drawGraphControls = function(elem, store) {
.attr('ga-event-category', 'TimeSeriesGraph') .attr('ga-event-category', 'TimeSeriesGraph')
.attr('ga-event-action', 'toggleCompare') .attr('ga-event-action', 'toggleCompare')
.on('click', function() { .on('click', function() {
store.dispatch(Actions.setIVTimeSeriesVisibility('compare', this.checked)); const state = store.getState();
const currentTimeRange = getTimeRange('current')(state);
store.dispatch(setCompareDataVisibility(this.checked));
store.dispatch(retrievePriorYearIVData(siteno, {
parameterCode: getSelectedParameterCode(state),
startTime: currentTimeRange.start,
endTime: currentTimeRange.end
}));
}) })
// Disables the checkbox if no compare time series for the current variable
.call(link(store,function(elem, compareTimeSeries) {
const exists = Object.keys(compareTimeSeries) ?
Object.values(compareTimeSeries).filter(tsValues => tsValues.points.length).length > 0 : false;
elem.property('disabled', !exists);
}, getCurrentVariableTimeSeries('compare')))
// Sets the state of the toggle // Sets the state of the toggle
.call(link(store,function(elem, checked) { .call(link(store,function(elem, checked) {
elem.property('checked', checked); elem.property('checked', checked);
...@@ -64,12 +65,9 @@ export const drawGraphControls = function(elem, store) { ...@@ -64,12 +65,9 @@ export const drawGraphControls = function(elem, store) {
.attr('ga-event-category', 'TimeSeriesGraph') .attr('ga-event-category', 'TimeSeriesGraph')
.attr('ga-event-action', 'toggleMedian') .attr('ga-event-action', 'toggleMedian')
.on('click', function() { .on('click', function() {
store.dispatch(Actions.setIVTimeSeriesVisibility('median', this.checked)); store.dispatch(setMedianDataVisibility(this.checked));
store.dispatch(retrieveMedianStatistics(siteno, getSelectedParameterCode(store.getState())));
}) })
// Disables the checkbox if no median data for the current variable
.call(link(store,function(elem, medianData) {
elem.property('disabled', medianData === null);
}, getCurrentVariableMedianStatistics))
// Sets the state of the toggle // Sets the state of the toggle
.call(link(store,function(elem, checked) { .call(link(store,function(elem, checked) {
elem.property('checked', checked); elem.property('checked', checked);
......
...@@ -6,40 +6,29 @@ import {DateTime} from 'luxon'; ...@@ -6,40 +6,29 @@ import {DateTime} from 'luxon';
import config from 'ui/config.js'; import config from 'ui/config.js';
import {drawInfoAlert} from 'd3render/alerts'; import {drawInfoAlert} from 'd3render/alerts';
import {drawLoadingIndicator} from 'd3render/loading-indicator'; import {drawLoadingIndicator} from 'd3render/loading-indicator';
//import {isPeriodWithinAcceptableRange, isPeriodCustom} from 'ml/iv-data-utils'; import {renderTimeSeriesUrlParams} from 'ml/url-params';
//import {renderTimeSeriesUrlParams} from 'ml/url-params';
//import {hasAnyVariables, getCurrentVariableID, getCurrentParmCd, getVariables} from 'ml/selectors/time-series-selector';
import {retrieveHydrographData} from 'ml/store/hydrograph-data'; import {retrieveHydrographData} from 'ml/store/hydrograph-data';
import {retrieveHydrographParameters} from 'ml/store/hydrograph-parameters'; import {retrieveHydrographParameters} from 'ml/store/hydrograph-parameters';
import {setSelectedParameterCode} from 'ml/store/hydrograph-state'; import {setSelectedParameterCode, setCompareDataVisibility} from 'ml/store/hydrograph-state';
//import {Actions as ivTimeSeriesDataActions} from 'ml/store/instantaneous-value-time-series-data';
//import {Actions as ivTimeSeriesStateActions} from 'ml/store/instantaneous-value-time-series-state';
//import {Actions as statisticsDataActions} from 'ml/store/statistics-data';
//import {Actions as timeZoneActions} from 'ml/store/time-zone';
import {Actions as floodDataActions} from 'ml/store/flood-inundation'; import {Actions as floodDataActions} from 'ml/store/flood-inundation';
//import {drawDateRangeControls} from './date-controls'; //import {drawDateRangeControls} from './date-controls';
//import {drawDataTables} from './data-table'; import {drawDataTables} from './data-table';
//import {renderDownloadLinks} from './download-links'; //import {renderDownloadLinks} from './download-links';
import {drawGraphBrush} from './graph-brush'; import {drawGraphBrush} from './graph-brush';
//import {drawGraphControls} from './graph-controls'; import {drawGraphControls} from './graph-controls';
import {drawTimeSeriesLegend} from './legend'; import {drawTimeSeriesLegend} from './legend';
import {drawMethodPicker} from './method-picker'; import {drawMethodPicker} from './method-picker';
import {drawSelectionTable} from './parameters'; import {drawSelectionTable} from './parameters';
import {drawTimeSeriesGraph} from './time-series-graph'; import {drawTimeSeriesGraph} from './time-series-graph';
import {drawTooltipCursorSlider} from './tooltip'; import {drawTooltipCursorSlider} from './tooltip';
//import {getLineSegmentsByParmCd} from './selectors/drawing-data';
//import {SPARK_LINE_DIM} from './selectors/layout';
//import {getAvailableParameterCodes} from './selectors/parameter-data';
//import {getTimeSeriesScalesByParmCd} from './selectors/scales';
/* /*
* Renders the hydrograph on the node element using the Redux store for state information. The siteno, latitude, and * Renders the hydrograph on the node element using the Redux store for state information. The siteno, latitude, and
...@@ -84,6 +73,7 @@ export const attachToNode = function(store, ...@@ -84,6 +73,7 @@ export const attachToNode = function(store,
loadCompare: compare, loadCompare: compare,
loadMedian: false loadMedian: false
})); }));
store.dispatch(setCompareDataVisibility(compare));
// if showing the controls, fetch the parameters // if showing the controls, fetch the parameters
let fetchParameters; let fetchParameters;
...@@ -121,15 +111,15 @@ export const attachToNode = function(store, ...@@ -121,15 +111,15 @@ export const attachToNode = function(store,
/* /*
nodeElem nodeElem
.call(drawDateRangeControls, store, siteno); .call(drawDateRangeControls, store, siteno);
legendControlsContainer */
.call(drawGraphControls, store); legendControlsContainer.call(drawGraphControls, store, siteno);
/*
nodeElem.select('#iv-graph-list-container') nodeElem.select('#iv-graph-list-container')
.call(renderDownloadLinks, store, siteno); .call(renderDownloadLinks, store, siteno);
*/
nodeElem.select('#iv-data-table-container') nodeElem.select('#iv-data-table-container')
.call(drawDataTables, store); .call(drawDataTables, store);
*/
// Set the parameter code explictly. We may eventually set this within the parameter selection table // Set the parameter code explictly. We may eventually set this within the parameter selection table
store.dispatch(setSelectedParameterCode(parameterCode)); store.dispatch(setSelectedParameterCode(parameterCode));
...@@ -137,10 +127,7 @@ export const attachToNode = function(store, ...@@ -137,10 +127,7 @@ export const attachToNode = function(store,
nodeElem.select('.select-time-series-container') nodeElem.select('.select-time-series-container')
.call(drawSelectionTable, store, siteno); .call(drawSelectionTable, store, siteno);
}); });
/*
renderTimeSeriesUrlParams(store); renderTimeSeriesUrlParams(store);
*/
} }
}); });
......
...@@ -2,9 +2,13 @@ import {format} from 'd3-format'; ...@@ -2,9 +2,13 @@ import {format} from 'd3-format';
import memoize from 'fast-memoize'; import memoize from 'fast-memoize';
import isEqual from 'lodash/isEqual'; import isEqual from 'lodash/isEqual';
import uniqWith from 'lodash/uniqWith'; import uniqWith from 'lodash/uniqWith';
import {DateTime} from 'luxon';
import {createSelector} from 'reselect'; import {createSelector} from 'reselect';
import {getIVData} from 'ml/selectors/hydrograph-data-selector'; import config from 'ui/config';
import {getIVData, getPrimaryParameter} from 'ml/selectors/hydrograph-data-selector';
import {getSelectedIVMethodID} from 'ml/selectors/hydrograph-state-selector';
const MASKED_QUALIFIERS = { const MASKED_QUALIFIERS = {
ice: {label: 'Ice Affected', class: 'ice-affected-mask'}, ice: {label: 'Ice Affected', class: 'ice-affected-mask'},
...@@ -23,7 +27,7 @@ const MASKED_QUALIFIERS = { ...@@ -23,7 +27,7 @@ const MASKED_QUALIFIERS = {
'***': {label: 'Unavailable', class: 'unavailable-mask'} '***': {label: 'Unavailable', class: 'unavailable-mask'}
}; };
const LINE_QUALIFIERS = { const APPROVAL_QUALIFIERS = {
a: {label: 'Approved', class: 'approved'}, a: {label: 'Approved', class: 'approved'},
e: {label: 'Estimated', class: 'estimated'} e: {label: 'Estimated', class: 'estimated'}
}; };
...@@ -86,17 +90,17 @@ export const getIVDataPoints = memoize(dataKind => createSelector( ...@@ -86,17 +90,17 @@ export const getIVDataPoints = memoize(dataKind => createSelector(
return Object.values(ivData.values).reduce((byMethodID, methodValues) => { return Object.values(ivData.values).reduce((byMethodID, methodValues) => {
byMethodID[methodValues.method.methodID] = methodValues.points.map(point => { byMethodID[methodValues.method.methodID] = methodValues.points.map(point => {
// We will only receive one masked qualifier // We will only receive one masked qualifier
let label = 'Default'; let label;
let pointClass = ''; let pointClass;
const pointQualifiers = point.qualifiers.map(qualifier => qualifier.toLowerCase()); const pointQualifiers = point.qualifiers.map(qualifier => qualifier.toLowerCase());
const maskedQualifier = pointQualifiers.find(qualifier => qualifier in MASKED_QUALIFIERS); const maskedQualifier = pointQualifiers.find(qualifier => qualifier in MASKED_QUALIFIERS);
const lineQualifier = pointQualifiers.find(qualifier => qualifier in LINE_QUALIFIERS); const approvalQualifier = pointQualifiers.find(qualifier => qualifier in APPROVAL_QUALIFIERS);
if (maskedQualifier) { if (maskedQualifier) {
label = MASKED_QUALIFIERS[maskedQualifier].label; label = MASKED_QUALIFIERS[maskedQualifier].label;
pointClass = MASKED_QUALIFIERS[maskedQualifier].class; pointClass = MASKED_QUALIFIERS[maskedQualifier].class;
} else if (lineQualifier) { } else if (approvalQualifier) {
label = LINE_QUALIFIERS[lineQualifier].label; label = APPROVAL_QUALIFIERS[approvalQualifier].label;
pointClass = LINE_QUALIFIERS[lineQualifier].class; pointClass = APPROVAL_QUALIFIERS[approvalQualifier].class;
} else { //default to provisional } else { //default to provisional
label = 'Provisional'; label = 'Provisional';
pointClass = 'provisional'; pointClass = 'provisional';
...@@ -105,6 +109,8 @@ export const getIVDataPoints = memoize(dataKind => createSelector( ...@@ -105,6 +109,8 @@ export const getIVDataPoints = memoize(dataKind => createSelector(
value: point.value, value: point.value,
dateTime: point.dateTime, dateTime: point.dateTime,
isMasked: !!maskedQualifier, isMasked: !!maskedQualifier,
maskedQualifier: maskedQualifier,
approvalQualifier: approvalQualifier,
label: label, label: label,
class: pointClass class: pointClass
}; };
...@@ -115,6 +121,26 @@ export const getIVDataPoints = memoize(dataKind => createSelector( ...@@ -115,6 +121,26 @@ export const getIVDataPoints = memoize(dataKind => createSelector(
} }
)); ));
export const getIVTableData = memoize(dataKind => createSelector(
getIVDataPoints(dataKind),
getPrimaryParameter,
getSelectedIVMethodID,
(ivData, parameter, selectedMethodID) => {
if (!ivData || !(selectedMethodID in ivData)) {
return [];
}
return ivData[selectedMethodID].map(point => {
return {
parameterName: parameter.name,
result: point.value,
dateTime: DateTime.fromMillis(point.dateTime).toISO({zone: config.locationTimeZone}),
approvals: point.approvalQualifier ? APPROVAL_QUALIFIERS[point.approvalQualifier].label : 'Provisional',
masks: point.isMasked ? MASKED_QUALIFIERS[point.maskedQualifier].label : ''
};
});
}
));
/* /*
* @return Keys are ts Ids, values are of array of objects. Each object has four properties and * @return Keys are ts Ids, values are of array of objects. Each object has four properties and
* represents a segment * represents a segment
......
...@@ -3,10 +3,9 @@ import {createSelector} from 'reselect'; ...@@ -3,10 +3,9 @@ import {createSelector} from 'reselect';
import {defineLineMarker, defineRectangleMarker, defineTextOnlyMarker} from 'd3render/markers'; import {defineLineMarker, defineRectangleMarker, defineTextOnlyMarker} from 'd3render/markers';
import {getWaterwatchFloodLevels, isWaterwatchVisible} from 'ml/selectors/flood-data-selector'; import {getWaterwatchFloodLevels, isWaterwatchVisible} from 'ml/selectors/flood-data-selector';
import {getPrimaryMedianStatisticsData} from 'ml/selectors/hydrograph-data-selector';
import {isCompareIVDataVisible, isMedianDataVisible} from 'ml/selectors/hydrograph-state-selector'; import {isCompareIVDataVisible, isMedianDataVisible} from 'ml/selectors/hydrograph-state-selector';
//import {getCurrentVariableMedianMetadata} from 'ml/selectors/median-statistics-selector';
import {getGroundwaterLevelsMarker} from '../discrete-data'; import {getGroundwaterLevelsMarker} from '../discrete-data';
import {getIVUniqueDataKinds, HASH_ID} from './iv-data'; import {getIVUniqueDataKinds, HASH_ID} from './iv-data';
...@@ -30,7 +29,7 @@ const TS_LABEL = { ...@@ -30,7 +29,7 @@ const TS_LABEL = {
const getLegendDisplay = createSelector( const getLegendDisplay = createSelector(
isCompareIVDataVisible, isCompareIVDataVisible,
isMedianDataVisible, isMedianDataVisible,
() => null, //getCurrentVariableMedianMetadata, getPrimaryMedianStatisticsData,
getIVUniqueDataKinds('primary'), getIVUniqueDataKinds('primary'),
getIVUniqueDataKinds('compare'), getIVUniqueDataKinds('compare'),
isWaterwatchVisible, isWaterwatchVisible,
...@@ -55,7 +54,7 @@ const getIVMarkers = function(dataKind, uniqueIVKinds) { ...@@ -55,7 +54,7 @@ const getIVMarkers = function(dataKind, uniqueIVKinds) {
if (ivKind.isMasked) { if (ivKind.isMasked) {
maskMarkers.push(defineRectangleMarker(null, `mask ${ivKind.class}`, ivKind.label, `url(#${HASH_ID[dataKind]})`)); maskMarkers.push(defineRectangleMarker(null, `mask ${ivKind.class}`, ivKind.label, `url(#${HASH_ID[dataKind]})`));
} else { } else {
return lineMarkers.push(defineLineMarker(null, `line-segment ${ivKind.class} ts-${dataKind}`, ivKind.label)); return lineMarkers.push(defineLineMarker(null, `line-segment ts-${ivKind.class} ts-${dataKind}`, ivKind.label));
} }
}); });
return [textMarker, ...lineMarkers, ...maskMarkers]; return [textMarker, ...lineMarkers, ...maskMarkers];
...@@ -66,6 +65,9 @@ const getIVMarkers = function(dataKind, uniqueIVKinds) { ...@@ -66,6 +65,9 @@ const getIVMarkers = function(dataKind, uniqueIVKinds) {
* @return {Array of Array} - each subarray rpresents the markes for a time series median data * @return {Array of Array} - each subarray rpresents the markes for a time series median data
*/ */
const getMedianMarkers = function(medianMetaData) { const getMedianMarkers = function(medianMetaData) {
if (!Object.keys(medianMetaData).length) {
return [];
}
return Object.values(medianMetaData).map((stats, index) => { return Object.values(medianMetaData).map((stats, index) => {
// Get the unique non-null years, in chronological order // Get the unique non-null years, in chronological order
let years = []; let years = [];
...@@ -77,7 +79,7 @@ const getMedianMarkers = function(medianMetaData) { ...@@ -77,7 +79,7 @@ const getMedianMarkers = function(medianMetaData) {
} }
const dateText = years.join(' - '); const dateText = years.join(' - ');
const descriptionText = stats.methodDescription ? `${stats.methodDescription} ` : ''; const descriptionText = stats.description ? `${stats.description} ` : '';
const classes = `median-data-series median-step median-step-${index % 6}`; const classes = `median-data-series median-step median-step-${index % 6}`;
const label = `${descriptionText}${dateText}`; const label = `${descriptionText}${dateText}`;
......
...@@ -10,13 +10,13 @@ import {appendAxes} from 'd3render/axes'; ...@@ -10,13 +10,13 @@ import {appendAxes} from 'd3render/axes';
import {renderMaskDefs} from 'd3render/data-masks'; import {renderMaskDefs} from 'd3render/data-masks';
import {appendInfoTooltip} from 'd3render/info-tooltip'; import {appendInfoTooltip} from 'd3render/info-tooltip';
import {getPrimaryParameter} from 'ml/selectors/hydrograph-data-selector';
import {isWaterwatchVisible, getWaterwatchFloodLevels} from 'ml/selectors/flood-data-selector'; import {isWaterwatchVisible, getWaterwatchFloodLevels} from 'ml/selectors/flood-data-selector';
import {getPrimaryParameter, getPrimaryMedianStatisticsData} from 'ml/selectors/hydrograph-data-selector';
import {getSelectedIVMethodID} from 'ml/selectors/hydrograph-state-selector';
import {getAxes} from './selectors/axes'; import {getAxes} from './selectors/axes';
import {getGroundwaterLevelPoints} from './selectors/discrete-data'; import {getGroundwaterLevelPoints} from './selectors/discrete-data';
import {getIVDataSegments, HASH_ID} from './selectors/iv-data'; import {getIVDataSegments, HASH_ID} from './selectors/iv-data';
import {getSelectedIVMethodID} from 'ml/selectors/hydrograph-state-selector';
import {getTitle, getDescription, isVisible} from './selectors/time-series-data'; import {getTitle, getDescription, isVisible} from './selectors/time-series-data';
import {getMainLayout} from './selectors/layout'; import {getMainLayout} from './selectors/layout';
...@@ -50,10 +50,10 @@ const plotMedianPoints = function(elem, {xscale, yscale, modulo, points}) { ...@@ -50,10 +50,10 @@ const plotMedianPoints = function(elem, {xscale, yscale, modulo, points}) {
const stepFunction = d3Line() const stepFunction = d3Line()
.curve(curveStepAfter) .curve(curveStepAfter)
.x(function(d) { .x(function(d) {
return xscale(d.date); return xscale(d.dateTime);
}) })
.y(function(d) { .y(function(d) {
return yscale(d.value); return yscale(d.point);
}); });
const medianGrp = elem.append('g'); const medianGrp = elem.append('g');
medianGrp.append('path') medianGrp.append('path')
...@@ -75,7 +75,7 @@ const plotMedianPoints = function(elem, {xscale, yscale, modulo, points}) { ...@@ -75,7 +75,7 @@ const plotMedianPoints = function(elem, {xscale, yscale, modulo, points}) {
*/ */
const plotAllMedianPoints = function(elem, {visible, xscale, yscale, seriesPoints, enableClip}) { const plotAllMedianPoints = function(elem, {visible, xscale, yscale, seriesPoints, enableClip}) {
elem.select('#median-points').remove(); elem.select('#median-points').remove();
if (!visible) { if (!visible || !seriesPoints) {
return; return;
} }
const container = elem const container = elem
...@@ -85,8 +85,8 @@ const plotAllMedianPoints = function(elem, {visible, xscale, yscale, seriesPoint ...@@ -85,8 +85,8 @@ const plotAllMedianPoints = function(elem, {visible, xscale, yscale, seriesPoint
container.attr('clip-path', 'url(#graph-clip'); container.attr('clip-path', 'url(#graph-clip');
} }
seriesPoints.forEach((points, index) => { Object.values(seriesPoints).forEach((series, index) => {
plotMedianPoints(container, {xscale, yscale, modulo: index % 6, points: points}); plotMedianPoints(container, {xscale, yscale, modulo: index % 6, points: series.values});
}); });
}; };
...@@ -269,22 +269,21 @@ export const drawTimeSeriesGraph = function(elem, store, siteNo, agencyCode, sit ...@@ -269,22 +269,21 @@ export const drawTimeSeriesGraph = function(elem, store, siteNo, agencyCode, sit
xScale: getMainXScale('current'), xScale: getMainXScale('current'),
yScale: getMainYScale, yScale: getMainYScale,
enableClip: () => true enableClip: () => true
}))); })))
/*
.call(link(store, plotAllMedianPoints, createStructuredSelector({ .call(link(store, plotAllMedianPoints, createStructuredSelector({
visible: isVisible('median'), visible: isVisible('median'),
xscale: getMainXScale('current'), xscale: getMainXScale('current'),
yscale: getMainYScale, yscale: getMainYScale,
seriesPoints: getCurrentVariableMedianStatPoints, seriesPoints: getPrimaryMedianStatisticsData,
enableClip: () => true enableClip: () => true
}))) })))
.call(link(store, plotAllFloodLevelPoints, createStructuredSelector({ .call(link(store, plotAllFloodLevelPoints, createStructuredSelector({
visible: isWaterwatchVisible, visible: isWaterwatchVisible,
xscale: getBrushXScale('current'), xscale: getBrushXScale,
yscale: getMainYScale, yscale: getMainYScale,
seriesPoints: getWaterwatchFloodLevels seriesPoints: getWaterwatchFloodLevels
}))); })));
*/
if (showTooltip) { if (showTooltip) {
dataGroup.call(drawTooltipFocus, store); dataGroup.call(drawTooltipFocus, store);
} }
......
...@@ -27,7 +27,7 @@ const drawLineSegment = function(group, {segment, isCurrentMethod, dataKind, xSc ...@@ -27,7 +27,7 @@ const drawLineSegment = function(group, {segment, isCurrentMethod, dataKind, xSc
lineElem lineElem
.classed('line-segment', true) .classed('line-segment', true)
.classed(segment.class, true) .classed(segment.class, true)
.classed(dataKind, true) .classed(`ts-${dataKind}`, true)
.classed('not-current-method', !isCurrentMethod); .classed('not-current-method', !isCurrentMethod);
}; };
...@@ -84,7 +84,7 @@ export const drawDataSegment = function(group, {segment, isCurrentMethod, dataKi ...@@ -84,7 +84,7 @@ export const drawDataSegment = function(group, {segment, isCurrentMethod, dataKi
* can be styled by using the class name. * can be styled by using the class name.
* @param {Boolean} visible * @param {Boolean} visible
* @param {String} currentMethodID * @param {String} currentMethodID
* @param {Array of Obect} - Each object is suitable for passing to drawDataLine * @param {Array of Object} - Each object is suitable for passing to drawDataLine
* @param {String} timeRangeKind - 'current' or 'compare' * @param {String} timeRangeKind - 'current' or 'compare'
* @param {Object} xScale - D3 scale for the x axis * @param {Object} xScale - D3 scale for the x axis
* @param {Object} yScale - D3 scale for the y axis * @param {Object} yScale - D3 scale for the y axis
......
...@@ -88,9 +88,12 @@ export const getPrimaryMedianStatisticsData = createSelector( ...@@ -88,9 +88,12 @@ export const getPrimaryMedianStatisticsData = createSelector(
let result = {}; let result = {};
Object.values(stats).forEach(statsForTsId => { Object.values(stats).forEach(statsForTsId => {
result[statsForTsId[0].ts_id] = { const tsID = statsForTsId[0].ts_id;
result[tsID] = {
values: [], values: [],
description: statsForTsId[0].loc_web_ds description: statsForTsId[0].loc_web_ds,
beginYear: statsForTsId[0].begin_yr,
endYear: statsForTsId[0].end_yr
}; };
let currentDateTime = DateTime.fromMillis(timeRange.start, {zone: config.locationTimeZone}); let currentDateTime = DateTime.fromMillis(timeRange.start, {zone: config.locationTimeZone});
...@@ -98,15 +101,17 @@ export const getPrimaryMedianStatisticsData = createSelector( ...@@ -98,15 +101,17 @@ export const getPrimaryMedianStatisticsData = createSelector(
const thisStatsData = find(statsForTsId, (stat) => { const thisStatsData = find(statsForTsId, (stat) => {
return stat.month_nu === currentDateTime.month && stat.day_nu === currentDateTime.day; return stat.month_nu === currentDateTime.month && stat.day_nu === currentDateTime.day;
}); });
result.values.push({ if (thisStatsData) {
point: thisStatsData.p50_va, result[tsID].values.push({
dateTime: currentDateTime point: thisStatsData.p50_va,
}); dateTime: currentDateTime.toMillis()
currentDateTime.plus({days: 1}).startOf(); });
}
currentDateTime = currentDateTime.plus({days: 1}).startOf('day');
} }
result.values.push({ result[tsID].values.push({
point: result.values[result.values.length - 1].point, point: result[tsID].values[result[tsID].values.length - 1].point,
dateTime: DateTime.fromMillis(timeRange.end, {zone: config.locationTimeZone}) dateTime: timeRange.end
}); });
}); });
return result; return result;
......
...@@ -89,7 +89,7 @@ const addGroundwaterLevels = function(gwLevels) { ...@@ -89,7 +89,7 @@ const addGroundwaterLevels = function(gwLevels) {
* @param {String} parameterCode * @param {String} parameterCode
* @param {String} period - ISO 8601 duration * @param {String} period - ISO 8601 duration
* @param {String} startTime - ISO 8601 time string * @param {String} startTime - ISO 8601 time string
* @param {String} endTie - ISO 8601 time string * @param {String} endTime - ISO 8601 time string
* @return {Function} that returns a Promise * @return {Function} that returns a Promise
*/ */
const retrieveIVData = function(siteno, dataKind, {parameterCode, period, startTime, endTime}) { const retrieveIVData = function(siteno, dataKind, {parameterCode, period, startTime, endTime}) {
...@@ -152,14 +152,14 @@ const retrieveIVData = function(siteno, dataKind, {parameterCode, period, startT ...@@ -152,14 +152,14 @@ const retrieveIVData = function(siteno, dataKind, {parameterCode, period, startT
* Asynchronous Redux action to fetch the IV data for siteno, parameterCode and startTime/endTime * Asynchronous Redux action to fetch the IV data for siteno, parameterCode and startTime/endTime
* @param {String} siteno * @param {String} siteno
* @param {String} parameterCode * @param {String} parameterCode
* @param {String} startTime - ISO 8601 time string * @param {String} startTime - Epoch time
* @param {String} endTime - ISO 8601 time string * @param {String} endTime - EpochTime
* @return {Function} that returns a Promise * @return {Function} that returns a Promise
*/ */
export const retrievePriorYearIVData = function(siteno, {parameterCode, startTime, endTime}) { export const retrievePriorYearIVData = function(siteno, {parameterCode, startTime, endTime}) {
return function(dispatch, getState) { return function(dispatch, getState) {
const priorYearStartTime = DateTime.fromISO(startTime).minus({days: 365}).toMillis(); const priorYearStartTime = DateTime.fromMillis(startTime).minus({days: 365}).toMillis();
const priorYearEndTime = DateTime.fromISO(endTime).minus({days: 365}).toMillis(); const priorYearEndTime = DateTime.fromMillis(endTime).minus({days: 365}).toMillis();
const currentPriorYearTimeRange = getState().hydrographData.compareTimeRange || null; const currentPriorYearTimeRange = getState().hydrographData.compareTimeRange || null;
if (currentPriorYearTimeRange && priorYearStartTime === currentPriorYearTimeRange.start && if (currentPriorYearTimeRange && priorYearStartTime === currentPriorYearTimeRange.start &&
priorYearEndTime === currentPriorYearTimeRange.end) { priorYearEndTime === currentPriorYearTimeRange.end) {
...@@ -191,18 +191,18 @@ export const retrieveMedianStatistics = function(siteno, parameterCode) { ...@@ -191,18 +191,18 @@ export const retrieveMedianStatistics = function(siteno, parameterCode) {
return fetchSiteStatistics({siteno: siteno, statType: 'median', params: [parameterToFetch]}) return fetchSiteStatistics({siteno: siteno, statType: 'median', params: [parameterToFetch]})
.then(stats => { .then(stats => {
let resultStats = {}; let resultStats = {};
if (isCalculatedParameterCode) { if (parameterToFetch in stats) {
Object.keys(stats[parameterToFetch]).forEach(methodID => { Object.keys(stats[parameterToFetch]).forEach(methodID => {
resultStats[methodID] = stats[parameterToFetch][methodID].map(stat => { resultStats[methodID] = stats[parameterToFetch][methodID].map(stat => {
const p50Va = isCalculatedParameterCode ? convertCelsiusToFahrenheit(stat.p50_va) : parseFloat(stat.p50_va);
return { return {
...stat, ...stat,
parameter_cd: parameterCode, month_nu: parseInt(stat.month_nu),
p50_va: convertCelsiusToFahrenheit(stat.p50_va) day_nu: parseInt(stat.day_nu),
p50_va: p50Va
}; };
}); });
}); });
} else {
resultStats = stats[parameterToFetch];
} }
dispatch(addMedianStatisticsData(resultStats)); dispatch(addMedianStatisticsData(resultStats));
}); });
...@@ -303,8 +303,8 @@ export const retrieveHydrographData = function(siteno, {parameterCode, period, s ...@@ -303,8 +303,8 @@ export const retrieveHydrographData = function(siteno, {parameterCode, period, s
fetchPromises.push(dispatch( fetchPromises.push(dispatch(
retrievePriorYearIVData(siteno, { retrievePriorYearIVData(siteno, {
parameterCode: parameterCode, parameterCode: parameterCode,
startTime: DateTime.fromMillis(timeRange.start).toISO(), startTime: timeRange.start,
endTime: DateTime.fromMillis(timeRange.end).toISO() endTime: timeRange.end
}))); })));
} }
if (hasIVData && loadMedian) { if (hasIVData && loadMedian) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment