@dra2020/dra-types 1.8.92 → 1.8.93

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.
@@ -1,7 +1,10 @@
1
1
  export interface DatasetField {
2
2
  shortCaption: string;
3
3
  longCaption: string;
4
+ order?: number;
5
+ isCombo?: boolean;
4
6
  }
7
+ export declare function sortFields(f1: DatasetField, f2: DatasetField): number;
5
8
  export type DatasetFields = {
6
9
  [key: string]: DatasetField;
7
10
  };
@@ -31,7 +34,7 @@ export interface Dataset {
31
34
  createTime?: string;
32
35
  modifyTime?: string;
33
36
  deleted?: boolean;
34
- published?: boolean;
37
+ published?: string;
35
38
  official?: boolean;
36
39
  state?: string;
37
40
  datasource?: string;
package/dist/dra-types.js CHANGED
@@ -257,7 +257,7 @@ exports.ethnicBackgroundColor = ethnicBackgroundColor;
257
257
  function ToAllEthnicColor(agg, dc, pd) {
258
258
  // Use VAP/CVAP if it exists
259
259
  const dataset = dc.primeVDS ? dc.primeVDS : dc.primeDDS;
260
- return AggregateEthnicColor(PF.ToGetter(agg, dc, dataset), pd, dataset.endsWith('NH'));
260
+ return AggregateEthnicColor(PF.ToGetter(agg, dc, '', dataset), pd, dataset.endsWith('NH'));
261
261
  }
262
262
  exports.ToAllEthnicColor = ToAllEthnicColor;
263
263
  function ToPartisanColorStr(agg, dc, pd) {
@@ -270,21 +270,21 @@ function ToPartisanDistrictColor(agg, dc, pd) {
270
270
  exports.ToPartisanDistrictColor = ToPartisanDistrictColor;
271
271
  function ToPartisanColor(agg, dc, stops) {
272
272
  if (dc.primeEDS === PF.DS_PVI2020) {
273
- const getter16 = PF.ToGetter(agg, dc, PF.DS_PRES2016);
274
- const getter20 = PF.ToGetter(agg, dc, PF.DS_PRES2020);
273
+ const getter16 = PF.ToGetter(agg, dc, '', PF.DS_PRES2016);
274
+ const getter20 = PF.ToGetter(agg, dc, '', PF.DS_PRES2020);
275
275
  const pviRaw = PF.calcRaw2020Pvi(getter16, getter20);
276
276
  const color = ColorFromRGBPcts((1 - pviRaw / 100), 0, pviRaw / 100, stops);
277
277
  //console.log('Pvi (r, d, color): (' + (1 - pviRaw/100) + ', ' + pviRaw/100 + ', ' + color + ')');
278
278
  return color;
279
279
  }
280
280
  else if (dc.primeEDS === PF.DS_PVI2016) {
281
- const getter = PF.ToGetter(agg, dc, dc.primeEDS);
281
+ const getter = PF.ToGetter(agg, dc, '', dc.primeEDS);
282
282
  const pviRaw = PF.calcRawPvi(getter);
283
283
  const color = ColorFromRGBPcts((1 - pviRaw / 100), 0, pviRaw / 100, stops);
284
284
  return color;
285
285
  }
286
286
  else {
287
- const getter = PF.ToGetter(agg, dc, dc.primeEDS);
287
+ const getter = PF.ToGetter(agg, dc, '', dc.primeEDS);
288
288
  return AggregatePartisanColorStr(getter, stops);
289
289
  }
290
290
  }
@@ -346,7 +346,7 @@ function ToEthnicColorStr(agg, dc, pd, detail) {
346
346
  break;
347
347
  default: break;
348
348
  }
349
- const getter = PF.ToGetter(agg, dc, dataset);
349
+ const getter = PF.ToGetter(agg, dc, '', dataset);
350
350
  let den = getter(total);
351
351
  let num = getter(ethnic);
352
352
  if (den === undefined || isNaN(den) || num === undefined || isNaN(num))
@@ -1253,6 +1253,11 @@ exports.StateNameMap = {
1253
1253
 
1254
1254
 
1255
1255
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1256
+ exports.sortFields = void 0;
1257
+ function sortFields(f1, f2) {
1258
+ return (f1.order || 0) - (f2.order || 0);
1259
+ }
1260
+ exports.sortFields = sortFields;
1256
1261
 
1257
1262
 
1258
1263
  /***/ }),
@@ -1372,34 +1377,8 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
1372
1377
 
1373
1378
 
1374
1379
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1375
- exports.pvi2020Str = exports.calcRaw2020Pvi = exports.pviStr = exports.calcRawPvi = exports.calcShift = exports.ToGetterPvi20 = exports.ToGetterPvi16 = exports.ToGetter = exports.findPackedField = exports.getPackedField = exports.diffPackedFields = exports.aggregatePackedFields = exports.packedCopy = exports.zeroPackedCopy = exports.zeroPackedFields = exports.retrievePackedFields = exports.setPackedFields = exports.hasPackedFields = exports.computePackedFields = exports.computeMetaIndex = exports.fGet = exports.fGetJoined = exports.fieldGetterNotLoaded = exports.DS_PRES2016 = exports.DS_PRES2020 = exports.DS_PVI2016 = exports.PVI2020_Title = exports.DS_PVI2020 = exports.DATASET_TYPE_PVI = exports.DATASET_TYPE_ELECTION = exports.DATASET_TYPE_DEMOGRAPHIC = exports.AGG_pvi = exports.AGG_pres2016 = exports.AGG_pres2008 = exports.AGG_DEMOGRAPHIC18 = exports.AGG_DEMOGRAPHIC = void 0;
1380
+ exports.pvi2020Str = exports.calcRaw2020Pvi = exports.pviStr = exports.calcRawPvi = exports.calcShift = exports.ToGetterPvi20 = exports.ToGetterPvi16 = exports.ToGetter = exports.fieldGetterNotLoaded = exports.findPackedField = exports.getPackedField = exports.diffPackedFields = exports.decrementPackedFields = exports.aggregateCount = exports.aggregatePackedFields = exports.packedCopy = exports.zeroPackedCopy = exports.zeroPackedFields = exports.retrievePackedFields = exports.pushedExtPackedFields = exports.featurePushedExtPackedFields = exports.featurePushExtPackedFields = exports.isExtDataset = exports.setPackedFields = exports.hasPackedFields = exports.computePackedFields = exports.computeMetaIndex = exports.fGet = exports.fGetJoined = exports.DS_PRES2016 = exports.DS_PRES2020 = exports.DS_PVI2016 = exports.PVI2020_Title = exports.DS_PVI2020 = exports.DATASET_TYPE_OTHER = exports.DATASET_TYPE_PVI = exports.DATASET_TYPE_ELECTION = exports.DATASET_TYPE_DEMOGRAPHIC = exports.AGG_pvi = exports.AGG_pres2016 = exports.AGG_pres2008 = exports.AGG_DEMOGRAPHIC18 = exports.AGG_DEMOGRAPHIC = void 0;
1376
1381
  const baseclient_1 = __webpack_require__(/*! @dra2020/baseclient */ "@dra2020/baseclient");
1377
- // **** Dataset Codes Explained ****
1378
- // Elections:
1379
- // EYYGCC, where YY = year and CC = contest [PR, SE, GO, AG]
1380
- // C16GCO = composite (spans number of years)
1381
- // PYYGPR = PVI, where YY is year [16, 20]
1382
- // Census/ACS:
1383
- // DYYF = Census/ACS Total Pop, where YY = year [10, 18, 19, 20]
1384
- // DYYT = Census/ACS VAP/CVAP, where YY = year [10, 18, 19, 20]
1385
- // D20FA = Census 2020 Total Prisoner-Adjusted Pop
1386
- // D20TNH = Census 2020 VAP with Non-Hispanic Alone Race fields
1387
- // **** Dataset Fields Explained ****
1388
- // Elections:
1389
- // D: Democratic
1390
- // R: Republican
1391
- // Tot (Total R + D + Other)
1392
- // Census/ACS/VAP/CVAP:
1393
- // Tot: total
1394
- // Wh: White alone, not Hispanic
1395
- // His: All Hispanics
1396
- // Bl: Black alone, not Hispanic; BlC: Black combo, incl Hispanic
1397
- // Asn: Asian alone, not Hispanic; AsnC: Asian combo, incl Hispanic
1398
- // Nat: Native alone, not Hispanic; NatC: Native combo, incl Hispanic
1399
- // Pac (also PI): Pacific alone, not Hispanic; PacC: Pacific combo, incl Hispanic
1400
- // OthAl: Other alone, not Hispanic; Oth: Other + Two or more races, incl Hispanic
1401
- // Mix: Two or more races, not Hispanic
1402
- // AsnPI: Asian + Pacific, not Hispanic
1403
1382
  exports.AGG_DEMOGRAPHIC = 'demographic';
1404
1383
  exports.AGG_DEMOGRAPHIC18 = 'demographic18';
1405
1384
  exports.AGG_pres2008 = 'pres2008';
@@ -1408,13 +1387,12 @@ exports.AGG_pvi = 'pvi';
1408
1387
  exports.DATASET_TYPE_DEMOGRAPHIC = 'demographic';
1409
1388
  exports.DATASET_TYPE_ELECTION = 'election';
1410
1389
  exports.DATASET_TYPE_PVI = 'pvi';
1390
+ exports.DATASET_TYPE_OTHER = 'other';
1411
1391
  exports.DS_PVI2020 = 'P20GPR';
1412
1392
  exports.PVI2020_Title = 'PVI 2016/2020';
1413
1393
  exports.DS_PVI2016 = 'P16GPR';
1414
1394
  exports.DS_PRES2020 = 'E20GPR';
1415
1395
  exports.DS_PRES2016 = 'E16GPR';
1416
- function fieldGetterNotLoaded(f) { return undefined; }
1417
- exports.fieldGetterNotLoaded = fieldGetterNotLoaded;
1418
1396
  function fGetJoined(f) {
1419
1397
  return (f.properties && f.properties.joined) ? f.properties.joined : undefined;
1420
1398
  }
@@ -1458,7 +1436,7 @@ function fGetW(f, datasetKey, p) {
1458
1436
  }
1459
1437
  return undefined;
1460
1438
  }
1461
- function computeMetaIndex(meta) {
1439
+ function computeMetaIndex(datasetid, meta) {
1462
1440
  if (meta == null)
1463
1441
  return null;
1464
1442
  let offset = 1; // first entry is count of aggregates
@@ -1471,26 +1449,27 @@ function computeMetaIndex(meta) {
1471
1449
  });
1472
1450
  index.fields[datasetKey] = fieldsIndex;
1473
1451
  });
