@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/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
@@ -9932,27 +9932,30 @@ function calculateLayerScale(name, scaleType, range, data) {
9932
9932
  let scaleDomain;
9933
9933
  let scaleColor = [];
9934
9934
  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) {
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));
9940
+ scaleDomain.push(value);
9950
9941
  scaleColor.push(color2);
9951
9942
  });
9943
+ domain = scaleDomain;
9944
+ } else {
9945
+ if (scaleType === "custom" && range.uiCustomScaleType === "logarithmic") {
9946
+ domain = calculateDomain(data, name, scaleType, colors.length);
9947
+ const [min2, max2] = domain;
9948
+ scaleDomain = getLog10ScaleSteps({
9949
+ min: min2,
9950
+ max: max2,
9951
+ steps: colors.length
9952
+ });
9953
+ scaleColor = colors;
9954
+ } else {
9955
+ domain = calculateDomain(data, name, scaleType, colors.length);
9956
+ scaleColor = colors;
9957
+ }
9952
9958
  }
9953
- } else if (scaleType !== "identity") {
9954
- domain = calculateDomain(data, name, scaleType, colors.length);
9955
- scaleColor = colors;
9956
9959
  if (scaleType === "ordinal") {
9957
9960
  domain = domain.slice(0, scaleColor.length);
9958
9961
  }