diff --git a/CHANGELOG.md b/CHANGELOG.md index b72bcadbf1399b03cfb7258b021b3fe2a00717e9..41e99ef14685fd9104bae19cc7615918b29d76bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,13 +4,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased](https://github.com/usgs/waterdataui/compare/waterdataui-0.32.0...master) -### Added -- Waterwatch flood levels to gage height graph on monitoring location page + ### Changed - Moved graph-server to it's own repo <https://github.com/usgs/wdfn-graph-server> ### Added - The current IV data now appear in a table within an accordion below the parameter selection list. +- Waterwatch flood levels to gage height graph on monitoring location page ## [0.32.0](https://github.com/usgs/waterdataui/compare/waterdataui-0.32.0...master) ### Added diff --git a/assets/src/scripts/components/hydrograph/drawing-data.js b/assets/src/scripts/components/hydrograph/drawing-data.js index 17dd9efc16ac0bc32355ad77a360b3a97b42dd6b..743696868f451cfb085f76a701308d9f0827d0e6 100644 --- a/assets/src/scripts/components/hydrograph/drawing-data.js +++ b/assets/src/scripts/components/hydrograph/drawing-data.js @@ -221,37 +221,6 @@ export const getCurrentVariableMedianStatPoints = createSelector( }); }); -/* - * @ return {Array of Arrays of Objects} where the properties are date (universal), and value -*/ -export const getWaterwatchFloodLevelDataPoints = createSelector( - getWaterwatchFloodLevels, - getRequestTimeRange('current'), - getIanaTimeZone, - (floodLevels, timeRange, ianaTimeZone) => { - if (!floodLevels || !timeRange) { - return []; - } - - let datesOfInterest = [DateTime.fromMillis(timeRange.start, {zone: ianaTimeZone}), - DateTime.fromMillis(timeRange.end, {zone: ianaTimeZone}) - ]; - - const floodLevelsKeys = ['actionStage', 'floodStage', 'moderateFloodStage', 'majorFloodStage']; - - return floodLevelsKeys.map((key) => { - return datesOfInterest - .map((date) => { - return { - value: floodLevels[key], - date: date.ts - }; - }); - }); - } -); - - /** * Factory function create a function that * returns an array of points for each visible time series. diff --git a/assets/src/scripts/components/hydrograph/drawing-data.spec.js b/assets/src/scripts/components/hydrograph/drawing-data.spec.js index 60f6b9f8b82d8ed3a586da3b1cc6b4faa3c563d4..82cc7f7ac2b423856b7fa9a0eb79ae045645a6f9 100644 --- a/assets/src/scripts/components/hydrograph/drawing-data.spec.js +++ b/assets/src/scripts/components/hydrograph/drawing-data.spec.js @@ -1071,106 +1071,5 @@ describe('drawingData module', () => { }; expect(getCurrentVariableMedianStatPoints(newTestState)).toEqual([]); }); - - describe('getWaterwatchtFloodLevelPoints', () => { - const TEST_VARS = { - '45807042': { - variableCode: { - 'value': '00060' - } - }, - '45807142': { - variableCode: { - 'value': '00010' - } - } - }; - - const TEST_STATE = { - ivTimeSeriesData: { - queryInfo: { - 'current:P7D': { - notes: { - requestDT: 1520966700000, - 'filter:timeRange': { - mode: 'PERIOD', - periodDays: '7', - modifiedSince: null - } - } - } - }, - variables: TEST_VARS, - timeSeries: { - '69928:00060': { - tsKey: 'current:P7D', - startTime: new Date('2018-03-06T15:45:00.000Z'), - endTime: new Date('2018-03-13t13:45:00.000Z'), - variable: '45807197', - method: 69928, - points: [{ - value: 10, - qualifiers: ['P'], - approved: false, - estimated: false - }, { - value: null, - qualifiers: ['P', 'ICE'], - approved: false, - estimated: false - }, { - value: null, - qualifiers: ['P', 'FLD'], - approved: false, - estimated: false - }] - } - } - }, - ianaTimeZone: 'America/Chicago', - ivTimeSeriesState: { - currentIVVariableID: '45807142', - currentIVDateRangeKind: 'P7D' - }, - floodData: { - floodLevels: { - site_no: '07144100', - action_stage: '20', - flood_stage: '22', - moderate_flood_stage: '25', - major_flood_stage: '26' - } - } - }; - - it('Return the expected data points', () => { - let result = getWaterwatchFloodLevelDataPoints(TEST_STATE); - expect(result.length).toBe(4); - expect(result[0].length).toBe(2); - expect(result[0][0]).toEqual({ - value: 20, - date: DateTime.fromObject({ - year: 2018, - month: 3, - day: 6, - hour: 13, - minute: 45, - second: 0, - zone: 'America/Chicago' - }).valueOf() - }); - }); - - const NO_FLOOD_DATA_STATE = { - ...TEST_STATE, - floodData: { - floodLevels: null - } - }; - - it('Return undefined points', () => { - expect(getWaterwatchFloodLevelDataPoints(NO_FLOOD_DATA_STATE)).toEqual([]); - }); - }); }); }); diff --git a/assets/src/scripts/components/hydrograph/index.spec.js b/assets/src/scripts/components/hydrograph/index.spec.js index 45ed4b63557f9d0ad17cf451d79b1b6aac07fd61..b0615342c43d6a8639276a664ab539a4d1161c81 100644 --- a/assets/src/scripts/components/hydrograph/index.spec.js +++ b/assets/src/scripts/components/hydrograph/index.spec.js @@ -4,7 +4,7 @@ import {configureStore} from '../../store'; import {Actions as ivTimeSeriesDataActions} from '../../store/instantaneous-value-time-series-data'; import {Actions as statisticsDataActions} from '../../store/statistics-data'; import {Actions as timeZoneActions} from '../../store/time-zone'; -import {Actions as floodStateActions} from '../../store/flood-inundation'; +import {Actions as floodDataActions} from '../../store/flood-inundation'; const TEST_STATE = { @@ -420,7 +420,7 @@ describe('Hydrograph charting and Loading indicators and data alerts', () => { /* eslint no-use-before-define: 0 */ let store; beforeEach((done) => { - spyOn(floodStateActions, 'retrieveWaterwatchData').and.returnValue(function() { + spyOn(floodDataActions, 'retrieveWaterwatchData').and.returnValue(function() { return Promise.resolve({}); }); spyOn(ivTimeSeriesDataActions, 'retrieveIVTimeSeries').and.returnValue(function() { diff --git a/assets/src/scripts/components/hydrograph/legend.js b/assets/src/scripts/components/hydrograph/legend.js index 5b2840d2f21dbd913326d772f725000c6e77be33..ae4ae506095dbd96b992bee398fa0d2271c9dfb8 100644 --- a/assets/src/scripts/components/hydrograph/legend.js +++ b/assets/src/scripts/components/hydrograph/legend.js @@ -106,7 +106,7 @@ const createLegendMarkers = function(displayItems) { if (displayItems.floodLevels) { const floodLevels = displayItems.floodLevels; - const keys = ['actionStage', 'floodStage', 'moderateFloodStage', 'mjaorFloodStage']; + const keys = ['actionStage', 'floodStage', 'moderateFloodStage', 'majorFloodStage']; const labels = ['Action Stage: ', 'Flood Stage: ', 'Moderate Flood Stage: ', 'Major Flood Stage: ']; const wwSeriesClass = 'waterwatch-data-series'; const classes = ['action-stage', 'flood-stage', 'moderate-flood-stage', 'major-flood-stage']; diff --git a/assets/src/scripts/components/hydrograph/time-series-graph.js b/assets/src/scripts/components/hydrograph/time-series-graph.js index 21df33397583c4f8a9b543b975dd6c57bdbedc7b..cc1a21e59b72cf442a8dac9a497082c2dfa99c2e 100644 --- a/assets/src/scripts/components/hydrograph/time-series-graph.js +++ b/assets/src/scripts/components/hydrograph/time-series-graph.js @@ -8,14 +8,13 @@ import {appendAxes} from '../../d3-rendering/axes'; import {renderMaskDefs} from '../../d3-rendering/data-masks'; import {link} from '../../lib/d3-redux'; import {getAgencyCode, getMonitoringLocationName} from '../../selectors/time-series-selector'; -import {waterwatchVisible} from '../../selectors/flood-data-selector'; +import {waterwatchVisible, getWaterwatchFloodLevels} from '../../selectors/flood-data-selector'; import {mediaQuery} from '../../utils'; import {getAxes} from './axes'; import { currentVariableLineSegmentsSelector, getCurrentVariableMedianStatPoints, - getWaterwatchFloodLevelDataPoints, HASH_ID } from './drawing-data'; import {getMainLayout} from './layout'; @@ -98,12 +97,11 @@ const plotAllMedianPoints = function (elem, {visible, xscale, yscale, seriesPoin */ const plotFloodLevelPoints = function(elem, {xscale, yscale, points, classes}) { const stepFunction = d3Line() - .curve(curveStepAfter) - .x(function (d) { - return xscale(d.date); + .x(function (_,i) { + return xscale(xscale.domain()[i]); }) .y(function (d) { - return yscale(d.value); + return yscale(d); }); const floodLevelGrp = elem.append('g'); floodLevelGrp.append('path') @@ -134,13 +132,15 @@ const plotAllFloodLevelPoints = function (elem, {visible, xscale, yscale, series if (enableClip) { container.attr('clip-path', 'url(#graph-clip'); } + const keys = ['actionStage', 'floodStage', 'moderateFloodStage', 'majorFloodStage']; const classes = [['waterwatch-data-series','action-stage'], ['waterwatch-data-series','flood-stage'], ['waterwatch-data-series','moderate-flood-stage'], ['waterwatch-data-series','major-flood-stage']]; - seriesPoints.forEach((points, index) => { - plotFloodLevelPoints(container, {xscale, yscale, points: points, classes: classes[index]}); + keys.forEach((key, index) => { + plotFloodLevelPoints(container, {xscale, yscale, points: Array(2).fill(seriesPoints[key]), + classes: classes[index]}); }); }; @@ -260,7 +260,7 @@ export const drawTimeSeriesGraph = function(elem, store, siteNo, showMLName, sho visible: waterwatchVisible, xscale: getBrushXScale('current'), yscale: getMainYScale, - seriesPoints: getWaterwatchFloodLevelDataPoints + seriesPoints: getWaterwatchFloodLevels }))); if (showTooltip) { dataGroup.call(drawTooltipFocus, store);