From e4ad3d544e5cc5a59fb7e772b735bfdf355b4178 Mon Sep 17 00:00:00 2001 From: netpyoung Date: Tue, 2 Jan 2024 22:55:13 +0900 Subject: [PATCH 1/2] add: config.scale option --- docs/radar.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/radar.js b/docs/radar.js index 1e4f4c5a..ff4bde86 100644 --- a/docs/radar.js +++ b/docs/radar.js @@ -191,6 +191,12 @@ function radar_visualization(config) { ].join(" "); } + { // adjust with config.scale. + config.scale = config.scale || 1; + config.width = config.width * config.scale; + config.height = config.height * config.scale; + } + var svg = d3.select("svg#" + config.svg_id) .style("background-color", config.colors.background) .attr("width", config.width) @@ -200,7 +206,7 @@ function radar_visualization(config) { if ("zoomed_quadrant" in config) { svg.attr("viewBox", viewbox(config.zoomed_quadrant)); } else { - radar.attr("transform", translate(config.width / 2, config.height / 2)); + radar.attr("transform", translate(config.width / 2, config.height / 2).concat(`scale(${config.scale})`)); } var grid = radar.append("g"); From ba0154302f9f3419c22990f28ed9f11eafb1e72b Mon Sep 17 00:00:00 2001 From: netpyoung Date: Tue, 2 Jan 2024 23:17:26 +0900 Subject: [PATCH 2/2] change: using scaled_width/height instead of override config.width/height --- docs/radar.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/docs/radar.js b/docs/radar.js index ff4bde86..1fbda6f8 100644 --- a/docs/radar.js +++ b/docs/radar.js @@ -191,22 +191,21 @@ function radar_visualization(config) { ].join(" "); } - { // adjust with config.scale. - config.scale = config.scale || 1; - config.width = config.width * config.scale; - config.height = config.height * config.scale; - } + // adjust with config.scale. + config.scale = config.scale || 1; + var scaled_width = config.width * config.scale; + var scaled_height = config.height * config.scale; var svg = d3.select("svg#" + config.svg_id) .style("background-color", config.colors.background) - .attr("width", config.width) - .attr("height", config.height); + .attr("width", scaled_width) + .attr("height", scaled_height); var radar = svg.append("g"); if ("zoomed_quadrant" in config) { svg.attr("viewBox", viewbox(config.zoomed_quadrant)); } else { - radar.attr("transform", translate(config.width / 2, config.height / 2).concat(`scale(${config.scale})`)); + radar.attr("transform", translate(scaled_width / 2, scaled_height / 2).concat(`scale(${config.scale})`)); } var grid = radar.append("g");