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

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.
@@ -9587,40 +9587,37 @@ function getColorAccessor({ name, colorColumn }, scaleType, { aggregation, range
9587
9587
  };
9588
9588
  }
9589
9589
  function calculateLayerScale(name, scaleType, range, data) {
9590
- let domain = [];
9591
9590
  let scaleDomain;
9592
- let scaleColor = [];
9591
+ let scaleColors = [];
9593
9592
  const { colors } = range;
9594
- if (scaleType === "custom") {
9595
- domain = calculateDomain(data, name, scaleType, colors.length);
9596
- const [min2, max2] = domain;
9597
- if (range.uiCustomScaleType === "logarithmic") {
9598
- scaleDomain = getLog10ScaleSteps({
9599
- min: min2,
9600
- max: max2,
9601
- steps: colors.length
9602
- });
9603
- scaleColor = colors;
9604
- } else if (range.colorMap) {
9593
+ const domain = calculateDomain(data, name, scaleType, colors.length);
9594
+ if (scaleType !== "identity") {
9595
+ if (range.colorMap) {
9605
9596
  const { colorMap } = range;
9606
9597
  scaleDomain = [];
9607
9598
  colorMap.forEach(([value, color2]) => {
9608
- scaleDomain.push(Number(value));
9609
- scaleColor.push(color2);
9599
+ scaleDomain.push(value);
9600
+ scaleColors.push(color2);
9610
9601
  });
9611
- }
9612
- } else if (scaleType !== "identity") {
9613
- domain = calculateDomain(data, name, scaleType, colors.length);
9614
- scaleColor = colors;
9615
- if (scaleType === "ordinal") {
9616
- domain = domain.slice(0, scaleColor.length);
9602
+ } else {
9603
+ if (scaleType === "custom" && range.uiCustomScaleType === "logarithmic") {
9604
+ const [min2, max2] = domain;
9605
+ scaleDomain = getLog10ScaleSteps({
9606
+ min: min2,
9607
+ max: max2,
9608
+ steps: colors.length
9609
+ });
9610
+ scaleColors = colors;
9611
+ } else {
9612
+ scaleColors = colors;
9613
+ }
9617
9614
  }
9618
9615
  }
9619
9616
  return {
9620
9617
  scale: createColorScale(
9621
9618
  scaleType,
9622
9619
  scaleDomain || domain,
9623
- scaleColor.map(hexToRGB),
9620
+ scaleColors.map(hexToRGB),
9624
9621
  UNKNOWN_COLOR_RGB
9625
9622
  ),
9626
9623
  domain