Now the question is: how do I do that from a ts React panel?
Another operation that is of interest is setting the time range. Trackmap just does this.timeSrv.setTime but I can see only reacting to time range changes in PanelProps - that is essentially the whole api that a panel gets as far as I can tell.
I am still learning this stuff, but my investigation of the code suggests that a react panel will get a reference to the dashboard model and the PanelModel. These emit events into the AngularJS world, and those events seem to be picked up and trigger changes in the larger system.
I think the code you linked deals with the state of the whole dashboard and an individual panel, but from Grafanaās viewpoint: like is the panel in view or edit mode. I donāt see any of this or reference thereof being passed to my panel when constructed.
I suspect the way grafana-trackmap-panel hooks into Grafana internals is systemjs (see Gruntfile L56, only 2 links allowed for newbie like me) - in that plugin you just import app/core/app_events and voila!, itās there at runtime.
But I have no idea where to start to incorporate that in my ts & React plugin.
PanelChrome does inject functionality for changing the time range (see lines 250 and 302), but it looks like there isnāt anything directly injected to set other variables (what I was seeing in my investigation was that stuff being injected into the panel header). I did find this How to change a dashboard variable value from a plugin?, and Iām currently working to understand the mechanism heās describing.
Sorry I canāt give you any official help, just offering my understanding as a fellow traveler
Iām not sure this is a really āreactā way to handle this, but glad it works for you :). Ideally, the Grafana team would update the PanelChrome code to provide a better way to get access to shared functionality in a clean way.
Agreed. @grafana/runtime readme says alpha and SystemJS smells like a kludge to me. With TypeScript the way to hook into G is pretty obvious so not much needs to be documented.
āCould not find a front entry so I came in via kitchen door.ā
There was a PR to improve event handling for React plugins that unfortunately was closed due to old age. If this is important to you, let us know by adding reactions and comments to it.