Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.
Closed
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
4 changes: 4 additions & 0 deletions src/partials/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ <h5 class="section-heading">Map Visual Options</h5>
label="Sticky Labels" label-class="width-10"
checked="ctrl.panel.stickyLabels" on-change="ctrl.toggleStickyLabels()">
</gf-form-switch>
<div class="gf-form">
<label class="gf-form-label width-10">Clickthrough URL</label>
<input type="text" class="input-small gf-form-input width-10" ng-model="ctrl.panel.clickthroughURL" ng-change="ctrl.refresh()" ng-model-onblur />
</div>
<div class="gf-form">
<label class="gf-form-label width-10">Decimals</label>
<input type="number" class="input-small gf-form-input width-10" ng-model="ctrl.panel.decimals" ng-change="ctrl.refresh()" ng-model-onblur />
Expand Down
11 changes: 11 additions & 0 deletions src/worldmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export default class WorldMap {
location: dataPoint.key,
});
circle.unbindPopup();
this.createClickthrough(circle, dataPoint.key);
this.createPopup(circle, dataPoint.locationName, dataPoint.valueRounded);
}
});
Expand All @@ -128,6 +129,7 @@ export default class WorldMap {
location: dataPoint.key
});

this.createClickthrough(circle, dataPoint.key);
this.createPopup(circle, dataPoint.locationName, dataPoint.valueRounded);
return circle;
}
Expand Down Expand Up @@ -164,6 +166,15 @@ export default class WorldMap {
}
}

createClickthrough(circle, key) {
if (this.ctrl.panel.clickthroughURL) {
const newURL = this.ctrl.panel.clickthroughURL.replace('$country', key);
circle.on('click', function onClick(evt) {
window.location.assign(newURL);
});
}
}

getColor(value) {
for (let index = this.ctrl.data.thresholds.length; index > 0; index -= 1) {
if (value >= this.ctrl.data.thresholds[index - 1]) {
Expand Down
3 changes: 2 additions & 1 deletion src/worldmap_ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ const panelDefaults = {
decimals: 0,
hideEmpty: false,
hideZero: false,
stickyLabels: false
stickyLabels: false,
clickthroughURL: ''
};

const mapCenters = {
Expand Down