@carto/api-client 0.5.18-alpha.colormapfix-1 → 0.5.18

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/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "homepage": "https://github.com/CartoDB/carto-api-client#readme",
9
9
  "author": "Don McCurdy <donmccurdy@carto.com>",
10
10
  "packageManager": "yarn@4.3.1",
11
- "version": "0.5.18-alpha.colormapfix-1",
11
+ "version": "0.5.18",
12
12
  "license": "MIT",
13
13
  "publishConfig": {
14
14
  "access": "public"
@@ -132,6 +132,5 @@
132
132
  "resolutions": {
133
133
  "@carto/api-client": "portal:./",
134
134
  "rollup": "^4.20.0"
135
- },
136
- "stableVersion": "0.5.17"
135
+ }
137
136
  }
@@ -374,23 +374,21 @@ export function calculateLayerScale(
374
374
  range: ColorRange,
375
375
  data: TilejsonResult
376
376
  ): {scale: D3Scale; domain: string[] | number[]} {
377
- let domain: string[] | number[] = [];
378
377
  let scaleDomain: number[] | string[] | undefined;
379
- let scaleColor: string[] = [];
378
+ let scaleColors: string[] = [];
380
379
  const {colors} = range;
381
380
 
381
+ const domain = calculateDomain(data, name, scaleType, colors.length);
382
382
  if (scaleType !== 'identity') {
383
383
  if (range.colorMap) {
384
384
  const {colorMap} = range;
385
385
  scaleDomain = [];
386
386
  colorMap.forEach(([value, color]) => {
387
387
  (scaleDomain as any[]).push(value);
388
- scaleColor.push(color);
388
+ scaleColors.push(color);
389
389
  });
390
- domain = scaleDomain;
391
390
  } else {
392
391
  if (scaleType === 'custom' && range.uiCustomScaleType === 'logarithmic') {
393
- domain = calculateDomain(data, name, scaleType, colors.length);
394
392
  const [min, max] = domain as number[];
395
393
  scaleDomain = getLog10ScaleSteps({
396
394
  min,
@@ -398,22 +396,17 @@ export function calculateLayerScale(
398
396
  steps: colors.length,
399
397
  });
400
398
 
401
- scaleColor = colors;
399
+ scaleColors = colors;
402
400
  } else {
403
- domain = calculateDomain(data, name, scaleType, colors.length);
404
- scaleColor = colors;
401
+ scaleColors = colors;
405
402
  }
406
403
  }
407
-
408
- if (scaleType === 'ordinal') {
409
- domain = domain.slice(0, scaleColor.length);
410
- }
411
404
  }
412
405
  return {
413
406
  scale: createColorScale(
414
407
  scaleType,
415
408
  scaleDomain || domain,
416
- scaleColor.map(hexToRGB),
409
+ scaleColors.map(hexToRGB),
417
410
  UNKNOWN_COLOR_RGB
418
411
  ),
419
412
  domain,