Add color configuration and extra signals to vehicle frames

This commit is contained in:
2026-07-23 13:26:37 +02:00
parent be7cf9cb6a
commit 0eac7a571f
3 changed files with 35 additions and 7 deletions
+3 -2
View File
@@ -23,6 +23,7 @@ class SignalDef:
class FrameDef:
can_id: str
description: str = ""
color: str = "#377eb8"
signals: List[SignalDef] = field(default_factory=list)
def normalize_id(can_id: str) -> str:
@@ -92,7 +93,7 @@ def decode_dataframe(df: pd.DataFrame, can_id: str, decoder_rules: dict) -> pd.D
return out
def plot_signal(df: pd.DataFrame, signal_name: str, title: str, height: int = 280) -> go.Figure:
def plot_signal(df: pd.DataFrame, signal_name: str, title: str, color: str = "#377eb8", height: int = 280) -> go.Figure:
fig = go.Figure()
if df.empty or signal_name not in df.columns:
@@ -109,7 +110,7 @@ def plot_signal(df: pd.DataFrame, signal_name: str, title: str, height: int = 28
x=df["Timestamp"],
y=df[signal_name],
mode="lines",
line=dict(width=2, color="#377eb8"),
line=dict(width=2, color=color),
name=signal_name,
hovertemplate=f"<b>{signal_name}</b><br>Time: %{{x}}<br>Value: %{{y:.2f}}<extra></extra>",
))