I made the following tiny change:
.../org.openhab.ui/web/src/assets/definitions/widgets/chart/index.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bundles/org.openhab.ui/web/src/assets/definitions/widgets/chart/index.js b/bundles/org.openhab.ui/web/src/assets/definitions/widgets/chart/index.js
index 27315258..36631ad3 100644
--- a/bundles/org.openhab.ui/web/src/assets/definitions/widgets/chart/index.js
+++ b/bundles/org.openhab.ui/web/src/assets/definitions/widgets/chart/index.js
@@ -286,7 +286,7 @@ export default {
props: {
parameterGroups: [actionGroup()],
parameters: [
- seriesTypeParameter('gauge', 'pie'),
+ seriesTypeParameter('gauge', 'pie', 'line', 'bar', 'heatmap', 'scatter'),
...actionParams()
]
}
…and ran this modified version of MainUI locally. This change makes the following widget work:
uid: widget_test5xx_bar
tags:
- bar
- temperature
props:
parameters:
- context: item
description: The current value
label: Item
name: item
required: true
type: TEXT
- context: number
description: The min range value
label: MinRange
name: minRange
required: false
type: TEXT
- context: number
description: The max range value
label: MaxRange
name: maxRange
required: false
type: TEXT
- context: number
description: The min value
label: Min
name: min
required: false
type: TEXT
- context: number
description: The max value
label: Max
name: max
required: false
type: TEXT
- context: string
description: The name
label: Name
name: name
required: false
type: TEXT
- context: number
description: The height of widget
label: Height
name: height
required: false
type: TEXT
parameterGroups: []
timestamp: Dec 20, 2024, 7:56:37 PM
component: oh-chart
config:
chartType: day
height: =props.height
periodVisible: false
slots:
grid:
- component: oh-chart-grid
config:
borderWidth: 0
includeLabels: false
width: 10
series:
- component: oh-data-series
config:
data:
- name: "Name of data"
value: =Number.parseFloat(items[props.item].state)
gridIndex: 0
itemStyle:
color: red
showBackground: false
type: bar
xAxisIndex: 0
yAxisIndex: 0
offset: 5
barWidth: 10
barGap: 0
barCategoryGap: 0
tooltip:
- component: oh-chart-tooltip
config:
orient: vertical
show: true
trigger: axis
xAxis:
- component: oh-value-axis
config:
axisLabel:
color: red
show: true
axisLine:
show: true
axisPointer:
show: true
axisTick:
interval: 1
lineStyle:
opacity: 1
show: true
gridIndex: 0
show: false
yAxis:
- component: oh-value-axis
config:
startValue: -30
scale: false
offset: 0
gridIndex: 0
inverse: false
max: 30
min: -30
show: true
splitNumber: 10
axisLine:
show: true
onZero: true
axisTick:
length: 40
minorTick:
show: true
length: 20
axisLabel:
show: true
margin: 23
align: right
verticalAlign: bottom
That means that you avoid the “workaround” with using aggregate/last, potential reliance on the Item being persisted - and it also gives more freedom to manipulate the data directly, handle units etc., since you can set the value directly (value: =Number.parseFloat(items[props.item].state)). I also think it makes it easier to understand the widget, less code is involved, and that it’s generally a better way to do it when you don’t need the aggregate function.
I don’t know how to test if this has some other “negative impact” on the system though, so I’m a bit hesitant to straight forward suggest this change, but it does look tempting. I have tried to look at related commits, and it doesn’t seem like there’s anything more too it. Here is the commit that enabled the use of pie for example:
https://github.com/openhab/openhab-webui/commit/a038730ee58650639c1f8254a1263dc95ecd9402
Is this something I should “suggest” at GitHub - or is it even a small enough change that I could make a PR and that it would fall into the “CLA exception” clause?