Skip to content

Commit

Permalink
Merge pull request #170 from chicio/title-legends-configurable-offsets
Browse files Browse the repository at this point in the history
Legend and title offset configurable - parameter + default value
  • Loading branch information
bocytko authored Nov 22, 2024
2 parents a94ff82 + de2d1a0 commit ba5b99a
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions docs/radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ function radar_visualization(config) {
config.links_in_new_tabs = ("links_in_new_tabs" in config) ? config.links_in_new_tabs : true;
config.repo_url = config.repo_url || '#';
config.print_ring_descriptions_table = ("print_ring_descriptions_table" in config) ? config.print_ring_descriptions_table : false;
config.legend_offset = config.legend_offset || [
{ x: 450, y: 90 },
{ x: -675, y: 90 },
{ x: -675, y: -310 },
{ x: 450, y: -310 }
]
config.title_offset = config.title_offset || { x: -675, y: -420 };
config.footer_offset = config.footer_offset || { x: -155, y: 450 };
config.legend_column_width = config.legend_column_width || 140

Expand Down Expand Up @@ -69,16 +76,6 @@ function radar_visualization(config) {
{ radius: 400 }
];

const title_offset =
{ x: -675, y: -420 };

const legend_offset = [
{ x: 450, y: 90 },
{ x: -675, y: 90 },
{ x: -675, y: -310 },
{ x: 450, y: -310 }
];

function polar(cartesian) {
var x = cartesian.x;
var y = cartesian.y;
Expand Down Expand Up @@ -282,8 +279,8 @@ function radar_visualization(config) {
dy = dy + 36 + segmented[quadrant][ring-1].length * 12;
}
return translate(
legend_offset[quadrant].x + dx,
legend_offset[quadrant].y + dy
config.legend_offset[quadrant].x + dx,
config.legend_offset[quadrant].y + dy
);
}

Expand All @@ -293,7 +290,7 @@ function radar_visualization(config) {
// title
radar.append("a")
.attr("href", config.repo_url)
.attr("transform", translate(title_offset.x, title_offset.y))
.attr("transform", translate(config.title_offset.x, config.title_offset.y))
.append("text")
.attr("class", "hover-underline") // add class for hover effect
.text(config.title)
Expand All @@ -304,7 +301,7 @@ function radar_visualization(config) {
// date
radar
.append("text")
.attr("transform", translate(title_offset.x, title_offset.y + 20))
.attr("transform", translate(config.title_offset.x, config.title_offset.y + 20))
.text(config.date || "")
.style("font-family", config.font_family)
.style("font-size", "14")
Expand All @@ -323,8 +320,8 @@ function radar_visualization(config) {
for (var quadrant = 0; quadrant < 4; quadrant++) {
legend.append("text")
.attr("transform", translate(
legend_offset[quadrant].x,
legend_offset[quadrant].y - 45
config.legend_offset[quadrant].x,
config.legend_offset[quadrant].y - 45
))
.text(config.quadrants[quadrant].name)
.style("font-family", config.font_family)
Expand Down

0 comments on commit ba5b99a

Please sign in to comment.