Skip to content

Double-click a legend item to isolate that group in every chart #158

Open

Description

@jvdd

Need

A user compares about 100 process runs (#88). Several charts show one line per run, for example pressure and temperature. The user wants to double-click one run in a legend and then see only that run in every chart, not only in the chart that they clicked.

Current state

  • Each figure is its own Plotly graph with Plotly's default legend. A click hides or shows one trace, and a double-click isolates one trace, inside that figure only.
  • legendVisibilityByUid (flexviz/adapters/js/plotly/traces.js) keeps the visibility of each trace across re-renders, keyed by logical uid. A grouped child's uid derives from its parent uid and its group value (_child_uid_for_group, flexviz/trace/base.py), so the same run has a different uid in each figure.
  • Colors already agree across figures. Grouped traces with the same source and group_by share params.group_domain_key ("{source}::{group_by}", flexviz/trace/base.py). ensureGroupColor (flexviz/adapters/js/runtime/delta.js) stores one color per group value in the client-owned state.group_domains. Each grouped child result carries its group_value_key.

What is needed

  1. Identity. A legend item is the pair (group_domain_key, group_value_key). Items with the same pair in other figures are the same group.
  2. Shared runtime. Keep the linked visibility on the client, keyed by that pair, like legendVisibilityByUid. It is interaction state, so the server does not need it.
  3. Plotly adapter. Handle plotly_legenddoubleclick in flexviz/adapters/js/plotly/init.js. Apply the visibility to every figure that has the pair, behind the programmatic-update guard, and return false to stop Plotly's own per-figure toggle. Ungrouped traces keep Plotly's default behavior.
  4. Decisions.
    • Link a single click (hide one run) too, or only the double-click (isolate one run)?
    • Always on for grouped traces that share a group_domain_key, or opt-in on Dashboard, like link_axes?
    • A second double-click shows all groups again, in every figure.
  5. Readback. Decide whether window.flexvizState() reports the hidden groups, so that an agent sees which run the user isolated.
  6. Tests. A browser test with two figures grouped by the same column: a double-click on one legend item leaves only that group in both figures, and a second double-click shows all groups again. A zoom or a selection after the double-click keeps the isolation.

Activity

  1. added
    enhancement
    on Oct 8, 2026
  2. richjli commented on Oct 14, 2026

    @richjli

    Is it feasible to implement a shared legend across multiple stacked Plotly figures such that there's one legend instead of a legend for each separate plot? I would like to approximate Plotly faceting feature, which looks something like this:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions