I would like to access the current selected time range in the Dynamic Text panel so that I can compare it to some custom time range picker buttons. I have subscribed to the time-range-updated event and I currently use angular.element(‘grafana-app’).injector().get(‘timeSrv’) to get the new time range. I’m worried that this will no longer be supported in the future. If I try using context.grafana.timeRange or the built-in time range variables ($__from and $__to) in my javascript, it seems to return the timeAtLoad object of the timeSrv object (time before update) rather than the time object (time after update). Is there a react equivalent of angular.element(‘grafana-app’).injector().get(‘timeSrv’) that I can use rather?
How can I access timeSrv using react rather than using the angular method in the Dynamic Text panel?
1 Like