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] Color mappings MVP #155037

Closed
markov00 opened this issue Apr 17, 2023 · 1 comment · Fixed by #162389
Closed

[Lens] Color mappings MVP #155037

markov00 opened this issue Apr 17, 2023 · 1 comment · Fixed by #162389
Assignees
Labels
enhancement New value added to drive a business result Feature:Lens impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. Meta Team:Visualizations Visualization editors, elastic-charts and infrastructure

Comments

@markov00
Copy link
Member

markov00 commented Apr 17, 2023

First MVP to introduce minimal color mappings configuration.

1. Scalable color mapping data model

The association between a color and a dimension
The dimension specification (is a plain category, a range, a formula, a regex, a series)
The theme that was used when the color was selected (allows us to understand when to compute a different color if the theme change)
The color should be linked to the original palette if it exists. If a palette changes color, then this should be reflected here.
Discrete/Continuous gradients can be defined and accessed
Custom color values can be stored

Reason: better to prepare a scalable/extensible data model to avoid breaking changes/migration when we add new features.

2. Saved automatically locally within the visualization

There is no need to add a CRUD experience for now because I feel this could be shaped differently in the future (see my notes at the end)

Reason: As the first step let’s first allow users to do the color-mapping association and then, subsequently we can enable them to reuse these associations. It simplifies the UX because you don’t have to deal with CRUD, give another naming/description to the palette/mapping/association and you can probably also just “copy from visualization” paradigm in the future

3. Ability to select and assign colors from our pre-built palettes as a primary choice

This should be the default and easier way to pick a color.
It should provide both palette colors and neutral colors too.

Reason: making it the primary and easier way to select a color gives us a bit of control over the quality of the chosen color

4. Ability to select a custom color with a hex/color picker

This should be available as a second/optional choice if the color you are looking for is not available in the pre-built palettes

Reason: is an escape hatch and allows users to select the colors they prefer with no limitation

5. Assignments

Associate color with a range
Associate one or more categories to a single color

Reason: will cover 2 out of 3 major use cases of color assignment. Associate a color gradient to a value is the 3rd major case that is already partially covered in some visualization.

6. Color contrast checks

We should warn (not block) the user from selecting colors with low contrast with the current theme background. Giving a justified, non-blocking, reason is enough to let them make a reasoned choice.
It’s hard to really detect the perfect contrast because it usually depends on the shape and the dimension where the color is applied (small/thin objects could appear less contrasty than bigger ones even with the same color, similar if we talk about colors).

Reason: Giving the ability to pick random colors, we ethically must provide a simple way to notify that the color is not optimal.

7. Theme-contrast checks

A color is chosen using the current theme background. A mechanism needs to be in place to compute the correct alternative color when rendering the chart in a theme different from the one where the color was chosen.
If the user selects a color in a light theme and then switch the theme, the auto-computed color should show up as “auto” computed and the user is able to change it to a static value.

Reason: This gives us the ability to introduce the “per-theme” color choice that will fix future tech debts accumulated due to single-themed color choices. It will not be perfect at the moment because it lacks a preview, but we can build that in a subsequent stage.

8. Palettes and gradients

For this MVP we can keep the gradient generation out and just define gradients as existing palettes. Each gradient palette will adapt itself to the number of ranges/category available.

Reason: simplify the current UX. Each gradient is defined in the model not as a palette, but as a real gradient. This will allow us to move the gradient palettes in the future

Linked GH issues:

@markov00 markov00 added Meta enhancement New value added to drive a business result Team:Visualizations Visualization editors, elastic-charts and infrastructure labels Apr 17, 2023
@elasticmachine
Copy link
Contributor

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

@markov00 markov00 changed the title [Lens][meta] Color mappings MVP [Lens] Color mappings MVP Apr 17, 2023
@markov00 markov00 self-assigned this Apr 17, 2023
@stratoula stratoula added the impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. label Jun 1, 2023
markov00 added a commit that referenced this issue Sep 28, 2023
## Summary

This PR introduces the new color mapping feature into Lens.

The color mapping feature is introduced as a standalone sharable
component available from `@kbn/coloring`. The
[README.md](https://github.com/elastic/kibana/blob/ddd216457d66912de43c7688ae99044c2c34bbd2/packages/kbn-coloring/src/shared_components/color_mapping/README.md)
file describes the components and the logic behind it.

The Color Mapping component is also connected to Lens and is available
in the following charts:
- XY (you can specify the mappings from a breakdown dimension
- Partition (you can specify the mappings from the main slice/group by
dimension)
- Tag cloud (you can specify the mappings from the tags dimension)

This MVP feature will be released under the Tech Preview flag.
This PR needs to prove the user experience and the ease of use. UI
styles, design improvements and embellishments will be released in
subsequent PRs.

The current MVP-provided palettes are just a placeholder. I'm
coordinating with @gvnmagni for a final set of palettes.

close #155037
close #6480
fix #28618
fix #96044
fix #101942
fix #112839
fix #116634


## Release note

This feature introduces the ability to change and map colors to break
down dimensions in Lens. The feature provides an improved way to specify
colors and their association with categories by giving the user a
predefined set of color choices
or customized one that drives the user toward a correct color selection.
It provides ways to pick new colors and generate gradients. 
This feature is in Tech Preview and is enabled by default on every new
visualization but can be turned off at will.

![image](https://github.com/elastic/kibana/assets/1421091/d03e59f8-4a6f-4761-ab4c-c53a57c1723a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New value added to drive a business result Feature:Lens impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. Meta Team:Visualizations Visualization editors, elastic-charts and infrastructure
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants