@dra2020/baseclient 1.0.68 → 1.0.69
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/baseclient.js +10 -25
- package/dist/baseclient.js.map +1 -1
- package/dist/colors/colors.d.ts +1 -1
- package/lib/colors/colors.ts +11 -27
- package/package.json +1 -1
package/dist/colors/colors.d.ts
CHANGED
|
@@ -6,6 +6,6 @@ export declare const EthnicFewClassicColors: string[];
|
|
|
6
6
|
export declare const PartisanPrecinctClassicColors: string[];
|
|
7
7
|
export declare function genColor(i: number, useFirstColor: boolean, palette: string): string;
|
|
8
8
|
export declare function getPalette(palette: string): string[];
|
|
9
|
-
export declare const defaultDistrictsPalette = "
|
|
9
|
+
export declare const defaultDistrictsPalette = "jet_r";
|
|
10
10
|
export declare function genDRAColor(i: number, useFirstColor: boolean): string;
|
|
11
11
|
export {};
|
package/lib/colors/colors.ts
CHANGED
|
@@ -270,29 +270,16 @@ export function genColor(i: number, useFirstColor: boolean, palette: string): st
|
|
|
270
270
|
|
|
271
271
|
export function getPalette(palette: string): string[]
|
|
272
272
|
{
|
|
273
|
-
|
|
274
|
-
switch (palette)
|
|
273
|
+
if (palette === 'draclassic')
|
|
275
274
|
{
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
case 'inferno':
|
|
282
|
-
case 'turbo':
|
|
283
|
-
case 'demographicsclassic':
|
|
284
|
-
case 'partisanclassic':
|
|
285
|
-
case 'allgroupsclassic':
|
|
286
|
-
return getColorTable(palette, true);
|
|
287
|
-
case 'greys':
|
|
288
|
-
return getColorTable(palette, false);
|
|
289
|
-
|
|
290
|
-
default:
|
|
291
|
-
// return draclassic palette with only 30 colors
|
|
292
|
-
for (let i = 1; i < 30; i++)
|
|
293
|
-
colors.push(genDRAColor(i, true));
|
|
294
|
-
return colors;
|
|
275
|
+
// return draclassic palette with only 30 colors
|
|
276
|
+
let colors: string[] = [];
|
|
277
|
+
for (let i = 1; i < 30; i++)
|
|
278
|
+
colors.push(genDRAColor(i, true));
|
|
279
|
+
return colors;
|
|
295
280
|
}
|
|
281
|
+
|
|
282
|
+
return getColorTable(palette);
|
|
296
283
|
}
|
|
297
284
|
|
|
298
285
|
const DistrictsColorOrder: number[] =
|
|
@@ -313,7 +300,7 @@ function orderedColors(palette: string): string[]
|
|
|
313
300
|
return OrderedColorTable[palette];
|
|
314
301
|
}
|
|
315
302
|
|
|
316
|
-
export const defaultDistrictsPalette = '
|
|
303
|
+
export const defaultDistrictsPalette = 'jet_r';
|
|
317
304
|
|
|
318
305
|
// DRA classic color palette
|
|
319
306
|
export function genDRAColor(i: number, useFirstColor: boolean): string
|
|
@@ -339,7 +326,7 @@ export function genDRAColor(i: number, useFirstColor: boolean): string
|
|
|
339
326
|
}
|
|
340
327
|
|
|
341
328
|
// Generate table for palette
|
|
342
|
-
function getColorTable(palette: string
|
|
329
|
+
function getColorTable(palette: string): string[]
|
|
343
330
|
{
|
|
344
331
|
if (palette === 'demographicsclassic')
|
|
345
332
|
{
|
|
@@ -362,9 +349,6 @@ function getColorTable(palette: string, reverse: boolean): string[]
|
|
|
362
349
|
return ColorTable[palette];
|
|
363
350
|
}
|
|
364
351
|
|
|
365
|
-
if (reverse && !palette.endsWith('_r'))
|
|
366
|
-
palette = palette + '_r';
|
|
367
|
-
|
|
368
352
|
if (allPaletteNames.includes(palette))
|
|
369
353
|
{
|
|
370
354
|
if (!ColorTable[palette])
|
|
@@ -386,7 +370,7 @@ function jscolormap(name: string, shades: number): string[]
|
|
|
386
370
|
let result: string[] = [];
|
|
387
371
|
for (let i = 0; i < shades; i++)
|
|
388
372
|
{
|
|
389
|
-
const rgb: number[] = partial(name)((i + 0.5) / shades);
|
|
373
|
+
const rgb: number[] = partial(name)((i + 0.5) / shades);
|
|
390
374
|
result.push(toHexColor(rgb[0], rgb[1], rgb[2]));
|
|
391
375
|
}
|
|
392
376
|
return result;
|