How to place the field name under each bar in a bar chart visualization?

Grafana v11.1.4 (2355de00c6) (running inside a docker container)

I would like instead of using the x axis for the time to place the field name below each corresponding bar. So that the user can automatically recognize which bar is for which sensor value.

Right now my Bar chart looks like this:


Instead of the time I would like to place the names of the Values (BME280_Humidity, BME280_pressure and BME280_Temperature) below the corresponding bars.

This is how my flux query looks like:

from(bucket: "sischamo")
  |> range(start: v.timeRangeStart, stop:v.timeRangeStop)
  |> filter(fn: (r) => r._measurement == "sensor_data")
  |> filter(fn: (r) => r._field == "BME280_Humidity" or r._field == "BME280_Pressure" or r._field == "BME280_Temperature")
  |> first()
  |> drop(columns: ["_start", "_stop", "_measurement", "type", "nav_status"])
  |> pivot(rowKey: ["_time"], columnKey: ["_field"], valueColumn: "_value")

This is how my query table looks like:

I would appriciate any help.

Check out the play.grafan.org demo:

https://play.grafana.org/d/barchart-label-rotation-skipping/barchart-label-rotation-and-skipping

i see you are pivoting to a single row with multiple columns, but the examples show the labels as a column value from each row…

I also tried to order all fields as rows but unfortunately if I do this with flux and pivot() I get this table:

How can I fix this with flux or with a transformation?

try a concatenate transformation to join the multiple results?

How does your table looks like without ‘pivot’ line.
Can you paste screen print from that, thanks

This is the data table without pivot:

@shyney7
I am afraid with that table structure i don’t think it will be possible.

closest i could get is something like this.

image 1


image 2

This is exactly what I want. How have you done it?

For that I think you will need to sacrifice/drop your ‘_time’ column (at the end of your query) above the yield field. Otherwise it’s not going to work.

See my table structure it doesn’t show the ‘headers’ but the values from the rows.
Maybe you can map another column “sensor type” with value/name of your headers “ BME280_Humidity” etc and after that you can use pivot