Fix dashboard charts title for non-numeric states

Fixes: #1041
pull/1042/head
Michael Zanetti 2023-06-06 14:44:24 +02:00
parent 02ed6f0099
commit 2cb2224e51
1 changed files with 11 additions and 1 deletions

View File

@ -62,7 +62,17 @@ DashboardDelegateBase {
StateChart {
id: graph
title: root.state && root.stateType ? root.thing.name + ", " + root.stateType.displayName + ": " + Types.toUiValue(root.state.value, root.stateType.unit).toFixed(0) + Types.toUiUnit(root.stateType.unit) : ""
title: {
if (!root.state || !root.stateType) {
return ""
}
var ret = root.thing.name + ", " + root.stateType.displayName
if (["int", "uint", "double"].indexOf(root.stateType.type.toLowerCase()) >= 0) {
ret += ": " + Types.toUiValue(root.state.value, root.stateType.unit).toFixed(0) + Types.toUiUnit(root.stateType.unit)
}
return ret
}
thing: root.thing
color: root.thing ? app.interfaceToColor(root.thing.thingClass.interfaces[0]) : Style.accentColor