From caba23c14e8aab3a132fa79b95c7779a2325afae Mon Sep 17 00:00:00 2001 From: Ike Saunders Date: Tue, 5 Nov 2024 15:36:20 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20explorer=20thumbnails=20code=20revi?= =?UTF-8?q?ew=20touchups?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/_common/grapherTools.ts | 2 +- functions/explorers/[slug].ts | 1 + packages/@ourworldindata/explorer/readme.md | 86 -------------------- packages/@ourworldindata/explorer/readme.svg | 2 - 4 files changed, 2 insertions(+), 89 deletions(-) delete mode 100644 packages/@ourworldindata/explorer/readme.md delete mode 100644 packages/@ourworldindata/explorer/readme.svg diff --git a/functions/_common/grapherTools.ts b/functions/_common/grapherTools.ts index de6bd1ed0db..27cb0cef3ec 100644 --- a/functions/_common/grapherTools.ts +++ b/functions/_common/grapherTools.ts @@ -180,5 +180,5 @@ export function rewriteMetaTags( }, }) - return rewriter.transform(page as unknown as Response) + return rewriter.transform(page) } diff --git a/functions/explorers/[slug].ts b/functions/explorers/[slug].ts index 71c0eca50d2..b8c84ce91b0 100644 --- a/functions/explorers/[slug].ts +++ b/functions/explorers/[slug].ts @@ -62,6 +62,7 @@ async function handleThumbnailRequest( try { const html = await explorerPage.text() const queryStr = url.searchParams.toString() + // The env URL class isn't compatible with the Url class from @ourworldindata/utils const urlObj = Url.fromURL(url.toString()) const [windowEntityNames] = [urlObj] .map(migrateSelectedEntityNamesParam) diff --git a/packages/@ourworldindata/explorer/readme.md b/packages/@ourworldindata/explorer/readme.md deleted file mode 100644 index 034f8d47ad2..00000000000 --- a/packages/@ourworldindata/explorer/readme.md +++ /dev/null @@ -1,86 +0,0 @@ -# Grapher - -This folder contains the code for Grapher, our client side data exploration and visualization library. The Grapher pipeline is explained below. - -## Step 1: The Grapher Config - -The user navigates to a grapher page and the browser fetches the **Grapher Config**. - -The _Grapher Config_ contains 3 main ingredients: - -- Where to get the **Data** and **Metadata** -- Any **Transforms** to apply to the data -- What **Chart Components** to show - -## Step 2: The Data - -Once the **Grapher Library** has parsed the _Grapher Config_, it fetches the _Data_ from the URLs in that config (or in some cases the _Data_ is embedded right in the _Grapher Config_). - -The _Data_ is downloaded in two pieces (though technically the second piece is optional): - -1. The _Data_ in CSV (or TSV, JSON, etc). For example: - -``` -Country,GDP,Year -Iceland,123,2020 -France,456,2020 -... -``` - -2. The _Metadata_ about the **Columns** in the _Data_ (including source information). For example: - -``` -Column,Name,Source -GDP,Gross Domestic Product,World Bank -... -``` - -Then Grapher's **Table Library** parsed the _Data_ into memory as a **Table**. This _Table_ has **Rows** and _Columns_. - -The initial _Table_ is called the **Root Table**. - -## Step 3: Global Transforms - -If the _Grapher Config_ specified any _Transforms_ such as filtering or grouping, the _Table Library_ will apply those. - -For example, if a "Min Year Transform" is specified, rows earlier than that year will be filtered. - -## Step 4: Child Tables - -The _Grapher Library_ then derives one **Child Table** for each _Chart Component_ from the _Root Table_. - -If the author specified different _Transforms_ for different _Chart Components_—i.e. a different year to show on the Map Component—those are applied. - -All _Chart Components_ can now also make any changes they want to their _Child Table_ without affecting other _Chart Components_. If _Transforms_ are -made to the "Root Table", those changes automatically propagate down to all _Child Tables_. - -## Step 5: Rendering - -Now all the _Chart Components_ have all their own _Tables_ and Grapher renders to the user's screen. - -As the user interacts with **Chart Controls**, changes are made to the respective _Tables_ and the visualizations update. - -### Flowchart - - - -```mermaid -graph LR -UserVisitsPage((When User Visits Page)) -UserVisitsPage --> Load[Load Grapher Config] -Load --> DataNeeds[Determine Data Needs] -DataNeeds --> Data[Download Data] -DataNeeds --> Metadata[Download Metadata] -Data --> RootTable[Make Root Table] -Metadata --> RootTable[Make Root Table] -RootTable --> GlobalTransforms[Apply Global Transforms] -GlobalTransforms --> ChildTable1[Derive Table for Map Chart] -GlobalTransforms --> ChildTable2[Derive Table for Line Chart] -GlobalTransforms --> ChildTableN[Derive Table for ...] -ChildTable1 --> Render -ChildTable2 --> Render -ChildTableN --> Render -Render --> UserEditsTransforms((When User Uses Controls)) -UserEditsTransforms --> GlobalTransforms -UserEditsTransforms --> DataNeeds -``` diff --git a/packages/@ourworldindata/explorer/readme.svg b/packages/@ourworldindata/explorer/readme.svg deleted file mode 100644 index addec5dfce7..00000000000 --- a/packages/@ourworldindata/explorer/readme.svg +++ /dev/null @@ -1,2 +0,0 @@ - -
When User Visits Page
Load Grapher Config
Determine Data Needs
Download Data
Download Metadata
Make Root Table
Apply Global Transforms
Derive Table for Map Chart
Derive Table for Line Chart
Derive Table for ...
Render
When User Uses Controls
\ No newline at end of file