diff --git a/assets/src/scripts/monitoring-location/components/daily-value-hydrograph/graph-controls.js b/assets/src/scripts/monitoring-location/components/daily-value-hydrograph/graph-controls.js index 4c72e8907a7503458e90b3abce64beb02fc0359d..80037e6fd9788c4d16134c30e0fc0178812f52aa 100644 --- a/assets/src/scripts/monitoring-location/components/daily-value-hydrograph/graph-controls.js +++ b/assets/src/scripts/monitoring-location/components/daily-value-hydrograph/graph-controls.js @@ -13,7 +13,6 @@ import { const drawDVTimeSeriesSelection = function(container, store, monitoringLocationId, initialParameterCode) { const availableTimeSeries = getAvailableGWDVTimeSeries(store.getState()); const availableParameterCodes = new Set(availableTimeSeries.map(ts => ts.parameterCode)); - store.dispatch(Actions.setCurrentDVParameterCode(initialParameterCode)); if (availableParameterCodes.size > 1) { container.append('div').append('legend') @@ -37,7 +36,6 @@ const drawDVTimeSeriesSelection = function(container, store, monitoringLocationI store.dispatch(Actions.retrieveDVTimeSeries(monitoringLocationId, timeSeries.mean)); store.dispatch(Actions.retrieveDVTimeSeries(monitoringLocationId, timeSeries.max)); store.dispatch(Actions.setCurrentDVTimeSeriesIds(timeSeries.min, timeSeries.mean, timeSeries.max)); - store.dispatch(Actions.setCurrentDVParameterCode(parameterCode)); }); inputContainer.append('label') .attr('class', 'usa-radio__label') diff --git a/assets/src/scripts/monitoring-location/components/daily-value-hydrograph/graph-controls.test.js b/assets/src/scripts/monitoring-location/components/daily-value-hydrograph/graph-controls.test.js index 2826e31e684fb690beaff909b51315ed87e21b02..adb409bc1297f593e968bb52c573a9f83b3bfad2 100644 --- a/assets/src/scripts/monitoring-location/components/daily-value-hydrograph/graph-controls.test.js +++ b/assets/src/scripts/monitoring-location/components/daily-value-hydrograph/graph-controls.test.js @@ -141,9 +141,6 @@ describe('monitoring-location/components/dailyValueHydrograph/graphControls', () expect(firstRadioButton.property('checked')).toBe(true); }); - it('Should update the DV parameter code', () => { - expect(store.getState().dailyValueTimeSeriesState.parameterCode).toBe('72019'); - }); }); describe('drawGraphControls with one param code', () => { diff --git a/assets/src/scripts/monitoring-location/components/daily-value-hydrograph/selectors/scales.js b/assets/src/scripts/monitoring-location/components/daily-value-hydrograph/selectors/scales.js index fa784e961f593fb8d5514cc2d5b163144919edcd..7754155e98ee35d8f0bb2f05213caae509e5d8c4 100644 --- a/assets/src/scripts/monitoring-location/components/daily-value-hydrograph/selectors/scales.js +++ b/assets/src/scripts/monitoring-location/components/daily-value-hydrograph/selectors/scales.js @@ -7,10 +7,11 @@ import { getCurrentDVTimeSeriesTimeRange, getCurrentDVTimeSeriesValueRange, getCurrentDVTimeSeriesData, - getDVParameterCode + getAvailableDVTimeSeriesParameterCodes } from 'ml/selectors/daily-value-time-series-selector'; import {getLayout} from './layout'; +import { parseInt } from 'lodash'; const REVERSE_AXIS_PARMS = [ '72019', @@ -46,15 +47,15 @@ export const getXScale = memoize((kind) => createSelector( export const getMainXScale = getXScale(); export const getBrushXScale = getXScale('BRUSH'); -const createYScale = function(layout, valueRange, parameterCode) { +const createYScale = function(layout, valueRange, parameterCodes) { const PADDING_RATIO = 0.2; let yScale = scaleLinear(); - yScale.range([layout.height - layout.margin.top - layout.margin.bottom, 0]); - if (REVERSE_AXIS_PARMS.includes(parameterCode)) { - yScale.range([layout.height - layout.margin.top - layout.margin.bottom, 0]); - } else { - yScale.range([0, layout.height - layout.margin.top - layout.margin.bottom]); - } + yScale.range([0, layout.height - layout.margin.top - layout.margin.bottom]); + parameterCodes.forEach((parameterCode) => { + if (REVERSE_AXIS_PARMS.includes(parameterCode)) { + yScale.range([layout.height - layout.margin.top - layout.margin.bottom, 0]); + } + }); if (valueRange) { const isPositive = valueRange.min > 0 && valueRange.max > 0; @@ -82,8 +83,8 @@ export const getMainYScale = createSelector( getLayout('MAIN'), getCurrentDVTimeSeriesData, getXScale('MAIN'), - getDVParameterCode, - (layout, allTSData, xScale, parameterCode) => { + getAvailableDVTimeSeriesParameterCodes, + (layout, allTSData, xScale, parameterCodes) => { const [startTime, endTime] = xScale.domain(); let minValues = []; let maxValues = []; @@ -105,7 +106,7 @@ export const getMainYScale = createSelector( max: Math.max(...maxValues) }; } - return createYScale(layout, valueRange, parameterCode); + return createYScale(layout, valueRange, parameterCodes); } ); @@ -115,8 +116,9 @@ export const getMainYScale = createSelector( export const getBrushYScale = createSelector( getLayout('BRUSH'), getCurrentDVTimeSeriesValueRange, - (layout, valueRange) => { - return createYScale(layout, valueRange); + getAvailableDVTimeSeriesParameterCodes, + (layout, valueRange, parameterCodes) => { + return createYScale(layout, valueRange, parameterCodes); } ); diff --git a/assets/src/scripts/monitoring-location/selectors/daily-value-time-series-selector.js b/assets/src/scripts/monitoring-location/selectors/daily-value-time-series-selector.js index 43158f78665572d0fd167ac0a679d46a34e20dc5..01fb36ff777a6a68eeb8ad2a0bbe394e0235d4e2 100644 --- a/assets/src/scripts/monitoring-location/selectors/daily-value-time-series-selector.js +++ b/assets/src/scripts/monitoring-location/selectors/daily-value-time-series-selector.js @@ -57,6 +57,19 @@ export const getAvailableGWDVTimeSeries = createSelector( } ); +/* + * Selector function to get all the current DV parameter codes + */ +export const getAvailableDVTimeSeriesParameterCodes = createSelector( + getAvailableDVTimeSeries, + (timeSeriesArray) => { + if(!timeSeriesArray.length) { + return []; + }; + return timeSeriesArray.map((item) => item.parameterCode); + } +); + /* * Selector function takes a parameter code and returns an Object with min, mean, max properties that * contain the available string tsIds for that parameter code. diff --git a/assets/src/scripts/monitoring-location/store/daily-value-time-series.js b/assets/src/scripts/monitoring-location/store/daily-value-time-series.js index 19edd5e66f9f0adf86fad5659e2deae3b5abb5f8..0907dee61df6efb01aff8bb1b1abacfd4eda504b 100644 --- a/assets/src/scripts/monitoring-location/store/daily-value-time-series.js +++ b/assets/src/scripts/monitoring-location/store/daily-value-time-series.js @@ -79,19 +79,6 @@ const clearDVGraphBrushOffset = function() { }; }; -/* - * Synchronous action to set the current parameter code for the dv graph - * @param {String} parameterCode - * @return {Object} Redux Action - */ -const setCurrentDVParameterCode = function(parameterCode) { - return { - type: 'SET_DV_PARAMETER_CODE', - parameterCode - }; -}; - - /* * Redux asynchronous action to fetch the available time series and * update the store. The dispatched action returns a Promise. @@ -192,11 +179,6 @@ export const dailyValueTimeSeriesStateReducer = function(dailyValueTimeSeriesSta ...dailyValueTimeSeriesState, dvGraphBrushOffset: undefined }; - case 'SET_DV_PARAMETER_CODE': - return { - ...dailyValueTimeSeriesState, - parameterCode: action.parameterCode - }; default: return dailyValueTimeSeriesState; } @@ -210,6 +192,5 @@ export const Actions = { retrieveAvailableDVTimeSeries, retrieveDVTimeSeries, setDVGraphBrushOffset, - clearDVGraphBrushOffset, - setCurrentDVParameterCode + clearDVGraphBrushOffset }; \ No newline at end of file diff --git a/assets/src/scripts/monitoring-location/store/daily-value-time-series.test.js b/assets/src/scripts/monitoring-location/store/daily-value-time-series.test.js index 7821e6434a0277bc999055a83f2de6d309497685..2483cb33a0e7de924f9796bc48c9a08467386b06 100644 --- a/assets/src/scripts/monitoring-location/store/daily-value-time-series.test.js +++ b/assets/src/scripts/monitoring-location/store/daily-value-time-series.test.js @@ -173,14 +173,6 @@ describe('monitoring-location/store/daily-value-time-series module', () => { expect(store.getState().dailyValueTimeSeriesState.dvGraphBrushOffset).not.toBeDefined(); }); }); - - describe('Actions.setCurrentDVParameterCode', () => { - it('updates brush offset', () => { - store.dispatch(Actions.setCurrentDVParameterCode('12345')); - - expect(store.getState().dailyValueTimeSeriesState.parameterCode).toEqual('12345'); - }); - }); }); });