# Dynamically change chart x-axis based on data

**URL:** <https://discourse.nodered.org/t/dynamically-change-chart-x-axis-based-on-data/15948>\
**Category:** Dashboard\
**Created:** [26 September 2019 12:57 UTC](https://discourse.nodered.org/t/dynamically-change-chart-x-axis-based-on-data/15948 "2019-09-26T12:57:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![davebanthorpe](https://avatars.discourse-cdn.com/v4/letter/d/ee7513/32.png) [@davebanthorpe](https://discourse.nodered.org/u/davebanthorpe)\
**Post date:** [26 September 2019 12:57 UTC](https://discourse.nodered.org/t/dynamically-change-chart-x-axis-based-on-data/15948/1 "2019-09-26T12:57:00Z")

</div>

Hi - I'm currently generating a line chart based on data returned from a mySQL query. Since I know what the timespan is for the data returned (due to the query) I want to dynamically change the x-axis timespan of the chart.

I've searched the forum and seen various similar articles but can't fathom out exactly what I need to do. I believe it can be done with a UI\_control node but don't know what message format and content to send to it to get the desired result.

How is this achieved?

-Dave

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [26 September 2019 14:24 UTC](https://discourse.nodered.org/t/dynamically-change-chart-x-axis-based-on-data/15948/2 "2019-09-26T14:24:04Z")

</div>

See the [options for the chart](https://github.com/node-red/node-red-dashboard/blob/master/config-fields.md).

"Dynamic"-x does not seem possible, other than inserting the data with the "dynamic" timeframe. [As per documentation](https://github.com/node-red/node-red-dashboard/blob/master/Charts.md)

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [26 September 2019 18:02 UTC](https://discourse.nodered.org/t/dynamically-change-chart-x-axis-based-on-data/15948/3 "2019-09-26T18:02:06Z")

</div>

Here is thread about how to change x-axis dynamically. Take it as a starting point, try to get some result and if stuck, share simple flow with small sample of your data. (we need to see the structure of data) Then we can deal with specific questions, what is possible and how to get it.

> [@Chart Variable Timeline X-Axis](https://discourse.nodered.org/t/chart-variable-timeline-x-axis/13945):
>
> Hello, I am wondering if anybody can help me find a solution to which allows me to dynamically change the length of time shown on a chart node? For example, I can change the y-axis min and max values with ui\_control, I'd like to be able to do the same with the x-axis, so that I can dynamically adjust if I want to see the trend of the last hour or just the last 5 minutes. This could possibly also be a zoom function. Alternatively, It could switch between displaying a fixed amount of time and bei…
