From b34b186e611a04f11dd1c0744e41fdc99d927ced Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Sat, 25 Apr 2026 13:30:23 -0500 Subject: [PATCH] fix(skewt): clip grid + traces to the plot box MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Skewed isotherms, dry adiabats, and mixing-ratio lines were drifting outside the frame at the corners — most visibly the warm-side isotherms exiting the right edge near the top of the diagram. The existing `clip_polyline/1` only filtered with a ±200 px slack, so segments crossing the boundary still drew past the frame. Wrap every grid layer + the T/Td/parcel polylines in a ``. The clipPath defines a rectangle from (left, top) to (right, bottom). Frame outline and axis labels stay outside the clip group so they keep rendering at the box edge unchanged. The hover-cursor crosshair also lives outside the clip so its readout box can sit flush against the plot corner without being trimmed. mix test: 2,902 / 2,902 + 221 properties green. mix credo --strict clean. --- lib/microwaveprop_web/live/skewt_svg.ex | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/microwaveprop_web/live/skewt_svg.ex b/lib/microwaveprop_web/live/skewt_svg.ex index 42b0fc4c..07f335f5 100644 --- a/lib/microwaveprop_web/live/skewt_svg.ex +++ b/lib/microwaveprop_web/live/skewt_svg.ex @@ -43,18 +43,29 @@ defmodule MicrowavepropWeb.SkewtSvg do cleaned = clean_profile(profile) parcel = Keyword.get(opts, :parcel_trace, []) + plot_w = @right - @left + plot_h = @bottom - @top + [ ~s||, style_block(), + # Define a rectangular clip the plot interior shares so any + # grid/trace polyline whose vertices stretch past the frame + # (e.g. skewed isotherms exiting the right edge near the top) + # is visually cropped. The frame and axis labels live *outside* + # this group, so the box outline still reads clean. + ~s||, + ~s||, isobars(), isotherms(), dry_adiabats(), moist_adiabats(), mixing_ratio_lines(), - frame(), - axis_labels(), profile_traces(cleaned), parcel_trace_line(parcel), + "", + frame(), + axis_labels(), cursor_layer(), "" ]