Skip to content

Commit a25a6b0

Browse files
committed
fix: serialization of box/lasso select data for multiple subplots
1 parent a5974ce commit a25a6b0

3 files changed

Lines changed: 43 additions & 37 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
88
- Fix `hex_to_rgb` parsing of 3-digit shorthand hexadecimal colors such as `#FFF` [[#5662](https://github.com/plotly/plotly.py/pull/5662)], with thanks to @genrichez for the contribution!
99
- Add `<!doctype html>` to the `to_html()` template to comply with modern web standards [[#5693](https://github.com/plotly/plotly.py/pull/5693)], with thanks to @mishrakushal for the contribution!
1010
- Fix `mpl_to_plotly` silently dropping matplotlib path collections in data coordinates (such as violin plots, pcolor, event plots, stack plots, fill_between, and stem plots) by rendering them as filled polygons or lines [[#5702](https://github.com/plotly/plotly.py/pull/5702)], with thanks to @robertoffmoura for the contribution!
11-
11+
- Fix serialization of box/lasso select data for multiple subplots
1212

1313
## [6.9.0] - 2026-07-09
1414

js/src/widget.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,7 @@ type Py2JsUpdateMsg = Py2JsMsg & {
109109

110110
type Selector = {
111111
type: "box" | "lasso";
112-
selector_state:
113-
| { xrange: number[]; yrange: number[] }
114-
| { xs: number[]; ys: number[] };
112+
selector_state: Record<string, any>;
115113
};
116114

117115
// Model
@@ -1149,22 +1147,30 @@ export class FigureView {
11491147
var selectorObject: Selector;
11501148

11511149
if (data.hasOwnProperty("range")) {
1152-
// Box selection
1150+
// Box selection - preserve all subplot-specific axis keys (x, x2, x3, ... and y, y2, y3, ...)
1151+
var rangeData = data["range"];
1152+
// Verify we have at least an x and y range (in any subplot)
1153+
var hasXRange = Object.keys(rangeData || {}).some((key: string) => /^x\d*$/.test(key));
1154+
var hasYRange = Object.keys(rangeData || {}).some((key: string) => /^y\d*$/.test(key));
1155+
if (!hasXRange || !hasYRange) {
1156+
return null;
1157+
}
11531158
selectorObject = {
11541159
type: "box",
1155-
selector_state: {
1156-
xrange: data["range"]["x"],
1157-
yrange: data["range"]["y"],
1158-
},
1160+
selector_state: rangeData,
11591161
};
11601162
} else if (data.hasOwnProperty("lassoPoints")) {
1161-
// Lasso selection
1163+
// Lasso selection - preserve all subplot-specific axis keys
1164+
var lassoData = data["lassoPoints"];
1165+
// Verify we have at least an x and y coordinate array (in any subplot)
1166+
var hasXCoords = Object.keys(lassoData || {}).some((key: string) => /^x\d*$/.test(key));
1167+
var hasYCoords = Object.keys(lassoData || {}).some((key: string) => /^y\d*$/.test(key));
1168+
if (!hasXCoords || !hasYCoords) {
1169+
return null;
1170+
}
11621171
selectorObject = {
11631172
type: "lasso",
1164-
selector_state: {
1165-
xs: data["lassoPoints"]["x"],
1166-
ys: data["lassoPoints"]["y"],
1167-
},
1173+
selector_state: lassoData,
11681174
};
11691175
} else {
11701176
selectorObject = null;

plotly/package_data/widgetbundle.js

Lines changed: 23 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)