From 95b3b61dccf4bf9167e39ecae7bbe98cc161c3e1 Mon Sep 17 00:00:00 2001 From: Sophia Mersmann Date: Wed, 20 Dec 2023 15:50:44 +0100 Subject: [PATCH] :sparkles: (grapher) reflect "Show selection only" toggle in the URL (#3034) --- packages/@ourworldindata/grapher/src/core/Grapher.tsx | 11 +++++++++++ .../grapher/src/core/GrapherInterface.ts | 1 + 2 files changed, 12 insertions(+) diff --git a/packages/@ourworldindata/grapher/src/core/Grapher.tsx b/packages/@ourworldindata/grapher/src/core/Grapher.tsx index 4ac6ebb6a8d..75a2341a73a 100644 --- a/packages/@ourworldindata/grapher/src/core/Grapher.tsx +++ b/packages/@ourworldindata/grapher/src/core/Grapher.tsx @@ -628,6 +628,12 @@ export class Grapher } else if (params.uniformYAxis === "1") { this.yAxis.facetDomain = FacetAxisDomain.shared } + + // only relevant for the table + if (params.showSelectionOnlyInTable) { + this.showSelectionOnlyInDataTable = + params.showSelectionOnlyInTable === "1" ? true : undefined + } } @action.bound private setTimeFromTimeQueryParam(time: string): void { @@ -2649,6 +2655,8 @@ export class Grapher this.maxTime = authorsVersion.maxTime this.map.time = authorsVersion.map.time this.map.projection = authorsVersion.map.projection + this.showSelectionOnlyInDataTable = + authorsVersion.showSelectionOnlyInDataTable this.clearSelection() } @@ -2700,6 +2708,9 @@ export class Grapher params.facet = this.selectedFacetStrategy params.uniformYAxis = this.yAxis.facetDomain === FacetAxisDomain.independent ? "0" : "1" + params.showSelectionOnlyInTable = this.showSelectionOnlyInDataTable + ? "1" + : "0" return setSelectedEntityNamesParam( Url.fromQueryParams(params), this.selectedEntitiesIfDifferentThanAuthors diff --git a/packages/@ourworldindata/grapher/src/core/GrapherInterface.ts b/packages/@ourworldindata/grapher/src/core/GrapherInterface.ts index 99542dae9b8..e7f93bab709 100644 --- a/packages/@ourworldindata/grapher/src/core/GrapherInterface.ts +++ b/packages/@ourworldindata/grapher/src/core/GrapherInterface.ts @@ -116,6 +116,7 @@ export interface GrapherQueryParams extends QueryParams { selection?: string facet?: string uniformYAxis?: string + showSelectionOnlyInTable?: string } export interface LegacyGrapherQueryParams extends GrapherQueryParams {