From fbdec05139d9d0a40e202e93968352b199ee1d05 Mon Sep 17 00:00:00 2001 From: Andrew Yan <ayan@usgs.gov> Date: Thu, 8 Feb 2018 11:02:19 -0600 Subject: [PATCH] clean-up index and store --- .../scripts/components/hydrograph/index.js | 7 +- .../scripts/components/hydrograph/store.js | 72 ------------------- 2 files changed, 3 insertions(+), 76 deletions(-) diff --git a/assets/src/scripts/components/hydrograph/index.js b/assets/src/scripts/components/hydrograph/index.js index 17277b580..0d93e7f99 100644 --- a/assets/src/scripts/components/hydrograph/index.js +++ b/assets/src/scripts/components/hydrograph/index.js @@ -253,10 +253,9 @@ const attachToNode = function (node, {siteno} = {}) { .call(provide(store)) .call(timeSeriesGraph) .select('.hydrograph-last-year-input') - .on('change', function() { - store.dispatch(Actions.toggleTimeseries('compare', this.checked)); - //store.dispatch(Actions.selectLegendMarkers()); - }); + .on('change', dispatch(function() { + return Actions.toggleTimeseries('compare', this.checked); + })); window.onresize = function() { store.dispatch(Actions.resizeTimeseriesPlot(node.offsetWidth)); diff --git a/assets/src/scripts/components/hydrograph/store.js b/assets/src/scripts/components/hydrograph/store.js index f4ecb9b50..ec660547a 100644 --- a/assets/src/scripts/components/hydrograph/store.js +++ b/assets/src/scripts/components/hydrograph/store.js @@ -18,12 +18,10 @@ export const Actions = { const timeSeries = getTimeseries({sites: [siteno], startDate, endDate}).then( series => { dispatch(Actions.addTimeseries('current', siteno, series[0])); - //dispatch(Actions.setLegendMarkers('current')); // Trigger a call to get last year's data const startTime = series[0].seriesStartDate; const endTime = series[0].seriesEndDate; dispatch(Actions.retrieveCompareTimeseries(siteno, startTime, endTime)); - //dispatch(Actions.setLegendMarkers('compare')); return series[0]; }, @@ -37,8 +35,6 @@ export const Actions = { let unit = replaceHtmlEntities(series.variableName.split(' ').pop()); let plotableStats = parseMedianData(stats, startDate, endDate, unit); dispatch(Actions.setMedianStatistics(plotableStats)); - //dispatch(Actions.setLegendMarkers('medianStatistics')); - //dispatch(Actions.selectLegendMarkers()); }); }; }, @@ -83,18 +79,6 @@ export const Actions = { type: 'RESIZE_TIMESERIES_PLOT', width }; - }, - setLegendMarkers(key) { - return { - type: 'SET_LEGEND_MARKERS', - key - }; - }, - selectLegendMarkers() { - return { - type: 'SELECT_DISPLAY_MARKERS', - text: 'Select Display Markers' - }; } }; @@ -165,62 +149,6 @@ export const timeSeriesReducer = function (state={}, action) { } }; - case 'SET_LEGEND_MARKERS': - let marker; - let text; - if (action.key === 'compare' || action.key === 'current') { - text = 'Current Year'; - let domId = `ts-${action.key}`; - let svgGroup = `${action.key}-line-marker`; - if (action.key === 'compare') { - text = 'Last Year'; - } - marker = defineLineMarker(domId, 'line', text, svgGroup); - } - else if (action.key === 'medianStatistics') { - let beginYear; - let endYear; - try { - beginYear = state.statisticalMetaData.beginYear; - endYear = state.statisticalMetaData.endYear; - text = `Median Discharge ${beginYear} - ${endYear}`; - } - catch(err) { - beginYear = ''; - endYear = ''; - text = 'Median Discharge'; - } - marker = defineCircleMarker(4, null, 'median-data-series', text, 'median-circle-marker'); - } - else { - marker = null; - } - return { - ...state, - legendMarkers: { - ...state.legendMarkers, - [action.key]: marker - } - }; - - case 'SELECT_DISPLAY_MARKERS': - let displayMarkers = []; - const showSeries = state.showSeries ? state.showSeries : {}; - const markers = state.legendMarkers ? state.legendMarkers : {}; - for (const [key, value] of Object.entries(showSeries)) { - let marker; - if (value) { - marker = markers[key]; - if (marker) { - displayMarkers.push(marker); - } - } - } - return { - ...state, - displayMarkers: displayMarkers - }; - case 'RESIZE_TIMESERIES_PLOT': return { ...state, -- GitLab