Skip to content

feat: aggregation grain selector for canvas (AggregationGrainSelector, grain in time_filters) - #10000

Merged
nishantmonu51 merged 1 commit into
mainfrom
nishant/canvas-grain-selector
Oct 13, 2026
Merged

nishantmonu51 merged 1 commit into
mainfrom
nishant/canvas-grain-selector

Conversation

@nishantmonu51

Copy link
Copy Markdown
Collaborator

Canvas had grain state and the grain URL param, but no way to set it once the new range picker became the default: the legacy pill segment that exposed it is gated on the old picker.

  • Extracts explore's "by Day ▾" chart toolbar dropdown into a shared AggregationGrainSelector and renders it in the canvas filter bar after the comparison pill. Options come from the current interval and the largest minimum grain, and selecting writes the existing grain URL param.
  • Shows the same control in the widget inspector. Its first item resets the widget's grain: "Inherit from canvas" when the range is inherited, "Default" when the widget has its own range.
  • time_filters now accepts grain on its own (grain=week keeps the canvas range and buckets that widget by week). A grain the canvas range cannot hold falls back to the canvas grain.
  • Widgets that set their own grain show a read-only "by Week" chip in their header next to the other local filter chips.
  • Hides the legacy pill grain segment on canvas so the old picker cannot show two controls.
  • Documents grain on the canvas data widgets page.

Checklist:

  • Covered by tests
  • Ran it and it works as intended
  • Reviewed the diff before requesting a review
  • Checked for unhandled edge cases
  • Linked the issues it closes
  • Checked if the docs need to be updated. If so, create a separate Linear DOCS issue
  • Intend to cherry-pick into the release branch
  • I'm proud of this work!

Extracts the explore "by Day" dropdown into AggregationGrainSelector and shows it in the canvas filter bar and the widget inspector. A widget can set grain on its own in time_filters, on top of the inherited canvas range, and shows it as a read-only chip in its header.
@nishantmonu51 nishantmonu51 added Type:Feature New feature request Area:Dashboard Size:M Medium change: 100-499 lines Area:Canvas Canvas dashboards labels Oct 10, 2026
@djbarnwal

Copy link
Copy Markdown
Member

The grain picker appears on widgets that don't use it

Leaderboards and maps show the new "by Day" dropdown in the inspector, and so do charts without a time axis. None of them use the grain, so picking "by Week" on a leaderboard leaves the data unchanged. It still saves grain=week to the YAML and marks the widget as having a local filter in its header. Could we hide the picker for those widgets?

The widget's grain stays when its time range goes back to the canvas

If a widget has its own range and grain, say last 24 hours by hour, and the user switches the range back to "Inherit from canvas," the hourly grain stays. On a 7-day canvas range, the widget keeps showing hourly data, though the user meant for it to follow the canvas. Existing YAML with a hand-written grain=day and no tr also changes behavior: that grain used to be ignored and is now applied. I'd suggest clearing the grain when the range is set back to inherit.

@nishantmonu51

Copy link
Copy Markdown
Collaborator Author

Thanks, both fixed.

The picker and header chip now check a usesTimeGrain(spec) method on the component: charts only with a temporal field, pivot/table/leaderboard/map never. Switching a widget's range back to inherit also deletes its grain.

A hand-written grain=day without tr is applied on purpose: that is the override this PR adds, and the docs describe it.

@nishantmonu51
nishantmonu51 merged commit 97ed867 into main Oct 13, 2026
18 of 19 checks passed
@nishantmonu51
nishantmonu51 deleted the nishant/canvas-grain-selector branch October 13, 2026 19:20
nishantmonu51 added a commit that referenced this pull request Oct 13, 2026
Resolves the overlap with the canvas grain selector (#10000): the adaptive option now lives in the shared AggregationGrainSelector as its default option, used by the explore chart toolbar and the canvas filter bar. The SuperPill no longer renders a grain selector for canvas.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area:Canvas Canvas dashboards Area:Dashboard Size:M Medium change: 100-499 lines Type:Feature New feature request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants