VolkovLabs / business-variable

Update dashboard variables for @grafana
https://docs.volkovlabs.io
Apache License 2.0
31 stars 0 forks source link

Tree branches with different depth #77

Closed Kaudse closed 5 months ago

Kaudse commented 10 months ago

Is it possible that branches in the tree representation have different depths? I am looking for the possibility to group values of one group into subgroups, while other values keep listed under their main group. I.e. something like this:

grafik

mikhail-vl commented 10 months ago

@Kaudse That's an interesting question. I have never tried trees with different depths. Have you tried it to do in the panel already?

mikhail-vl commented 10 months ago

Variable panel supports tabs for different Tree structures. Different depths are not supported in one tree.

Kaudse commented 10 months ago

Although it was already closed, I want to leave some remarks on this issue. Especially, I want to substantiate why a tree with different depths in its branches would be very useful.

Let me take your own example of the temperate devices in several countries, as mentioned in the tutorial to the Variable panel. While it is common in the US to mention the state when speaking about a city, this is less typical in other countries. This leads to inconsistencies in your example, as in the case of Sweden, Stockholm is listed, both, in the State and City variables.

So even in your example, a tree with different branch depths would be beneficial. The branch of devices in the US would be organized as country → state → city → device, while other countries may look like country → city → device. So the full tree could look like this:

US
 |--FL
 |   |--Tampa
 |   |   |--device1
 |   |--Miami
 |       |--device2
 |       |--device3
 |--IL
 |   |--Chicago
 |       |--device4
Sweden
 |--Stockholm
 |   |--device5
 |   |--device6
Germany
 |--Berlin
     |--device7

A possible input table for the tree structure could look like this:

Country State City Device
US FL Tampa device1
US FL Miami device2
US FL Miami device3
US IL Chicago device4
Sweden NULL Stockholm device5
Sweden NULL Stockholm device6
Germany NULL Berlin device7

As @mikhail-vl suggested, I tried to use several tabs to organize my device groups having different branch depths. This works, but the drawback is, that I need to have at least one device marked in every group, which is not what I wanted (but I can live with it ;) ). Transferred to your example: Implementing it with several tabs, one for each country, would force you to select at least one sensor from each country, which may not be what you want to display in your dashboard.

To conclude, I suggest keeping this issue open. Maybe other users will show interest in different branch depths in the future.

mikhail-vl commented 10 months ago

@Kaudse Let's see if there is will be an interest from the community.

ToMs77130 commented 7 months ago

Also interested, my use case is it display some product folders with different depth, for example

root folder
 |--dress
 |   |--short
 |   |   |--model 1
 |   |   |--model 2
 |   |--long
 |       |--model 1
 |       |--model 3
 |--tshirts
 |   |--model 1
 |   |--model 2
carlosImagu commented 6 months ago

why don't you use IFNULL(State,"NONE")

asimonok commented 5 months ago

@Kaudse thanks for the feature request. But we are not going to implement it due to the complexity and getting not enough benefit from it. You can handle it by adding the missed levels with the same values as parent. Like Sweden -> Sweden -> Stockholm

krdosier commented 2 weeks ago

Please add support for multi depth trees! This enhancement would bring huge value to my use case.

JavaScript should be able to recursively traverse a parent column and a child column to render the tree.

mikhail-vl commented 2 weeks ago

@krdosier As @asimonok replied, it's adds complexity and we are not looking to implement it unless we find a sponsor.

Multi depth trees would be possible with the Business Table panel, which supports tree structure already and will have actions to update variables in the upcoming release. It's under development and we plan to release it in September.