Skip to content

Commit 4d1d08a

Browse files
authored
FEAT: Added a settings parameter to hide value (#62)
When using this plugin to display only entities on a map, without a relevant value, a new option was added to hide the N/A string which usually gets appended to all points in the map.
1 parent fed78be commit 4d1d08a

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/partials/editor.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,14 @@ <h5>Filtering</h5>
181181
</gf-form-switch>
182182
</div>
183183

184+
<div class="gf-form-group">
185+
<h5>Formatting</h5>
186+
187+
<gf-form-switch class="gf-form" label="Omit value when empty" label-class="width-14"
188+
checked="ctrl.panel.formatOmitEmptyValue" on-change="ctrl.refresh()">
189+
</gf-form-switch>
190+
</div>
191+
184192
</div>
185193

186194
</div>

src/worldmap.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,12 @@ export default class WorldMap {
392392
} else {
393393
unit = value && value === 1 ? this.ctrl.settings.unitSingular : this.ctrl.settings.unitPlural;
394394
}
395-
const label = `${locationName}: ${value} ${unit || ''}`.trim();
396-
return label;
395+
396+
if (this.ctrl.settings.formatOmitEmptyValue && value === 'n/a') {
397+
return `${locationName}`.trim();
398+
} else {
399+
return `${locationName}: ${value} ${unit || ''}`.trim();
400+
}
397401
}
398402

399403
private getCategoryColor(label) {

src/worldmap_ctrl.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ const panelDefaults = {
7676
},
7777
ignoreEscapeKey: false,
7878
hideTimepickerNavigation: false,
79+
formatOmitEmptyValue: false,
7980
};
8081

8182
export default class WorldmapCtrl extends MetricsPanelCtrl {

0 commit comments

Comments
 (0)