Skip to content

Commit

Permalink
Merge pull request zalando#103 from bocytko/adjust-link-behavior
Browse files Browse the repository at this point in the history
Enables links for blips. Makes link target configurable.
  • Loading branch information
bocytko authored Dec 21, 2022
2 parents ccdc5d0 + 5982675 commit 61c710e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ radar_visualization({
{ name: "OUTER", color: "#e09b96" }
],
print_layout: true,
links_in_new_tabs: true,
entries: [
{
label: "Some Entry",
Expand Down
1 change: 1 addition & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
{ name: "HOLD", color: "#e09b96" }
],
print_layout: true,
links_in_new_tabs: true,
// zoomed_quadrant: 0,
//ENTRIES
entries: [
Expand Down
16 changes: 12 additions & 4 deletions docs/radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,13 @@ function radar_visualization(config) {
.data(segmented[quadrant][ring])
.enter()
.append("a")
.attr("href", function (d, i) {
return d.link ? d.link : "#"; // stay on same page if no link was provided
})
.attr("href", function (d, i) {
return d.link ? d.link : "#"; // stay on same page if no link was provided
})
// Add a target if (and only if) there is a link and we want new tabs
.attr("target", function (d, i) {
return (d.link && config.links_in_new_tabs) ? "_blank" : null;
})
.append("text")
.attr("transform", function(d, i) { return legend_transform(quadrant, ring, i); })
.attr("class", "legend" + quadrant + ring)
Expand Down Expand Up @@ -410,9 +414,13 @@ function radar_visualization(config) {
var blip = d3.select(this);

// blip link
if (!config.print_layout && d.active && d.hasOwnProperty("link")) {
if (d.active && d.hasOwnProperty("link") && d.link) {
blip = blip.append("a")
.attr("xlink:href", d.link);

if (config.links_in_new_tabs) {
blip.attr("target", "_blank");
}
}

// blip shape
Expand Down

0 comments on commit 61c710e

Please sign in to comment.