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

[Lens][ColorMapping] Auto Assignment breaks for gradient with 1 or more assignments #209164

Open
nickofthyme opened this issue Jan 31, 2025 · 2 comments · May be fixed by #207957
Open

[Lens][ColorMapping] Auto Assignment breaks for gradient with 1 or more assignments #209164

nickofthyme opened this issue Jan 31, 2025 · 2 comments · May be fixed by #207957
Assignees
Labels
bug Fixes for quality problems that affect the customer experience Feature:Lens Team:Visualizations Visualization editors, elastic-charts and infrastructure

Comments

@nickofthyme
Copy link
Contributor

Kibana version:

latest

Describe the bug:

When assigning a gradient palette to terms in a Lens chart using the new color mapping UI, assigning an auto assignment incorrectly caps the color loop at the number of auto assignments instead of the total assignments.

Zight.Recording.2025-01-31.at.01.14.12.PM.mp4

Steps to reproduce:

  1. Create a bar chart with a y metric and a breakdown by.
  2. Open the palette settings and select the new color mapping mode.
  3. Click the gradient option. Do not create an assignment yet.
  4. Notice the colors are correctly assigned.
  5. Add one assignment and leave it blank (i.e. auto assignment)
  6. Notice all series are colored the same, the first color.
  7. Now add another auto assignment.
  8. Notice the series are looping every other color.

Expected behavior:

Auto assignments should be colored correctly according to the defined gradient.

Any additional context:

This code is to blame...

const totalColorsIfGradient = assignments.length || notAssignedCategories.length;
const indexIfGradient =
(nonAssignedCategoryIndex - autoByOrderAssignments.length) % totalColorsIfGradient;

@nickofthyme nickofthyme added bug Fixes for quality problems that affect the customer experience Feature:Lens Team:Visualizations Visualization editors, elastic-charts and infrastructure labels Jan 31, 2025
@nickofthyme nickofthyme self-assigned this Jan 31, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-visualizations (Team:Visualizations)

@nickofthyme
Copy link
Contributor Author

After closer inspection I believe this is expected behavior.

Zight.Recording.2025-01-31.at.01.54.01.PM.mp4

There is however a major difference in how this Color for unassigned terms behavior works between the categorical mode and gradient mode. The main difference being that the number of assignment on the gradient mode determines the extent of the color scale. So in gradient mode, if you have 2 auto assignments with 4 categories/series in the chart, the scale will start looping after the 2nd color assignment. This is not the case with categorical palettes as their colors are predetermined.

I wonder if we can improve this behavior because it really feels like a bug.

What if we had a separate input to dictate the total steps of the steps in gradient. This could have an auto mode that updates to the number of assignments as it is now, or the user can change this to the desired count.

cc: @markov00 @MichaelMarcialis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Feature:Lens Team:Visualizations Visualization editors, elastic-charts and infrastructure
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants