Skip to content

fix: let a figure with its own selection follow the selections of other figures - #93

Open
jvdd wants to merge 3 commits into
mainfrom
fix/crossfilter-owner-refresh
Open

jvdd wants to merge 3 commits into
mainfrom
fix/crossfilter-owner-refresh

Conversation

@jvdd

@jvdd jvdd commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Fixes #80. In update mode, a figure with a cross-filter selection of its own is now filtered by the selections of the other figures, in any order. This is the model of crossfilter.js, Mosaic (Selection.crossfilter()), Superset (PR apache/superset#14046), Power BI and Qlik. Architecture.md already stated it: a figure is never filtered by its own selection, only by the selections of other figures.

The problem

Before this change, the data of a brush-owning figure depended on the event history, not on the state. Three figures A, B, C on ts, update mode, A brushed and then B brushed:

Step A shows
After B's brush unfiltered (A was skipped)
After a zoom on A filtered by B
After a restore of the same state (shared URL, import, flexvizApply) unfiltered

A switch from overlay to update mode also left the owners unfiltered.

Changes

  • Event field. InteractionEvent.selection_figure_uid names the figure whose selection changed. In update mode, the engine skips only that figure, because a figure's own selection never filters it. Every other figure is re-aggregated, also a figure with a selection of its own. An event without the field (a restore or a mode switch) re-aggregates every figure. Overlay mode is not changed: an owner shows only its unfiltered background.
  • Client. The five senders that change one figure's selection pass selection_figure_uid: brush, click, figure clear, summary remove and panel reset.
  • Cube commit. Cube targets skip every figure with a selection. So in update mode, a cube commit now sends its request when another figure has a selection (_fvCommitNeedsServer). Otherwise the owner is never refreshed.
  • Overlay background (second commit). In update mode, an owner's delta was also stored as its unfiltered overlay background, although other selections filtered it. isUnfilteredBaseForFigure now returns true only when no other figure has a selection. A zoom marks such a figure's old background stale. This was reachable before this PR (zoom an owner, then switch to overlay mode), and this PR makes it more frequent.
  • Architecture.md, the cross-filtering and live-brushing guides and CHANGELOG.md are updated.

Trade-offs

  • In update mode, the passive-keyed local cube commit no longer happens when another figure owns a selection. Each such commit sends one request. That request also re-aggregates the targets that the cube already drew. The live preview during the drag still comes from the cube. The local commit with foreign selections remains in overlay mode. A follow-up could make owners cube targets, with one extra passive key per owner.
  • During a live brush, an owner keeps its data. It updates when the mouse is released.
  • A click with a foreign selection in update mode no longer warms the cube, because its commit always posts.

Tests

  • Engine: TestEngineSelectionOwners covers the issue case, a cleared brush, a selection event without a changed figure, and the two overlay cases.
  • Integration: three tests encoded the old rule and are rewritten. test_selection_on_A_then_B_only_updates_C is now test_selection_on_A_then_B_updates_A_and_C. The rewritten tests check the filtered x range, not only that a delta exists.
  • Browser: TestSelectionOwnerBrowser covers a real second brush, a restore with two brushes, and the overlay background of a zoomed owner. Five cube tests expected the commit to stay local. They now check the commit request and the owner's data against a server reference.
  • The new tests fail on the old code. Engine and integration tests: 6 failed without the engine change. Browser: checked with the client code of main.
  • Non-browser suite: 2399 passed. Full browser suite: 304 passed, 9 skipped. The first commit alone: 2399 and 303 passed.

@jvdd

jvdd commented Sep 25, 2026

Copy link
Copy Markdown
Contributor Author

Not merging for now. #80 now describes the trade-off and its options. This PR is option B there and stays open as a reference. The two overlay-background fixes moved to #94.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update mode: a figure with its own selection does not follow other selections live (trade-off)

1 participant