grafana/scenes

Question: when should I use a custom scene object over a custom visualization?

Closed this issue · 1 comments

Please let me know if there's a better forum for this conversation, happy to redirect elsewhere!

I'm working on a custom panel in a scene app that displays query data. I first implemented the panel as a CustomSceneObject, but ended up with formatting issues putting the object into a SceneFlexLayout - the width and height would overflow and didn't scroll nicely.

After reading the docs on custom visualizations, I decided to rewrite the panel as a custom visualization. It looks a lot better, but now I'm not sure of the best way to interact with the sceneGraph to look up variables and ancestors. Additionally, I'm having trouble rendering data links correctly in this visualization -- the ${__value.text} macro isn't being interpolated.

Do you have a suggestion or reference implementation for interacting with the scene graph from a custom visualization? Or should I move back to the custom scene object model?

The ${__value.text} has been implemented, see here https://github.com/grafana/scenes/blob/main/packages/scenes/src/variables/macros/dataMacros.ts#L45

Im not sure of the best way to interact with the sceneGraph to look up variables and ancestors

We have yet to add a scene context ability to visualization components, it will likely be exposed via the new SceneContext added recently (still work in progress)

what you can do in the meantime get the root scene node from window.__sceneObject , or it should also be present in the data passed via PanelProps, data.scopedVars.__sceneObject.value, this last one will be the scene object of the SceneQueryRunner issuing the query (if there was one )