Skip to content

Commit 35715e0

Browse files
feedback
1 parent 64d0496 commit 35715e0

File tree

1 file changed

+11
-23
lines changed

1 file changed

+11
-23
lines changed

x-pack/legacy/plugins/maps/public/layers/styles/vector/properties/dynamic_color_property.js

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,12 @@ export class DynamicColorProperty extends DynamicStyleProperty {
109109
return null;
110110
}
111111

112-
return this._getMBDataDrivenColor({
113-
targetName: getComputedFieldName(this._styleName, this._options.field.name),
114-
});
112+
const targetName = getComputedFieldName(this._styleName, this._options.field.name);
113+
if (this.isCategorical()) {
114+
return this._getMbDataDrivenCategoricalColor({ targetName });
115+
} else {
116+
return this._getMbDataDrivenOrdinalColor({ targetName });
117+
}
115118
}
116119

117120
_getMbDataDrivenOrdinalColor({ targetName }) {
@@ -159,13 +162,11 @@ export class DynamicColorProperty extends DynamicStyleProperty {
159162
stops.push({
160163
stop: config.stop,
161164
color: config.color,
162-
isDefault: false,
163165
});
164166
}
165167
stops.push({
166168
stop: this._options.customColorPalette[0].stop,
167169
color: this._options.customColorPalette[0].color,
168-
isDefault: true,
169170
});
170171
return stops;
171172
}
@@ -186,7 +187,6 @@ export class DynamicColorProperty extends DynamicStyleProperty {
186187
const isDefault = i === maxLength - 1;
187188
stops.push({
188189
stop: isDefault ? '__DEFAULT__' : fieldMeta.categories[i].key,
189-
isDefault: isDefault,
190190
color: colors[i],
191191
});
192192
}
@@ -211,7 +211,7 @@ export class DynamicColorProperty extends DynamicStyleProperty {
211211
let defaultColor = null;
212212
for (let i = 0; i < paletteStops.length; i++) {
213213
const stop = paletteStops[i];
214-
if (stop.isDefault) {
214+
if (i === paletteStops.length - 1) {
215215
defaultColor = stop.color;
216216
} else {
217217
mbStops.push(stop.stop);
@@ -225,23 +225,11 @@ export class DynamicColorProperty extends DynamicStyleProperty {
225225
return ['match', ['get', this._options.field.name], ...mbStops];
226226
}
227227

228-
_getMBDataDrivenColor({ targetName }) {
229-
if (this.isCategorical()) {
230-
return this._getMbDataDrivenCategoricalColor({ targetName });
231-
} else {
232-
return this._getMbDataDrivenOrdinalColor({ targetName });
233-
}
234-
}
235-
236-
_getOrdinalColorStopsFromCustom() {
237-
return this._options.customColorRamp.reduce((accumulatedStops, nextStop) => {
238-
return [...accumulatedStops, nextStop.stop, nextStop.color];
239-
}, []);
240-
}
241-
242228
_getMbOrdinalColorStops() {
243229
if (this._options.useCustomColorRamp) {
244-
return this._getOrdinalColorStopsFromCustom();
230+
return this._options.customColorRamp.reduce((accumulatedStops, nextStop) => {
231+
return [...accumulatedStops, nextStop.stop, nextStop.color];
232+
}, []);
245233
} else {
246234
return getOrdinalColorRampStops(this._options.color);
247235
}
@@ -299,7 +287,7 @@ export class DynamicColorProperty extends DynamicStyleProperty {
299287
const stops = this._getColorStops();
300288
return stops.map((config, index) => {
301289
let textValue;
302-
if (config.isDefault) {
290+
if (index === stops.length - 1) {
303291
textValue = (
304292
<EuiText size={'xs'}>
305293
<EuiTextColor color="secondary">{getOtherCategoryLabel()}</EuiTextColor>

0 commit comments

Comments
 (0)