From e9e26dd5533294b4d77a2c8ac1060961d2a2801d Mon Sep 17 00:00:00 2001 From: Teale Fristoe Date: Fri, 20 Dec 2024 17:23:39 -0800 Subject: [PATCH] Fix update graph displayOnlySelectedCases. (#1696) --- .../inspector-panel/hide-show-menu-list.tsx | 14 ++------------ ...aph.test.ts => graph-component-handler.test.ts} | 0 v3/src/components/graph/graph-component-handler.ts | 6 +++++- .../components/graph/models/graph-content-model.ts | 14 +++++++++++++- 4 files changed, 20 insertions(+), 14 deletions(-) rename v3/src/components/graph/{component-handler-graph.test.ts => graph-component-handler.test.ts} (100%) diff --git a/v3/src/components/graph/components/inspector-panel/hide-show-menu-list.tsx b/v3/src/components/graph/components/inspector-panel/hide-show-menu-list.tsx index dc541b826..d86da6847 100644 --- a/v3/src/components/graph/components/inspector-panel/hide-show-menu-list.tsx +++ b/v3/src/components/graph/components/inspector-panel/hide-show-menu-list.tsx @@ -47,13 +47,7 @@ export const HideShowMenuList = observer(function HideShowMenuList({tile}: IProp const displayOnlySelectedCases = () => { dataConfig?.applyModelChange( - () => { - dataConfig?.addNewHiddenCases(dataConfig?.unselectedCases ?? []) - dataConfig?.setDisplayOnlySelectedCases(true) - if (dataConfig?.selection.length > 0) { - graphModel?.rescale() - } - }, + () => graphModel?.displayOnlySelectedCases(), { undoStringKey: "DG.Undo.displayOnlySelected", redoStringKey: "DG.Redo.displayOnlySelected", @@ -64,11 +58,7 @@ export const HideShowMenuList = observer(function HideShowMenuList({tile}: IProp const showAllCases = () => { dataConfig?.applyModelChange( - () => { - dataConfig?.clearHiddenCases() - dataConfig?.setDisplayOnlySelectedCases(false) - graphModel?.rescale() - }, + () => graphModel?.showAllCases(), { undoStringKey: "DG.Undo.showAllCases", redoStringKey: "DG.Redo.showAllCases", diff --git a/v3/src/components/graph/component-handler-graph.test.ts b/v3/src/components/graph/graph-component-handler.test.ts similarity index 100% rename from v3/src/components/graph/component-handler-graph.test.ts rename to v3/src/components/graph/graph-component-handler.test.ts diff --git a/v3/src/components/graph/graph-component-handler.ts b/v3/src/components/graph/graph-component-handler.ts index 04635ab9e..7b033bf7d 100644 --- a/v3/src/components/graph/graph-component-handler.ts +++ b/v3/src/components/graph/graph-component-handler.ts @@ -425,7 +425,11 @@ export const graphComponentHandler: DIComponentHandler = { // Update odd features if (backgroundColor != null) content.setPlotBackgroundColor(backgroundColor) - if (displayOnlySelectedCases != null) dataConfiguration.setDisplayOnlySelectedCases(displayOnlySelectedCases) + if (displayOnlySelectedCases) { + content.displayOnlySelectedCases() + } else if (displayOnlySelectedCases != null) { + content.showAllCases() + } if (filterFormula != null) dataConfiguration.setFilterFormula(filterFormula) if (hiddenCases != null) dataConfiguration.setHiddenCases(hiddenCases.map(id => toV3CaseId(id))) if (pointColor != null) pointDescription.setPointColor(pointColor) diff --git a/v3/src/components/graph/models/graph-content-model.ts b/v3/src/components/graph/models/graph-content-model.ts index 7cc49361e..30c7b821c 100644 --- a/v3/src/components/graph/models/graph-content-model.ts +++ b/v3/src/components/graph/models/graph-content-model.ts @@ -644,6 +644,18 @@ export const GraphContentModel = DataDisplayContentModel } })) .actions(self => ({ + displayOnlySelectedCases() { + self.dataConfiguration.addNewHiddenCases(self.dataConfiguration.unselectedCases ?? []) + self.dataConfiguration.setDisplayOnlySelectedCases(true) + if (self.dataConfiguration.selection.length > 0) { + self.rescale() + } + }, + showAllCases() { + self.dataConfiguration.clearHiddenCases() + self.dataConfiguration.setDisplayOnlySelectedCases(false) + self.rescale() + }, setBarCountAxis() { const { maxOverAllCells, maxCellLength, primaryRole, secondaryRole } = self.dataConfiguration const { binWidth, minValue, totalNumberOfBins } = self.binDetails() @@ -663,7 +675,7 @@ export const GraphContentModel = DataDisplayContentModel }) setNiceDomain([0, maxCellCaseCount], countAxis, {clampPosMinAtZero: true}) self.setAxis(secondaryPlace, countAxis) - }, + } })) .actions(self => ({ setPointsFusedIntoBars(fuseIntoBars: boolean) {