JonasF
(Jonas)
September 9, 2023, 3:54pm
1
Hello
Is it possible to automatically display the year as the serial name?
config:
chartType: year
label: linkyPapp
slots:
grid:
- component: oh-chart-grid
config: {}
xAxis:
- component: oh-category-axis
config:
gridIndex: 0
categoryType: year
monthFormat: short
weekdayFormat: short
yAxis:
- component: oh-value-axis
config:
gridIndex: 0
name: W
series:
- component: oh-aggregate-series
config:
name: 2021
item: linkyPapp
gridIndex: 0
xAxisIndex: 0
yAxisIndex: 0
type: bar
dimension1: month
offsetUnit: year
offsetAmount: 2
- component: oh-aggregate-series
config:
name: 2022
item: linkyPapp
gridIndex: 0
xAxisIndex: 0
yAxisIndex: 0
type: bar
dimension1: month
offsetUnit: year
offsetAmount: 1
- component: oh-aggregate-series
config:
name: 2023
item: linkyPapp
gridIndex: 0
xAxisIndex: 0
yAxisIndex: 0
type: bar
dimension1: month
tooltip:
- component: oh-chart-tooltip
config:
confine: true
legend:
- component: oh-chart-legend
config:
bottom: 3
I would like
name: 2021
name: 2022
name: 2023
to be updated automatically
JustinG
(JustinG)
September 9, 2023, 5:17pm
2
Use dayjs
in the expression:
name: =dayjs().year()
name: =dayjs().year()-1
name: =dayjs().year()-2
JonasF
(Jonas)
September 10, 2023, 7:58am
3
it doesn’t work
for other elements in a widget it works but in the chart it doesn’t work
I’m using openHAB 3.4.4. Is it working on OH 4?
And if I understand correctly, it takes “today’s” year, not the year on the chart.
JonasF
(Jonas)
September 13, 2023, 8:14pm
4
opened 08:27PM - 12 Jun 21 UTC
closed 09:03AM - 21 Jan 23 UTC
enhancement
main ui
Inside an oh-mark-area object the items doesn't get called from props. It only w… orks when its hardcoded by its name.
I made a minimal example. See the last line - the item is not selected.
If I hardcode the item by its name its working, but thats not very flexible.
I tried _=props.window_item_ and _=items[props.window_item]_.
```
uid: test
tags: []
props:
parameters:
- context: item
description: Window Sensor Item shown in chart
label: Window Item
name: window_item
required: false
type: TEXT
component: f7-card
config:
title: test
slots:
default:
- component: oh-chart
config:
label: test
periodVisible: false
slots:
grid:
- component: oh-chart-grid
config:
show: true
left: 50
right: 50
xAxis:
- component: oh-time-axis
config:
gridIndex: 0
yAxis:
- component: oh-value-axis
config:
gridIndex: 0
series:
- component: oh-time-series
config:
name: Fenster
gridIndex: 0
xAxisIndex: 0
yAxisIndex: 0
type: bar
color: red
slots:
markArea:
- component: oh-mark-area
config:
name: Fenster
item: =props.window_item #=items[props.window_item]
```
So in principle it works on oh4. The migration is planned, so problem 1 has been solved.
But is it possible to recover the date selected in the graph ?
JustinG
(JustinG)
September 13, 2023, 9:20pm
5
Sorry, somehow I missed your previously reply. Yes, the expression works just fine in OH4.
That I don’t think is possible. The widget expressions are not full javascript engines, each one is run in it’s own context by a js-like expression parser so there are limitations to the information available in expressions.
Off the top of my head, I would say that to achieve something like this you would need to develop your own custom widget with a chart that is linked to another widget for selection of the year. Then you would be able to pass a widget variable with the year to both the chart and the chart labels.
JonasF
(Jonas)
September 14, 2023, 5:50pm
6
It seems complicated. I’m just going to use dayjs as a first step anyway, for the moment I don’t have any data for more than 3 years.
Thanks a lot!