Skip to content
Snippets Groups Projects
Commit df39c485 authored by Williams, Darius Shamar's avatar Williams, Darius Shamar
Browse files

EoD

parent a089b5a8
No related branches found
No related tags found
1 merge request!421Wdfn 768 - Convert the legend component to vue
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
<CursorSlider /> <CursorSlider />
<GraphBrush /> <GraphBrush />
<div class="ts-legend-controls-container"> <div class="ts-legend-controls-container">
<HydrographLegend /> <HydrographLegend
:graphType="'IV'"
/>
<div class="graph-controls-container"> <div class="graph-controls-container">
<GraphControls /> <GraphControls />
</div> </div>
......
...@@ -20,6 +20,61 @@ describe('monitoring-location/components/hydrograph/legend module', () => { ...@@ -20,6 +20,61 @@ describe('monitoring-location/components/hydrograph/legend module', () => {
config.gwPeriodOfRecord = { config.gwPeriodOfRecord = {
'72019': {} '72019': {}
}; };
const DV_TEST_STATE = {
dailyValueTimeSeriesData: {
dvTimeSeries: {
'12345': {
type: 'Feature',
id: '12345',
properties: {
phenomenonTimeStart: '2018-01-02',
phenomenonTimeEnd: '2018-01-10',
timeStep: ['2018-01-05', '2018-01-03', '2018-01-02', '2018-01-04',
'2018-01-06', '2018-01-07', '2018-01-08', '2018-01-09', '2018-01-10'],
result: ['3.2', '4.0', '5.0', '6.1',
'7.3', '8.1', '6.2', '2.9', '3.4'],
approvals: [['Approved'], ['Approved'], ['Approved'], ['Approved'],
['Approved'], ['Approved'], ['Approved'], ['Approved'], ['Working']],
nilReason: [null, 'AA', null, null, null, null, null, null, null],
qualifiers: [['ICE'], null, null, null,
['ICE', 'EQUIP'], ['ICE', 'EQUIP'], ['ESTIMATED'], ['ESTIMATED'], null],
grades: [['60'], ['50'], ['50'], ['60'], ['50'], ['50'], ['50'], ['50'], ['50']]
}
},
'12346': {
type: 'Feature',
id: '12346',
properties: {
phenomenonTimeStart: '2018-01-02',
phenomenonTimeEnd: '2018-01-10',
timeStep: ['2018-01-02', '2018-01-03', '2018-01-04', '2018-01-05',
'2018-01-06', '2018-01-07', '2018-01-08', '2018-01-09', '2018-01-10'],
result: ['5.2', '3.0', '6.0', '7.1',
'8.3', '9.1', '7.2', '3.9', '4.4'],
approvals: [['Approved'], ['Approved'], ['Approved'], ['Approved'],
['Approved'], ['Approved'], ['Approved'], ['Approved'], ['Working']],
nilReason: [null, 'AA', null, null, null, null, null, null, null],
qualifiers: [null, null, null, ['ICE'],
['ICE', 'EQUIP'], ['ICE', 'EQUIP'], ['ESTIMATED'], ['ESTIMATED'], null],
grades: [['50'], ['50'], ['50'], ['60'], ['50'], ['50'], ['50'], ['50'], ['50']]
}
}
}
},
dailyValueTimeSeriesState: {
currentDVTimeSeriesId: {
min: '12345',
mean: null,
max: '12346'
}
},
ui: {
windowWidth: 1024,
width: 800
}
};
const TEST_STATE = { const TEST_STATE = {
hydrographData: { hydrographData: {
currentTimeRange: { currentTimeRange: {
...@@ -56,6 +111,9 @@ describe('monitoring-location/components/hydrograph/legend module', () => { ...@@ -56,6 +111,9 @@ describe('monitoring-location/components/hydrograph/legend module', () => {
mapStateToPropsFactory: createStructuredSelector mapStateToPropsFactory: createStructuredSelector
}] }]
] ]
},
props: {
graphType: 'IV'
} }
}); });
}); });
...@@ -64,6 +122,25 @@ describe('monitoring-location/components/hydrograph/legend module', () => { ...@@ -64,6 +122,25 @@ describe('monitoring-location/components/hydrograph/legend module', () => {
expect(wrapper.findAll('.legend g')).toHaveLength(9); expect(wrapper.findAll('.legend g')).toHaveLength(9);
}); });
it('Should have the correct number of legend markers when working for the DV graph', () => {
wrapper = mount(HydrographLegend, {
global: {
plugins: [
[ReduxConnectVue, {
store: configureStore(DV_TEST_STATE),
mapDispatchToPropsFactory: (actionCreators) => (dispatch) => bindActionCreators(actionCreators, dispatch),
mapStateToPropsFactory: createStructuredSelector
}]
]
},
props: {
graphType: 'DV'
}
});
expect(wrapper.findAll('.legend g')).toHaveLength(1);
});
it('If no markers are provided legend-svg will contain no groups', () => { it('If no markers are provided legend-svg will contain no groups', () => {
wrapper = mount(HydrographLegend, { wrapper = mount(HydrographLegend, {
global: { global: {
...@@ -74,6 +151,9 @@ describe('monitoring-location/components/hydrograph/legend module', () => { ...@@ -74,6 +151,9 @@ describe('monitoring-location/components/hydrograph/legend module', () => {
mapStateToPropsFactory: createStructuredSelector mapStateToPropsFactory: createStructuredSelector
}] }]
] ]
},
props: {
graphType: 'IV'
} }
}); });
......
...@@ -18,17 +18,31 @@ ...@@ -18,17 +18,31 @@
<script> <script>
import {useState} from 'redux-connect-vue'; import {useState} from 'redux-connect-vue';
import {computed, ref, watchEffect} from 'vue'; import {computed, ref, toRefs, watchEffect} from 'vue';
import {select} from 'd3-selection'; import {select} from 'd3-selection';
import {getMainLayout} from '../selectors/layout'; import {getMainLayout} from '../selectors/layout';
import {getLegendMarkerRows} from '../selectors/legend-data'; import {getLegendMarkerRows} from '../selectors/legend-data';
import {getMainLayout as getDVMainLayout} from '../../daily-value-hydrograph/selectors/layout';
import {getLegendMarkers as getDVLegendMarkers} from '../../daily-value-hydrograph/selectors/legend-data';
import {mediaQuery} from 'ui/utils'; import {mediaQuery} from 'ui/utils';
import config from 'ui/config'; import config from 'ui/config';
export default { export default {
name: 'HydrographLegend', name: 'HydrographLegend',
setup() { props: {
graphType: {
type: String,
required: true,
validator: function(value) {
return ['DV', 'IV'].includes(value);
}
}
},
setup(props) {
const trackedType = toRefs(props).graphType;
const legend = ref(null); const legend = ref(null);
const RECTANGLE_MARKER_WIDTH = 20; const RECTANGLE_MARKER_WIDTH = 20;
...@@ -37,10 +51,21 @@ export default { ...@@ -37,10 +51,21 @@ export default {
const MARKER_GROUP_X_OFFSET = 15; const MARKER_GROUP_X_OFFSET = 15;
const VERTICAL_ROW_OFFSET = 18; const VERTICAL_ROW_OFFSET = 18;
const state = useState({ let state;
legendMarkerRows: getLegendMarkerRows,
layout: getMainLayout if (trackedType.value === 'IV') {
}); state = useState({
legendMarkerRows: getLegendMarkerRows,
layout: getMainLayout
});
}
if (trackedType.value === 'DV') {
state = useState({
legendMarkerRows: getDVLegendMarkers,
layout: getDVMainLayout
});
}
const legendTransform = computed(() => { const legendTransform = computed(() => {
return `translate(${mediaQuery(config.USWDS_MEDIUM_SCREEN) ? state.layout.value.margin.left : 0}, 0)`; return `translate(${mediaQuery(config.USWDS_MEDIUM_SCREEN) ? state.layout.value.margin.left : 0}, 0)`;
......
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