Automatically find time range for data in graphs

Hello, I am currently using a time series chart, and initially, it had a date range from 1990 to 2021, which is the dashboard’s date range.

The problem is that when I update the database that the chart reads and add a value for 2022, the dashboard doesn’t update automatically. I have to change the time range again manually.

Is there a way to do this and change the time range based on the minimum and maximum year values? Currently, the URL does not contain any “to” and “from” parameters.

I don’t want to have to constantly change the time range and save it every time I update and add another year to the database.

If I add, for example, 2023, I want the charts to start displaying 2022 and so on.

are you using those time ranges in your query?

I think no, On my database I only have years and my query for my charts its

SELECT STR_TO_DATE(CONCAT(year, '-01-01'), '%Y-%m-%d') AS time, quantity AS 'Total GHG emissions with LULUCF'
FROM net4co2.annual_green_house_gas_data
WHERE category = 'TGL'
ORDER BY time;

SELECT STR_TO_DATE(CONCAT(year, '-01-01'), '%Y-%m-%d') AS time, quantity AS 'Total GHG emissions without LULUCF including indirect CO₂'
FROM net4co2.annual_green_house_gas_data
WHERE category = 'TGIC'
ORDER BY time;


two more like this

So basicly it gets all the times and etc. But because of the dashboard its saved with that time range I need to updated it mannualy after add new lines do my database. But I would like to discard the timeranges and show all values that the query returns

does not seem like you are using those times ranges. so if you currently change those dates to 1990-01-01 to 1992-01-01 what happens? please post screen shot of that filter range

I got this

The problem is that if I have like the time range as I said from 1990 - 2021 and then on database a new year with a new field appears the time range will not display it and I need manually update this range.

When I’m saving the panel or dashboard, I got this option

ah ok, so it seems at one time you might have clicked that checkbox?

if you go into the json model of that dashboard what do you see here

  "time": {
    "from": "now-6h",
    "to": "now"
  },

No, when I go to the dashboard setting I have

  "time": {
    "from": "1990-01-01T00:00:00.000Z",
    "to": "2021-01-01T00:00:00.000Z"
  },

change 2021 to 3021. will you be using the timepicker to narrow down to specific date ranges?

Now my chart look like this

weird! well I guess we should not touch that. :joy:

not sure how to force it not to filter your data

Me neither, the only way I can change it is saving the year that I want to be my last one and then on my client side because I’m using embed iframe, I send a from= & to= with the lat year in milliseconds

what happens if you force the year in the query?

SELECT STR_TO_DATE(CONCAT(year, '-01-01'), '%Y-%m-%d') AS time, quantity AS 'Total GHG emissions without LULUCF including indirect CO₂'
FROM net4co2.annual_green_house_gas_data
WHERE category = 'TGIC'
and year between 1990 and 3021
ORDER BY time;

Nothing happens, this is very strange but its what I got and I’m gonna work with it.
Another thing its the date format, I want to display only the year but I’m unable to do that, unless I change this config, but this changes it for the entire system and not only for the dashboard.

1 Like