10000 Add `layout.subplots` to enable (x|y) hover effects across multiple cartesian and splom suplots sharing one axis by archmoj · Pull Request #6947 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Add layout.subplots to enable (x|y) hover effects across multiple cartesian and splom suplots sharing one axis #6947

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
revise attribute def
  • Loading branch information
archmoj committed Apr 5, 2024
commit fd867c33b2c3f08606aa26df197fe06c098fc877
2 changes: 1 addition & 1 deletion src/components/fx/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ function _hover(gd, evt, subplot, noHoverEvent, eventTarget) {
var hovermodeHasX = (hovermode || '').charAt(0) === 'x';
var hovermodeHasY = (hovermode || '').charAt(0) === 'y';

if(hoverthrough && hasCartesian && (hovermodeHasX || hovermodeHasY)) {
if(hasCartesian && (hovermodeHasX || hovermodeHasY) && hoverthrough === 'axis') {
var subplotsLength = subplots.length;
for(var p = 0; p < subplotsLength; p++) {
spId = subplots[p];
Expand Down
6 changes: 4 additions & 2 deletions src/components/fx/layout_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,13 @@ module.exports = {
].join(' ')
},
hoverthrough: {
valType: 'boolean',
valType: 'enumerated',
values: ['axis', false],
dflt: false,
editType: 'none',
description: [
'Determines expansion of hover effects to other subplots in case of sharing an axis.',
'Determines expansion of hover effects to other subplots',
'If *axis*, points from subplots linked to the axis of hovered subplot are included.',
'Has an effect only when `hovermode` is set to *x*, *x unified*, *y* or *y unified*.',
].join(' ')
},
Expand Down
2 changes: 1 addition & 1 deletion src/traces/splom/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function hoverPoints(pointData, xval, yval, hovermode, opts) {

var points = _hoverPoints(pointData, xpx, ypx);

if(opts.hoverthrough && (hovermodeHasX || hovermodeHasY)) {
if((hovermodeHasX || hovermodeHasY) && opts.hoverthrough === 'axis') {
var _xpx = points[0]._xpx;
var _ypx = points[0]._ypx;

Expand Down
18 changes: 9 additions & 9 deletions test/jasmine/tests/hover_label_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2380,12 +2380,12 @@ describe('hover info on stacked subplots', function() {
});
});

describe('hover on subplots when hoverthrough is set to true and x hovermodes', function() {
describe('hover on subplots when hoverthrough is set to *axis* and x hovermodes', function() {
'use strict';

var mock = {
layout: {
hoverthrough: true,
hoverthrough: 'axis',
hovermode: 'x',
grid: {
rows: 3,
Expand Down Expand Up @@ -2423,7 +2423,7 @@ describe('hover on subplots when hoverthrough is set to true and x hovermodes',

afterEach(destroyGraphDiv);

it('hovermode: *x* | *x unified* with hoverthrough: true', function() {
it('hovermode: *x* | *x unified* with hoverthrough: *axis*', function() {
var pos = 0;
var subplot = 'xy';
Lib.clearThrottle();
Expand Down Expand Up @@ -2468,12 +2468,12 @@ describe('hover on subplots when hoverthrough is set to true and x hovermodes',
});
});

describe('hover on subplots when hoverthrough is set to true and y hovermodes', function() {
describe('hover on subplots when hoverthrough is set to *axis* and y hovermodes', function() {
'use strict';

var mock = {
layout: {
hoverthrough: true,
hoverthrough: 'axis',
hovermode: 'y',
grid: {
rows: 2,
Expand Down Expand Up @@ -2511,7 +2511,7 @@ describe('hover on subplots when hoverthrough is set to true and y hovermodes',

afterEach(destroyGraphDiv);

it('hovermode: *y* | *y unified* with hoverthrough: true', function() {
it('hovermode: *y* | *y unified* with hoverthrough: *axis*', function() {
var pos = 0;
var subplot = 'xy';
Lib.clearThrottle();
Expand Down Expand Up @@ -2556,12 +2556,12 @@ describe('hover on subplots when hoverthrough is set to true and y hovermodes',
});
});

describe('splom hover on subplots when hoverthrough is set to true and (x|y) hovermodes', function() {
describe('splom hover on subplots when hoverthrough is set to *axis* and (x|y) hovermodes', function() {
'use strict';

var mock = Lib.extendDeep({}, splomLogMock);
mock.layout.hovermode = 'x';
mock.layout.hoverthrough = true;
mock.layout.hoverthrough = 'axis';

var gd;

Expand All @@ -2572,7 +2572,7 @@ describe('splom hover on subplots when hoverthrough is set to true and (x|y) hov

afterEach(destroyGraphDiv);

it('splom hoverthrough: true', function() {
it('splom hoverthrough: *axis*', function() {
Lib.clearThrottle();
Plotly.Fx.hover(gd, {x: 200, y: 200}, 'xy');
expect(gd._hoverdata.length).toBe(3);
Expand Down
8 changes: 6 additions & 2 deletions test/plot-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2635,10 +2635,14 @@
]
},
"hoverthrough": {
"description": "Determines expansion of hover effects to other subplots in case of sharing an axis. Has an effect only when `hovermode` is set to *x*, *x unified*, *y* or *y unified*.",
"description": "Determines expansion of hover effects to other subplots If *axis*, points from subplots linked to the axis of hovered subplot are included. Has an effect only when `hovermode` is set to *x*, *x unified*, *y* or *y unified*.",
"dflt": false,
"editType": "none",
"valType": "boolean"
"valType": "enumerated",
"values": [
"axis",
false
]
},
"images": {
"items": {
Expand Down
0