diff --git a/src/actions/loadData.js b/src/actions/loadData.js index 036a08b71..f711be90c 100644 --- a/src/actions/loadData.js +++ b/src/actions/loadData.js @@ -2,8 +2,40 @@ import { updateColorScale, updateNodeColors } from "./colors"; import { dataURLStem } from "../util/globals"; import * as types from "./types"; -/* request metadata */ +const updateDateRange = function () { + return function (dispatch, getState) { + const { controls, metadata } = getState(); + /* bail if all required params aren't (yet) available! */ + if (!(metadata.loadStatus === 2)) { + return null; + } + if (metadata.metadata.date_range) { + if (metadata.metadata.date_range.date_min) { + dispatch({ + type: types.CHANGE_ABSOLUTE_DATE_MIN, + data: metadata.metadata.date_range.date_min + }); + dispatch({ + type: types.CHANGE_DATE_MIN, + data: metadata.metadata.date_range.date_min + }); + } + if (metadata.metadata.date_range.date_max) { + dispatch({ + type: types.CHANGE_ABSOLUTE_DATE_MAX, + data: metadata.metadata.date_range.date_max + }); + dispatch({ + type: types.CHANGE_DATE_MAX, + data: metadata.metadata.date_range.date_max + }); + } + } + }; +}; + +/* request metadata */ const requestMetadata = () => { return { type: types.REQUEST_METADATA @@ -42,6 +74,7 @@ const populateMetadataStore = (queryParams) => { dispatch(receiveMetadata(json)); dispatch(updateColorScale()); dispatch(updateNodeColors()); + dispatch(updateDateRange()); }, (err) => dispatch(metadataFetchError(err)) ); diff --git a/src/components/controls/date-range-inputs.js b/src/components/controls/date-range-inputs.js index f5024c8fa..8c730da04 100644 --- a/src/components/controls/date-range-inputs.js +++ b/src/components/controls/date-range-inputs.js @@ -150,6 +150,8 @@ class DateRangeInputs extends React.Component { const selectedMinNumDate = calendarToNumeric(selectedMin); const selectedMaxNumDate = calendarToNumeric(selectedMax); + const minDistance = (absoluteMaxNumDate - absoluteMinNumDate) / 10.0; + return (
@@ -161,7 +163,7 @@ class DateRangeInputs extends React.Component { /* debounce the onChange event, but ensure the final one goes through */ onChange={this.updateFromSlider.bind(this, true)} onAfterChange={this.updateFromSlider.bind(this, false)} - minDistance={0.5} // minDistance is in years + minDistance={minDistance} pearling withBars/>
diff --git a/src/util/getColorScale.js b/src/util/getColorScale.js index 3c8cfc17e..f8214d99c 100644 --- a/src/util/getColorScale.js +++ b/src/util/getColorScale.js @@ -23,7 +23,7 @@ const genericScale = (cmin, cmax) => { const range = cmax - cmin; const tmpColorScale = d3.scale.linear() .domain(genericDomain.map((d) => offset + d * range)) - .range(colors[10]); + .range(colors[9]); return tmpColorScale; };