Hi guys,
so here's a "requirement" I would like to implement with UI-Builder: Imagine in one of your flows you've prepared an array like below and you wanna display that in the frontend. The problem here is that the size of the array may vary dynamically in the flow where data is assembled:
series [200]
0: object
name: chartForSeries1
data: array[4711] // contains timeseries data
1: object
name: chartForSeries2
data: array[4711] // contains timeseries data
...
199: object
name: chartForSeries200
data: array[4711] // contains timeseries data
Now with UI-Builder in src/index.js we usually define options and a series arrays like this:
var app1 = new Vue({
el: '#app',
data: {
optionsForSeries1: { chart: { id: 'series1', height: 300, type: 'bar' }, /* other chart options... */ },
timeseries0: [ /* will be updated dynamically */ ]
...
optionsForSeries200: { chart: { id: 'series200', height: 300, type: 'bar' }, /* other chart options... */ },
timeseries200: [ /* will be updated dynamically */ ]
You can already see that this is seriously tedious much work (and I have more than just 200 charts).
And thinking of the update mechanisms, well that should be easier to dynamically fill..
mounted: function() {
uibuilder.start()
var vueApp = this
// Process new messages from Node-RED
uibuilder.onChange('msg', function (newMsg) {
if (newMsg.update === "updateAllSeries") {
vueApp.timeseries1 = newMsg.series[0];
...
vueApp.timeseries200 = newMsg.series[199];
}
Via update we fill those arrays which are then rendered in (e.g.) predefined Apex charts that are wrapped in nice looking bootstrap-vue elements (e.g. b-card) in the index.html:
<!doctype html>
...
<head>...</head>
<body>
<div id="app">
<b-container id="app_container">
<b-row>
<b-card col class="w-100"><apexchart width="95%" :options="optionsForSeries1" :series="timeseries1"></apexchart></b-card>
</b-row>
...
<b-row>
<b-card col class="w-100"><apexchart width="95%" :options="optionsForSeries200" :series="timeseries200"></apexchart></b-card>
</b-row>
</b-container>
</div>
</body></html>
If I have an unknown amount of series can you think of a way to create the number of frontend elements dynamically?
Best regards from Germany,
Marcel