@dra2020/dra-types 1.8.115 → 1.8.116

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/lib/colormgr.ts CHANGED
@@ -215,7 +215,7 @@ function ToPartisanColor(agg: PF.PackedFields, dc: PF.DatasetContext, stops: Uti
215
215
  }
216
216
  }
217
217
 
218
- export function ToPartisanShiftColor(agg: PF.PackedFields, dc: PF.DatasetContext, datasets: string[], pd: PaletteDefaults): string
218
+ export function ToPartisanShiftColor(agg: PF.PackedFields, dc: PF.DatasetContext, datasets: string[], pd: PaletteDefaults, isDistrict?: boolean): string
219
219
  {
220
220
  if (!datasets || datasets.length < 2)
221
221
  return '';
@@ -223,11 +223,14 @@ export function ToPartisanShiftColor(agg: PF.PackedFields, dc: PF.DatasetContext
223
223
  const shift: number = PF.calcShift(agg, dc, datasets[0], datasets[1]);
224
224
  if (shift == null)
225
225
  return null;
226
+
227
+ const defaultIsDistrict = isDistrict ?? false; // make the optional isDistrict parameter to false by default
228
+
226
229
  const rep: number = 0.5 - (shift / 2);
227
230
  const dem: number = 0.5 + (shift / 2);
228
- const stops: Util.GradientStops = partisanStops(PartisanPrecinctStops, pd);
231
+ const stops: Util.GradientStops = partisanStops(defaultIsDistrict ? PartisanDistrictStops : PartisanPrecinctStops, pd);
229
232
  const color: string = ColorFromRGBPcts(rep, 0, dem, stops);
230
- //console.log('Shift (r, d, color): (' + rep + ', ' + dem + ', ' + color + ')');
233
+ // console.log('Shift (r, d, color): (' + rep + ', ' + dem + ', ' + color + ')');
231
234
  return color;
232
235
  }
233
236
 
@@ -529,6 +532,7 @@ export interface DistrictColorParams
529
532
  useFirstColor: boolean,
530
533
  usePalette: string,
531
534
  colorDistrictsBy: string,
535
+ shiftDatasets?: string[],
532
536
  }
533
537
 
534
538
  function safeNumber(n: any): number { n = Number(n); return typeof n !== 'number' || isNaN(n) ? 0 : n }
@@ -618,6 +622,16 @@ export function computeDistrictColors(params: DistrictColorParams): DistrictCach
618
622
  dc.colorEthnic = ToEthnicColorStr(agg, params.datasetContext, params.paletteDefaults, params.colorDistrictsBy);
619
623
  dc.colorSolid = dc.colorEthnic;
620
624
  break;
625
+ case 'elecshift':
626
+ if (params.shiftDatasets && params.shiftDatasets.length == 2)
627
+ {
628
+ dc.colorSolid = ToPartisanShiftColor(agg, params.datasetContext, params.shiftDatasets, params.paletteDefaults, true);
629
+ }
630
+ else
631
+ {
632
+ dc.colorSolid = mapColor;
633
+ }
634
+ break;
621
635
  default:
622
636
  if (isColorBy(params.colorDistrictsBy))
623
637
  {
package/lib/datasets.ts CHANGED
@@ -56,7 +56,6 @@ export interface DatasetFormat {
56
56
  shortCaption: string,
57
57
  longCaption: string,
58
58
  expr: string,
59
- numberFormat?: string, // (locale|integer|general|currency).precision
60
59
  };
61
60
  export type DatasetFormats = DatasetFormat[];
62
61
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dra2020/dra-types",
3
- "version": "1.8.115",
3
+ "version": "1.8.116",
4
4
  "description": "Shared types used between client, server and tools.",
5
5
  "main": "dist/dra-types.js",
6
6
  "types": "./dist/all.d.ts",