nouvelle planification

This commit is contained in:
maxime committed 2026-10-23 21:52:08 +02:00
1 parent 8d9b927600
commit 23f01d7c23
23 files changed
+1897 -11

No files matched your search

@@ -121,6 +121,12 @@
#r-trends { margin: 0 0 12px; }
#r-events details { margin: 0 0 12px; color: var(--text); }
#r-events summary { font-size: 15px; cursor: pointer; padding: 4px 0; }
/* Onglet Journal (spec « L'onglet Journal ») : courbes, frise des épisodes, journal en texte de la plage visible. */
#journal .hint { color: var(--muted); font-size: 12px; margin: 2px 0 10px; }
.jentry { padding: 6px 4px; border-bottom: 1px solid var(--line); color: var(--text); cursor: pointer; }
.jentry:hover { background: #e8f0fb; }
.jentry i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.rtable { border-collapse: collapse; width: 100%; margin-top: 4px; color: var(--text); }
.rtable th, .rtable td { padding: 5px 6px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.rtable th { color: var(--muted); font-weight: normal; white-space: normal; vertical-align: bottom; }
@@ -168,6 +174,7 @@
<button type="button" data-pane="view" class="active">View</button>
<button type="button" data-pane="diagnosis">Diagnosis</button>
<button type="button" data-pane="displacements">Displacements</button>
<button type="button" data-pane="journal">Journal</button>
</nav>
<div class="pane" id="time_series"></div>
<div class="pane" id="advanced"></div>
@@ -244,6 +251,12 @@
<div id="r-curves"></div>
</div>
</div>
<div class="pane" id="journal">
<div id="j-curves"></div>
<p class="hint">Grey zones: do not trust the data there (they are kept, not removed). Hover a bar for details; zoom the curves
with the wheel or by dragging, double-click for the whole period.</p>
<div id="j-list"></div>
</div>
</section>
</main>
@@ -897,6 +910,70 @@ function drawRegime() { // toutes les cibles en gris fin, celles qui ont sauté
}
drawRegime();
// Onglet Journal (spec « L'onglet Journal ») : le journal du matin du client. Courbes corr_x et corr_y des cibles, zones à
// ignorer grisées, une frise des épisodes (une ligne par détecteur), puis le journal en texte de la plage visible.
const J = D.journal;
const J_NAMES = { visibilite: "Visibility", sauts: "Jumps", turbulence: "Turbulence", thermique: "Thermal", trous: "Missing data" };
const J_KINDS = [...new Set([...Object.keys(J_NAMES), ...J.map(e => e.kind)])].filter(k => J.some(e => e.kind === k));
// une couleur fixe par détecteur, d'une station à l'autre ; vert pour ce qui est normal (le cycle thermique)
const J_COLORS = { visibilite: "#1f77b4", sauts: "#d62728", turbulence: "#ff7f0e", thermique: "#2ca02c", trous: "#7f7f7f" };
const jName = k => J_NAMES[k] || k, jColor = k => J_COLORS[k] || PALETTE[J_KINDS.indexOf(k) % PALETTE.length];
const MON = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
const jWhen = t => `${MON[+t.slice(5, 7) - 1]} ${+t.slice(8, 10)}, ${t.slice(11, 16)}`;
const plotT = ms => new Date(ms).toISOString().slice(0, 19).replace("T", " "); // instant en ms -> date Plotly (UTC)
const jEnd = e => Math.max(Date.parse(e.end), Date.parse(e.start) + 3600e3); // dessin : 1 h au moins, sinon invisible
function drawJournal() {
const targets = S.filter(s => s.kind === "target" || s.kind === "ref");
const traces = targets.flatMap((s, n) => [["corr_x", "Horizontal"], ["corr_y", "Vertical"]].map(([c, label], r) => ({
type: "scatter", mode: "lines", x: D.times, y: s.values[c], yaxis: `y${r ? 2 : ""}`, name: s.name, showlegend: false,
line: { color: PALETTE[n % PALETTE.length], width: 1 },
hovertemplate: `${s.name} · %{x|%d %b %H:%M} UTC<br>${label} %{y:.2f} px<extra></extra>` })));
for (const k of J_KINDS) { // frise : une barre par épisode, de son début à sa fin
const eps = J.filter(e => e.kind === k);
traces.push({ type: "bar", orientation: "h", yaxis: "y3", name: jName(k), showlegend: false,
y: eps.map(() => jName(k)), base: eps.map(e => e.start), x: eps.map(e => jEnd(e) - Date.parse(e.start)),
marker: { color: jColor(k) }, text: eps.map(e => e.label), textposition: "inside", insidetextanchor: "middle",
insidetextfont: { color: "#fff" }, hovertext: eps.map(e => `<b>${e.label}</b><br>${e.text}<br>Sensors: ${
e.sensors.length ? e.sensors.join(", ") : "all"}`), hovertemplate: "%{hovertext}<extra></extra>" });
}
const C = 220, G = 24, F = 30 * Math.max(J_KINDS.length, 1), A = 2 * C + 2 * G + F; // hauteurs en px, A : zone tracée
const grey = J.filter(e => e.ignore).flatMap(e => ["y domain", "y2 domain"].map(yref => ({ type: "rect", xref: "x", yref,
x0: e.start, x1: plotT(jEnd(e)), y0: 0, y1: 1, fillcolor: "#888", opacity: 0.25, line: { width: 0 }, layer: "below" })));
const end = Date.parse(D.times[D.times.length - 1]);
Plotly.newPlot("j-curves", traces, {
height: A + 70, margin: { l: 110, r: 10, t: 20, b: 50 }, barmode: "overlay", bargap: 0.25, uniformtext: { mode: "hide", minsize: 10 },
xaxis: { type: "date", anchor: "y3", range: [ASKED.get("from") || plotT(end - 3 * 864e5), plotT(end)] }, // départ : les 3 derniers jours (#from=AAAA-MM-JJ : captures)
yaxis: { domain: [1 - C / A, 1], fixedrange: true, title: { text: "Horizontal (px)" } },
yaxis2: { domain: [1 - (2 * C + G) / A, 1 - (C + G) / A], fixedrange: true, title: { text: "Vertical (px)" } },
yaxis3: { domain: [0, F / A], fixedrange: true, type: "category", categoryorder: "array",
categoryarray: J_KINDS.map(jName).reverse(), showgrid: false }, // inversé : le premier détecteur en haut
shapes: grey,
}, CONFIG).then(() => {
autoscale("j-curves"); // les barres de la frise (ordonnées en texte) n'entrent pas dans le recalage
const gd = document.getElementById("j-curves");
gd.on("plotly_relayout", () => listJournal(gd.layout.xaxis.range.map(v => Date.parse(minute(v)))));
Plotly.relayout(gd, { "xaxis.range": gd.layout.xaxis.range.slice() }); // ordonnées et journal dès l'ouverture
});
}
function listJournal([a, b]) { // les épisodes de la plage visible, dans l'ordre du temps ; clic : zoom sur l'épisode
const eps = J.filter(e => Date.parse(e.end) >= a && Date.parse(e.start) <= b);
document.getElementById("j-list").innerHTML = eps.length ? eps.map(e => `<div class="jentry" data-n="${J.indexOf(e)}">
<i style="background:${jColor(e.kind)}"></i>${jWhen(e.start)}${e.end === e.start ? "" : ` – ${
e.end.slice(0, 10) === e.start.slice(0, 10) ? e.end.slice(11, 16) : jWhen(e.end)}`} UTC · <b>${e.label}</b> · ${e.text}${
e.sensors.length ? ` <span class="meta">(${e.sensors.join(", ")})</span>` : ""}</div>`).join("")
: '<p class="empty">Nothing to report on this period.</p>';
}
document.getElementById("j-list").addEventListener("click", ev => {
const el = ev.target.closest("[data-n]");
if (!el) return;
const e = J[+el.dataset.n], a = Date.parse(e.start), b = Date.parse(e.end), m = Math.max((b - a) / 2, 2 * 3600e3); // marge
Plotly.relayout("j-curves", { "xaxis.range": [plotT(a - m), plotT(b + m)] });
});
drawJournal();
</script>
</body>
</html>