diff --git a/src/worldmap.ts b/src/worldmap.ts
index 4408531..2a0b97f 100644
--- a/src/worldmap.ts
+++ b/src/worldmap.ts
@@ -126,11 +126,18 @@ export default class WorldMap {
case ColorModes.threshold.id:
default:
return () => {
- const thresholds = this.ctrl.data.thresholds;
+ const thresholds = this.ctrl.data.thresholds.slice();
+ const colors = this.ctrl.settings.colors.slice();
+
+ if (this.ctrl.settings.reverseLegend) {
+ thresholds.reverse();
+ colors.reverse();
+ }
+
let legendHtml = '';
legendHtml +=
'
' +
'< ' +
thresholds[0] +
@@ -138,7 +145,7 @@ export default class WorldMap {
for (let index = 0; index < thresholds.length; index += 1) {
legendHtml +=
'
' +
thresholds[index] +
(thresholds[index + 1] ? '–' + thresholds[index + 1] + '
' : '+');
diff --git a/src/worldmap_ctrl.ts b/src/worldmap_ctrl.ts
index ae4a80f..194a2a5 100644
--- a/src/worldmap_ctrl.ts
+++ b/src/worldmap_ctrl.ts
@@ -38,6 +38,7 @@ const panelDefaults = {
unitSingular: '',
unitPlural: '',
showLegend: true,
+ reverseLegend: false,
legendContainerSelector: null,
showZoomControl: true,
showAttribution: true,
@@ -549,6 +550,10 @@ export default class WorldmapCtrl extends MetricsPanelCtrl {
this.render();
}
+ toggleLegendDirection() {
+ this.map.legend.update();
+ }
+
refreshOverlay() {
this.map.overlay.remove();
this.map.overlay = null;