Skip to content

[Lens] Gradient colors for numeric table cells based on palette #68428

@wylieconlon

Description

@wylieconlon

This issue describes how Lens should support gradient colors, which some visualizations will use instead of or in addition to categorical color functions. The main use cases for this type of coloring is conditional styling of table columns, but should also be supported by the pie/treemap charts.

Example of a "blues" gradient which shows CPU usage linearly from the lowest recorded value to the highest recorded value:

Screenshot 2020-06-04 17 31 37

The simplest gradient color function takes a number from 0 to 1 and returns a color definition. This gives users two choices: defining the colors and converting to a value from 0 to 1

Defining the colors

To choose colors, users will either use a predefined gradient or choose their own color stops.

Screenshot 2020-06-05 13 52 29

For any predefined gradient, such as these EUI gradients, users should also be provided with extra form options for:

  • Using reverse order
  • Use continuous gradient or a fixed number of steps (also how many steps)

For defining a custom gradient, users will use the EUI color stops component.

Screenshot 2020-06-05 13 53 59 Screenshot 2020-06-05 13 54 05

When using custom gradients, users should also have a switch between "continuous" and "fixed steps".

Finally, an important toggle in the custom color gradient is to switch between "percentage" and "absolute" mode: this will make it easier in some use cases to define non-linear color gradients. For example, this would make sense when showing response times in MS.

Converting to a percentage

To calculate the color, we convert the raw value to a percentage. Imagine that all of our numbers represent the response time in MS. There are still multiple ways of converting this to a percent:

  • The user just wants the least configuration, so they set the min and max to "automatic". For this example, it will be from 60ms to 3,000ms. This will change each time it's rendered.
  • The user is unhappy with the constantly changing scale, so they set a lower and upper bound in terms of their data. For example, the color scale now goes from 0 to 10,000.
  • Finally, the user wants to make the color even more obvious, so they use a custom color gradient with numeric stops to set a stop at 100ms and 1000ms- anything below 100 is green, and anything above 1000 is red.

This leads to three types of conversion:

  • Use the lowest or highest value in the data
  • Use a fixed number typed by the user
  • Use a stop-based approach like we do for colors

Putting it all together

I like the way the Infrastructure monitoring app in Kibana has put it together, so I'm going to leave this as inspiration. It includes many of the elements that I've described above.

The biggest missing feature in the infrastructure monitoring app is the ability to define a custom gradient.

Screenshot 2020-06-05 13 42 04

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature:LensTeam:VisualizationsTeam label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t//enhancementNew value added to drive a business result

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions