Skip to content

Implement updates tracking OWID grapher#6

Open
xrendan wants to merge 785 commits intoBuildCanada:masterfrom
owid:master
Open

Implement updates tracking OWID grapher#6
xrendan wants to merge 785 commits intoBuildCanada:masterfrom
owid:master

Conversation

@xrendan
Copy link
Copy Markdown
Member

@xrendan xrendan commented Feb 26, 2026

Context

Links to issues, Figma, Slack, and a technical introduction to the work.

Screenshots / Videos / Diagrams

Add if relevant, i.e. might not be necessary when there are no UI changes.

Testing guidance

Step-by-step instructions on how to test this change

  • Does the change work in the archive?
  • Does the staging experience have sign-off from product stakeholders?

Reminder to annotate the PR diff with design notes, alternatives you considered, and any other helpful context.

Checklist

(delete all that do not apply)

Before merging

  • Google Analytics events were adapted to fit the changes in this PR
  • Changes to CSS/HTML were checked on Desktop and Mobile Safari at all three breakpoints
  • Changes to HTML were checked for accessibility concerns

If DB migrations exists:

  • If columns have been added/deleted, all necessary views were recreated
  • The DB type definitions have been updated
  • The DB types in the ETL have been updated
  • If tables/views were added/removed, the Datasette export has been updated to take this into account
  • Update the documentation in db/docs

After merging

  • If a table was touched that is synced to R2, the sync script to update R2 has been run

sophiamersmann and others added 29 commits March 5, 2026 18:00
Add a new CF Pages Function at /api/detect-country that uses the
existing regions data as the source of truth. Update the client to
use a relative URL and remove the old redirect.

Closes #6101
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
## Context

This PR refactors the stacked chart components (StackedAreaChart and StackedBarChart) to improve code organization and consistency. The changes consolidate hover state management, simplify prop passing between components, and extract placement logic into utility functions.

Key technical changes:
- Moved chart placement logic from individual components to utility functions (`toPlacedStackedAreaSeries` and `toPlacedStackedBarSeries`)
- Consolidated hover state management using the existing `getHoverStateForSeries` utility
- Simplified component interfaces by pre-computing placed series data and hover states
- Removed redundant hover tracking properties and methods
- Updated type definitions to better represent placed chart elements

## Testing guidance

Test stacked area and bar charts to ensure hover interactions and visual rendering work correctly:

- [ ] Verify hover effects work on chart areas/bars, legends, and labels
- [ ] Check that focus states display properly when hovering over different chart elements
- [ ] Confirm tooltips appear correctly when hovering over chart elements
- [ ] Test both entity-based and column-based series strategies
- [ ] Verify charts render correctly in both full-size and thumbnail views
- [ ] Does the change work in the archive?
- [ ] Does the staging experience have sign-off from product stakeholders?

## Checklist

### Before merging

- [ ] Changes to CSS/HTML were checked on Desktop and Mobile Safari at all three breakpoints
## Context

This PR introduces a new `Emphasis` enum to replace the previous focus/hover state logic for visual styling across chart components. The change consolidates opacity and styling decisions into a centralized system that maps interaction states to visual emphasis levels (Default, Highlighted, Muted).

## Testing guidance

Test various chart types to ensure proper visual feedback during interactions:

- [ ] Hover over chart elements (bars, lines, areas) and verify opacity changes work correctly
- [ ] Test legend interactions - hovering should highlight/mute appropriate chart elements
- [ ] Verify focus states still work properly when selecting entities
- [ ] Check that connector lines in vertical labels update color appropriately
- [ ] Test discrete bar charts, line charts, stacked charts, slope charts, and scatter plots
- [ ] Does the change work in the archive?
- [ ] Does the staging experience have sign-off from product stakeholders?

## Checklist

### Before merging

- [ ] Changes to CSS/HTML were checked on Desktop and Mobile Safari at all three breakpoints
- [ ] Changes to HTML were checked for accessibility concerns
## Context

This PR refactors the stacked discrete bar chart implementation to improve focus functionality and code organization. The main changes include:

- Enabling focus support for stacked discrete bar charts by removing the restriction in `EditorFeatures.tsx`
- Introducing a new `focusableSeriesNames` getter that includes both chart series and selected entity names for stacked discrete bar charts
- Consolidating the chart rendering logic by removing the separate `StackedDiscreteBars` component and integrating it directly into `StackedDiscreteBarChart`
- Adding proper focus and hover state management with emphasis resolution
- Introducing new type definitions for better code organization (`StackedDiscreteBarChartConstants.ts`)

## Testing guidance

Step-by-step instructions on how to test this change:

1. Navigate to a stacked discrete bar chart in the admin interface
2. Verify that the focus functionality is now available in the editor data tab
3. Test focusing on individual series (both columns and entities) and verify visual emphasis changes
4. Test hover interactions on legend items and bar segments
5. Verify tooltips display correctly when hovering over bars
6. Test sorting functionality to ensure bars animate smoothly when reordered
7. Check that total value labels display correctly when enabled

- [ ] Does the change work in the archive?
- [ ] Does the staging experience have sign-off from product stakeholders?

## Checklist

### Before merging

- [ ] Changes to CSS/HTML were checked on Desktop and Mobile Safari at all three breakpoints
- [ ] Changes to HTML were checked for accessibility concerns
## Context

This PR removes unused CSS class names and cleans up redundant code across chart components. The changes include removing className attributes from SVG elements in DiscreteBarChart, ScatterPlotChart, MarimekkoChart, and StackedBarChart components, as well as simplifying conditional rendering logic in StackedBars and StackedDiscreteBarRow components.

## Testing guidance

Step-by-step instructions on how to test this change:

1. Verify that all chart types (discrete bar, scatter plot, marimekko, stacked bar) render correctly
2. Check that chart interactions (hover, tooltips, mouse events) still function properly
3. Ensure that missing data points are now properly filtered out in stacked bar charts
4. Confirm that Figma IDs are still generated correctly for chart elements

- [ ] Does the change work in the archive?
- [ ] Does the staging experience have sign-off from product stakeholders?

## Checklist

### Before merging

- [ ] Changes to CSS/HTML were checked on Desktop and Mobile Safari at all three breakpoints
…6133)

## Context

Follow-up to #6132.

PR #6132 (already merged) attempted to mitigate the issue by disabling HTTP caching on the R2 URL fetch path.
This PR is a separate follow-up branch created from `master` and switches grapher config reads in CF functions from HTTP requests to R2 bindings.

## Description

This PR updates Cloudflare Functions grapher config loading to use R2 bucket bindings instead of fetching from `https://grapher-configs*.owid.io/...`.

What changed:
- `functions/_common/grapherTools.ts`
  - Replace URL-based `fetch()` reads with `R2Bucket.get()` reads.
  - Preserve conditional fetch behavior using `If-None-Match` (`onlyIf`) so `304` can still be returned.
  - Keep primary + fallback lookup behavior, now via primary/fallback R2 bindings.
  - Preserve key construction with configured path prefixes (`GRAPHER_CONFIG_R2_BUCKET_PATH`, `GRAPHER_CONFIG_R2_BUCKET_FALLBACK_PATH`).
- `functions/_common/env.ts`
  - Add R2 binding env types for grapher configs.
  - Keep URL env vars present for possible rollback/experimentation.
- `wrangler.jsonc`
  - Add `GRAPHER_CONFIG_R2_BUCKET` and `GRAPHER_CONFIG_R2_BUCKET_FALLBACK` bindings for default/preview/production.
  - Set grapher-config bindings to `"remote": true` for local dev so Wrangler reads from real buckets instead of empty local emulation.
  - Keep existing URL vars in config.

Expected effect:
- Avoid Cloudflare internal HTTP cache behavior on the R2 URL fetch path.
- Read config objects directly through R2 bindings while preserving status semantics (`200`/`304`/`404`).

## Screenshots / Videos / Diagrams

None (no UI changes).

## Testing guidance

1. Start local CF functions (`yarn startLocalCloudflareFunctions`).
2. Request a known config endpoint, e.g. `/grapher/life-expectancy.config.json`.
3. Verify config is served from binding-backed lookup and returns expected status codes.
4. Optionally test with `If-None-Match` to verify `304` behavior.

Automated checks run:
- `yarn fixPrettierChanged > /dev/null 2>&1 && yarn typecheck`
- `yarn testLintChanged`
- `yarn testPrettierChanged`

- [ ] Does the change work in the archive?
- [ ] Does the staging experience have sign-off from product stakeholders?

## Checklist

### Before merging

- [ ] Google Analytics events were adapted to fit the changes in this PR
- [ ] Changes to CSS/HTML were checked on Desktop and Mobile Safari at all three breakpoints
- [ ] Changes to HTML were checked for accessibility concerns
- add a worker-runtime e2e test suite for /grapher/:slug.config.json
- seed local Miniflare R2 buckets with a real life-expectancy config fixture
- cover primary bucket fetch, ETag 304, fallback bucket, 404, and nocache behavior
- use a dedicated wrangler e2e config with local-only R2 bindings (no remote: true)
- simplify test worker context by always injecting a test ASSETS stub
- add a test-only r2-has-key endpoint for assertions
- strengthen fallback test to assert key is absent in primary and present in fallback before fetch
## Context

This PR adds end-to-end testing infrastructure for the grapher config R2 functionality using Wrangler's local development capabilities.

## Testing guidance

Run the new e2e tests to verify R2 bucket functionality:

```bash
yarn test:functions:e2e-r2
```

The tests verify:
- Grapher config retrieval from primary R2 bucket
- ETag-based caching with 304 responses for unchanged configs
- Fallback to secondary R2 bucket when primary bucket misses
- 404 responses when configs are missing from both buckets
- Cache control headers when nocache parameter is present
sophiamersmann and others added 30 commits March 26, 2026 14:50
✨ (peers) dataRange strategy for target country
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…jects/example (#6293)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
`encodeURIComponent` doesn't encode parenthesis, i.e. `(` and `)`. This
is fine in browsers, but social media previews don't work without
encoding them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.