Control property used in choropleth
This commit is contained in:
parent
8e12e6cf24
commit
5d350a7cc9
1 changed files with 15 additions and 2 deletions
|
@ -123,9 +123,14 @@ L.U.Layer.Choropleth = L.FeatureGroup.extend({
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_getValue: function (feature) {
|
||||||
|
const key = this.datalayer.options.choropleth.property || 'value'
|
||||||
|
return feature.properties[key]
|
||||||
|
},
|
||||||
|
|
||||||
computeLimits: function () {
|
computeLimits: function () {
|
||||||
const values = []
|
const values = []
|
||||||
this.datalayer.eachLayer((layer) => values.push(layer.properties.density))
|
this.datalayer.eachLayer((layer) => values.push(this._getValue(layer)))
|
||||||
this.options.limits = chroma.limits(
|
this.options.limits = chroma.limits(
|
||||||
values,
|
values,
|
||||||
this.datalayer.options.choropleth.mode || 'q',
|
this.datalayer.options.choropleth.mode || 'q',
|
||||||
|
@ -139,7 +144,7 @@ L.U.Layer.Choropleth = L.FeatureGroup.extend({
|
||||||
|
|
||||||
getColor: function (feature) {
|
getColor: function (feature) {
|
||||||
if (!feature) return // FIXME shold not happen
|
if (!feature) return // FIXME shold not happen
|
||||||
const featureValue = feature.properties.density
|
const featureValue = this._getValue(feature)
|
||||||
// Find the bucket/step/limit that this value is less than and give it that color
|
// Find the bucket/step/limit that this value is less than and give it that color
|
||||||
for (let i = 0; i < this.options.limits.length; i++) {
|
for (let i = 0; i < this.options.limits.length; i++) {
|
||||||
if (featureValue <= this.options.limits[i]) {
|
if (featureValue <= this.options.limits[i]) {
|
||||||
|
@ -169,6 +174,14 @@ L.U.Layer.Choropleth = L.FeatureGroup.extend({
|
||||||
|
|
||||||
getEditableOptions: function () {
|
getEditableOptions: function () {
|
||||||
return [
|
return [
|
||||||
|
[
|
||||||
|
'options.choropleth.property',
|
||||||
|
{
|
||||||
|
handler: 'BlurInput',
|
||||||
|
placeholder: L._('Choropleth property value'),
|
||||||
|
helpText: L._('Choropleth property value'),
|
||||||
|
},
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'options.choropleth.steps',
|
'options.choropleth.steps',
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue