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

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.17",
11
+ "version": "0.5.18-alpha.colormapfix-1",
12
12
  "license": "MIT",
13
13
  "publishConfig": {
14
14
  "access": "public"
@@ -132,5 +132,6 @@
132
132
  "resolutions": {
133
133
  "@carto/api-client": "portal:./",
134
134
  "rollup": "^4.20.0"
135
- }
135
+ },
136
+ "stableVersion": "0.5.17"
136
137
  }
@@ -375,38 +375,40 @@ export function calculateLayerScale(
375
375
  data: TilejsonResult
376
376
  ): {scale: D3Scale; domain: string[] | number[]} {
377
377
  let domain: string[] | number[] = [];
378
- let scaleDomain: number[] | undefined;
378
+ let scaleDomain: number[] | string[] | undefined;
379
379
  let scaleColor: string[] = [];
380
380
  const {colors} = range;
381
381
 
382
- if (scaleType === 'custom') {
383
- domain = calculateDomain(data, name, scaleType, colors.length);
384
- const [min, max] = domain as number[];
385
- if (range.uiCustomScaleType === 'logarithmic') {
386
- scaleDomain = getLog10ScaleSteps({
387
- min,
388
- max,
389
- steps: colors.length,
390
- });
391
-
392
- scaleColor = colors;
393
- } else if (range.colorMap) {
382
+ if (scaleType !== 'identity') {
383
+ if (range.colorMap) {
394
384
  const {colorMap} = range;
395
385
  scaleDomain = [];
396
386
  colorMap.forEach(([value, color]) => {
397
- (scaleDomain as number[]).push(Number(value));
387
+ (scaleDomain as any[]).push(value);
398
388
  scaleColor.push(color);
399
389
  });
390
+ domain = scaleDomain;
391
+ } else {
392
+ if (scaleType === 'custom' && range.uiCustomScaleType === 'logarithmic') {
393
+ domain = calculateDomain(data, name, scaleType, colors.length);
394
+ const [min, max] = domain as number[];
395
+ scaleDomain = getLog10ScaleSteps({
396
+ min,
397
+ max,
398
+ steps: colors.length,
399
+ });
400
+
401
+ scaleColor = colors;
402
+ } else {
403
+ domain = calculateDomain(data, name, scaleType, colors.length);
404
+ scaleColor = colors;
405
+ }
400
406
  }
401
- } else if (scaleType !== 'identity') {
402
- domain = calculateDomain(data, name, scaleType, colors.length);
403
- scaleColor = colors;
404
407
 
405
408
  if (scaleType === 'ordinal') {
406
409
  domain = domain.slice(0, scaleColor.length);
407
410
  }
408
411
  }
409
-
410
412
  return {
411
413
  scale: createColorScale(
412
414
  scaleType,