From 23d7696076d4fb549b96a263f3fcc4734392850e Mon Sep 17 00:00:00 2001 From: Erick Ahmed Date: Fri, 24 Jul 2026 08:53:29 +0200 Subject: [PATCH] Change pie chart font for consistency --- vehicle/komatsu.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/vehicle/komatsu.py b/vehicle/komatsu.py index 0e933ca..1988826 100644 --- a/vehicle/komatsu.py +++ b/vehicle/komatsu.py @@ -118,7 +118,18 @@ _LOAD_STATE_COLORS = { def plot_load_state_pie(decoded_df, color): """Render a pie chart showing the distribution of engine load states.""" if decoded_df is None or decoded_df.empty or "Engine Load State" not in decoded_df.columns: - return px.pie(title="No data for Engine Load State") + fig = px.pie() + fig.update_layout( + title=dict( + text="Engine Load State", + font=dict(size=14, color="#1a1a1a"), + x=0.5, xanchor="center", pad=dict(b=10) + ), + height=280, + template="plotly_white", + annotations=[dict(text="No data", showarrow=False, x=0.5, y=0.5, font=dict(size=13, color="#888"))] + ) + return fig states = pd.to_numeric(decoded_df["Engine Load State"], errors="coerce").dropna().astype(int) @@ -135,7 +146,6 @@ def plot_load_state_pie(decoded_df, color): values="Count", names="Legend", color="State", - title="Engine Load State Distribution", color_discrete_map=_LOAD_STATE_COLORS, ) @@ -145,7 +155,16 @@ def plot_load_state_pie(decoded_df, color): domain={"x": [0.05, 0.55], "y": [0.05, 0.95]}, ) fig.update_layout( - margin=dict(l=0, r=10, t=40, b=0), + title=dict( + text="Engine Load State", + font=dict(size=14, color="#1a1a1a"), + x=0.5, xanchor="center", pad=dict(b=10) + ), + height=280, + autosize=True, + template="plotly_white", + margin=dict(l=20, r=20, t=55, b=45), + font=dict(family="Segoe UI, Arial, sans-serif", size=11, color="#2a2a2a"), legend=dict(x=0.6, y=0.5), ) return fig