fix telemtrie na dahsbaordu (15min misto 1h)
Some checks failed
deploy / deploy (push) Failing after 1m42s
test / smoke-test (push) Successful in 2s

This commit is contained in:
Dusan Vojacek
2026-04-10 20:48:41 +02:00
parent 920d9ff40c
commit eb8dd0368f
11 changed files with 131 additions and 23 deletions

View File

@@ -13,9 +13,11 @@ import {
type Props = {
slots: SlotData[]
nowIndex: number
/** Stejný zdroj jako horní karta SOC (živá telemetrie); bod v aktuálním slotu. */
liveBatSoc?: number | null
}
export function SocTuvChart({ slots, nowIndex }: Props) {
export function SocTuvChart({ slots, nowIndex, liveBatSoc = null }: Props) {
const canvasRef = useRef<HTMLCanvasElement>(null)
const chartRef = useRef<Chart | null>(null)
@@ -50,12 +52,22 @@ export function SocTuvChart({ slots, nowIndex }: Props) {
)
const series = useMemo(() => {
const socReal = slots.map((s, i) => (i <= nowIndex ? s.soc_actual_pct : null))
const socReal = slots.map((s, i) => {
if (i > nowIndex) return null
if (
i === nowIndex &&
liveBatSoc != null &&
Number.isFinite(liveBatSoc)
) {
return liveBatSoc
}
return s.soc_actual_pct
})
const socPlan = slots.map((s) => s.soc_plan_pct)
const tuvReal = slots.map((s, i) => (i <= nowIndex ? s.tuv_actual_c : null))
const tuvPlan = slots.map((s) => s.tuv_plan_c)
return { socReal, socPlan, tuvReal, tuvPlan }
}, [slots, nowIndex])
}, [slots, nowIndex, liveBatSoc])
const bgPlugin = useMemo(
() => createSlotBackgroundPluginRefs(slotsRef, negRangesRef),