1452
+ let groupindex = { [datasetid]: index };
1474
1453
  index.length = offset;
1475
1454
  index.getDatasetField = (f, dataset, field) => {
1476
1455
  let pf = retrievePackedFields(f);
1477
- return getPackedField(index, pf, dataset, field);
1456
+ return getPackedField(groupindex, pf, datasetid, dataset, field);
1478
1457
  };
1479
1458
  return index;
1480
1459
  }
1481
1460
  exports.computeMetaIndex = computeMetaIndex;
1482
1461
  let nAlloc = 0;
1483
- function allocPackedFields(length) {
1462
+ function allocPackedFieldsArray(length) {
1484
1463
  let ab = new ArrayBuffer(8 * length);
1485
1464
  let af = new Float64Array(ab);
1486
1465
  nAlloc++;
1487
- //if ((nAlloc % 10000) == 0) console.log(`allocPackedFields: ${nAlloc} allocs`);
1466
+ //if ((nAlloc % 10000) == 0) console.log(`allocPackedFieldsArray: ${nAlloc} allocs`);
1488
1467
  return af;
1489
1468
  }
1490
1469
  function computePackedFields(f, index) {
1491
1470
  if (f.properties.packedFields)
1492
1471
  return f.properties.packedFields;
1493
- let af = allocPackedFields(index.length);
1472
+ let af = allocPackedFieldsArray(index.length);
1494
1473
  af[0] = 0; // count of number of aggregates
1495
1474
  Object.keys(index.fields).forEach((dataset) => {
1496
1475
  let fields = index.fields[dataset];
@@ -1501,11 +1480,11 @@ function computePackedFields(f, index) {
1501
1480
  af[fields[field]] = n;
1502
1481
  });
1503
1482
  });
1504
- f.properties.packedFields = af; // cache here
1483
+ f.properties.packedFields = { ['']: af }; // cache here
1505
1484
  f.properties.getDatasetField = index.getDatasetField;
1506
1485
  // Major memory savings to delete this after packing
1507
1486
  delete f.properties.datasets;
1508
- return af;
1487
+ return f.properties.packedFields;
1509
1488
  }
