Radar

<o-radar> is a scope with range rings, spokes, a rotating sweep and blips.

Each blip is a satellite on orbit-12: --o-angle-composite points it and --o-alignment pulls it in toward the center. Spokes are vectors from the center, one radius long. Updating targets only touches the blips, so the sweep never restarts.

Attributes

AttributeDefaultWhat it does
targets[]Blips: [{ angle, dist, color?, label? }]. angle in degrees clockwise from the top, dist from min (center) to max (edge).
min / max0 / 1The distance range, so blips can be in kilometers or miles.
rings4Range rings.
spokes8Lines from the center.
sweeponsweep="false" hides the beam.
sweep-width110Width of the beam, in degrees.
speed4Seconds per turn.
color#22d3eeColor of the whole scope. accent works too.
labelText under the center dot.
size240pxWidth of the widget.
format, decimals, currency, localeNumber format of distances in the accessible name, through Intl.NumberFormat. See Shared options.
themedark, light or glass. Also inherited from an ok-theme-* class on a container. See Shared options.

Styling

PropertyDefaultWhat it does
--ok-radar-color#22d3eeRings, spokes, beam, blips and label.
--ok-radar-speed4sDuration of one turn of the beam.
--ok-font-size6cqminLabel size.

More examples

Moving targets

Narrow, fast beam

No sweep, as a static map

Accessibility

The radar has role="img" and a name that lists the targets, like “Scan; Alpha: 60 degrees, 80% distance; …”. Give targets a label so the list makes sense. With reduced motion, the beam and the pings stand still.