Skip to content
Snippets Groups Projects
Commit 1087aa12 authored by Briggs, Aaron Shane's avatar Briggs, Aaron Shane
Browse files

streamline some functions

parent 158df34e
No related branches found
No related tags found
1 merge request!388WDFN-732 Plot Secondary Time Series - graph the time series
......@@ -177,6 +177,13 @@ export const getFullArrayOfAdditionalTickMarks = function(tickValues, yDomain) {
return Array.from(new Set(additionalTickValues.concat(tickValues)));
};
/**
* Redux selector function to find the maximum and minimum of all data values displayed on the primary y-axis. Information
* which can then be used to determine the correct values for numbering the tick marks of the primary y-axis.
* @return {Array} An array with two values representing the lowest and highest values for the primary
* y-axis. Defaults to a range of 0 to 1 if there are no values.
*/
export const getPrimaryValueRange = createSelector(
isVisible('compare'),
isVisible('median'),
......@@ -187,7 +194,6 @@ export const getPrimaryValueRange = createSelector(
getPrimaryParameter,
(showCompare, showMedian, primaryRange, compareRange, medianRange, gwLevelsRange, parameter) => {
const valueExtent = [];
let result = [0, 1];
if (primaryRange) {
valueExtent.push(...primaryRange);
}
......@@ -200,30 +206,26 @@ export const getPrimaryValueRange = createSelector(
if (showMedian && medianRange) {
valueExtent.push(...medianRange);
}
if (valueExtent.length) {
result = [Math.min(...valueExtent), Math.max(...valueExtent)];
// Add padding to the extent and handle empty data sets.
result = extendDomain(result, useSymlog(parameter));
}
return result;
return valueExtent.length ?
extendDomain([Math.min(...valueExtent), Math.max(...valueExtent)], useSymlog(parameter)) : [0, 1];
}
);
/**
* Redux selector function to find the maximum and minimum of all data values displayed on the secondary y-axis. Information
* which can then be used to determine the correct values for numbering the tick marks of the secondary y-axis.
* @return {Array} secondaryYAxisDomain - array with two values, representing the lowest and highest values for the secondary
* y-axis. Defaults to a range of 0 to 1 if there are no values.
*/
export const getSecondaryValueRange = createSelector(
getIVDataRange('secondary'),
getIVParameter('secondary'),
(secondaryParameterRange, secondaryParameter) => {
let result = [0, 1];
if (secondaryParameterRange) {
result = [Math.min(...secondaryParameterRange), Math.max(...secondaryParameterRange)];
// Add padding to the extent and handle empty data sets.
result = extendDomain(secondaryParameterRange, useSymlog(secondaryParameter));
}
return result;
return secondaryParameterRange ?
extendDomain([Math.min(...secondaryParameterRange), Math.max(...secondaryParameterRange)], useSymlog(secondaryParameter)) :
[0, 1];
}
);
......@@ -240,10 +242,10 @@ const getYTickDetails = memoize(tickKind => createSelector(
getPrimaryParameter,
getSecondaryValueRange,
getIVParameter('secondary'),
(primaryDomain, primaryParameter, secondaryYDomain, SecondaryParameter) => {
(primaryDomain, primaryParameter, secondaryYDomain, secondaryParameter) => {
const parameter = tickKind === 'primary' ? primaryParameter : SecondaryParameter;
const yDomain = tickKind === 'primary' ? primaryDomain : secondaryYDomain;
const parameter = tickKind === 'secondary' ? secondaryParameter : primaryParameter;
const yDomain = tickKind === 'secondary' ? secondaryYDomain : primaryDomain;
let tickValues = ticks(yDomain[0], yDomain[1], Y_TICK_COUNT);
......
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