@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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ - fix(fetchMap): getColorAccessor treats colorMap as override of actual domain (#238)
6
+
5
7
  ## 0.5
6
8
 
7
9
  ### 0.5.17
@@ -9928,40 +9928,37 @@ function getColorAccessor({ name, colorColumn }, scaleType, { aggregation, range
9928
9928
  };
9929
9929
  }
9930
9930
  function calculateLayerScale(name, scaleType, range, data) {
9931
- let domain = [];
9932
9931
  let scaleDomain;
9933
- let scaleColor = [];
9932
+ let scaleColors = [];
9934
9933
  const { colors } = range;
9935
- if (scaleType === "custom") {
9936
- domain = calculateDomain(data, name, scaleType, colors.length);
9937
- const [min2, max2] = domain;
9938
- if (range.uiCustomScaleType === "logarithmic") {
9939
- scaleDomain = getLog10ScaleSteps({
9940
- min: min2,
9941
- max: max2,
9942
- steps: colors.length
9943
- });
9944
- scaleColor = colors;
9945
- } else if (range.colorMap) {
9934
+ const domain = calculateDomain(data, name, scaleType, colors.length);
9935
+ if (scaleType !== "identity") {
9936
+ if (range.colorMap) {
9946
9937
  const { colorMap } = range;
9947
9938
  scaleDomain = [];
9948
9939
  colorMap.forEach(([value, color2]) => {
9949
- scaleDomain.push(Number(value));
9950
- scaleColor.push(color2);
9940
+ scaleDomain.push(value);
9941
+ scaleColors.push(color2);
9951
9942
  });
9952
- }
9953
- } else if (scaleType !== "identity") {
9954
- domain = calculateDomain(data, name, scaleType, colors.length);
9955
- scaleColor = colors;
9956
- if (scaleType === "ordinal") {
9957
- domain = domain.slice(0, scaleColor.length);
9943
+ } else {
9944
+ if (scaleType === "custom" && range.uiCustomScaleType === "logarithmic") {
9945
+ const [min2, max2] = domain;
9946
+ scaleDomain = getLog10ScaleSteps({
9947
+ min: min2,
9948
+ max: max2,
9949
+ steps: colors.length
9950
+ });
9951
+ scaleColors = colors;
9952
+ } else {
9953
+ scaleColors = colors;
9954
+ }
9958
9955
  }
9959
9956
  }
9960
9957
  return {
9961
9958
  scale: createColorScale(
9962
9959
  scaleType,
9963
9960
  scaleDomain || domain,
9964
- scaleColor.map(hexToRGB),
9961
+ scaleColors.map(hexToRGB),
9965
9962
  UNKNOWN_COLOR_RGB
9966
9963
  ),
9967
9964
  domain