mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 15:50:36 -05:00
Interactive engine data charts: click to zoom, crosshair readout, range stats
Clicking a chart opens a viewer with higher-resolution data (new JSON endpoint, fetched once): drag to zoom, tabs keep the zoom across metrics, legend toggles, and min/avg/max for the visible range in monitor time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4b6329843d
commit
2d068e1a63
8 files changed
+498
-16
No files matched your search
@@ -51,21 +51,57 @@
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-6 border-t border-slate-100 p-4 lg:grid-cols-2">
|
||||
<% colors = FlightLogsHelper::CYLINDER_COLORS %>
|
||||
<% [
|
||||
[ "CHT", recording.cht_keys, "°F", colors ],
|
||||
[ "EGT", recording.egt_keys, "°F", colors ],
|
||||
[ "RPM", [ :rpm ], "rpm" ],
|
||||
[ "Manifold pressure", [ :map ], "inHg" ],
|
||||
[ "Fuel flow", [ :fuel_flow ], "gph" ],
|
||||
[ "Oil temp", [ :oil_t ], "°F" ],
|
||||
[ "Oil pressure", [ :oil_p ], "psi" ],
|
||||
[ "Volts", [ :volts ], "V" ]
|
||||
].each do |title, keys, unit, palette| %>
|
||||
<% chart = engine_chart(recording, *keys, ytitle: unit, colors: palette) %>
|
||||
<% if chart %><figure><figcaption class="mb-1 text-xs font-semibold text-slate-600"><%= title %></figcaption><%= chart %></figure><% end %>
|
||||
<% end %>
|
||||
<div data-controller="engine-chart" data-engine-chart-url-value="<%= engine_data_aircraft_flight_log_path(@aircraft, flight_log, format: :json) %>"
|
||||
class="border-t border-slate-100">
|
||||
<p class="px-4 pt-3 text-xs text-slate-500">Click a chart to explore it: zoom into any part of the flight and read exact values.</p>
|
||||
<div class="grid gap-6 p-4 lg:grid-cols-2">
|
||||
<% engine_chart_groups(recording).each_with_index do |group, i| %>
|
||||
<% chart = engine_chart(recording, *group[:keys], ytitle: group[:unit], colors: group[:colors].many? ? group[:colors] : nil) %>
|
||||
<% next unless chart %>
|
||||
<figure role="button" tabindex="0" aria-label="Explore the <%= group[:title] %> chart"
|
||||
class="group cursor-zoom-in rounded-md p-1 ring-sky-500/40 transition hover:ring-2 focus-visible:outline-none focus-visible:ring-2"
|
||||
data-action="click->engine-chart#open keydown.enter->engine-chart#open keydown.space->engine-chart#open"
|
||||
data-engine-chart-group-param="<%= i %>">
|
||||
<figcaption class="mb-1 flex items-center justify-between text-xs font-semibold text-slate-600">
|
||||
<%= group[:title] %>
|
||||
<span class="font-normal text-slate-400 group-hover:text-sky-700" aria-hidden="true">⤢ Explore</span>
|
||||
</figcaption>
|
||||
<%= chart %>
|
||||
</figure>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<dialog data-engine-chart-target="dialog" aria-label="Engine data viewer"
|
||||
class="m-auto h-dvh max-h-none w-screen max-w-none bg-surface p-0 text-slate-800 shadow-2xl backdrop:bg-black/60 sm:h-[min(52rem,94dvh)] sm:w-[min(80rem,96vw)] sm:rounded-lg"
|
||||
data-action="keydown->engine-chart#keydown close->engine-chart#closed">
|
||||
<div class="flex h-full flex-col">
|
||||
<div class="flex items-center gap-2 border-b border-slate-200 px-3 py-2">
|
||||
<div data-engine-chart-target="tabs" role="tablist" class="flex min-w-0 flex-1 gap-1 overflow-x-auto"></div>
|
||||
<button type="button" data-action="engine-chart#close" class="rounded px-2 py-1 text-lg leading-none text-slate-500 hover:bg-slate-100" aria-label="Close">✕</button>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-2 px-4 py-2 text-xs text-slate-500">
|
||||
<span data-engine-chart-target="range" class="tabular-nums"></span>
|
||||
<span class="hidden sm:inline">· Drag across the chart to zoom in, double-click to reset.</span>
|
||||
<span class="sm:hidden">· Drag to zoom.</span>
|
||||
<span class="ml-auto flex gap-2">
|
||||
<button type="button" data-engine-chart-target="zoomOut" data-action="engine-chart#zoomOut" class="btn-secondary btn-sm" disabled>Zoom out</button>
|
||||
<button type="button" data-engine-chart-target="reset" data-action="engine-chart#resetZoom" class="btn-secondary btn-sm" disabled>Reset zoom</button>
|
||||
</span>
|
||||
</div>
|
||||
<div class="relative min-h-0 flex-1 touch-none select-none px-2 sm:px-4" data-engine-chart-target="frame"
|
||||
data-action="pointerdown->engine-chart#dragStart pointermove->engine-chart#dragMove pointerup->engine-chart#dragEnd pointercancel->engine-chart#dragCancel dblclick->engine-chart#resetZoom">
|
||||
<canvas data-engine-chart-target="canvas"></canvas>
|
||||
<div data-engine-chart-target="selection" hidden class="pointer-events-none absolute border-x border-sky-500 bg-sky-500/15"></div>
|
||||
<p data-engine-chart-target="status" class="absolute inset-0 grid place-items-center text-sm text-slate-500">Loading…</p>
|
||||
</div>
|
||||
<div class="max-h-[30%] overflow-auto border-t border-slate-200">
|
||||
<table class="table text-sm">
|
||||
<thead><tr><th>Series <span class="font-normal normal-case text-slate-400">(visible range)</span></th><th class="text-right">Min</th><th class="text-right">Avg</th><th class="text-right">Max</th></tr></thead>
|
||||
<tbody data-engine-chart-target="stats"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</dialog>
|
||||
</div>
|
||||
<% elsif error %>
|
||||
<p class="card-body text-sm text-amber-700"><%= error %></p>
|
||||
|
||||
Reference in new issue
Block a user