Autozoom graph to all datapoints

Hello everyone,

I’m fairly new to grafana and I’m currently working on a project where we want to display information from machines in a factory in a grafana dashboard. A feature we want to use is that there is a graph in the dashboard that shows various data within an order that the machine is currently working on. How it works:

  1. We use the data source Microsoft SQL server.
  2. We look at the order number of the last written record in the table of a particular machine.
  3. Based on the previously searched order number, all data is retrieved from the machine that contains the relevant order number.
  4. This data will appear in a graph.

The problem we now have is as follows: We want all data points within the relevant order to be shown in the chart used. However, what we now see are only the data points that fall within the time range selected at the top of the dashboard. This time range is always fixed on a certain previously set time. We want this time range to be set automatically timefrom: (order start time) timeto: now.

Because all orders have a different start time, the timefrom variable must be dynamic and not fixed. Earlier forms seem to show that this is not possible.

https://localhost:3000/t/how-to-autozoom-graph-to-data/60726
https://localhost:3000/t/set-time-range-for-panel-dynamically-autofocus-autozoom/48386

I tried several things and something I found is the following: GitHub - WilliamVenner/grafana-timepicker-buttons: :bar_chart: Datasource-configured buttons panel plugin which set the time range of your Grafana dashboard 53. In this panel the times are adjusted when you click on the button of this panel. The code I used in this panel are as followed:
SELECT
MIN(Time_current) AS ‘time_from’, --selects lowest timestamp within order
‘TijdsInterval’ AS ‘Naam’
FROM
[Machine]
WHERE
Order_Nummer = (SELECT Order_Nummer FROM [Machine] WHERE ID = (SELECT MAX(ID) FROM [Machine]))

This works fine, but the problem is that the time is only adjusted when the button of this panel is clicked. Is there by any chance a possibility to write a piece of code somewhere that automatically selects this button every time the dashboard is refreshed?

1 Like

Same concern with using Influx; I have graphs that look back day/week/month that all have to be manually re-set.