How is it possible to integrate other echart types? I would like to integrate tree-type diagrams to create a dynamic overview of the devices I use.
I tried the following based on the information in the documentation.
Unfortunately the preview remains empty, what am I doing wrong or is there even a way to copy the config from echart?
I am afraid it might not be possible, or can lead to unstable results. Overall - some of charts require specific shape of data, and preparation of this data is done in UI functions which process output of persistence services.
Iām not an expert in that topic, but I was able to use e.g. the pie chart for eChart directly - but you have to process the data most likely in a rule to have a format than can be used. I did not use other chart types yet - but it seems to work to a degree in 4.1.1. The only problem Iāve encountered is that I could not define callback functions in the UI to perform more advanced formatting ā¦
Let me know if it helped - and if it worked maybe also document what was the things that need to be considered.
I do not know if this will prevent e.g. pie chart to work in the future - weāll see - maybe thereāll be a way to keep the bundle size reasonable and keep the functionality (e.g. lazy loading of modules in case they are used ā¦).
If it works maybe you have time to check if it still works with the snapshot including the updates. At the moment Iām very busy & do not have time - but if you do not know how to do this Iāll add it to my todo list let me know.
Btw.: For such experiments with other openHAB version a docker container can be very useful to isolate the test system from your productive environment.
I have kept everything that was supported previously, pie chart is hence still included into the UI bundle and should still work ā tree was never included and therefore wonāt work.
The oh-chart-component is already lazy loaded, but we should try to keep the size of this component small by not including the whole echarts library. Adding tree charts however should be fine (I guess so), we just should not include the whole echarts library.
@Elrusso - then you do not need to spend the time to experiment obviously. The only thing I can think of is what would happen if you use a script element to load the missing eChart parts inside the widget - but Iām do not know if that is possible and never tried something like this. But as html element can be used it depends - I do not know how the UI processed the yml exactly and if there are mechanisms that will prevent the load of a script like this. That would be try and error to see what happens ā¦
If it does not work we could consider a feature request for the UI that allows to include custom resources like scripts and css - but Iām not a web specialist; this might be more complex than I think and most likely be something only for very advanced users - as it can also be a security risk to load side load code like this.
as the graph element you need will probably be included soon you might just wait - or spend some time and experiment if the script approach is feasible (or a completely stupid idea, but would be very interesting to know what can be done in that regards to have a basis for a potential feature request/discussion).
Thanks for all the answers and tips. I am pleased that it may be included in one of the next milestones.
Iāve also thought about possibly integrating it as HTML, but I donāt have much experience in creating it. The script approach is a point where I also get clever. But since my time is definitely limited for another 1-2 months, probably not with a timely result.
In addition to the example of a structured representation of the devices and their communication medium, it is also possible to display the energy flow in the house on the individual phases and fuses and, if necessary, to make a decision on which phase a wallbox should be connected to if cable cross-sections are limited or other large consumers are already connected to one phase. Most of the information is already integrated into Openhab, I just havenāt been able to create a clear representation here yet. Tree eChart seems to be a promising and simple approach here.
I have already recreated the PI chart (for the top electrical consumers) and that is how I discovered all the possibilities of the eCharts
It is possible to use the widget yaml to include scripts, both inline and loaded from source. This is not widely advertised and definitely not officially supported (and not likely to ever be, for obvious reasons), but it can be done. Iām not sure itās going to solve this particular problem, however, as passing data between the widget context script and the mainUI backend is non-trivial.
Then youād need to load them from a CDN and also activate them for openHABās Echarts instance.
I would rather recommend that we import the TreeChart component for Echarts and see how bundle size changes. I guess it is not that much so I would be fine with it.
@ysc
Wrt to this being a security risk: At least only the admin user is able to load custom scripts into the UI for all other users, I would consider this case the same as the scripting engines on the server, itās like remote code execution/injection explicitly allowed to the admin user.
But Iām against documenting this approach, I donāt think it should ever be widely used.
Anyway Iām curious how powerful it is, I will have a look at it.