grafana icon indicating copy to clipboard operation
grafana copied to clipboard

Dashboard: Bidirectional colour gradients

Open Bobblybook opened this issue 2 years ago • 2 comments

What is this feature? Adds bidirectional, mirrored colour gradients of the existing continuous gradients. These allow gradient mapping in both directions away from a center value, eg. above and below zero, or centered around a mean, etc.

Why do we need this feature? The current, single-direction gradients cannot be used for mapping deviation from a central point.

Who is this feature for? As mentioned, anyone trying to map deviation from a central value, with gradient scaling away in both directions. A real use-case which I ran into myself, which prompted me to submit this: https://community.grafana.com/t/gradient-value-mapping-centered-around-zero/76397

Notes Compiled and tested by me on 9.2.5 and it works fine. Straightforward code, just mirrored gradients added to the list. Can be renamed if needed.

Bobblybook avatar Nov 22 '22 12:11 Bobblybook

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Nov 22 '22 12:11 CLAassistant

Could someone please have a look at this, or let me know what needs to be done to get it approved for merging? Thanks

Bobblybook avatar Dec 02 '22 08:12 Bobblybook

Hey @Bobblybook , thanks for contributing to Grafana! 👋🏾

I was trying to reproduce your use case and the changes from this PR locally, but I think I am not getting the expected behavior 😅 , could you please share your dashboard JSON? I read the community post and used the test data, but I think I'm not fully understanding the main goal of the PR.

My failed attempt:

image

Thank you 🙏🏾

Steps to share Dashboard Json

Click the Share Dashboard Icon image

Click on Export, and Click on Export for sharing externally image

Click View JSON and then Copy it to Clipboard image

axelavargas avatar Dec 21 '22 12:12 axelavargas

Hi, thanks for taking a look at this :)

Sorry, I think perhaps the sample data is confusing.

Col 1 are labels, Col 2 are graphed values. Col 3 is potentially not necessary - it's just the absolute value of col 2. I was using it for colouring purposes in the "color by field" setting and it should NOT be graphed as values. I forgot to add a title row in the sample csv data, so I've done that in the below dashboard.

From your failed version, all you should probably need to do is set the "Color by field" to the third column, which will remove it as a data column and instead use the absolute value for coloration purposes.

Here is a pretty minimalist dashboard which demonstrates the intended behaviour: https://pastebin.com/raw/fPzpmCLX

Also an image: grafana

You can see that the colour gradient progresses in both directions from the centre point (in this case it's 0, but it might be a mean or similar sort of central value from which you would want to measure deviation). I've been unable to produce this sort of graph with the current release version of grafana, without my gradients compiled.

Bobblybook avatar Dec 21 '22 13:12 Bobblybook

note that this solution requires manually setting axis limits (hard or soft) around the center point. in the case of the drmo dashboard they are soft limits, so if the data exceeds them thr gradiant will no longer be centered and will diverge/mirror from another point.

for this to be a bit more explicit/stable it feels like we should have a "diverging" toggle that affects both the axis range and centers the desired number and properly generates the color gradient on demand. this way we dont need to maintain two copies of each scheme and proper rendering doesnt require explicit and stable hard/soft limits. we have a setting called "centeredZero" that works a bit like this but without the color scale regen.

leeoniya avatar Dec 22 '22 12:12 leeoniya

note that this solution requires manually setting axis limits (hard or soft) around the center point. in the case of the drmo dashboard they are soft limits, so if the data exceeds them thr gradiant will no longer be centered and will diverge/mirror from another point.

for this to be a bit more explicit/stable it feels like we should have a "diverging" toggle that affects both the axis range and centers the desired number and properly generates the color gradient on demand. this way we dont need to maintain two copies of each scheme and proper rendering doesnt require explicit and stable hard/soft limits. we have a setting called "centeredZero" that works a bit like this but without the color scale regen.

I agree, and yes it does require manual centering to ensure the gradient works. I think a dynamic approach to generating mirrored gradients around a center point would be the most flexible, and it would also avoid bloating the gradient list with what are otherwise just duplicates of the current gradients. However I don't know enough about the grafana code to write that up without making a mess, so this was a simple solution that I initially came up with.

Bobblybook avatar Dec 22 '22 13:12 Bobblybook

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 2 weeks if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

grafanabot avatar Jan 22 '23 02:01 grafanabot

Hi - Any new updates or decisions made about this?😀

Bobblybook avatar Jan 22 '23 04:01 Bobblybook

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 2 weeks if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

grafanabot avatar Feb 22 '23 02:02 grafanabot

@torkelo @leeoniya any more pointers here?

natellium avatar Mar 06 '23 09:03 natellium

Hi @Bobblybook, thanks for this contribution! I have included this PR on our squads grooming review list - once reviewed we will provide an update on how we will proceed with this PR / feature request.

nmarrs avatar Mar 09 '23 21:03 nmarrs

Hi @Bobblybook, thanks for this contribution! I have included this PR on our squads grooming review list - once reviewed we will provide an update on how we will proceed with this PR / feature request.

Great thanks, I'll keep a watch on this and wait for any updates.

Bobblybook avatar Mar 12 '23 04:03 Bobblybook

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 2 weeks if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

grafanabot avatar Apr 12 '23 01:04 grafanabot

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 2 weeks if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

grafanabot avatar May 14 '23 01:05 grafanabot

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 2 weeks if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

grafanabot avatar Jun 14 '23 02:06 grafanabot

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 2 weeks if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

github-actions[bot] avatar Jul 28 '23 01:07 github-actions[bot]

This pull request has been automatically closed because it has not had activity in the last 2 weeks. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

github-actions[bot] avatar Aug 12 '23 01:08 github-actions[bot]