@dra2020/dra-types 1.8.102 → 1.8.104

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.
@@ -69,3 +69,33 @@ export interface DistrictColorParams {
69
69
  }
70
70
  export declare function ToExtendedColor(agg: PF.PackedFields, dc: PF.DatasetContext, colorBy: string): string;
71
71
  export declare function computeDistrictColors(params: DistrictColorParams): DistrictCache[];
72
+ export interface RGB {
73
+ r: number;
74
+ g: number;
75
+ b: number;
76
+ }
77
+ export declare const BinRed = 0;
78
+ export declare const BinOrangeRed = 1;
79
+ export declare const BinBrown = 2;
80
+ export declare const BinOrange = 3;
81
+ export declare const BinGold = 4;
82
+ export declare const BinYellow = 5;
83
+ export declare const BinGreenish = 6;
84
+ export declare const BinChartreuse = 7;
85
+ export declare const BinLime = 8;
86
+ export declare const BinMediumSpringGreen = 9;
87
+ export declare const BinCyan = 10;
88
+ export declare const BinLightBlue = 11;
89
+ export declare const BinBlue = 12;
90
+ export declare const BinBlueViolet = 13;
91
+ export declare const BinDarkViolet = 14;
92
+ export declare const BinMagenta = 15;
93
+ export declare const BinDeepPink = 16;
94
+ export declare const BinColorLookup: RGB[];
95
+ export declare const FieldCountToColors: {
96
+ [nfields: number]: number[];
97
+ };
98
+ export declare function colorindexToRGB(colorindex: number): RGB;
99
+ export declare const ColorFlags = "abcdefghijklmnopqrstuvwxyz";
100
+ export declare function colorflagToColorindex(nfields: number, colorflag: string): number;
101
+ export declare function colororderToColorindex(nfields: number, order: number): number;
package/dist/dra-types.js CHANGED
@@ -107,7 +107,8 @@ exports.BucketMap = {
107
107
 
108
108
 
109
109
  Object.defineProperty(exports, "__esModule", ({ value: true }));
110
- exports.computeDistrictColors = exports.ToExtendedColor = exports.allGroups16Colors = exports.colorsFromStopsPartisan = exports.colorsFromStops = exports.PaletteNames = exports.ColorFromRGBPcts = exports.AggregatePartisanColorStr = exports.AggregatePartisanColor = exports.AggregateEthnicColor = exports.ToEthnicColorStr = exports.ToPartisanShiftColor = exports.ToPartisanDistrictColor = exports.ToPartisanColorStr = exports.ToAllEthnicColor = exports.ethnicBackgroundColor = exports.makeStops = exports.DefaultPaletteDefaults = exports.EthnicFewStops = exports.PartisanPrecinctStops = exports.PartisanDistrictStops = exports.ColorByGreatD = exports.ColorByGoodD = exports.ColorByFairD = exports.ColorByEven = exports.ColorByFairR = exports.ColorByGoodR = exports.ColorByGreatR = exports.EthnicTextColor = exports.ColorByBlackAsian = exports.ColorByAsianHispanic = exports.ColorByAsianWhite = exports.ColorByHispanicBlack = exports.ColorByBlackWhite = exports.ColorByHispanicWhite = exports.ColorByMix = exports.ColorByMostlyNative = exports.ColorByMostlyAsian = exports.ColorByMostlyHispanic = exports.ColorByMostlyBlack = exports.ColorByMostlyWhite = exports.ColorBySolidAsian = exports.ColorBySolidHispanic = exports.ColorBySolidBlack = exports.ColorBySolidWhite = void 0;
110
+ exports.BinGold = exports.BinOrange = exports.BinBrown = exports.BinOrangeRed = exports.BinRed = exports.computeDistrictColors = exports.ToExtendedColor = exports.allGroups16Colors = exports.colorsFromStopsPartisan = exports.colorsFromStops = exports.PaletteNames = exports.ColorFromRGBPcts = exports.AggregatePartisanColorStr = exports.AggregatePartisanColor = exports.AggregateEthnicColor = exports.ToEthnicColorStr = exports.ToPartisanShiftColor = exports.ToPartisanDistrictColor = exports.ToPartisanColorStr = exports.ToAllEthnicColor = exports.ethnicBackgroundColor = exports.makeStops = exports.DefaultPaletteDefaults = exports.EthnicFewStops = exports.PartisanPrecinctStops = exports.PartisanDistrictStops = exports.ColorByGreatD = exports.ColorByGoodD = exports.ColorByFairD = exports.ColorByEven = exports.ColorByFairR = exports.ColorByGoodR = exports.ColorByGreatR = exports.EthnicTextColor = exports.ColorByBlackAsian = exports.ColorByAsianHispanic = exports.ColorByAsianWhite = exports.ColorByHispanicBlack = exports.ColorByBlackWhite = exports.ColorByHispanicWhite = exports.ColorByMix = exports.ColorByMostlyNative = exports.ColorByMostlyAsian = exports.ColorByMostlyHispanic = exports.ColorByMostlyBlack = exports.ColorByMostlyWhite = exports.ColorBySolidAsian = exports.ColorBySolidHispanic = exports.ColorBySolidBlack = exports.ColorBySolidWhite = void 0;
111
+ exports.colororderToColorindex = exports.colorflagToColorindex = exports.ColorFlags = exports.colorindexToRGB = exports.FieldCountToColors = exports.BinColorLookup = exports.BinDeepPink = exports.BinMagenta = exports.BinDarkViolet = exports.BinBlueViolet = exports.BinBlue = exports.BinLightBlue = exports.BinCyan = exports.BinMediumSpringGreen = exports.BinLime = exports.BinChartreuse = exports.BinGreenish = exports.BinYellow = void 0;
111
112
  // App libraries
112
113
  const PF = __webpack_require__(/*! ./packedfields */ "./lib/packedfields.ts");
113
114
  const datasets_1 = __webpack_require__(/*! ./datasets */ "./lib/datasets.ts");
@@ -642,6 +643,79 @@ function computeDistrictColors(params) {
642
643
  return dcNew;
643
644
  }
644
645
  exports.computeDistrictColors = computeDistrictColors;
646
+ ;
647
+ exports.BinRed = 0;
648
+ exports.BinOrangeRed = 1;
649
+ exports.BinBrown = 2;
650
+ exports.BinOrange = 3;
651
+ exports.BinGold = 4;
652
+ exports.BinYellow = 5;
653
+ exports.BinGreenish = 6;
654
+ exports.BinChartreuse = 7;
655
+ exports.BinLime = 8;
656
+ exports.BinMediumSpringGreen = 9;
657
+ exports.BinCyan = 10;
658
+ exports.BinLightBlue = 11;
659
+ exports.BinBlue = 12;
660
+ exports.BinBlueViolet = 13;
661
+ exports.BinDarkViolet = 14;
662
+ exports.BinMagenta = 15;
663
+ exports.BinDeepPink = 16;
664
+ exports.BinColorLookup = [
665
+ { r: 0xff, g: 0x00, b: 0x00 },
666
+ { r: 0xff, g: 0x45, b: 0x00 },
667
+ { r: 0x99, g: 0x66, b: 0x33 },
668
+ { r: 0xff, g: 0xaa, b: 0x00 },
669
+ { r: 0xff, g: 0xd7, b: 0x00 },
670
+ { r: 0xff, g: 0xd7, b: 0x00 },
671
+ { r: 0x9f, g: 0xd4, b: 0x00 },
672
+ { r: 0x7f, g: 0xff, b: 0x00 },
673
+ { r: 0x00, g: 0xff, b: 0x00 },
674
+ { r: 0x00, g: 0xfa, b: 0x9a },
675
+ { r: 0x00, g: 0xff, b: 0xff },
676
+ { r: 0x73, g: 0xb2, b: 0xff },
677
+ { r: 0x00, g: 0x00, b: 0xff },
678
+ { r: 0x8a, g: 0x2b, b: 0xe2 },
679
+ { r: 0x94, g: 0x00, b: 0xd3 },
680
+ { r: 0xff, g: 0x00, b: 0xff },
681
+ { r: 0xff, g: 0x14, b: 0x93 }, // 16 - deep pink
682
+ ];
683
+ // Map ordering to Bin* lookup values
684
+ const ColorOrderEthnic = 'wbaho'; // abcde
685
+ // Map number of fields to color selection
686
+ exports.FieldCountToColors = {
687
+ [1]: [exports.BinBrown],
688
+ [2]: [exports.BinRed, exports.BinBlue],
689
+ [3]: [exports.BinRed, exports.BinBlue, exports.BinBrown],
690
+ [4]: [exports.BinRed, exports.BinBlue, exports.BinBrown, exports.BinGreenish],
691
+ [5]: [exports.BinLightBlue, exports.BinGreenish, exports.BinRed, exports.BinOrange, exports.BinBrown],
692
+ [6]: [exports.BinRed, exports.BinBrown, exports.BinGold, exports.BinGreenish, exports.BinLightBlue, exports.BinBlueViolet],
693
+ [7]: [exports.BinRed, exports.BinBrown, exports.BinGold, exports.BinGreenish, exports.BinLightBlue, exports.BinBlueViolet, exports.BinMagenta],
694
+ [8]: [exports.BinRed, exports.BinBrown, exports.BinGold, exports.BinGreenish, exports.BinLightBlue, exports.BinBlueViolet, exports.BinMagenta, exports.BinDeepPink],
695
+ [9]: [exports.BinRed, exports.BinBrown, exports.BinGold, exports.BinGreenish, exports.BinLightBlue, exports.BinBlue, exports.BinBlueViolet, exports.BinMagenta, exports.BinDeepPink],
696
+ [10]: [exports.BinRed, exports.BinBrown, exports.BinGold, exports.BinGreenish, exports.BinCyan, exports.BinLightBlue, exports.BinBlue, exports.BinBlueViolet, exports.BinMagenta, exports.BinDeepPink],
697
+ [11]: [exports.BinRed, exports.BinBrown, exports.BinGold, exports.BinGreenish, exports.BinLime, exports.BinCyan, exports.BinLightBlue, exports.BinBlue, exports.BinBlueViolet, exports.BinMagenta, exports.BinDeepPink],
698
+ [12]: [exports.BinRed, exports.BinBrown, exports.BinOrange, exports.BinGold, exports.BinGreenish, exports.BinLime, exports.BinCyan, exports.BinLightBlue, exports.BinBlue, exports.BinBlueViolet, exports.BinMagenta, exports.BinDeepPink],
699
+ [13]: [exports.BinRed, exports.BinBrown, exports.BinOrange, exports.BinGold, exports.BinGreenish, exports.BinLime, exports.BinMediumSpringGreen, exports.BinCyan, exports.BinLightBlue, exports.BinBlue, exports.BinBlueViolet, exports.BinMagenta, exports.BinDeepPink],
700
+ [14]: [exports.BinRed, exports.BinOrangeRed, exports.BinBrown, exports.BinOrange, exports.BinGold, exports.BinGreenish, exports.BinLime, exports.BinMediumSpringGreen, exports.BinCyan, exports.BinLightBlue, exports.BinBlue, exports.BinBlueViolet, exports.BinMagenta, exports.BinDeepPink],
701
+ [15]: [exports.BinRed, exports.BinOrangeRed, exports.BinBrown, exports.BinOrange, exports.BinGold, exports.BinGreenish, exports.BinLime, exports.BinMediumSpringGreen, exports.BinCyan, exports.BinLightBlue, exports.BinBlue, exports.BinBlueViolet, exports.BinDarkViolet, exports.BinMagenta, exports.BinDeepPink],
702
+ [16]: [exports.BinRed, exports.BinOrangeRed, exports.BinBrown, exports.BinOrange, exports.BinGold, exports.BinYellow, exports.BinGreenish, exports.BinLime, exports.BinMediumSpringGreen, exports.BinCyan, exports.BinLightBlue, exports.BinBlue, exports.BinBlueViolet, exports.BinDarkViolet, exports.BinMagenta, exports.BinDeepPink],
703
+ };
704
+ const MaxFields = 16;
705
+ function colorindexToRGB(colorindex) {
706
+ return exports.BinColorLookup[colorindex] || exports.BinColorLookup[exports.BinBrown];
707
+ }
708
+ exports.colorindexToRGB = colorindexToRGB;
709
+ exports.ColorFlags = 'abcdefghijklmnopqrstuvwxyz';
710
+ function colorflagToColorindex(nfields, colorflag) {
711
+ let i = exports.ColorFlags.indexOf(colorflag);
712
+ return i >= 0 && nfields > 0 && nfields <= MaxFields ? exports.FieldCountToColors[nfields][i] : exports.BinBrown;
713
+ }
714
+ exports.colorflagToColorindex = colorflagToColorindex;
715
+ function colororderToColorindex(nfields, order) {
716
+ return order >= 0 && nfields > 0 && nfields <= MaxFields ? exports.FieldCountToColors[nfields][order] : exports.BinBrown;
717
+ }
718
+ exports.colororderToColorindex = colororderToColorindex;
645
719
 
646
720
 
647
721
  /***/ }),
