diff --git a/site/DataPageV2Content.tsx b/site/DataPageV2Content.tsx index 9ed5d13f27..b41f738e01 100644 --- a/site/DataPageV2Content.tsx +++ b/site/DataPageV2Content.tsx @@ -149,11 +149,10 @@ export const DataPageV2Content = ({ (grapher2State.chartInstance as MapChart).projection ) - const focusedEntity = ( - grapher2State.chartInstance as MapChart - ).projection + const projection = (grapher2State.chartInstance as MapChart) + .projection grapher1State.selection.clearSelection() - if (focusedEntity) + if (projection) grapher1State.selection.addToSelection([projection]) } ) diff --git a/site/GrapherFigureView.tsx b/site/GrapherFigureView.tsx index 8f1d472f56..e60bac03cf 100644 --- a/site/GrapherFigureView.tsx +++ b/site/GrapherFigureView.tsx @@ -1,6 +1,10 @@ import { useRef } from "react" -import { Grapher, GrapherProgrammaticInterface } from "@ourworldindata/grapher" +import { + Grapher, + GrapherProgrammaticInterface, + GrapherState, +} from "@ourworldindata/grapher" import { ADMIN_BASE_URL, BAKED_GRAPHER_URL, @@ -19,28 +23,25 @@ export const GrapherFigureView = ({ const base = useRef(null) const bounds = useElementBounds(base) - const grapherProps: GrapherProgrammaticInterface = { - ...grapher.toObject(), - isEmbeddedInADataPage: grapher.isEmbeddedInADataPage, - bindUrlToWindow: grapher.props.bindUrlToWindow, - queryStr: grapher.props.bindUrlToWindow + const grapherState: GrapherState = new GrapherState({ + ...grapher.grapherState.toObject(), + isEmbeddedInADataPage: grapher.grapherState.isEmbeddedInADataPage, + bindUrlToWindow: grapher.grapherState.initialOptions.bindUrlToWindow, + queryStr: grapher.grapherState.initialOptions.bindUrlToWindow ? window.location.search - : undefined, + : "", // TODO: 2025-01-03 changed this from undefined to empty string - is this a problem? bounds, dataApiUrl: DATA_API_URL, enableKeyboardShortcuts: true, + adminBaseUrl: ADMIN_BASE_URL, + bakedGrapherURL: BAKED_GRAPHER_URL, ...extraProps, - } + }) return ( // They key= in here makes it so that the chart is re-loaded when the slug changes.
{bounds && ( - + )}
)