Skip to content

Commit

Permalink
Merge fe61eda into ce6bf9e
Browse files Browse the repository at this point in the history
  • Loading branch information
eduelias authored Nov 5, 2021
2 parents ce6bf9e + fe61eda commit bc1f6bd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/worldmap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ describe('Worldmap', () => {
mapCenterLongitude: 0,
initialZoom: 1,
colors: ['red', 'blue', 'green'],
replaceVariables: (interpolation: string) => {}
},
tileServer: 'CartoDB Positron',
};
Expand Down
10 changes: 6 additions & 4 deletions src/worldmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,15 @@ export default class WorldMap {
}

filterEmptyAndZeroValues(data) {
const minValue = this.ctrl.panel.minValue;
const maxValue = this.ctrl.panel.maxValue;
const minValue = this.ctrl.panel.minValue || parseInt(this.ctrl.panel.replaceVariables('$minDisplayValue'));
const maxValue = this.ctrl.panel.maxValue || parseInt(this.ctrl.panel.replaceVariables('$maxDisplayValue'));
return _.filter(data, o => {
return !(this.ctrl.panel.hideEmpty && _.isNil(o.value))
&& !(this.ctrl.panel.hideZero && o.value === 0)
&& ([undefined, ''].includes(minValue) || o.value >= minValue)
&& ([undefined, ''].includes(maxValue) || o.value <= maxValue)
// The result of parseInt in case of "No Limit" or any other numberless string will be a NaN.
// In that case all "not numbers" should invalidate the filter and be ignored.
&& ([undefined, NaN, 0, ''].includes(minValue) || o.value >= minValue)
&& ([undefined, NaN, ''].includes(maxValue) || o.value <= maxValue)
});
}

Expand Down

0 comments on commit bc1f6bd

Please sign in to comment.