defmodule MicrowavepropWeb.Components.SkewTChart do
@moduledoc """
Function component that renders a skew-T log-P diagram from a
pressure-level profile (list of `%{"pres", "tmpc", "dwpc"}` maps).
Returns empty output when the profile has fewer than three usable
levels.
"""
use Phoenix.Component
alias MicrowavepropWeb.SkewT
attr :profile, :list, required: true
@spec skew_t_chart(map()) :: Phoenix.LiveView.Rendered.t()
def skew_t_chart(assigns) do
chart = SkewT.build(assigns.profile)
usable_points = if chart, do: length(chart.t_points), else: 0
assigns = assign(assigns, chart: chart, usable_points: usable_points)
~H"""
= 2} class="mt-3">
Skew-T log-P
Orange curves: dry adiabats · dashed teal: saturation mixing ratio ·
thin gray: isotherms and isobars