Default datetime formatting to weekday possible?

Dear all,

i’m monitoring my energy consumption per day, which looks like this:

I would like to display the day of the week on the x-axis like “Monday Tuesday” etc.
Is this possible?

Currently i am transforming my time to a string and chose as unit “Datetime default”

This is how my table looks:

Here are my queries and transformations:


Thanks!
Florian

The timeseries plugin is designed to use time on the x axis, and I don’t know how or even if you can aggregate many time stamps into “buckets” arranged by day of the week.

But the bar chart can use any arbitrary string on the x axis to do just this. If you could get you data to fit thaat data model, then I think this is possible

As I upgraded my Grafana from 8.3.3 to 8.4.1, it understood the timestamp without converting it to a string and then overriding the unit to DateTime.
With this change, each bar got a label like “12/02 00:01”, which already was acceptable for me.

After looking in the grafana.ini, i found out that it automatically uses the format interval_hour = MM/DD HH:mm. Sadly I did not find out, how to change the bar chart to use another format.

So i chose a not-so-elegant approach and just changed the format in the config to interval_hour = dddd which displays the week day (src: momentjs.com). Since no other graph uses this format in my dashboards, this was an OK solution.

This is the final result:

And also thanks for the hint with template variables!

Greetings,
Florian

2 Likes

Thanks, this helped me to get started with the same issue, but I found another solution based on the latest Grafana (9.3.2) without changing the global config, just for reference.

btw used spread function to simplify the query:

import “timezone”
option location = timezone.location(name: “Europe/Berlin”)
from(bucket: “OpenHab”)
|> range(start: -1w)
|> filter(fn: (r) => r[“_measurement”] == “kWH_Total”)
|> aggregateWindow(every: 1d, fn: spread)

With the data in place I used Override function to reformat the Y axis to days:
Override fields with Name = Time
Standard options > Unit = time:dddd (needed to copy paste this as auto completion would kill it otherwise)

Hello and thanks!

Indeed we just need to override the unit with time:dddd without modifying any config file or environment variable.

This also works with older Grafana 8.4.1.

hello, sorry, but I didn’t get it to work in the time series, is it possible there?

What do you mean? Does the formatting Override of the time unit not work?