Skip to content

feat: add legend.groupdoubleclick to set group behavior on double-click - #7997

Open
rascal-sl wants to merge 2 commits into
plotly:mainfrom
rascal-sl:legend-groupdoubleclick
Open

feat: add legend.groupdoubleclick to set group behavior on double-click#7997
rascal-sl wants to merge 2 commits into
plotly:mainfrom
rascal-sl:legend-groupdoubleclick

Conversation

@rascal-sl

Copy link
Copy Markdown

Summary

layout.legend.groupdoubleclick sets the group behavior for a legend double-click. A figure can now toggle a whole legendgroup on a single click and isolate one trace on a double click.

Closes #6812

Why this shape

handleItemClick read groupclick for every action, so a double click could not differ from a single click.

groupdoubleclick takes the coerced groupclick value as its default. A figure that omits the attribute keeps the current behavior.

The isolation path now honors the resolved group value. This corrects one existing case. With groupclick: 'toggleitem' and the default itemdoubleclick: 'toggleothers', a double click now isolates the clicked trace instead of its whole legendgroup. The old output contradicted the description of toggleitem, which toggles "the individual item clicked on the graph". I flag that correction here for your judgment.

groupclick still drives the draw-time branches in get_legend_data.js and draw.js. A draw cannot depend on a later click.

Tests

Suite: test/jasmine/tests/legend_test.js

npm run test-jasmine -- legend --nowatch

Result on my machine, Chrome 151: TOTAL: 128 SUCCESS.

New specs:

  • legend defaults - groupdoubleclick follows groupclick, and it also coerces on its own
  • legend interaction - legendgroup visibility case of groupdoubleclick: "toggleitem", one spec for the double click and one for the single click

I put the old isolation line back and ran the suite again. That run reported TOTAL: 1 FAILED, 127 SUCCESS, so the new spec covers the change.

No new mock, and no baseline moves. The attribute changes no drawn output before a user double-clicks.

Rendered check

I loaded the local bundle and compared two figures that hold the same four traces. Trace 1 and trace 3 share legendgroup: 'foo'. Trace 0 is visible: false.

Figure visible after a double click on trace 3
default [false, true, "legendonly", true]
groupdoubleclick: 'toggleitem' [false, "legendonly", "legendonly", true]

The two figures render the same before the double click. A second double click restores [false, true, true, true].

Checks

Command Result
npm run lint pass
npm run typecheck pass
npm run test-syntax pass
npm run schema-typegen-diff-check pass

Note

traceIndicesInGroup in handle_click.js takes a value that no line reads. That predates this change, so I left it alone.

🐦


Tisankan Jeyakumar
Developed and verified

handleItemClick read groupclick for every action, so a double click could
not differ from a single click. A figure could not keep togglegroup on a
single click and isolate one trace on a double click.

groupdoubleclick takes the coerced groupclick value as its default, so a
figure that omits the attribute keeps the current behavior. The isolation
path now honors the resolved group value, which corrects the case where
groupclick is toggleitem and the double click still isolated a whole
legendgroup.

Closes plotly#6812
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.

add 'toggleitem' for layout.legend.groupdoubleclick

1 participant