Skip to content

Commit 5b75e18

Browse files
committed
fixes
1 parent 3dd1589 commit 5b75e18

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

‎frontend/src/plugins/impl/plotly/__tests__/usePlotlyLayout.test.ts‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ function createFigure(layoutOverrides: Partial<Plotly.Layout> = {}): Figure {
1313
return {
1414
data: [],
1515
layout: { ...layoutOverrides } as Plotly.Layout,
16+
frames: null,
1617
};
1718
}
1819

@@ -74,14 +75,14 @@ describe("computeLayoutOnFigureChange", () => {
7475

7576
describe("computeOmitKeys", () => {
7677
it("omits user-interaction keys unless they changed in figure", () => {
77-
const unchanged = computeOmitKeys({} as Plotly.Layout, {} as Plotly.Layout);
78+
const unchanged = computeOmitKeys({}, {});
7879
expect([...unchanged]).toEqual(
7980
expect.arrayContaining(["autosize", "dragmode", "xaxis", "yaxis"]),
8081
);
8182

8283
const changed = computeOmitKeys(
83-
{ dragmode: "zoom", xaxis: { range: [0, 10] } } as Plotly.Layout,
84-
{ dragmode: "select", xaxis: { range: [0, 5] } } as Plotly.Layout,
84+
{ dragmode: "zoom", xaxis: { range: [0, 10] } },
85+
{ dragmode: "select", xaxis: { range: [0, 5] } },
8586
);
8687
expect(changed.has("dragmode")).toBe(false);
8788
expect(changed.has("xaxis")).toBe(false);
@@ -93,8 +94,8 @@ describe("computeLayoutUpdate", () => {
9394
it("merges figure layout while respecting omit keys", () => {
9495
// dragmode unchanged in figure -> preserve prev layout's dragmode
9596
const result1 = computeLayoutUpdate(
96-
{ dragmode: "pan", title: { text: "New" } } as Plotly.Layout,
97-
{ dragmode: "pan" } as Plotly.Layout,
97+
{ dragmode: "pan", title: { text: "New" } },
98+
{ dragmode: "pan" },
9899
{ dragmode: "zoom", height: 400 },
99100
);
100101
expect(result1.dragmode).toBe("zoom");
@@ -103,8 +104,8 @@ describe("computeLayoutUpdate", () => {
103104

104105
// dragmode changed in figure -> use figure's dragmode
105106
const result2 = computeLayoutUpdate(
106-
{ dragmode: "pan" } as Plotly.Layout,
107-
{ dragmode: "select" } as Plotly.Layout,
107+
{ dragmode: "pan" },
108+
{ dragmode: "select" },
108109
{ dragmode: "zoom" },
109110
);
110111
expect(result2.dragmode).toBe("pan");

‎frontend/src/plugins/impl/plotly/usePlotlyLayout.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ export function computeLayoutOnFigureChange(
5858
* If a key changed in the figure, we should update it even if it's normally omitted.
5959
*/
6060
export function computeOmitKeys(
61-
currentLayout: Plotly.Layout,
62-
previousLayout: Plotly.Layout,
61+
currentLayout: Partial<Plotly.Layout>,
62+
previousLayout: Partial<Plotly.Layout>,
6363
): Set<keyof Plotly.Layout> {
6464
const omitKeys = new Set<keyof Plotly.Layout>(LAYOUT_OMIT_KEYS);
6565

@@ -79,8 +79,8 @@ export function computeOmitKeys(
7979
* Omits keys that shouldn't override user interactions unless they changed.
8080
*/
8181
export function computeLayoutUpdate(
82-
figureLayout: Plotly.Layout,
83-
previousFigureLayout: Plotly.Layout,
82+
figureLayout: Partial<Plotly.Layout>,
83+
previousFigureLayout: Partial<Plotly.Layout>,
8484
prevLayout: Partial<Plotly.Layout>,
8585
): Partial<Plotly.Layout> {
8686
const omitKeys = computeOmitKeys(figureLayout, previousFigureLayout);

0 commit comments

Comments
 (0)