@carto/api-client 0.5.21 → 0.5.22

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.
@@ -835,6 +835,7 @@ type VisualChannels = {
835
835
  heightField?: VisualChannelField;
836
836
  heightScale?: ScaleType;
837
837
  weightField?: VisualChannelField;
838
+ uniqueValuesColorScale?: ScaleType;
838
839
  };
839
840
  type ColorRange = {
840
841
  category: string;
@@ -1040,13 +1041,18 @@ declare function getRasterTileLayerStyleProps({ layerConfig, visualChannels, ras
1040
1041
  } | {
1041
1042
  dataTransform?: undefined;
1042
1043
  updateTriggers?: undefined;
1044
+ domain?: undefined;
1045
+ scaleDomain?: undefined;
1046
+ range?: undefined;
1047
+ type?: undefined;
1048
+ field?: undefined;
1043
1049
  };
1044
1050
 
1045
1051
  type Scale = {
1046
1052
  type: ScaleType;
1047
- field: VisualChannelField;
1053
+ field?: VisualChannelField;
1048
1054
  /** Natural domain of the scale, as defined by the data */
1049
- domain: string[] | number[];
1055
+ domain?: string[] | number[];
1050
1056
  /** Domain of the user to construct d3 scale */
1051
1057
  scaleDomain?: string[] | number[];
1052
1058
  range?: string[] | number[];
@@ -835,6 +835,7 @@ type VisualChannels = {
835
835
  heightField?: VisualChannelField;
836
836
  heightScale?: ScaleType;
837
837
  weightField?: VisualChannelField;
838
+ uniqueValuesColorScale?: ScaleType;
838
839
  };
839
840
  type ColorRange = {
840
841
  category: string;
@@ -1040,13 +1041,18 @@ declare function getRasterTileLayerStyleProps({ layerConfig, visualChannels, ras
1040
1041
  } | {
1041
1042
  dataTransform?: undefined;
1042
1043
  updateTriggers?: undefined;
1044
+ domain?: undefined;
1045
+ scaleDomain?: undefined;
1046
+ range?: undefined;
1047
+ type?: undefined;
1048
+ field?: undefined;
1043
1049
  };
1044
1050
 
1045
1051
  type Scale = {
1046
1052
  type: ScaleType;
1047
- field: VisualChannelField;
1053
+ field?: VisualChannelField;
1048
1054
  /** Natural domain of the scale, as defined by the data */
1049
- domain: string[] | number[];
1055
+ domain?: string[] | number[];
1050
1056
  /** Domain of the user to construct d3 scale */
1051
1057
  scaleDomain?: string[] | number[];
1052
1058
  range?: string[] | number[];
@@ -10028,19 +10028,8 @@ function domainFromRasterMetadataBand(band, scaleType, colorRange) {
10028
10028
  if (scaleType === "ordinal") {
10029
10029
  return colorRange.colorMap?.map(([value]) => value) || [];
10030
10030
  }
10031
- if (scaleType === "custom") {
10032
- if (colorRange.uiCustomScaleType === "logarithmic") {
10033
- return getLog10ScaleSteps({
10034
- min: band.stats.min,
10035
- max: band.stats.max,
10036
- steps: colorRange.colors.length
10037
- });
10038
- } else {
10039
- return colorRange.colorMap?.map(([value]) => value) || [];
10040
- }
10041
- }
10042
- const scaleLength = colorRange.colors.length;
10043
10031
  if (scaleType === "quantile") {
10032
+ const scaleLength = colorRange.colors.length;
10044
10033
  const quantiles = band.stats.quantiles?.[scaleLength];
10045
10034
  if (!quantiles) {
10046
10035
  return [0, 1];
@@ -10066,9 +10055,21 @@ function getRasterTileLayerStylePropsScaledBand({
10066
10055
  return {};
10067
10056
  }
10068
10057
  const domain = domainFromRasterMetadataBand(bandInfo, scaleType, colorRange);
10058
+ let scaleDomain = domain;
10059
+ if (scaleType === "custom") {
10060
+ if (colorRange.uiCustomScaleType === "logarithmic") {
10061
+ scaleDomain = getLog10ScaleSteps({
10062
+ min: bandInfo.stats.min,
10063
+ max: bandInfo.stats.max,
10064
+ steps: colorRange.colors.length
10065
+ });
10066
+ } else {
10067
+ scaleDomain = colorRange.colorMap?.map(([value]) => value) || [];
10068
+ }
10069
+ }
10069
10070
  const scaleFun = createColorScale(
10070
10071
  scaleType,
10071
- domain,
10072
+ scaleDomain,
10072
10073
  colorRange.colors.map(hexToRGB2),
10073
10074
  UNKNOWN_COLOR2
10074
10075
  );
@@ -10083,7 +10084,12 @@ function getRasterTileLayerStylePropsScaledBand({
10083
10084
  updateTriggers: getRasterTileLayerUpdateTriggers({
10084
10085
  layerConfig,
10085
10086
  visualChannels
10086
- })
10087
+ }),
10088
+ domain,
10089
+ scaleDomain: scaleFun.domain(),
10090
+ range: colorRange.colors,
10091
+ type: scaleType,
10092
+ field: colorField
10087
10093
  };
10088
10094
  }
10089
10095
  function getRasterTileLayerStyleProps({
@@ -10295,18 +10301,27 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
10295
10301
  rasterMetadata,
10296
10302
  visualChannels
10297
10303
  }),
10298
- scales: {}
10299
- // TODO
10304
+ scales: {
10305
+ fillColor: {
10306
+ type: "identity"
10307
+ }
10308
+ }
10300
10309
  };
10301
10310
  } else {
10311
+ const { dataTransform, updateTriggers: updateTriggers2, ...scaleProps } = getRasterTileLayerStylePropsScaledBand({
10312
+ layerConfig: config2,
10313
+ visualChannels,
10314
+ rasterMetadata
10315
+ });
10302
10316
  return {
10303
- channelProps: getRasterTileLayerStylePropsScaledBand({
10304
- layerConfig: config2,
10305
- visualChannels,
10306
- rasterMetadata
10307
- }),
10317
+ channelProps: {
10318
+ dataTransform,
10319
+ updateTriggers: updateTriggers2
10320
+ },
10308
10321
  scales: {
10309
- // TODO
10322
+ ...scaleProps.type && {
10323
+ fillColor: scaleProps
10324
+ }
10310
10325
  }
10311
10326
  };
10312
10327
  }