diff --git a/CHANGELOG.md b/CHANGELOG.md index a97191efd104bb6020c6171fb782214794daf81e..14f29288bcc97b39d03fcf47b4c1f5371a3a5f62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Parameter codes with multiple methods will now show statistical data for each method available. - The hydrograph legend and time span shortcuts will now correctly display for calculated temperature parameter codes. - The DV graph will now have an inverted y-axis for only certain parameter codes. +- When there is no data, title info icon will display appropriate text, rather than being blank. ## [1.2.0](https://code.usgs.gov/wma/iow/waterdataui/~/compare/waterdataui-1.1.0...waterdataui-1.2.0) - 2022-06-10 ### Added diff --git a/assets/src/scripts/d3-rendering/info-tooltip.js b/assets/src/scripts/d3-rendering/info-tooltip.js index ccd4ffdfbbf75dff0b524e1b0d0b8a8265bb2b24..86f2950c9a1de2c9447f54846332f31f3c468bfb 100644 --- a/assets/src/scripts/d3-rendering/info-tooltip.js +++ b/assets/src/scripts/d3-rendering/info-tooltip.js @@ -12,7 +12,7 @@ import config from 'ui/config.js'; import uswds_tooltip from 'uswds-components/usa-tooltip/src/index.js'; export const appendInfoTooltip = function(elem, text, position = 'right') { - let tooltip = elem.append('div') + const tooltip = elem.append('div') .attr('class', 'usa-tooltip') .attr('data-position', position) .attr('title', text); @@ -20,6 +20,6 @@ export const appendInfoTooltip = function(elem, text, position = 'right') { .attr('class', 'usa-icon') .html(`<use xlink:href="${config.STATIC_URL}img/sprite.svg#info"></use>`); - // Need to initialize USWDS tooltip explictly after page load + // Need to initialize USWDS tooltip explicitly after page load uswds_tooltip.on(elem.node()); }; diff --git a/assets/src/scripts/monitoring-location/components/hydrograph/time-series-graph.js b/assets/src/scripts/monitoring-location/components/hydrograph/time-series-graph.js index c92552701ab18aa473d105691d89fa6e911fe65c..52dbf010cb00a718dcb3c666b6983fdeccaeee67 100644 --- a/assets/src/scripts/monitoring-location/components/hydrograph/time-series-graph.js +++ b/assets/src/scripts/monitoring-location/components/hydrograph/time-series-graph.js @@ -116,25 +116,33 @@ const drawTitle = function(elem, store, siteNo, agencyCode, sitename, showMLName } titleDiv.append('div') .attr('class', 'primary-title') - .call(link(store, (elem, {title, parameter}) => { + .call(link(store, (elem, {title, primaryParameter}) => { elem.html(title); if (showTooltip) { - elem.call(appendInfoTooltip, parameter ? parameter.description : 'No description available', 'bottom'); + elem.call( + appendInfoTooltip, + primaryParameter ? primaryParameter.description || 'No description available' : '', + 'bottom' + ); } }, createStructuredSelector({ title: getTitle('primary'), - parameter: getPrimaryParameter + primaryParameter: getPrimaryParameter }))); titleDiv.append('div') .attr('class', 'secondary-title') - .call(link(store, (elem, {title, parameter}) => { + .call(link(store, (elem, {title, secondaryParameter}) => { elem.html(title); - if (showTooltip && parameter) { - elem.call(appendInfoTooltip, parameter ? parameter.description : 'No description available', 'bottom'); + if (showTooltip && secondaryParameter) { + elem.call( + appendInfoTooltip, + secondaryParameter ? secondaryParameter.description || 'No description available' : '', + 'bottom' + ); } }, createStructuredSelector({ title: getTitle('secondary'), - parameter: getIVParameter('secondary') + secondaryParameter: getIVParameter('secondary') }))); }; diff --git a/assets/src/scripts/monitoring-location/components/hydrograph/time-series-graph.test.js b/assets/src/scripts/monitoring-location/components/hydrograph/time-series-graph.test.js index c9bb24ae31ec794f3ee147014039244d6a7fe5ef..eae5fa66bb7c43cb7958c7be7b518fad12e6a0e3 100644 --- a/assets/src/scripts/monitoring-location/components/hydrograph/time-series-graph.test.js +++ b/assets/src/scripts/monitoring-location/components/hydrograph/time-series-graph.test.js @@ -5,7 +5,8 @@ import * as utils from 'ui/utils'; import {configureStore} from 'ml/store'; import {setMedianDataVisibility} from 'ml/store/hydrograph-state'; -import {TEST_PRIMARY_IV_DATA, TEST_GW_LEVELS, TEST_STATS_DATA, +import { + TEST_PRIMARY_IV_DATA, TEST_GW_LEVELS, TEST_STATS_DATA, TEST_CURRENT_TIME_RANGE } from './mock-hydrograph-state'; import {drawTimeSeriesGraphData, initializeTimeSeriesGraph} from './time-series-graph'; @@ -114,4 +115,32 @@ describe('monitoring-location/components/hydrograph/time-series-graph', () => { expect(div.selectAll('.iv-graph-gw-levels-group').html()).not.toEqual(''); expect(div.selectAll('.median-stats-group').size()).toBe(2); }); + + it('expects the correct tooltip text when the description is available', () => { + initializeTimeSeriesGraph(div, store, '11112222', 'USGS', 'This site', true, true); + + const titleDiv = div.select('.time-series-graph-title'); + expect(titleDiv.select('.usa-tooltip').text()).toBe('Depth to water level, feet'); + }); + + it('expects the correct tooltip text when the description is NOT available', () => { + const NO_PARAMETER_DATA = { + parameter: { + parameterCode: '00065' + }, + values: {} + }; + + store = configureStore({ + ...TEST_STATE, + hydrographData: { + primaryIVData: NO_PARAMETER_DATA + } + }); + + initializeTimeSeriesGraph(div, store, '11112222', 'USGS', 'This site', true, true); + + const titleDiv = div.select('.time-series-graph-title'); + expect(titleDiv.select('.usa-tooltip').text()).toBe('No description available'); + }); }); diff --git a/assets/src/styles/components/hydrograph/_app.scss b/assets/src/styles/components/hydrograph/_app.scss index c584a9272f71f93d8c2d8d514732fa3c62cbd8ec..8f2342f379dc8e69c7553d8c67d16732caf83fbd 100644 --- a/assets/src/styles/components/hydrograph/_app.scss +++ b/assets/src/styles/components/hydrograph/_app.scss @@ -153,7 +153,7 @@ } #hydrograph-no-data-overlay { - color: red; + pointer-events: none; position: absolute; top: 0; left: 0;