Color by field name

Hello,

I have the following query result and I would like to use the same color for every sensor in every blocks:

When I group the data only by ‘name’ I can achieve this, but all the blocks are merged.
I am using flux for query language.

Can you give me an idea how to move on?
Thank you!

What kind of visualization is that?

The built in TimeSeries.
Grafana version: 9.3.2

1 Like

Can you please share your Flux query?

Sure:

from(bucket: "v6")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "cp_channel")
  |> filter(fn: (r) => r["_field"] == "pMax")
  |> group(columns: ["block", "name"])
  |> yield(name: "mean")

Could you share what table(s) are produced by this query using Influx Data Explorer? Just wanting to get a better idea of the columns being returned by your query.

Here it is: https://file.io/WvD57jxYubr2

Not seeing anything in that link…

I hope this one works: Easyupload.io - Upload files for free and transfer big files easily.

Got it. Thanks. I am not able to throw this into my InfluxDB at the moment, but I did think of this…can you just change the color of each item on the legend to the same color? Just click on the colored bar in the legend and pick a color? Or is that not the issue? I suppose you could use Overrides in Grafana as well.
image

Yes, that was my first idea. But the number of the sensors are not fixed. I suppose there is a fixed number of colors in grafana, so that the first sensor always have the color A, the second one is B, etc. This is fine because each sensor position will have the same color. But when I use the extra tag ‘block’, this order can not be maintaned.

@grant2, Do you have any idea to move on?

Hi @danielvamos

Sorry for the delay. Does creating an Override like this help apply the color to each “block”? I guess this assumes all the values are being returned by the same Query A.

1 Like

Hello,

In your suggestion, I have only one series.
image

But for my only query called A has multiple series due to the number of tags used. Each of which as name field. How can I assign same color for each series where tag name ‘name’ has the same value?

Thank you!

What are the tag names?

Hello,

My goal is to provide a single color for each series where the name tag has the same value, as noted above.
For example: the value of the name tag: Series 1 occured in multiple series, but each series has different color due to the group() fulx function and the default nature of coloring in grafana.

Here are my tags:

Using multiple columns in group function, I can visually separate series of points belong to one common tag so that I need to keep this tag in group function. When I apply the group function only for name, the coloring is OK, but all line-segments are connected, which is not good for me.

Is there any override function to keep the line segments separated, but provide single color for a given series where name tags are the same?
Maybe:

  • fields returned by query
  • fields with names matching regex

But I cant make it work with none of these.
Thank you for your help!

Have you experimented with this to see if it helps to keep the line segments separated?
image

Hello!
There is no null value in my query result, so that this option does not have any effect. I am not using aggregate window either.

Any idea?

What does the above query look like when run in Influx Data Explorer with the toggle selected to show raw data? If you can also remove the |> group line from your query and share that screenshot as well, that will help me and others see the shape of your data being returned.

Here are the results:

Check the panel titles.

In the first picture, the line segments are OK due to block is involved to the group, but coloring is different for the same name.

In the second one, the coloring is OK, but segments are lost.