Skip to content

Conversation

@adamwoodnz
Copy link
Contributor

@adamwoodnz adamwoodnz commented Dec 17, 2025

Fixes CHARTS-149: Add US geochart

Proposed changes:

This PR enhances the GeoChart component with region and resolution props, enabling users to display maps at different geographic levels beyond just the world view.

Key Changes:

  • Added region prop - Specify which region to display ('world', or any ISO 3166-1 alpha-2 country code)
  • Added resolution prop - Control granularity level ('countries', 'provinces', or 'metros')
  • New USStates story - Demonstrates state-level visualization for the United States
  • New EuropeanCountries story - Demonstrates continent-level visualization for Europe
  • Exported new types - GeoRegion and GeoResolution types available for consumers

Screenshots

World US Europe
Screenshot 2025-12-17 at 4 59 55 PM Screenshot 2025-12-17 at 5 00 04 PM Screenshot 2025-12-17 at 5 00 12 PM

Benefits:

  • State-level views - Display data at state/province level for any country
  • Metropolitan areas - Show US metropolitan area data with 'metros' resolution
  • Flexible region focus - Zoom into any specific country or region with its own color scale
  • Full type support - TypeScript types exported for all new props

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

Does this pull request change what data or activity we track or use?

No, this PR only adds configuration props to the GeoChart component. No tracking or data collection changes.

Testing instructions:

Basic Region/Resolution Usage

  1. Check out this branch
  2. Navigate to projects/js-packages/charts
  3. Run pnpm install and pnpm storybook
  4. Open Storybook and navigate to "JS Packages/Charts Library/Charts/Geo Chart"
  5. View the "US States" story - verify it displays a US map with state-level data
  6. View the "European Countries" story - verify it displays a Western Europe map with country-level data

Verify Props

  1. In the "US States" story, confirm states like California, Texas, Florida are highlighted
  2. In the "European Countries" story, confirm states like United Kingdom, France and Germany are highlighted
  3. Use the Storybook controls to change region and resolution props
  4. Verify the map updates correctly when props change

TypeScript Usage

import { GeoChart, type GeoRegion, type GeoResolution } from '@automattic/charts';

const region: GeoRegion = 'US';
const resolution: GeoResolution = 'provinces';

const stateData = [
  ['State', 'Views'],
  ['California', 2500],
  ['Texas', 1800],
];

<GeoChart 
  data={stateData} 
  region={region} 
  resolution={resolution}
  width={800} 
  height={500} 
/>

Verify Type Checking

cd projects/js-packages/charts
pnpm typecheck

All types should compile without errors.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 17, 2025

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@github-actions github-actions bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Dec 17, 2025
@adamwoodnz adamwoodnz marked this pull request as draft December 17, 2025 03:13
@adamwoodnz adamwoodnz self-assigned this Dec 17, 2025
@adamwoodnz adamwoodnz added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Dec 17, 2025
@github-actions github-actions bot added [Status] In Progress [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Dec 17, 2025
@adamwoodnz adamwoodnz force-pushed the charts-149-add-us-geochart branch from 8901d4c to 11bff5c Compare December 17, 2025 03:49
@github-actions
Copy link
Contributor

github-actions bot commented Dec 17, 2025

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the charts-149-add-us-geochart branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack charts-149-add-us-geochart

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the GeoChart component to support region and resolution configurations, enabling state/province-level map visualizations beyond the default world view. The changes allow users to display maps focused on specific countries (using ISO 3166-1 alpha-2 codes) with different granularity levels (countries, provinces/states, or metro areas).

Key Changes

  • Added region and resolution props to GeoChart with proper TypeScript types
  • New types GeoRegion and GeoResolution exported for consumer use
  • Comprehensive test coverage for the new props including default behavior and combinations
  • New "US States" Storybook story demonstrating state-level visualization

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
projects/js-packages/charts/src/charts/geo-chart/types.ts Added GeoRegion and GeoResolution type definitions and corresponding props to GeoChartProps interface with JSDoc documentation
projects/js-packages/charts/src/charts/geo-chart/geo-chart.tsx Implemented region/resolution prop handling with defaults ('world', 'countries') and conditional inclusion in Google Charts options
projects/js-packages/charts/src/charts/geo-chart/index.ts Exported new GeoRegion and GeoResolution types
projects/js-packages/charts/src/index.ts Re-exported new types at package level for consumer access
projects/js-packages/charts/src/charts/geo-chart/test/geo-chart.test.tsx Added comprehensive tests for region/resolution props including default behavior, individual props, and combined usage
projects/js-packages/charts/src/charts/geo-chart/stories/index.stories.tsx Added "USStates" story demonstrating state-level map with sample US state data
projects/js-packages/charts/changelog/charts-149-add-us-geochart Added changelog entry documenting the new feature

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@adamwoodnz adamwoodnz marked this pull request as ready for review December 17, 2025 04:01
@adamwoodnz adamwoodnz added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Dec 17, 2025
@jp-launch-control
Copy link

jp-launch-control bot commented Dec 17, 2025

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/js-packages/charts/src/stories/sample-data/index.ts 23/23 (100.00%) 0.00% 0 💚

Full summary · PHP report · JS report

@adamwoodnz adamwoodnz requested review from a team December 17, 2025 18:50
kangzj
kangzj previously approved these changes Dec 19, 2025
Copy link
Contributor

@kangzj kangzj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Base automatically changed from charts-150-add-support-for-custom-tooltip-rendering to trunk December 19, 2025 01:25
@adamwoodnz adamwoodnz dismissed kangzj’s stale review December 19, 2025 01:25

The base branch was changed.

Introduce GeoRegion and GeoResolution types to support displaying maps
at different geographic levels (world, country, state/province).
Pass region and resolution options to Google Charts to enable
state/province-level map views (e.g., US states).
Demonstrate the region and resolution props with a US states map
showing views data across 15 states.
Test that region and resolution options are correctly passed to
Google Charts and omitted when using default values.
Introduce a new story for the GeoChart component that visualizes views data for various European countries, enhancing the demonstration of region and resolution props.
@adamwoodnz adamwoodnz force-pushed the charts-149-add-us-geochart branch from 05e4208 to 3df78fa Compare December 19, 2025 01:35
…an countries

Updated the USStates and EuropeanCountries stories in the GeoChart component to utilize new sample data imports, enhancing maintainability and clarity. The data for both stories now references the newly defined viewsByUSState and viewsByEuropeanCountry datasets.
@adamwoodnz adamwoodnz merged commit a5ccb56 into trunk Dec 19, 2025
88 checks passed
@adamwoodnz adamwoodnz deleted the charts-149-add-us-geochart branch December 19, 2025 02:01
@github-actions github-actions bot removed [Status] In Progress [Status] Needs Review This PR is ready for review. labels Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[JS Package] Charts RNA [Tests] Includes Tests [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants