# Grafana custom time range for custom Graph Panel

**URL:** <https://community.grafana.com/t/grafana-custom-time-range-for-custom-graph-panel/44885>\
**Category:** Time Series Panel\
**Created:** [March 22, 2021, 10:05am UTC](https://community.grafana.com/t/grafana-custom-time-range-for-custom-graph-panel/44885 "2021-03-22T10:05:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![asieroyan](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@asieroyan](https://community.grafana.com/u/asieroyan)\
**Post date:** [March 22, 2021, 10:05am UTC](https://community.grafana.com/t/grafana-custom-time-range-for-custom-graph-panel/44885/1 "2021-03-22T10:05:33Z")

</div>

Hello,

I have a custom Graph panel which takes the data from the PostgreSQL datasource and processes it in an external server before plotting it. The new data is from the future, and I would like to have a dashboard with a graph filled with the actual data with the dashboard time range (now - now-90d) and my custom graph with a future time range (i.e. now - now+30d).

Possible solutions I’ve already tried:  
**1. Add a relative time in the PostgreSQL Datasource query options** : This solution seemed to be the one, but I need to take past data from the DB, so although the custom graph was correctly showing the future time range, no data was being queried and therefore no data was being processed.

**2. Editing graph.ts and module.ts in custom graph plugin** : I’ve been trying to set a manual time range in the code in order to get it set in the custom graph, but every change I’ve been making in methods buildFlotOptions(), addTimeAxis() and addXSeriesAxis() have no effect in the plot, it still takes the dashboard time range.

**3. Longer dashboard time range** : Setting the dashboard time range to now-90d - now+30d shows all the data I want, but the last 30d of the first graph and the first 90d of the second one are empty.

now-90d - now+30d time range display:  
 ![github-request](https://user-images.githubusercontent.com/48553789/111974611-dd5bb300-8aff-11eb-8d23-cb4c6bc3cea7.png)

Thank you for your help.

---

<div class="post-metadata">

**Author:** ![asieroyan](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@asieroyan](https://community.grafana.com/u/asieroyan)\
**Post date:** [March 30, 2021, 7:43am UTC](https://community.grafana.com/t/grafana-custom-time-range-for-custom-graph-panel/44885/2 "2021-03-30T07:43:52Z")

</div>

Solved! All I had to do is modify addTimeAxis() function as I mentioned in the second possible solution (I had an import problem, that’s why I couldn’t see its changes).

I modified ‘min’ and ‘max’ variables there before they were sent to the panels options and it’s all working now.

---

<div class="post-metadata">

**Author:** ![z1198476521](https://avatars.discourse-cdn.com/v4/letter/z/9e8a1a/32.png) [@z1198476521](https://community.grafana.com/u/z1198476521)\
**Post date:** [May 31, 2023, 9:31am UTC](https://community.grafana.com/t/grafana-custom-time-range-for-custom-graph-panel/44885/3 "2023-05-31T09:31:32Z")

</div>

> [@asieroyan](#):
>
> addTimeAxis

hello，can u show your code and the difference on the graph

---

<div class="post-metadata">

**Author:** ![z1198476521](https://avatars.discourse-cdn.com/v4/letter/z/9e8a1a/32.png) [@z1198476521](https://community.grafana.com/u/z1198476521)\
**Post date:** [May 31, 2023, 9:34am UTC](https://community.grafana.com/t/grafana-custom-time-range-for-custom-graph-panel/44885/4 "2023-05-31T09:34:43Z")

</div>

If you modify the function, all the panel min\max will hard code?
