Skip to content

Canvas heatmap: add normalize option for row/column percentage normalization #9130

Description

@jklaise

Problem
There's no way to display a heatmap where cell values are normalised as a percentage of their row or column total in a way that responds to filters. The workaround of pre-computing percentages in a SQL model breaks reactivity - when a user applies a dimension filter, the denominator was computed before the filter, so cells can exceed 100%. Window functions referencing dimension columns are also explicitly disallowed in measure expressions (#4103).

Proposed solution

Add a normalize option to the heatmap canvas component:

- heatmap:
    metrics_view: my_metrics
    normalize: rows        # or: columns, none (default)
    x:
      field: category
      type: nominal
    y:
      field: region
      type: nominal
    color:
      field: event_count
      type: quantitative

When set, Rill fetches raw measure values and computes each cell's percentage of its row (or column) total client-side, after filters are applied. This is purely a chart-layer transform - no changes to the metrics view or model layer needed.

Prior art

stacked_bar_normalized already implements percentage normalization at the chart layer (#6740) - this is the same concept applied to heatmaps. Vega-Lite's joinaggregate transform also handles this natively post-fetch.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions