From f9c76661226146781f20a7dc0da10a14f646b108 Mon Sep 17 00:00:00 2001 From: b Date: Sun, 20 Jun 2021 16:49:03 -0700 Subject: [PATCH] Fix boxes going too low --- dps_vis.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dps_vis.js b/dps_vis.js index bbe013b..79a3dab 100644 --- a/dps_vis.js +++ b/dps_vis.js @@ -142,7 +142,8 @@ let details = graph.append("g") details.append("rect").attr("z", "100"); function showDetails(data, i, xfunc, yfunc) { - let xpos = xfunc(i[1]); + let _bbox = bbox(); + let xpos = xfunc(i[1]) let ypos = yfunc(dps_getter_func(i)); let texts = [[1, i[0]], [3, "Prepowder: "+i[4].toFixed(2)], @@ -158,11 +159,13 @@ function showDetails(data, i, xfunc, yfunc) { texts.push([idx, explanation[0] + ": " + explanation[1]]); idx += 1; } + let box_height = (14 * idx) - 4; + if (ypos + box_height > _bbox.height) ypos = _bbox.height - box_height; details.select("rect") .attr("x", xpos) .attr("y", ypos) .attr("width", 200) - .attr("height", (14 * idx) - 4) + .attr("height", box_height) .attr("opacity", 0.8); details.selectAll("text") .data(texts, d => d[0])