1510
1489
  exports.computePackedFields = computePackedFields;
1511
1490
  function hasPackedFields(f) {
@@ -1519,6 +1498,58 @@ function setPackedFields(f, pf, fIndex) {
1519
1498
  f.properties.getDatasetField = fIndex.properties.getDatasetField;
1520
1499
  }
1521
1500
  exports.setPackedFields = setPackedFields;
1501
+ const reExtDataset = /^.*\.ds$/;
1502
+ function isExtDataset(did) {
1503
+ return did && reExtDataset.test(did);
1504
+ }
1505
+ exports.isExtDataset = isExtDataset;
1506
+ function featurePushExtPackedFields(f, datasetid, data, card) {
1507
+ var _a;
1508
+ let blocks = ((_a = f === null || f === void 0 ? void 0 : f.properties) === null || _a === void 0 ? void 0 : _a.blocks) || (card.has(f.properties.id) ? [f.properties.id] : null);
1509
+ if (!blocks)
1510
+ return;
1511
+ if (!f.properties.packedFields)
1512
+ throw ('pushExtPackedFields: base datasets should be pushed first');
1513
+ if (card.size != data[0])
1514
+ throw ('pushExtPackedFields: packed fields and block cardinality do not match');
1515
+ if (f.properties.packedFields[datasetid])
1516
+ return; // already pushed
1517
+ let nfields = data[1];
1518
+ let pfa = allocPackedFieldsArray(nfields + 1); // field count
1519
+ pfa[0] = 0;
1520
+ for (let j = 0; j < nfields; j++)
1521
+ pfa[j] = 0;
1522
+ blocks.forEach((blockid) => {
1523
+ if (!card.has(blockid))
1524
+ throw (`pushExtPackedFields: missing blockid ${blockid} in cardinality set`);
1525
+ let x = 2 + (nfields * card.get(blockid));
1526
+ for (let i = 1; i <= nfields; i++)
1527
+ pfa[i] += data[x++];
1528
+ });
1529
+ f.properties.packedFields[datasetid] = pfa;
1530
+ }
1531
+ exports.featurePushExtPackedFields = featurePushExtPackedFields;
1532
+ function featurePushedExtPackedFields(f, datasetid, card) {
1533
+ var _a;
1534
+ if (!f)
1535
+ return true;
1536
+ if (f.features)
1537
+ return featurePushedExtPackedFields(f.features[0], datasetid, card);
1538
+ if (!((_a = f === null || f === void 0 ? void 0 : f.properties) === null || _a === void 0 ? void 0 : _a.blocks) && !card.has(f.properties.id))
1539
+ return true;
1540
+ if (!f.properties.packedFields)
1541
+ return true;
1542
+ return !!f.properties.packedFields[datasetid];
1543
+ }
1544
+ exports.featurePushedExtPackedFields = featurePushedExtPackedFields;
1545
+ function pushedExtPackedFields(pf, datasetids) {
1546
+ if (pf && datasetids)
1547
+ for (let i = 0; i < datasetids.length; i++)
1548
+ if (!pf[datasetids[i]])
1549
+ return false;
1550
+ return !!pf;
1551
+ }
1552
+ exports.pushedExtPackedFields = pushedExtPackedFields;
1522
1553
  function retrievePackedFields(f) {
1523
1554
  if (f.properties.packedFields === undefined)
1524
1555
  throw 'Feature should have pre-computed packed fields';
@@ -1530,84 +1561,121 @@ exports.retrievePackedFields = retrievePackedFields;
1530
1561
  let abZero = new ArrayBuffer(8);
1531
1562
  let afZero = new Float64Array(abZero);
1532
1563
  afZero[0] = 0;
1564
+ let pfZero = { ['']: afZero };
1533
1565
  function zeroPackedFields(index) {
1534
1566
  if (index == null)
1535
- return afZero;
1536
- let af = allocPackedFields(index.length);
1537
- for (let i = 0; i < af.length; i++)
1538
- af[i] = 0;
1539
- return af;
1567
+ return pfZero;
1568
+ let pf = {};
1569
+ Object.keys(index).forEach(datasetid => {
1570
+ let af = allocPackedFieldsArray(index[datasetid].length);
1571
+ for (let i = 0; i < af.length; i++)
1572
+ af[i] = 0;
1573
+ pf[datasetid] = af;
1574
+ });
1575
+ return pf;
1540
1576
  }
1541
1577
  exports.zeroPackedFields = zeroPackedFields;
1542
1578
  function zeroPackedCopy(pf) {
1543
1579
  if (pf == null)
1544
- return afZero;
1545
- let af = allocPackedFields(pf.length);
1546
- for (let i = 0; i < af.length; i++)
1547
- af[i] = 0;
1548
- return af;
1580
+ return pfZero;
1581
+ let copy = {};
1582
+ Object.keys(pf).forEach(datasetid => {
1583
+ let cf = allocPackedFieldsArray(pf[datasetid].length);
1584
+ for (let i = 0; i < cf.length; i++)
1585
+ cf[i] = 0;
1586
+ copy[datasetid] = cf;
1587
+ });
1588
+ return copy;
1549
1589
  }
1550
1590
  exports.zeroPackedCopy = zeroPackedCopy;
1551
1591
  function packedCopy(pf) {
1552
1592
  if (pf == null)
1553
1593
  return null;
1554
- let af = allocPackedFields(pf.length);
1555
- for (let i = 0; i < pf.length; i++)
1556
- af[i] = pf[i];
1557
- return af;
1594
+ let copy = {};
1595
+ Object.keys(pf).forEach(datasetid => {
1596
+ let af = pf[datasetid];
1597
+ let cf = allocPackedFieldsArray(af.length);
1598
+ for (let i = 0; i < af.length; i++)
1599
+ cf[i] = af[i];
1600
+ copy[datasetid] = cf;
1601
+ });
1602
+ return copy;
1558
1603
  }
1559
1604
  exports.packedCopy = packedCopy;
1560
1605
  function aggregatePackedFields(agg, pf) {
1561
1606
  if (agg == null || pf == null)
1562
1607
  return agg;
1563
- if (agg.length != pf.length) {
1564
- return agg; // bug, but don't crash
1565
- //throw 'aggregatePackedFields: unexpected length mismatch';
1566
- }
1567
- let n = agg.length;
1568
- for (let i = 1; i < n; i++)
1569
- agg[i] += pf[i];
1570
- agg[0]++; // count of number of aggregates
1608
+ Object.keys(agg).forEach(datasetid => {
1609
+ let af = agg[datasetid];
1610
+ let sf = pf[datasetid];
1611
+ if (sf && sf.length == af.length) {
1612
+ let n = af.length;
1613
+ for (let i = 1; i < n; i++)
1614
+ af[i] += sf[i];
1615
+ af[0]++; // count of aggregates
1616
+ }
1617
+ });
1571
1618
  return agg;
1572
1619
  }
1573
1620
  exports.aggregatePackedFields = aggregatePackedFields;
1621
+ function aggregateCount(agg) {
1622
+ if (!agg || !agg[''])
1623
+ return 0;
1624
+ return agg[''][0];
1625
+ }
1626
+ exports.aggregateCount = aggregateCount;
1627
+ function decrementPackedFields(agg, pf) {
1628
+ if (agg == null || pf == null)
1629
+ return agg;
1630
+ Object.keys(agg).forEach(datasetid => {
1631
+ let af = agg[datasetid];
1632
+ let sf = pf[datasetid];
1633
+ if (sf && sf.length == af.length) {
1634
+ let n = af.length;
1635
+ for (let i = 1; i < n; i++)
1636
+ af[i] -= sf[i];
1637
+ af[0]++; // count of aggregates
1638
+ }
1639
+ });
1640
+ return agg;
1641
+ }
1642
+ exports.decrementPackedFields = decrementPackedFields;
1574
1643
  function diffPackedFields(main, parts) {
1575
1644
  main = packedCopy(retrievePackedFields(main));
1576
1645
  if (main == null || parts == null || parts.length == 0)
1577
1646
  return null;
1578
1647
  parts = parts.map(retrievePackedFields);
1579
- parts.forEach((pf) => {
1580
- for (let i = 0; i < main.length; i++)
1581
- main[i] -= pf[i];
1582
- });
1648
+ parts.forEach((pf) => decrementPackedFields(main, pf));
1583
1649
  return main;
1584
1650
  }
1585
1651
  exports.diffPackedFields = diffPackedFields;
1586
- function getPackedField(index, pf, dataset, field) {
1587
- if (index == null || pf == null)
1652
+ function getPackedField(index, pf, datasetid, dataset, field) {
1653
+ if (!index || !pf || !index[datasetid] || !pf[datasetid])
1588
1654
  return 0;
1589
- let fields = index.fields[dataset];
1590
- return fields ? (fields[field] !== undefined ? pf[fields[field]] : 0) : 0;
1655
+ let fields = index[datasetid].fields[dataset];
1656
+ return fields ? (fields[field] !== undefined ? pf[datasetid][fields[field]] : 0) : 0;
1591
1657
  }
1592
1658
  exports.getPackedField = getPackedField;
1593
- function findPackedField(index, pf, dataset, field) {
1594
- let fields = index.fields[dataset];
1659
+ function findPackedField(index, pf, datasetid, dataset, field) {
1660
+ let fields = index[datasetid].fields[dataset];
1595
1661
  return fields ? (fields[field] !== undefined ? fields[field] : -1) : -1;
1596
1662
  }
1597
1663
  exports.findPackedField = findPackedField;
1598
- function ToGetter(agg, dc, datasetKey) {
1599
- return (field) => { return getPackedField(dc.dsIndex, agg, datasetKey, field); };
1664
+ function fieldGetterNotLoaded(f) { return undefined; }
1665
+ exports.fieldGetterNotLoaded = fieldGetterNotLoaded;
1666
+ function ToGetter(agg, dc, datasetid, datasetKey) {
1667
+ return (field) => { return getPackedField(dc.dsIndex, agg, datasetid, datasetKey, field); };
1600
1668
  }
1601
1669
  exports.ToGetter = ToGetter;
1602
1670
  function ToGetterPvi16(agg, dc, datasetKey) {
1603
1671
  return (field) => {
1604
1672
  if (field === 'R')
1605
- return Math.round((getPackedField(dc.dsIndex, agg, datasetKey, 'R12') + getPackedField(dc.dsIndex, agg, datasetKey, 'R16')) / 2);
1673
+ return Math.round((getPackedField(dc.dsIndex, agg, '', datasetKey, 'R12') + getPackedField(dc.dsIndex, agg, '', datasetKey, 'R16')) / 2);
1606
1674
  if (field === 'D')
1607
- return Math.round((getPackedField(dc.dsIndex, agg, datasetKey, 'D12') + getPackedField(dc.dsIndex, agg, datasetKey, 'D16')) / 2);
1675
+ return Math.round((getPackedField(dc.dsIndex, agg, '', datasetKey, 'D12') + getPackedField(dc.dsIndex, agg, '', datasetKey, 'D16')) / 2);
1608
1676
  if (field === 'Tot')
1609
- return Math.round((getPackedField(dc.dsIndex, agg, datasetKey, 'R12') + getPackedField(dc.dsIndex, agg, datasetKey, 'R16') +
1610
- getPackedField(dc.dsIndex, agg, datasetKey, 'D12') + getPackedField(dc.dsIndex, agg, datasetKey, 'D16')) / 2);
1677
+ return Math.round((getPackedField(dc.dsIndex, agg, '', datasetKey, 'R12') + getPackedField(dc.dsIndex, agg, '', datasetKey, 'R16') +
1678
+ getPackedField(dc.dsIndex, agg, '', datasetKey, 'D12') + getPackedField(dc.dsIndex, agg, '', datasetKey, 'D16')) / 2);
1611
1679
  return 0;
1612
1680
  };
1613
1681
  }
@@ -1615,12 +1683,12 @@ exports.ToGetterPvi16 = ToGetterPvi16;
1615
1683
  function ToGetterPvi20(agg, dc) {
1616
1684
  return (field) => {
1617
1685
  if (field === 'R')
1618
- return Math.round((getPackedField(dc.dsIndex, agg, exports.DS_PRES2016, 'R') + getPackedField(dc.dsIndex, agg, exports.DS_PRES2020, 'R')) / 2);
1686
+ return Math.round((getPackedField(dc.dsIndex, agg, '', exports.DS_PRES2016, 'R') + getPackedField(dc.dsIndex, agg, '', exports.DS_PRES2020, 'R')) / 2);
1619
1687
  if (field === 'D')
1620
- return Math.round((getPackedField(dc.dsIndex, agg, exports.DS_PRES2016, 'D') + getPackedField(dc.dsIndex, agg, exports.DS_PRES2020, 'D')) / 2);
1688
+ return Math.round((getPackedField(dc.dsIndex, agg, '', exports.DS_PRES2016, 'D') + getPackedField(dc.dsIndex, agg, '', exports.DS_PRES2020, 'D')) / 2);
1621
1689
  if (field === 'Tot')
1622
- return Math.round((getPackedField(dc.dsIndex, agg, exports.DS_PRES2016, 'R') + getPackedField(dc.dsIndex, agg, exports.DS_PRES2020, 'R') +
1623
- getPackedField(dc.dsIndex, agg, exports.DS_PRES2016, 'D') + getPackedField(dc.dsIndex, agg, exports.DS_PRES2020, 'D')) / 2);
1690
+ return Math.round((getPackedField(dc.dsIndex, agg, '', exports.DS_PRES2016, 'R') + getPackedField(dc.dsIndex, agg, '', exports.DS_PRES2020, 'R') +
1691
+ getPackedField(dc.dsIndex, agg, '', exports.DS_PRES2016, 'D') + getPackedField(dc.dsIndex, agg, '', exports.DS_PRES2020, 'D')) / 2);
1624
1692
  return 0;
1625
1693
  };
1626
1694
  }
@@ -1630,12 +1698,12 @@ function calcShift(agg, dc, datasetOld, datasetNew) {
1630
1698
  ToGetterPvi16(agg, dc, datasetOld) :
1631
1699
  datasetOld === exports.DS_PVI2020 ?
1632
1700
  ToGetterPvi20(agg, dc) :
1633
- ToGetter(agg, dc, datasetOld);
1701
+ ToGetter(agg, dc, '', datasetOld);
1634
1702
  const getterNew = datasetNew === exports.DS_PVI2016 ?
1635
1703
  ToGetterPvi16(agg, dc, datasetNew) :
1636
1704
  datasetNew === exports.DS_PVI2020 ?
1637
1705
  ToGetterPvi20(agg, dc) :
1638
- ToGetter(agg, dc, datasetNew);
1706
+ ToGetter(agg, dc, '', datasetNew);
1639
1707
  // Calc two-party Swing
1640
1708
  const repOld = getterOld('R');
1641
1709
  const demOld = getterOld('D');