@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.
@@ -349,27 +349,14 @@ function genColor(i, useFirstColor, palette) {
349
349
  }
350
350
  exports.genColor = genColor;
351
351
  function getPalette(palette) {
352
- let colors = [];
353
- switch (palette) {
354
- case 'jet':
355
- case 'viridis':
356
- case 'magma':
357
- case 'plasma':
358
- case 'bone':
359
- case 'inferno':
360
- case 'turbo':
361
- case 'demographicsclassic':
362
- case 'partisanclassic':
363
- case 'allgroupsclassic':
364
- return getColorTable(palette, true);
365
- case 'greys':
366
- return getColorTable(palette, false);
367
- default:
368
- // return draclassic palette with only 30 colors
369
- for (let i = 1; i < 30; i++)
370
- colors.push(genDRAColor(i, true));
371
- return colors;
352
+ if (palette === 'draclassic') {
353
+ // return draclassic palette with only 30 colors
354
+ let colors = [];
355
+ for (let i = 1; i < 30; i++)
356
+ colors.push(genDRAColor(i, true));
357
+ return colors;
372
358
  }
359
+ return getColorTable(palette);
373
360
  }
374
361
  exports.getPalette = getPalette;
375
362
  const DistrictsColorOrder = [0, 49, 24, 36, 12, 42, 6, 30, 18, 45, 3, 27, 9, 33, 15, 46, 21, 39, 4, 28, 10, 34, 16, 48, 22, 40, 5, 29, 11, 35, 17, 1, 23, 41,
@@ -384,7 +371,7 @@ function orderedColors(palette) {
384
371
  }
385
372
  return OrderedColorTable[palette];
386
373
  }
387
- exports.defaultDistrictsPalette = 'jet';
374
+ exports.defaultDistrictsPalette = 'jet_r';
388
375
  // DRA classic color palette
389
376
  function genDRAColor(i, useFirstColor) {
390
377
  // i is district number, 0 => District[0] (unassigned), so subtract 1 to access ColorTable
@@ -404,7 +391,7 @@ function genDRAColor(i, useFirstColor) {
404
391
  }
405
392
  exports.genDRAColor = genDRAColor;
406
393
  // Generate table for palette
407
- function getColorTable(palette, reverse) {
394
+ function getColorTable(palette) {
408
395
  if (palette === 'demographicsclassic') {
409
396
  if (!ColorTable[palette]) {
410
397
  ColorTable[palette] = [];
@@ -421,8 +408,6 @@ function getColorTable(palette, reverse) {
421
408
  }
422
409
  return ColorTable[palette];
423
410
  }
424
- if (reverse && !palette.endsWith('_r'))
425
- palette = palette + '_r';
426
411
  if (allPaletteNames.includes(palette)) {
427
412
  if (!ColorTable[palette])
428
413
  ColorTable[palette] = jscolormap(palette, MaxColors);
@@ -438,7 +423,7 @@ function toHexColor(r, g, b) {
438
423
  function jscolormap(name, shades) {
439
424
  let result = [];
440
425
  for (let i = 0; i < shades; i++) {
441
- const rgb = partial(name)((i + 0.5) / shades); //evaluate_cmap((i + 0.5) / shades, name, reverse);
426
+ const rgb = partial(name)((i + 0.5) / shades);
442
427
  result.push(toHexColor(rgb[0], rgb[1], rgb[2]));
443
428
  }
444
429
  return result;