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:
parent
c4156ae334
commit
5493a83114
2 changed files with 3 additions and 3 deletions
|
|
@ -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: {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue