@carto/kepler.gl 0.0.72 → 0.0.73
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 +2 -0
- package/dist/components/side-panel/layer-panel/layer-configurator.js +59 -22
- package/dist/constants/default-settings.js +1 -1
- package/dist/layers/base-layer.js +4 -2
- package/package.json +1 -1
- package/src/components/side-panel/layer-panel/layer-configurator.js +82 -46
- package/src/layers/base-layer.js +1 -1
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@carto/kepler.gl",
|
|
3
3
|
"author": "CARTO",
|
|
4
4
|
"homepage": "https://github.com/CartoDB/carto-kepler#readme",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.73",
|
|
6
6
|
"description": "kepler.gl is a webgl based application to visualize large scale location data in the browser",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"main": "dist/index.js",
|
|
@@ -1123,7 +1123,30 @@ export function ArcLayerColorSelectorFactory(ColorSelector) {
|
|
|
1123
1123
|
LayerColorRangeSelectorFactory.deps = [ColorSelectorFactory];
|
|
1124
1124
|
export function LayerColorRangeSelectorFactory(ColorSelector) {
|
|
1125
1125
|
class LayerColorRangeSelector extends Component {
|
|
1126
|
-
|
|
1126
|
+
__renderHeatmapColorSelectorComponent() {
|
|
1127
|
+
const property = 'colorRange';
|
|
1128
|
+
const {layer, onChange, setColorUI} = this.props;
|
|
1129
|
+
return (
|
|
1130
|
+
<ColorSelector
|
|
1131
|
+
colorSets={[
|
|
1132
|
+
{
|
|
1133
|
+
selectedColor: layer.config.visConfig[property],
|
|
1134
|
+
isRange: true,
|
|
1135
|
+
setColor: colorRange => {
|
|
1136
|
+
const {colorMap} = layer.config.visConfig[property];
|
|
1137
|
+
const colorRangeUpdated = colorMap
|
|
1138
|
+
? layer.updateColorMap(property, colorMap, colorRange)
|
|
1139
|
+
: colorRange;
|
|
1140
|
+
onChange({[property]: colorRangeUpdated});
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
]}
|
|
1144
|
+
colorUI={layer.config.colorUI[property]}
|
|
1145
|
+
setColorUI={newConfig => setColorUI(property, newConfig)}
|
|
1146
|
+
/>
|
|
1147
|
+
);
|
|
1148
|
+
}
|
|
1149
|
+
__renderDefaultColorSelectorComponent() {
|
|
1127
1150
|
const {
|
|
1128
1151
|
layer,
|
|
1129
1152
|
onChange,
|
|
@@ -1133,56 +1156,69 @@ export function LayerColorRangeSelectorFactory(ColorSelector) {
|
|
|
1133
1156
|
handleCustomOnSelectHexColumn = () => null
|
|
1134
1157
|
} = this.props;
|
|
1135
1158
|
const {range: property, field, scale} = layer.visualChannels[channel];
|
|
1159
|
+
return (
|
|
1160
|
+
<ColorSelector
|
|
1161
|
+
fields={fields}
|
|
1162
|
+
colorSets={[
|
|
1163
|
+
{
|
|
1164
|
+
selectedColor: layer.config.visConfig[property],
|
|
1165
|
+
isRange: true,
|
|
1166
|
+
setColor: colorRange => {
|
|
1167
|
+
const {colorMap} = layer.config.visConfig[property];
|
|
1168
|
+
const colorRangeUpdated = colorMap
|
|
1169
|
+
? layer.updateColorMap(property, colorMap, colorRange)
|
|
1170
|
+
: colorRange;
|
|
1171
|
+
// Ensure that scale changes from identity to ordinal
|
|
1172
|
+
// Validate scale to ensure that it changes from `identity` to the correct one.
|
|
1173
|
+
layer.updateLayerConfig({
|
|
1174
|
+
[field]: {
|
|
1175
|
+
...layer.config[field],
|
|
1176
|
+
colorColumn: null,
|
|
1177
|
+
colorColumnIdx: null
|
|
1178
|
+
},
|
|
1179
|
+
[scale]: SCALE_TYPES.ordinal
|
|
1180
|
+
});
|
|
1181
|
+
layer.validateScale(channel);
|
|
1182
|
+
// ---------------------------------------
|
|
1183
|
+
onChange({[property]: colorRangeUpdated});
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
]}
|
|
1187
|
+
colorUI={layer.config.colorUI[property]}
|
|
1188
|
+
setColorUI={newConfig => setColorUI(property, newConfig)}
|
|
1189
|
+
onSelectHexColorColumn={colorColumn => {
|
|
1190
|
+
// It's defined in CN: see workspace-www/src/features/builder/ui/KeplerGl/SidePanel/LayerPanel/LayerColorRangeSelector.tsx
|
|
1191
|
+
handleCustomOnSelectHexColumn(layer, colorColumn);
|
|
1192
|
+
|
|
1193
|
+
layer.updateLayerConfig({
|
|
1194
|
+
[field]: {
|
|
1195
|
+
...layer.config[field],
|
|
1196
|
+
colorColumn: colorColumn?.name,
|
|
1197
|
+
colorColumnIdx: colorColumn?.fieldIdx
|
|
1198
|
+
},
|
|
1199
|
+
[scale]: SCALE_TYPES.identity
|
|
1200
|
+
});
|
|
1201
|
+
|
|
1202
|
+
onChange({[property]: hexColorCustomPalette});
|
|
1203
|
+
}}
|
|
1204
|
+
/>
|
|
1205
|
+
);
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
render() {
|
|
1209
|
+
const {layer} = this.props;
|
|
1210
|
+
let renderColorSelectorComponent = this.__renderDefaultColorSelectorComponent.bind(this);
|
|
1211
|
+
|
|
1212
|
+
if (layer.type === LAYER_TYPES.heatmap) {
|
|
1213
|
+
renderColorSelectorComponent = this.__renderHeatmapColorSelectorComponent.bind(this);
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1136
1216
|
return (
|
|
1137
1217
|
<SidePanelSection>
|
|
1138
1218
|
<PanelLabel>
|
|
1139
1219
|
<FormattedMessage id="layer.colorRange" />
|
|
1140
1220
|
</PanelLabel>
|
|
1141
|
-
|
|
1142
|
-
fields={fields}
|
|
1143
|
-
colorSets={[
|
|
1144
|
-
{
|
|
1145
|
-
selectedColor: layer.config.visConfig[property],
|
|
1146
|
-
isRange: true,
|
|
1147
|
-
setColor: colorRange => {
|
|
1148
|
-
const {colorMap} = layer.config.visConfig[property];
|
|
1149
|
-
const colorRangeUpdated = colorMap
|
|
1150
|
-
? layer.updateColorMap(property, colorMap, colorRange)
|
|
1151
|
-
: colorRange;
|
|
1152
|
-
// Ensure that scale changes from identity to ordinal
|
|
1153
|
-
// Validate scale to ensure that it changes from `identity` to the correct one.
|
|
1154
|
-
layer.updateLayerConfig({
|
|
1155
|
-
[field]: {
|
|
1156
|
-
...layer.config[field],
|
|
1157
|
-
colorColumn: null,
|
|
1158
|
-
colorColumnIdx: null
|
|
1159
|
-
},
|
|
1160
|
-
[scale]: SCALE_TYPES.ordinal
|
|
1161
|
-
});
|
|
1162
|
-
layer.validateScale(channel);
|
|
1163
|
-
// ---------------------------------------
|
|
1164
|
-
onChange({[property]: colorRangeUpdated});
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
1167
|
-
]}
|
|
1168
|
-
colorUI={layer.config.colorUI[property]}
|
|
1169
|
-
setColorUI={newConfig => setColorUI(property, newConfig)}
|
|
1170
|
-
onSelectHexColorColumn={colorColumn => {
|
|
1171
|
-
// It's defined in CN: see workspace-www/src/features/builder/ui/KeplerGl/SidePanel/LayerPanel/LayerColorRangeSelector.tsx
|
|
1172
|
-
handleCustomOnSelectHexColumn(layer, colorColumn);
|
|
1173
|
-
|
|
1174
|
-
layer.updateLayerConfig({
|
|
1175
|
-
[field]: {
|
|
1176
|
-
...layer.config[field],
|
|
1177
|
-
colorColumn: colorColumn?.name,
|
|
1178
|
-
colorColumnIdx: colorColumn?.fieldIdx
|
|
1179
|
-
},
|
|
1180
|
-
[scale]: SCALE_TYPES.identity
|
|
1181
|
-
});
|
|
1182
|
-
|
|
1183
|
-
onChange({[property]: hexColorCustomPalette});
|
|
1184
|
-
}}
|
|
1185
|
-
/>
|
|
1221
|
+
{renderColorSelectorComponent()}
|
|
1186
1222
|
</SidePanelSection>
|
|
1187
1223
|
);
|
|
1188
1224
|
}
|
package/src/layers/base-layer.js
CHANGED
|
@@ -1119,7 +1119,7 @@ class Layer {
|
|
|
1119
1119
|
updateVisualChannelFields(dataset) {
|
|
1120
1120
|
for (const {field, range} of Object.values(this.visualChannels)) {
|
|
1121
1121
|
const oldField = this.config[field];
|
|
1122
|
-
const isUsingHexColorCode = this.config.visConfig[range]
|
|
1122
|
+
const isUsingHexColorCode = this.config.visConfig[range]?.hexColor;
|
|
1123
1123
|
if (!oldField) {
|
|
1124
1124
|
return;
|
|
1125
1125
|
}
|