forked from covid19india/covid19india-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconstants.js
447 lines (414 loc) · 9.6 KB
/
constants.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
import {scaleOrdinal} from 'd3-scale';
// export const API_DOMAIN = 'http://localhost:8080';
// export const API_DOMAIN =
// 'https://raw.githubusercontent.com/shuklaayush/api/test/tmp';
// export const API_DOMAIN = 'https://api.covid19india.org';
export const API_DOMAIN = 'https://data.covid19india.org';
export const DATA_API_ROOT = `${API_DOMAIN}/v4/min`;
export const API_REFRESH_INTERVAL = 100000; // seconds
export const LOCALE_SHORTHANDS = {
english: 'en-US',
hindi: 'hi',
telugu: 'te',
kannada: 'en-US',
gujarati: 'gu',
marathi: 'en-US',
tamil: 'ta',
bengali: 'bn',
punjabi: 'en-US',
malayalam: 'en-US',
odiya: 'en-US',
};
export const STATISTIC_CONFIGS = {
confirmed: {
displayName: 'confirmed',
color: '#ff073a',
format: 'long',
showDelta: true,
hasPrimary: true,
},
active: {
displayName: 'active',
color: '#007bff',
format: 'long',
hasPrimary: true,
},
recovered: {
displayName: 'recovered',
color: '#28a745',
format: 'long',
showDelta: true,
hasPrimary: true,
},
deceased: {
displayName: 'deceased',
color: '#6c757d',
format: 'long',
showDelta: true,
hasPrimary: true,
},
other: {
displayName: 'other',
format: 'long',
color: '#fd7e14',
showDelta: true,
tableConfig: {
notes: 'Migrated cases or non-COVID deaths',
},
hasPrimary: true,
},
tested: {
displayName: 'tested',
color: '#4b1eaa',
format: 'short',
showDelta: true,
hideZero: true,
category: 'tested',
},
vaccinated1: {
displayName: 'vaccinated (at least one dose)',
color: '#fb5581',
format: 'short',
showDelta: true,
hideZero: true,
category: 'vaccinated',
},
vaccinated2: {
displayName: 'fully vaccinated',
color: '#fb5581',
format: 'short',
showDelta: true,
hideZero: true,
category: 'vaccinated',
},
vaccinated: {
displayName: 'vaccine doses administered',
color: '#fb5581',
format: 'short',
showDelta: true,
hideZero: true,
category: 'vaccinated',
},
tpr: {
displayName: 'test positivity ratio',
format: '%',
color: '#fd7e14',
nonLinear: true,
onlyDelta7: true,
hideZero: true,
category: 'tested',
tableConfig: {
notes: 'Calculated over last 7 days',
},
hasPrimary: true,
},
cfr: {
displayName: 'case fatality ratio',
format: '%',
color: '#fd7e14',
nonLinear: true,
hasPrimary: true,
},
recoveryRatio: {
displayName: 'recovery ratio',
format: '%',
nonLinear: true,
tableConfig: {
hide: true,
},
hasPrimary: true,
},
activeRatio: {
displayName: 'active ratio',
format: '%',
nonLinear: true,
tableConfig: {
hide: true,
},
hasPrimary: true,
},
caseGrowth: {
displayName: 'Case Growth',
format: '%',
nonLinear: true,
canBeInfinite: true,
tableConfig: {
notes:
'Percentage growth of cases last week compared to the week a fortnight ago',
},
hasPrimary: true,
mapConfig: {
transformFn: (val) => {
if (val <= 0) return '≤ 0%';
else if (val <= 20) return '0 - 20%';
else if (val <= 50) return '20 - 50%';
else if (val > 50) return '> 50%';
},
colorScale: scaleOrdinal(
['≤ 0%', '0 - 20%', '20 - 50%', '> 50%'],
['#1a9850', '#fee08b', '#fc8d59', '#d73027']
),
},
},
population: {
displayName: 'population',
format: 'short',
color: '#b6854d',
hideZero: true,
mapConfig: {
spike: true,
},
},
};
export const PRIMARY_STATISTICS = [
'confirmed',
'active',
'recovered',
'deceased',
];
export const LEVEL_STATISTICS = [...PRIMARY_STATISTICS];
export const TABLE_STATISTICS = [...PRIMARY_STATISTICS, 'tested', 'vaccinated'];
export const TABLE_STATISTICS_EXPANDED = Object.keys(STATISTIC_CONFIGS).filter(
(statistic) => !STATISTIC_CONFIGS[statistic]?.tableConfig?.hide
);
export const MAP_STATISTICS = [...PRIMARY_STATISTICS];
export const TIMESERIES_STATISTICS = [
...PRIMARY_STATISTICS,
'tested',
'vaccinated',
'tpr',
];
export const BRUSH_STATISTICS = ['confirmed'];
export const UPDATES_COUNT = 5;
export const DISTRICT_TABLE_COUNT = 40;
export const D3_TRANSITION_DURATION = 300;
export const MINIGRAPH_LOOKBACK_DAYS = 21;
export const TESTED_EXPIRING_DAYS = 7;
export const UNASSIGNED_STATE_CODE = 'UN';
export const UNKNOWN_DISTRICT_KEY = 'Unknown';
export const DISTRICT_START_DATE = '2020-04-26';
export const DISTRICT_TEST_END_DATE = '2021-02-02';
export const ISO_DATE_REGEX = /^\d{4}-([0]\d|1[0-2])-([0-2]\d|3[01])$/g;
export const INDIA_ISO_SUFFIX = 'T00:00:00+05:30';
export const SPRING_CONFIG_NUMBERS = {clamp: true, precision: 1};
export const TIMESERIES_CHART_TYPES = {
total: 'Cumulative',
delta: 'Daily',
};
export const TIMESERIES_LOOKBACK_DAYS = [null, 90, 30];
export const MAP_VIZS = {
CHOROPLETH: 0,
BUBBLE: 1,
SPIKE: 2,
};
export const MAP_VIEWS = {
STATES: 0,
DISTRICTS: 1,
};
export const MAP_TYPES = {
COUNTRY: 0,
STATE: 1,
};
export const MAPS_DIR =
process.env.NODE_ENV === 'production' ? '/mini_maps' : '/projected_maps';
export const MAP_META = {
AP: {
geoDataFile: `${MAPS_DIR}/andhrapradesh.json`,
mapType: MAP_TYPES.STATE,
},
AR: {
geoDataFile: `${MAPS_DIR}/arunachalpradesh.json`,
mapType: MAP_TYPES.STATE,
},
AS: {
geoDataFile: `${MAPS_DIR}/assam.json`,
mapType: MAP_TYPES.STATE,
},
BR: {
geoDataFile: `${MAPS_DIR}/bihar.json`,
mapType: MAP_TYPES.STATE,
},
CT: {
geoDataFile: `${MAPS_DIR}/chhattisgarh.json`,
mapType: MAP_TYPES.STATE,
},
GA: {
geoDataFile: `${MAPS_DIR}/goa.json`,
mapType: MAP_TYPES.STATE,
},
GJ: {
geoDataFile: `${MAPS_DIR}/gujarat.json`,
mapType: MAP_TYPES.STATE,
},
HR: {
geoDataFile: `${MAPS_DIR}/haryana.json`,
mapType: MAP_TYPES.STATE,
},
HP: {
geoDataFile: `${MAPS_DIR}/himachalpradesh.json`,
mapType: MAP_TYPES.STATE,
},
JK: {
geoDataFile: `${MAPS_DIR}/jammukashmir.json`,
mapType: MAP_TYPES.STATE,
},
JH: {
geoDataFile: `${MAPS_DIR}/jharkhand.json`,
mapType: MAP_TYPES.STATE,
},
KA: {
geoDataFile: `${MAPS_DIR}/karnataka.json`,
mapType: MAP_TYPES.STATE,
},
KL: {
geoDataFile: `${MAPS_DIR}/kerala.json`,
mapType: MAP_TYPES.STATE,
},
MP: {
geoDataFile: `${MAPS_DIR}/madhyapradesh.json`,
mapType: MAP_TYPES.STATE,
},
MH: {
geoDataFile: `${MAPS_DIR}/maharashtra.json`,
mapType: MAP_TYPES.STATE,
},
MN: {
geoDataFile: `${MAPS_DIR}/manipur.json`,
mapType: MAP_TYPES.STATE,
},
ML: {
geoDataFile: `${MAPS_DIR}/meghalaya.json`,
mapType: MAP_TYPES.STATE,
},
MZ: {
geoDataFile: `${MAPS_DIR}/mizoram.json`,
mapType: MAP_TYPES.STATE,
},
NL: {
geoDataFile: `${MAPS_DIR}/nagaland.json`,
mapType: MAP_TYPES.STATE,
},
OR: {
geoDataFile: `${MAPS_DIR}/odisha.json`,
mapType: MAP_TYPES.STATE,
},
PB: {
geoDataFile: `${MAPS_DIR}/punjab.json`,
mapType: MAP_TYPES.STATE,
},
RJ: {
geoDataFile: `${MAPS_DIR}/rajasthan.json`,
mapType: MAP_TYPES.STATE,
},
SK: {
geoDataFile: `${MAPS_DIR}/sikkim.json`,
mapType: MAP_TYPES.STATE,
},
TN: {
geoDataFile: `${MAPS_DIR}/tamilnadu.json`,
mapType: MAP_TYPES.STATE,
},
TG: {
geoDataFile: `${MAPS_DIR}/telangana.json`,
mapType: MAP_TYPES.STATE,
},
TR: {
geoDataFile: `${MAPS_DIR}/tripura.json`,
mapType: MAP_TYPES.STATE,
},
UT: {
geoDataFile: `${MAPS_DIR}/uttarakhand.json`,
mapType: MAP_TYPES.STATE,
},
UP: {
geoDataFile: `${MAPS_DIR}/uttarpradesh.json`,
mapType: MAP_TYPES.STATE,
},
WB: {
geoDataFile: `${MAPS_DIR}/westbengal.json`,
mapType: MAP_TYPES.STATE,
},
AN: {
geoDataFile: `${MAPS_DIR}/andamannicobarislands.json`,
mapType: MAP_TYPES.STATE,
},
CH: {
geoDataFile: `${MAPS_DIR}/chandigarh.json`,
mapType: MAP_TYPES.STATE,
},
DN: {
geoDataFile: `${MAPS_DIR}/dnh-and-dd.json`,
mapType: MAP_TYPES.STATE,
},
DL: {
geoDataFile: `${MAPS_DIR}/delhi.json`,
mapType: MAP_TYPES.STATE,
},
LA: {
geoDataFile: `${MAPS_DIR}/ladakh.json`,
mapType: MAP_TYPES.STATE,
},
LD: {
geoDataFile: `${MAPS_DIR}/lakshadweep.json`,
mapType: MAP_TYPES.STATE,
},
PY: {
geoDataFile: `${MAPS_DIR}/puducherry.json`,
mapType: MAP_TYPES.STATE,
},
TT: {
geoDataFile: `${MAPS_DIR}/india.json`,
mapType: MAP_TYPES.COUNTRY,
},
};
export const MAP_DIMENSIONS = [432, 488];
export const MAP_LEGEND_HEIGHT = 50;
export const STATE_NAMES = {
AP: 'Andhra Pradesh',
AR: 'Arunachal Pradesh',
AS: 'Assam',
BR: 'Bihar',
CT: 'Chhattisgarh',
GA: 'Goa',
GJ: 'Gujarat',
HR: 'Haryana',
HP: 'Himachal Pradesh',
JH: 'Jharkhand',
KA: 'Karnataka',
KL: 'Kerala',
MP: 'Madhya Pradesh',
MH: 'Maharashtra',
MN: 'Manipur',
ML: 'Meghalaya',
MZ: 'Mizoram',
NL: 'Nagaland',
OR: 'Odisha',
PB: 'Punjab',
RJ: 'Rajasthan',
SK: 'Sikkim',
TN: 'Tamil Nadu',
TG: 'Telangana',
TR: 'Tripura',
UT: 'Uttarakhand',
UP: 'Uttar Pradesh',
WB: 'West Bengal',
AN: 'Andaman and Nicobar Islands',
CH: 'Chandigarh',
DN: 'Dadra and Nagar Haveli and Daman and Diu',
DL: 'Delhi',
JK: 'Jammu and Kashmir',
LA: 'Ladakh',
LD: 'Lakshadweep',
PY: 'Puducherry',
TT: 'India',
[UNASSIGNED_STATE_CODE]: 'Unassigned',
};
const stateCodes = [];
const stateCodesMap = {};
Object.keys(STATE_NAMES).map((key, index) => {
stateCodesMap[STATE_NAMES[key]] = key;
stateCodes.push({code: key, name: STATE_NAMES[key]});
return null;
});
export const STATE_CODES = stateCodesMap;
export const STATE_CODES_ARRAY = stateCodes;