How to autozoom graph to data?

Hello everyone, pretty new to Grafana with PostgresSQL and so far I love it! I will be presetting to our company the capabilities of Grafana next week and proposing to switching onto this platform - but I need help with one little thing:

I want to create an environment where I can show processes from industry plant. The dashboard should look something like this at the end (our current application):

So far I got to the point where I can select process numbers based on a query variable.

The problem I am facing right now is that the data shown in the graph doesn’t automatically zoom in to data. This can be a problem because processes can be years old. And the user shouldn’t scroll and “look” for the process through all the years.

Please tell me that there is a way how to do this?
I have been searching on the internet and couldn’t find any answers (I am limited to 2 links so I will put the rest into comments):

  1. Set time range for panel dynamically (autofocus, autozoom)
  2. Auto zoom on available data

Other links about this issue:
3) Time range controls | Grafana Labs
4) [Dashboard time range]: Automatically find time range for data in graphs · Issue #6288 · grafana/grafana · GitHub

I hope I will be proven wrong, but I had a similar question a few weeks back and the answer was that it cannot be done.
You can run the make a panel to user a relative time, which means that it will always fix to the last minutes, hours that you specify:

But it is always a range that ends in the current time. So if your process completes 5pm and you are running the report at 6pm, there will a 1 hour empty space in your graph. Similarly it is always a fixed period to the past. I wanted a graph which zooms in the data on my solar panels, which always start and stop depending when the sun rises and sets in the day. And I could not do it.

I hope you find a solution, it there will be a solution for that in the future. For me it seems what we need is not so much a setting on the graph, but some option to programmatically influence the time range on the dashboard. But in my understanding, this is not possible at the moment. Only if we could add a script to the dashboard page source…

1 Like

Ah … I can’t believe such a simple yet so powerful feature isn’t added! :frowning:

I hope someone can come up with a solution!

Isn’t it somehow possible for example to connect Y axis to variables?

Actually, have a look at this: GitHub - WilliamVenner/grafana-timepicker-buttons: 📊 Datasource-configured buttons panel plugin which set the time range of your Grafana dashboard

Just spend a few minutes scrolling through it, but it looks like a bespoke panel type where you can have buttons on your panel, and that will change the time range. So your button can determine the start and end of your data range and set the time range to that. Let me know if you can get this working.

I have stumbled across this plugin myself but idk how I could make it do what I want:

I don’t thing adding those buttons will automatically adjust the time range … user still manually has to type in the dates doesn’t he?

Or can I somehow make the buttons default value set up by query?

Yes, you are probably correct. But at least it auto zooms the time range. Maybe there is another plugin somewhere which can press the button for you :slight_smile:

Hmm maybe I could use the code for autozooming and just feed it a value programmatically.

Issue with this is that I can use this only on desktop version and not in cloud am I correct?