@@ -1495,7 +1569,7 @@ function computeMetaIndex(datasetid, meta) {
1495
1569
  index.getDatasetField = (f, dataset, field) => {
1496
1570
  let pf = retrievePackedFields(f);
1497
1571
  let groupindex = retrievePackedIndex(f);
1498
- let datasetid = dataset.length > 20 ? dataset : ''; // hack - extended datasets use 26 char guids, built-in ones are short
1572
+ let datasetid = toDatasetID(dataset);
1499
1573
  return getPackedField(groupindex, pf, datasetid, dataset, field);
1500
1574
  };
1501
1575
  return index;
@@ -1750,16 +1824,18 @@ function ToGetterPvi20(agg, dc) {
1750
1824
  }
1751
1825
  exports.ToGetterPvi20 = ToGetterPvi20;
1752
1826
  function calcShift(agg, dc, datasetOld, datasetNew) {
1827
+ const didOld = toDatasetID(datasetOld);
1828
+ const didNew = toDatasetID(datasetNew);
1753
1829
  const getterOld = datasetOld === exports.DS_PVI2016 ?
1754
1830
  ToGetterPvi16(agg, dc, datasetOld) :
1755
1831
  datasetOld === exports.DS_PVI2020 ?
1756
1832
  ToGetterPvi20(agg, dc) :
1757
- ToGetter(agg, dc, '', datasetOld);
1833
+ ToGetter(agg, dc, didOld, datasetOld);
1758
1834
  const getterNew = datasetNew === exports.DS_PVI2016 ?
1759
1835
  ToGetterPvi16(agg, dc, datasetNew) :
1760
1836
  datasetNew === exports.DS_PVI2020 ?
1761
1837
  ToGetterPvi20(agg, dc) :
1762
- ToGetter(agg, dc, '', datasetNew);
1838
+ ToGetter(agg, dc, didNew, datasetNew);
1763
1839
  // Calc two-party Swing
1764
1840
  const repOld = getterOld('R');
1765
1841
  const demOld = getterOld('D');
@@ -2099,6 +2175,7 @@ exports.Schemas = {
2099
2175
  official: 'BOOL',
2100
2176
  state: 'S',
2101
2177
  datasource: 'S',
2178
+ groups: 'M',
2102
2179
  // meta: { dataset metadata structure },
2103
2180
  // dotmap: 'BOOL',
2104
2181
  },
@@ -2135,6 +2212,15 @@ exports.Schemas = {
2135
2212
  },
2136
2213
  KeySchema: { id: 'HASH', sid: 'RANGE' },
2137
2214
  },
2215
+ 'groupsdatasets': {
2216
+ FileOptions: { map: true },
2217
+ Schema: {
2218
+ id: 'S',
2219
+ sid: 'S',
2220
+ permission: 'N',
2221
+ },
2222
+ KeySchema: { id: 'HASH', sid: 'RANGE' },
2223
+ },
2138
2224
  'notifications': {
2139
2225
  FileOptions: { map: true },
2140
2226
  Schema: {