@carto/api-client 0.5.19 → 0.5.20

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.19",
11
+ "version": "0.5.20",
12
12
  "license": "MIT",
13
13
  "publishConfig": {
14
14
  "access": "public"
@@ -240,9 +240,19 @@ function domainFromAttribute(
240
240
  }
241
241
 
242
242
  if (scaleType === 'quantile' && attribute.quantiles) {
243
- return 'global' in attribute.quantiles
244
- ? attribute.quantiles.global[scaleLength]
245
- : attribute.quantiles[scaleLength];
243
+ const quantiles: Record<number, number[]> =
244
+ 'global' in attribute.quantiles
245
+ ? attribute.quantiles.global
246
+ : attribute.quantiles;
247
+
248
+ // Stats API doesn't provide quantile[2] - which would be effecively [min, median, max]
249
+ // so let's derive median from Quartiles (quantile[4]), of which second is median
250
+ if (scaleLength === 2 && !quantiles[2] && quantiles[4]?.length === 5) {
251
+ return [quantiles[4][0], quantiles[4][2], quantiles[4][4]];
252
+ }
253
+ if (quantiles[scaleLength]) {
254
+ return quantiles[scaleLength];
255
+ }
246
256
  }
247
257
 
248
258
  let {min} = attribute;