From 2fabfa3415a59badff6aafdb02c97d2e3401c9ed Mon Sep 17 00:00:00 2001 From: Nathan McRae Date: Tue, 19 Aug 2025 20:15:57 -0700 Subject: [PATCH] Fix text offset calculation --- src/TernaryGraph.purs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/TernaryGraph.purs b/src/TernaryGraph.purs index f14caef..6f8d65b 100644 --- a/src/TernaryGraph.purs +++ b/src/TernaryGraph.purs @@ -94,9 +94,9 @@ svgTextID idMaybe text { x: x, y: y } angle style dimension = XMLFragment $ " idText <> " xml:space=\"preserve\" style=\"font-size:" <> (toString style.sizePx) <> "px;line-height:131%;font-family:'" <> style.typeface <> "';fill:#000000;stroke:#000000;stroke-width:0.0999998;stroke-linecap:round;stop-color:#000000;fill-opacity:1\" " <> "transform=\"translate(" <> (toString centerX) <> ", " <> (toString centerY) <> ") rotate(" <> (toString (angle * 180.0 / pi)) <> ")\">" <> text <> "" where - offset = rotate angle {x: dimension.widthPx, y: dimension.heightPx} - centerX = x - offset.x / 4.0 - centerY = y - offset.y / 4.0 + offset = rotate angle {x: dimension.widthPx / 4.0, y: -dimension.heightPx / 8.0} + centerX = x - offset.x + centerY = y - offset.y idText = case idMaybe of Maybe.Nothing -> "" Maybe.Just id -> "id=\"" <> id <> "\""