Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Color Definitions to ColorSchema Enum (HeatMap) (from #4283) #4306

Conversation

Nirus2000
Copy link
Member

@Nirus2000 Nirus2000 commented Oct 25, 2024

Add Color Definitions to ColorSchema Enum

  1. GREEN_YELLOW_RED: Green for gains, Red for losses, Yellow for neutral values.
  2. GREEN_WHITE_RED: Green for gains, White for neutral, Red for losses.
  3. GREEN_RED_GREY: Green for gains, Red for losses, Grey for neutral.
  4. BLUE_ORANGE_GREY: Blue for stable values, Orange for volatile values, Grey for neutral.
  5. BLACK_YELLOW_WHITE: Black for extreme gains, Yellow for moderate returns, White for neutral.

Sorry... Reopen this... i kill my fork :-(
#4283

@Nirus2000
Copy link
Member Author

Here an example in light and dark theme

grafik

@Nirus2000 Nirus2000 force-pushed the Add-Color-Definitions-to-ColorSchema-Enum branch from 4b16faa to 6e5e0a4 Compare November 10, 2024 18:59
Updated the YELLOW_WHITE_BLACK color schema to use the default background color from the theme, similar to the existing implementation in the GREEN_WHITE_RED schema.

Add Color Definitions to ColorSchema Enum

1. **GREEN_YELLOW_RED**: Green for gains, Red for losses, Yellow for neutral values.
2. **GREEN_WHITE_RED**: Green for gains, White for neutral, Red for losses.
3. **GREEN_RED_GREY**: Green for gains, Red for losses, Grey for neutral.
4. **BLUE_ORANGE_GREY**: Blue for stable values, Orange for volatile values, Grey for neutral.
5. **BLACK_YELLOW_WHITE**: Black for extreme gains, Yellow for moderate returns, White for neutral.

The colors are obtained from colors.java

Pull Request: Refactoring of the ColorSchema Enum Class

GREEN_RED_GREY has been renamed to GREEN_GRAY_RED
BLUE_ORANGE_GREY has been renamed to BLUE_GRAY_ORANGE
BLACK_YELLOW_WHITE has been renamed to YELLOW_WHITE_BLACK.

Updating Documentation

Update GREEN_WHITE_RED Color Schema and Improve Interpolation Method

Modified the GREEN_WHITE_RED color schema to interpolate with the default background color from the theme using Colors.theme().defaultBackground().getRGB(). This change improves visual appearance in dark themes and enhances overall UI consistency.

Updated the interpolate method to clamp the factor parameter between 0 and 1. This ensures that the method handles out-of-bounds values properly, preventing unexpected results and invalid RGB values.

Enhances the color interpolation logic

GREEN_WHITE_RED
Added a transition to yellow for performance values over 0.6, improving the gradient from green to yellow.

YELLOW_WHITE_BLACK
Implemented a transition from yellow to black for values above 0.6 for better visibility of high performance.

Optimize Color Normalization and Interpolation Logic

GREEN_WHITE_RED Color Schema:
Adjusted the transition to yellow to occur earlier (from 0.6 to 0.4), allowing for a smoother gradient.
Used -p for negative performance values to ensure a proper mapping to red.

Modified GREEN_GRAY_RED Color Schema:
Incorporated the use of -p to correctly interpolate colors for negative performance values.

Refined BLUE_GRAY_ORANGE Color Schema:
Updated the interpolation for negative performance values to use -p, enhancing color representation.
@Nirus2000 Nirus2000 force-pushed the Add-Color-Definitions-to-ColorSchema-Enum branch from 8b3507a to c4def80 Compare November 10, 2024 19:01
Comment on lines +66 to +67
color = Colors.interpolate(Colors.theme().defaultBackground().getRGB(), Colors.RED.getRGB(),
(float) -p);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By using -p all negative values will be white (= the color of the background) because the interpolate function clamps the value between 0 and 1 (and p is always between 0 and 1)

buchen pushed a commit that referenced this pull request Nov 29, 2024
1. **GREEN_YELLOW_RED**: Green for gains, Red for losses, Yellow for neutral values.
2. **GREEN_WHITE_RED**: Green for gains, White for neutral, Red for losses.
3. **GREEN_GRAY_RED**: Green for gains, Red for losses, Grey for neutral.
4. **BLUE_GRAY_ORANGE**: Blue for stable values, Orange for volatile values, Grey for neutral.
5. **BLACK_WHITE_YELLOW**: Black for extreme gains, Yellow for moderate returns, White for neutral.

Updated the interpolate method to clamp the factor parameter between
0 and 1. This ensures that the method handles out-of-bounds values
properly, preventing unexpected results and invalid RGB values.

Issue: #4306
buchen added a commit that referenced this pull request Nov 29, 2024
@buchen
Copy link
Member

buchen commented Nov 29, 2024

Merged.

I have refactored the creation of the gradients into a separate class. And used multiple color points in order to increase the fidelity of the colors (for example, always interpolating between green and gray makes the lighter greens "dirty"). See 7ea526e

@Nirus2000
The only thing I am not yet happy with is the "background -> yellow -> black" color schema. From my point of view, it does not work in dark mode. It becomes "black -> yellow -> black". Then it has a completely different meaning (color the outliers black) than in light mode.

We can:

  • make it always "white -> yellow -> black". But then it might not look good in dark mode

You had an example somewhere (but I cannot find it anymore). How do they handle dark/light mode?

@buchen buchen closed this Nov 29, 2024
@Nirus2000 Nirus2000 deleted the Add-Color-Definitions-to-ColorSchema-Enum branch November 29, 2024 14:15
@Nirus2000
Copy link
Member Author

Nirus2000 commented Nov 29, 2024

Hello @buchen
grafik

buchen added a commit that referenced this pull request Nov 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants