@cdc/dashboard 4.24.5 → 4.24.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdcdashboard.js +122872 -112065
- package/examples/custom/css/respiratory.css +236 -0
- package/examples/custom/js/respiratory.js +242 -0
- package/examples/default-multi-dataset-shared-filter.json +1729 -0
- package/examples/ed-visits-county-file.json +618 -0
- package/examples/filtered-dash.json +6 -21
- package/index.html +10 -1
- package/package.json +12 -11
- package/src/CdcDashboard.tsx +5 -1
- package/src/CdcDashboardComponent.tsx +165 -306
- package/src/DashboardContext.tsx +9 -1
- package/src/_stories/Dashboard.stories.tsx +38 -34
- package/src/_stories/_mock/api-filter-chart.json +11 -35
- package/src/_stories/_mock/api-filter-map.json +17 -31
- package/src/_stories/_mock/multi-viz.json +2 -3
- package/src/_stories/_mock/pivot-filter.json +14 -12
- package/src/components/CollapsibleVisualizationRow.tsx +44 -0
- package/src/components/Column.tsx +1 -1
- package/src/components/DashboardFilters/DashboardFilters.tsx +80 -0
- package/src/components/DashboardFilters/DashboardFiltersEditor/DashboardFiltersEditor.tsx +218 -0
- package/src/components/DashboardFilters/DashboardFiltersEditor/components/DeleteFilterModal.tsx +48 -0
- package/src/components/DashboardFilters/DashboardFiltersEditor/components/FilterEditor.tsx +367 -0
- package/src/components/DashboardFilters/DashboardFiltersEditor/index.ts +1 -0
- package/src/components/DashboardFilters/DashboardFiltersWrapper.tsx +143 -0
- package/src/components/DashboardFilters/index.ts +3 -0
- package/src/components/DataDesignerModal.tsx +9 -9
- package/src/components/ExpandCollapseButtons.tsx +20 -0
- package/src/components/Header/Header.tsx +1 -97
- package/src/components/MultiConfigTabs/MultiConfigTabs.tsx +4 -4
- package/src/components/Row.tsx +52 -19
- package/src/components/Toggle/Toggle.tsx +2 -4
- package/src/components/VisualizationRow.tsx +82 -24
- package/src/components/VisualizationsPanel/VisualizationsPanel.tsx +116 -0
- package/src/components/VisualizationsPanel/index.ts +1 -0
- package/src/components/VisualizationsPanel/visualizations-panel-styles.css +12 -0
- package/src/components/Widget.tsx +26 -90
- package/src/helpers/apiFilterHelpers.ts +51 -0
- package/src/helpers/changeFilterActive.ts +30 -0
- package/src/helpers/filterData.ts +10 -48
- package/src/helpers/generateValuesForFilter.ts +1 -1
- package/src/helpers/getAutoLoadVisualization.ts +11 -0
- package/src/helpers/getFilteredData.ts +4 -2
- package/src/helpers/getVizConfig.ts +23 -2
- package/src/helpers/getVizRowColumnLocator.ts +2 -1
- package/src/helpers/hasDashboardApplyBehavior.ts +5 -0
- package/src/helpers/iconHash.tsx +3 -3
- package/src/helpers/mapDataToConfig.ts +29 -0
- package/src/helpers/processData.ts +2 -3
- package/src/helpers/reloadURLHelpers.ts +68 -0
- package/src/helpers/tests/filterData.test.ts +1 -93
- package/src/scss/editor-panel.scss +1 -1
- package/src/scss/grid.scss +34 -27
- package/src/scss/main.scss +41 -3
- package/src/scss/variables.scss +4 -0
- package/src/store/dashboard.actions.ts +12 -4
- package/src/store/dashboard.reducer.ts +30 -4
- package/src/types/APIFilter.ts +1 -5
- package/src/types/ConfigRow.ts +2 -0
- package/src/types/Dashboard.ts +1 -1
- package/src/types/DashboardConfig.ts +2 -4
- package/src/types/DashboardFilters.ts +7 -0
- package/src/types/InitialState.ts +1 -1
- package/src/types/MultiDashboard.ts +2 -2
- package/src/types/SharedFilter.ts +2 -5
- package/src/types/Tab.ts +1 -1
- package/LICENSE +0 -201
- package/src/components/Filters.tsx +0 -88
- package/src/components/Header/FilterModal.tsx +0 -510
- package/src/components/VisualizationsPanel.tsx +0 -95
- package/src/helpers/getApiFilterKey.ts +0 -5
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
|
|
2
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .cove-dashboard-filters #filter-2,
|
|
3
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .cove-dashboard-filters label[for="filter-2"]{
|
|
4
|
+
display: none;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .cove-dashboard-filters {
|
|
9
|
+
max-width: 150px;
|
|
10
|
+
margin: 0.5em !important;
|
|
11
|
+
margin-bottom: 0 !important;
|
|
12
|
+
vertical-align: middle;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .cove-dashboard-filters:nth-child(3){
|
|
16
|
+
vertical-align: middle;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .cove-dashboard-filters:nth-child(3)::after{
|
|
20
|
+
content: 'Reset';
|
|
21
|
+
padding: .375rem .75rem;
|
|
22
|
+
font-size: 1rem;
|
|
23
|
+
color: #fff;
|
|
24
|
+
background-color: #005eaa;
|
|
25
|
+
border-radius: .1875rem;
|
|
26
|
+
cursor: pointer;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row:nth-child(1),
|
|
30
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row:nth-child(1) .dashboard-col {
|
|
31
|
+
margin-bottom: 0 !important;
|
|
32
|
+
display: block;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row.no-county:nth-child(1)::after {
|
|
36
|
+
content: 'Please select "All" to see values for your state.';
|
|
37
|
+
display: block;
|
|
38
|
+
margin-left: .5em;
|
|
39
|
+
margin-bottom: 1em;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row.no-county:nth-child(1) .dashboard-col::after {
|
|
43
|
+
content: 'County-level data unavailable';
|
|
44
|
+
display: block;
|
|
45
|
+
font-weight: bold;
|
|
46
|
+
margin-left: .5em;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row.no-counties:nth-child(1) .dashboard-col::after {
|
|
50
|
+
content: 'County level displays are not available for this state/territory';
|
|
51
|
+
display: block;
|
|
52
|
+
font-weight: bold;
|
|
53
|
+
margin-left: .5em;
|
|
54
|
+
margin-bottom: 1em;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row:nth-child(4){
|
|
58
|
+
display: none !important;
|
|
59
|
+
justify-content: normal !important;
|
|
60
|
+
column-gap: normal !important;
|
|
61
|
+
position: relative;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row:nth-child(4) .cove-component__content {
|
|
65
|
+
padding-top: 0;
|
|
66
|
+
border: 1px solid gray !important;
|
|
67
|
+
border-top: none !important;
|
|
68
|
+
border-bottom-left-radius: 0;
|
|
69
|
+
border-bottom-right-radius: 0;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row:nth-child(4) header {
|
|
74
|
+
border: 1px solid gray;
|
|
75
|
+
background-color: lightgray;
|
|
76
|
+
color: black;
|
|
77
|
+
border-top-left-radius: 0 !important;
|
|
78
|
+
border-top-right-radius: 0 !important;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row:nth-child(4) header::before {
|
|
82
|
+
content: '';
|
|
83
|
+
display: inline-block;
|
|
84
|
+
width: 1em;
|
|
85
|
+
height: 1em;
|
|
86
|
+
border-radius: .5em;
|
|
87
|
+
border: 1px solid lightgray;
|
|
88
|
+
margin-right: .5em;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row:nth-child(4) .dashboard-col:nth-child(1) header::before {
|
|
92
|
+
display: none;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row:nth-child(4) .dashboard-col:nth-child(2) header::before {
|
|
96
|
+
background-color: rgb(244, 128, 42);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row:nth-child(4) .dashboard-col:nth-child(3) header::before {
|
|
100
|
+
background-color: rgb(15, 102, 200);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row:nth-child(4) .dashboard-col:nth-child(4) header::before {
|
|
104
|
+
background-color: rgb(148, 3, 111);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row:nth-child(4) .dashboard-col:nth-child(1) p::before {
|
|
108
|
+
display: none;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row:nth-child(4) p {
|
|
112
|
+
padding-top: 1.5em;
|
|
113
|
+
min-height: 3.5em;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row:nth-child(4) p::before {
|
|
117
|
+
content: '\2192';
|
|
118
|
+
font-weight: 900;
|
|
119
|
+
font-size: xx-large;
|
|
120
|
+
display: inline-block;
|
|
121
|
+
color: rgb(15, 102, 200);
|
|
122
|
+
vertical-align: top;
|
|
123
|
+
line-height: .5em;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row:nth-child(4) p.increasing::before {
|
|
127
|
+
transform: rotate(-45deg);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row:nth-child(4) p.decreasing::before {
|
|
131
|
+
transform: rotate(45deg);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row:nth-child(4)::before {
|
|
135
|
+
content: 'County Trends';
|
|
136
|
+
position: absolute;
|
|
137
|
+
top: -2em;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row:nth-child(2) {
|
|
141
|
+
display: block;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row:nth-child(2) .dashboard-col {
|
|
145
|
+
display: inline-block;
|
|
146
|
+
vertical-align: top;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row:nth-child(2) .dashboard-col:nth-child(1) {
|
|
150
|
+
width: calc(150px + 3em);
|
|
151
|
+
margin-left: -.5em;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row:nth-child(2) .dashboard-col:nth-child(1)::before {
|
|
155
|
+
position: relative;
|
|
156
|
+
content: 'Selection:';
|
|
157
|
+
margin-left: 1rem;
|
|
158
|
+
top: .6em;
|
|
159
|
+
font-weight: bold;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row:nth-child(2) .dashboard-col:nth-child(2) {
|
|
163
|
+
width: calc(100% - 150px - 4.5em);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row:nth-child(2) .dashboard-col:nth-child(2) .theme-blue {
|
|
167
|
+
background-color: #EEE;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row:nth-child(2) .dashboard-col:nth-child(2) h2 {
|
|
171
|
+
color: black !important;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row:nth-child(2) .dashboard-col:nth-child(2) header {
|
|
175
|
+
background: none;
|
|
176
|
+
border: none;
|
|
177
|
+
color: black;
|
|
178
|
+
position: relative;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row:nth-child(2) .dashboard-col:nth-child(2) header.show-modal::before {
|
|
182
|
+
content: 'x';
|
|
183
|
+
position: absolute;
|
|
184
|
+
right: calc(5% + 1em);
|
|
185
|
+
top: -150px;
|
|
186
|
+
z-index: 1;
|
|
187
|
+
cursor: pointer;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row:nth-child(2) .dashboard-col:nth-child(2) header.show-modal::after {
|
|
191
|
+
content: 'Groups of counties often share healthcare resources. The data shown for the selected county include emergency department visit data collected for the entire area (which may include multiple counties).';
|
|
192
|
+
position: absolute;
|
|
193
|
+
bottom: calc(100% + 1em);
|
|
194
|
+
right: 5%;
|
|
195
|
+
padding: .5em 2em 5em .5em;
|
|
196
|
+
height: 140px;
|
|
197
|
+
width: 250px;
|
|
198
|
+
background-color: rgb(243,247,251);
|
|
199
|
+
color: rgb(56,100,151);
|
|
200
|
+
border: 1px solid rgb(56,100,151);
|
|
201
|
+
border-radius: 5px;
|
|
202
|
+
max-width: 80%;
|
|
203
|
+
font-size: .8em;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row:nth-child(2) .dashboard-col:nth-child(2) header h2::after {
|
|
207
|
+
content: 'More Info';
|
|
208
|
+
cursor: pointer;
|
|
209
|
+
text-decoration: underline;
|
|
210
|
+
color:#0000EE;
|
|
211
|
+
float: right;
|
|
212
|
+
font-weight: normal;
|
|
213
|
+
margin-left: 1em;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row:nth-child(2) .dashboard-col:nth-child(2) header div {
|
|
217
|
+
font-weight: bold;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row.state-level:nth-child(4)::before {
|
|
221
|
+
content: 'State Trends';
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .margin-left-href {
|
|
225
|
+
display: none;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
@media screen and (max-width: 767px) {
|
|
229
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row:nth-child(2) .dashboard-col {
|
|
230
|
+
width: 100% !important;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
div[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"] .dashboard-row:nth-child(2) .dashboard-col:nth-child(2) {
|
|
234
|
+
margin-bottom: 2em;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
$(document).ready(function() {
|
|
2
|
+
function trackMetric(interactionValue){
|
|
3
|
+
if ( window.hasOwnProperty( '_satellite' ) ) {
|
|
4
|
+
var dataObject = {};
|
|
5
|
+
var _satellite = window._satellite;
|
|
6
|
+
var eventLabel = 'respiratory-dasboard-chart';
|
|
7
|
+
var eventValue = interactionValue.replace(/ /g, '-').toLowerCase();
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
dataObject.ch = 'OADC';
|
|
12
|
+
dataObject.pageName = document.title;
|
|
13
|
+
dataObject.label = eventLabel;
|
|
14
|
+
dataObject.interactionType = 'o';
|
|
15
|
+
dataObject.interactionValue = 'ci-' + eventLabel + ': ' + eventValue;
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
_satellite.track( 'interaction', dataObject );
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function onSelectChange(e){
|
|
24
|
+
trackMetric('state-select-' + $(e.target).find('option:selected').text());
|
|
25
|
+
if(e.target.id === 'filter-0'){
|
|
26
|
+
setTimeout(function(){
|
|
27
|
+
var $countySelect = $viz.find('#filter-1');
|
|
28
|
+
var select = $countySelect[0];
|
|
29
|
+
$countySelect.val('All');
|
|
30
|
+
Object.getOwnPropertyDescriptor(window.HTMLSelectElement.prototype, 'value').set.call(select, 'All');
|
|
31
|
+
select.dispatchEvent(new Event('change', { bubbles: true}));
|
|
32
|
+
}, 50);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function onMoreInfoClick(e){
|
|
37
|
+
if(!e.keyCode || e.keyCode === 13){
|
|
38
|
+
var $moreInfoLink = $viz.find('.dashboard-row:nth-child(2) .dashboard-col:nth-child(2) header');
|
|
39
|
+
if($moreInfoLink.hasClass('show-modal')){
|
|
40
|
+
$moreInfoLink.removeClass('show-modal');
|
|
41
|
+
} else {
|
|
42
|
+
$moreInfoLink.addClass('show-modal');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function onResetClick(e){
|
|
48
|
+
if(!e.keyCode || e.keyCode === 13){
|
|
49
|
+
var $stateSelect = $viz.find('#filter-0');
|
|
50
|
+
var select = $stateSelect[0];
|
|
51
|
+
$stateSelect.val('United States');
|
|
52
|
+
Object.getOwnPropertyDescriptor(window.HTMLSelectElement.prototype, 'value').set.call(select, 'United States');
|
|
53
|
+
select.dispatchEvent(new Event('change', { bubbles: true}));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
var $viz = $('.wcms-viz-container[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"]')
|
|
58
|
+
|
|
59
|
+
var observer = new MutationObserver(function(mutations, observer) {
|
|
60
|
+
var $select = $viz.find('select');
|
|
61
|
+
if($select.length > 0){
|
|
62
|
+
$select.off('change', onSelectChange)
|
|
63
|
+
$select.on('change', onSelectChange)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
var $resetButton = $viz.find('.cove-dashboard-filters:nth-child(3)');
|
|
67
|
+
if($resetButton.length > 0){
|
|
68
|
+
$resetButton.off('click keypress', onResetClick)
|
|
69
|
+
$resetButton.on('click keypress', onResetClick)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
var $moreInfoLink = $viz.find('.dashboard-row:nth-child(2) .dashboard-col:nth-child(2) header');
|
|
73
|
+
if($moreInfoLink.length > 0){
|
|
74
|
+
$moreInfoLink.off('click keypress', onMoreInfoClick)
|
|
75
|
+
$moreInfoLink.on('click keypress', onMoreInfoClick)
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
if($viz.length > 0){
|
|
80
|
+
observer.observe($viz[0], {
|
|
81
|
+
subtree: true,
|
|
82
|
+
attributes: true
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
$(document).ready(function() {
|
|
88
|
+
var $viz = $('.wcms-viz-container[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"');
|
|
89
|
+
var hasStateChanged = false;
|
|
90
|
+
var hasCountyChanged = false;
|
|
91
|
+
|
|
92
|
+
function onMutation(mutations, observer) {
|
|
93
|
+
var $stateSelect = $viz.find('#filter-0');
|
|
94
|
+
var $countySelect = $viz.find('#filter-1');
|
|
95
|
+
|
|
96
|
+
var hashVal = window.location.hash ? decodeURIComponent(window.location.hash.replace('#', '')) : '';
|
|
97
|
+
var stateVal
|
|
98
|
+
var countyVal
|
|
99
|
+
if(hashVal.indexOf(',') !== -1){
|
|
100
|
+
stateVal = hashVal.split(',')[0]
|
|
101
|
+
countyVal = hashVal.split(',')[1]
|
|
102
|
+
} else {
|
|
103
|
+
stateVal = hashVal
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if(stateVal === 'District Of Columbia') stateVal = 'District of Columbia';
|
|
107
|
+
|
|
108
|
+
if(stateVal && !hasStateChanged && $stateSelect.length > 0){
|
|
109
|
+
var options = $stateSelect.find('option').toArray().map(el => el.value ? el.value.toLowerCase() : '');
|
|
110
|
+
if(stateVal && options.length > 0 && options.indexOf(stateVal.toLowerCase()) !== -1){
|
|
111
|
+
var select = $stateSelect[0];
|
|
112
|
+
$stateSelect.val(stateVal);
|
|
113
|
+
Object.getOwnPropertyDescriptor(window.HTMLSelectElement.prototype, 'value').set.call(select, stateVal);
|
|
114
|
+
select.dispatchEvent(new Event('change', { bubbles: true}));
|
|
115
|
+
$viz[0].scrollIntoView();
|
|
116
|
+
|
|
117
|
+
hasStateChanged = true;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if(countyVal && !hasCountyChanged && hasStateChanged && $countySelect.length > 0){
|
|
121
|
+
var options = $countySelect.find('option').toArray().map(el => el.value ? el.value.toLowerCase() : '');
|
|
122
|
+
if(options.length > 0 && options.indexOf(countyVal.toLowerCase()) !== -1){
|
|
123
|
+
var select = $countySelect[0];
|
|
124
|
+
$countySelect.val(countyVal);
|
|
125
|
+
Object.getOwnPropertyDescriptor(window.HTMLSelectElement.prototype, 'value').set.call(select, countyVal);
|
|
126
|
+
select.dispatchEvent(new Event('change', { bubbles: true}));
|
|
127
|
+
$viz[0].scrollIntoView();
|
|
128
|
+
|
|
129
|
+
hasCountyChanged = true;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if($viz.length > 0){
|
|
136
|
+
onMutation();
|
|
137
|
+
|
|
138
|
+
var observer = new MutationObserver(onMutation);
|
|
139
|
+
|
|
140
|
+
observer.observe($viz[0], {
|
|
141
|
+
subtree: true,
|
|
142
|
+
attributes: true
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
$(document).ready(function() {
|
|
148
|
+
var suppressedFlags;
|
|
149
|
+
var $viz = $('.wcms-viz-container[data-config-url="/respiratory-viruses/modules/ed-visits-county-file.json"]')
|
|
150
|
+
|
|
151
|
+
if($viz.length > 0){
|
|
152
|
+
$.get("https://www.cdc.gov/wcms/vizdata/Respitory_Viruses/NSSPSubStateOptOut.json", function( data ) {
|
|
153
|
+
suppressedFlags = data;
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
setInterval(function(){
|
|
157
|
+
var $select = $viz.find('#filter-0');
|
|
158
|
+
var $countySelect = $viz.find('#filter-1');
|
|
159
|
+
var $targetSelect = $viz.find('#filter-2');
|
|
160
|
+
|
|
161
|
+
if($select.val() !== $targetSelect.val()){
|
|
162
|
+
setTimeout(function(){
|
|
163
|
+
var targetSelect = $targetSelect[0];
|
|
164
|
+
$targetSelect.val($select.val()).trigger('change');
|
|
165
|
+
Object.getOwnPropertyDescriptor(window.HTMLSelectElement.prototype, 'value').set.call(targetSelect, $select.val());
|
|
166
|
+
targetSelect.dispatchEvent(new Event('change', { bubbles: true}));
|
|
167
|
+
$select.val($select.val())
|
|
168
|
+
|
|
169
|
+
}, 50);
|
|
170
|
+
}
|
|
171
|
+
}, 200);
|
|
172
|
+
|
|
173
|
+
var observer = new MutationObserver(function(mutations, observer) {
|
|
174
|
+
var $select = $viz.find('#filter-0');
|
|
175
|
+
var $countySelect = $viz.find('#filter-1');
|
|
176
|
+
var $targetSelect = $viz.find('#filter-2');
|
|
177
|
+
|
|
178
|
+
if($countySelect.find('option').length === 1 && $select.val() !== 'District of Columbia' && $select.val() !== 'United States'){
|
|
179
|
+
$viz.find('.dashboard-row:nth-child(1)').addClass('no-counties');
|
|
180
|
+
$viz.find('.dashboard-row:nth-child(4)').removeClass('county-level').addClass('state-level');
|
|
181
|
+
} else {
|
|
182
|
+
$viz.find('.dashboard-row:nth-child(1)').removeClass('no-counties');
|
|
183
|
+
$viz.find('.dashboard-row:nth-child(4)').removeClass('state-level').addClass('county-level');
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if(suppressedFlags){
|
|
187
|
+
var suppressedNode = suppressedFlags.find(function(d){
|
|
188
|
+
if(d['geography'] === $select.val() && d['county'] === $countySelect.val()){
|
|
189
|
+
return true
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
if(suppressedNode && suppressedNode['is_hsa_opt_out'] === 'true'){
|
|
193
|
+
$viz.find('.cdc-chart-inner-container').hide()
|
|
194
|
+
$viz.find('.dashboard-row:nth-child(1)').addClass('no-county');
|
|
195
|
+
} else {
|
|
196
|
+
$viz.find('.dashboard-row:nth-child(1)').removeClass('no-county');
|
|
197
|
+
$viz.find('.cdc-chart-inner-container').show()
|
|
198
|
+
}
|
|
199
|
+
} else {
|
|
200
|
+
$viz.find('.dashboard-row:nth-child(1)').removeClass('no-county');
|
|
201
|
+
$viz.find('.cdc-chart-inner-container').show()
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
var countyAll = $countySelect.find('option[value="All"]')
|
|
205
|
+
if(countyAll.length === 1 && countyAll.index() !== 0){
|
|
206
|
+
countyAll.remove();
|
|
207
|
+
$countySelect.prepend(countyAll);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
var stateAll = $select.find('option[value="United States"]')
|
|
211
|
+
if(stateAll.length === 1 && stateAll.index() !== 0){
|
|
212
|
+
stateAll.remove();
|
|
213
|
+
$select.prepend(stateAll);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
$viz.find('.dashboard-row:nth-child(4) p').each(function(index, el){
|
|
217
|
+
var className = el.innerText.trim().toLowerCase().replace(' ', '-');
|
|
218
|
+
if(!$(el).hasClass(className)){
|
|
219
|
+
$(el).removeClass('increasing decreasing')
|
|
220
|
+
$(el).addClass(className);
|
|
221
|
+
}
|
|
222
|
+
})
|
|
223
|
+
|
|
224
|
+
if($viz.find('.dashboard-row:nth-child(4) .dashboard-col').length === 3){
|
|
225
|
+
$viz.find('.dashboard-row:nth-child(4)').prepend('<div class="dashboard-col dashboard-col-4"><div class="cove theme-blue "><header class="cove-component__header theme-blue " style="font-size: 16px;">Respiratory Illness</header><div class="cove-component__content component--has-title no-borders"><div class="cove-component__content-wrap"><p class="decreasing" style="font-size: 16px;">Weekly Trend</p></div></div></div></div>');
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if($viz.find('.dashboard-row:nth-child(2) .dashboard-col:nth-child(2) header').length > 0 && !$viz.find('.dashboard-row:nth-child(2) .dashboard-col:nth-child(2) header').attr('tabindex')){
|
|
229
|
+
$viz.find('.dashboard-row:nth-child(2) .dashboard-col:nth-child(2) header').attr('tabindex', '0');
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if($viz.find('.cove-dashboard-filters:nth-child(3)').length > 0 && !$viz.find('.cove-dashboard-filters:nth-child(3)').attr('tabindex')){
|
|
233
|
+
$viz.find('.cove-dashboard-filters:nth-child(3)').attr('tabindex', '0');
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
observer.observe($viz[0], {
|
|
238
|
+
subtree: true,
|
|
239
|
+
attributes: true
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
});
|