OH 5.1.3
I would want to create a bar chart with 1,2,3 or 4 data series. I use 2 series for testing purposes - especially to test the oh-repeater logic.
Worth noting that empty oh-aggregate-series (no item configured for it) crashes the oh-chart → no chart visible → the number of oh-aggregate-series needs to match the number of charts to be shown.
That is exactly where I would want to make use of the oh-repeater in order to generate the exact number of oh-aggregate-series blocks in the widget.
I’ve got a working array for testing the oh-repeater:
in: [ {"item":"SmartmeterMQTT_180", "label":"Label 1", "color":"blue", "service":"rrd4j"}, {"item":"SmartmeterMQTT_280", "label":"Label 2", "color":"green", "service":"rrd4j"} ]
… however, with the following code the 2 data series are not shown on the chart:
- component: oh-chart
config:
chartType: year
height: calc(100vh - var(--f7-navbar-height) - 48px - env(safe-area-inset-top) -
env(safe-area-inset-bottom))
slots:
grid:
- component: oh-chart-grid
config:
right: 15%
legend:
- component: oh-chart-legend
config:
bottom: 15
orient: horizontal
show: true
series:
- component: oh-repeater
config:
for: series
in: [ {"item":"SmartmeterMQTT_180", "label":"Label 1", "color":"blue", "service":"rrd4j"}, {"item":"SmartmeterMQTT_280", "label":"Label 2", "color":"green", "service":"rrd4j"} ]
fragment: true
slots:
default:
- component: oh-aggregate-series
config:
aggregationFunction: diff_last
color: =loop.series.color
dimension1: month
item: =loop.series.item
label:
formatter: =v => Number.parseFloat(v.data[1]).toFixed(0).toLocaleString('de-DE')
position: top
show: true
markLine:
animation: false
data:
- type: average
label:
formatter: =v => Number.parseFloat(v.value).toFixed(0) + ' ' +
items[loop.series.item].unit
show: true
symbol: none
name: =loop.series.label
service: =loop.series.service
type: bar
xAxis:
- component: oh-category-axis
config:
categoryType: year
monthFormat: short
weekdayFormat: default
name: " "
yAxis:
- component: oh-value-axis
config:
axisLabel:
formatter: =v => Number(v).toLocaleString('de-DE')
name: =items[props.itemSeries1].unit
Hope that oh-repeater can be used within oh-chart to setup the desired number of oh-aggregate-series.
Ist there anything wrong with the oh-repeater?