Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix categorized layers colors palette not updating #2447

Merged
merged 5 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion umap/static/umap/js/modules/data/features.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ class Feature {
if (this._umap.currentFeature === this) {
this.view()
}
this.datalayer.indexProperties(this)
}
this.redraw()
}
Expand All @@ -235,7 +236,7 @@ class Feature {

const properties = []
let labelKeyFound = undefined
for (const property of this.datalayer._propertiesIndex) {
for (const property of this.datalayer.allProperties()) {
if (!labelKeyFound && U.LABEL_KEYS.includes(property)) {
labelKeyFound = property
continue
Expand Down
18 changes: 11 additions & 7 deletions umap/static/umap/js/modules/rendering/layers/classified.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ const ClassifiedMixin = {
},

getColorSchemes: function (classes) {
return this.colorSchemes.filter((scheme) => Boolean(colorbrewer[scheme][classes]))
const found = this.colorSchemes.filter((scheme) =>
Boolean(colorbrewer[scheme][classes])
)
if (found.length) return found
return [['', translate('Default')]]
},
}

Expand Down Expand Up @@ -191,7 +195,7 @@ export const Choropleth = FeatureGroup.extend({
'options.choropleth.property',
{
handler: 'Select',
selectOptions: this.datalayer._propertiesIndex,
selectOptions: this.datalayer.allProperties(),
label: translate('Choropleth property value'),
},
],
Expand Down Expand Up @@ -300,7 +304,7 @@ export const Circles = FeatureGroup.extend({
'options.circles.property',
{
handler: 'Select',
selectOptions: this.datalayer._propertiesIndex,
selectOptions: this.datalayer.allProperties(),
label: translate('Property name to compute circles'),
},
],
Expand Down Expand Up @@ -377,7 +381,7 @@ export const Categorized = FeatureGroup.extend({

_getValue: function (feature) {
const key =
this.datalayer.options.categorized.property || this.datalayer._propertiesIndex[0]
this.datalayer.options.categorized.property || this.datalayer.allProperties()[0]
return feature.properties[key]
},

Expand Down Expand Up @@ -420,7 +424,7 @@ export const Categorized = FeatureGroup.extend({
} else {
this.options.colors = colorbrewer?.Accent[this._classes]
? colorbrewer?.Accent[this._classes]
: U.COLORS // Fixme: move COLORS to modules/
: Utils.COLORS
}
},

Expand All @@ -430,7 +434,7 @@ export const Categorized = FeatureGroup.extend({
'options.categorized.property',
{
handler: 'Select',
selectOptions: this.datalayer._propertiesIndex,
selectOptions: this.datalayer.allProperties(),
label: translate('Category property'),
},
],
Expand Down Expand Up @@ -464,7 +468,7 @@ export const Categorized = FeatureGroup.extend({

onEdit: function (field, builder) {
// Only compute the categories if we're dealing with categorized
if (!field.startsWith('options.categorized')) return
if (!field.startsWith('options.categorized') && field !== 'options.type') return
// If user touches the categories, then force manual mode
if (field === 'options.categorized.categories') {
this.datalayer.options.categorized.mode = 'manual'
Expand Down
2 changes: 1 addition & 1 deletion umap/static/umap/js/modules/tableeditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default class TableEditor extends WithTemplate {
}

resetProperties() {
this.properties = this.datalayer._propertiesIndex
this.properties = this.datalayer.allProperties()
if (this.properties.length === 0) {
this.properties = [U.DEFAULT_LABEL_KEY, 'description']
}
Expand Down
Loading