From 5493a83114e6dff41ce10c9d9503e530452619bc Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Wed, 18 Mar 2026 15:49:20 -0500 Subject: [PATCH] show decimal precision and units on graph y-axis (#76) Chart.js was showing integer-rounded values like '2' instead of '2.1 ms'. Uses toFixed(1) in tick callbacks for proper decimal display with units. Reviewed-on: https://git.mcintire.me/graham/towerops-web/pulls/76 --- assets/js/app.ts | 4 ++-- lib/towerops_web/live/graph_live/show.ex | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/js/app.ts b/assets/js/app.ts index 066bc644..3c4bc0f8 100644 --- a/assets/js/app.ts +++ b/assets/js/app.ts @@ -220,7 +220,7 @@ const SensorChart: SensorChartHook = { if (unit === '') { return Math.round(value) } - return value + ' ' + unit + return value.toFixed(1) + ' ' + unit } }, grid: { @@ -253,7 +253,7 @@ const SensorChart: SensorChartHook = { if (unit === '') { return Math.round(value) } - return value + unit + return value.toFixed(1) + ' ' + unit } }, grid: { diff --git a/lib/towerops_web/live/graph_live/show.ex b/lib/towerops_web/live/graph_live/show.ex index ca24d828..cf55bc81 100644 --- a/lib/towerops_web/live/graph_live/show.ex +++ b/lib/towerops_web/live/graph_live/show.ex @@ -766,7 +766,7 @@ defmodule ToweropsWeb.GraphLive.Show do end defp format_value(value, unit) when is_integer(value) do - "#{value} #{unit}" + "#{Float.round(value / 1, 1)} #{unit}" end # Live polling functions