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: graham/towerops-web#76
This commit is contained in:
Graham McIntire 2026-03-18 15:49:20 -05:00 committed by graham
parent c4156ae334
commit 5493a83114
2 changed files with 3 additions and 3 deletions

View file

@ -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: {

View file

@ -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