Skip to content

Feature request: support mid_value in color_scale for Excel-like diverging gradients #4

@MarekOzana

Description

@MarekOzana

First of all, thank you for building this library. Development seems to be moving fast, and I really appreciate the work — I’ve been enjoying streamlit-pivot a lot.

I’d like to suggest a small enhancement to color_scale:

Could it support an optional numeric mid_value (for example 0)?

My main use case is a PnL column where I want a continuous diverging scale like in Excel:

  • more negative values = darker red
  • 0 = white
  • more positive values = darker blue

What I’m looking for is not a threshold/banded rule, but a smooth gradient anchored at a meaningful midpoint.

Example:

rule = {
    "type": "color_scale",
    "apply_to": ["pnl"],
    "min_color": "#ff0000",
    "mid_color": "#ffffff",
    "max_color": "#0000ff",
    "mid_value": 0,
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions