From a9b16fb31d67f19ba852a2362382501d886466ea Mon Sep 17 00:00:00 2001 From: Nikhil Date: Mon, 17 Aug 2026 12:07:25 +0530 Subject: [PATCH 1/3] Premium Analytics: add a Regions view to the Locations widget The Locations widget offered Countries and Cities only, so regions were reachable just by drilling into one country. Current Jetpack Stats has a Regions tab, so v2 lost state-level traffic for sites that rely on it. Regions joins the View by dropdown and spans every country. Google GeoChart draws subdivisions only inside a single country's map, so region rows are summed onto their country on the world map, and each country carries its own regions in a tooltip. Fixes WOOA7S-1922 --- .../changelog/wooa7s-1922-locations-regions | 4 + projects/js-packages/charts/src/index.ts | 3 +- .../changelog/wooa7s-1922-locations-regions | 4 + .../packages/externals/src/index.ts | 1 + .../packages/widgets-toolkit/src/index.ts | 1 + .../widgets/locations/package.json | 1 + .../widgets/locations/render.tsx | 75 ++++++++++++++++--- .../stories/locations-widget.stories.tsx | 4 +- .../changelog/wooa7s-1922-locations-regions | 4 + .../changelog/wooa7s-1922-locations-regions | 4 + .../changelog/wooa7s-1922-locations-regions | 4 + .../changelog/wooa7s-1922-locations-regions | 4 + 12 files changed, 95 insertions(+), 14 deletions(-) create mode 100644 projects/js-packages/charts/changelog/wooa7s-1922-locations-regions create mode 100644 projects/packages/premium-analytics/changelog/wooa7s-1922-locations-regions create mode 100644 projects/plugins/jetpack/changelog/wooa7s-1922-locations-regions create mode 100644 projects/plugins/mu-wpcom-plugin/changelog/wooa7s-1922-locations-regions create mode 100644 projects/plugins/premium-analytics/changelog/wooa7s-1922-locations-regions create mode 100644 projects/plugins/wpcomsh/changelog/wooa7s-1922-locations-regions diff --git a/projects/js-packages/charts/changelog/wooa7s-1922-locations-regions b/projects/js-packages/charts/changelog/wooa7s-1922-locations-regions new file mode 100644 index 000000000000..7f9c665e34d1 --- /dev/null +++ b/projects/js-packages/charts/changelog/wooa7s-1922-locations-regions @@ -0,0 +1,4 @@ +Significance: minor +Type: added + +Charts: Export GoogleDataTableColumnRoleType so consumers can build a GeoChart tooltip column. diff --git a/projects/js-packages/charts/src/index.ts b/projects/js-packages/charts/src/index.ts index bb962d911e78..6712e0f97067 100644 --- a/projects/js-packages/charts/src/index.ts +++ b/projects/js-packages/charts/src/index.ts @@ -4,6 +4,8 @@ export { BarChart, BarChartUnresponsive } from './charts/bar-chart'; export { BarListChart, BarListChartUnresponsive } from './charts/bar-list-chart'; export { ConversionFunnelChart } from './charts/conversion-funnel-chart'; export { GeoChart, GeoChartUnresponsive } from './charts/geo-chart'; +// A value export, not a type: building a tooltip column header needs the enum member itself. +export { GoogleDataTableColumnRoleType } from './types'; export { HeatmapChart, HeatmapChartUnresponsive, @@ -63,7 +65,6 @@ export type { SeriesChartLegendConfig, BaseChartProps, GoogleDataTableColumn, - GoogleDataTableColumnRoleType, GoogleDataTableRow, LegendShape, LegendShapeLabel, diff --git a/projects/packages/premium-analytics/changelog/wooa7s-1922-locations-regions b/projects/packages/premium-analytics/changelog/wooa7s-1922-locations-regions new file mode 100644 index 000000000000..f3d7a008079b --- /dev/null +++ b/projects/packages/premium-analytics/changelog/wooa7s-1922-locations-regions @@ -0,0 +1,4 @@ +Significance: minor +Type: added + +Locations: Add a Regions view, at parity with the Locations report. diff --git a/projects/packages/premium-analytics/packages/externals/src/index.ts b/projects/packages/premium-analytics/packages/externals/src/index.ts index 2c8794bf88ec..45b0b8d04324 100644 --- a/projects/packages/premium-analytics/packages/externals/src/index.ts +++ b/projects/packages/premium-analytics/packages/externals/src/index.ts @@ -19,6 +19,7 @@ export { ConversionFunnelChart, GeoChart, GlobalChartsProvider, + GoogleDataTableColumnRoleType, HeatmapChart, HeatmapChartUnresponsive, LeaderboardChartUnresponsive, diff --git a/projects/packages/premium-analytics/packages/widgets-toolkit/src/index.ts b/projects/packages/premium-analytics/packages/widgets-toolkit/src/index.ts index 64317e11376f..8aea32e7707f 100644 --- a/projects/packages/premium-analytics/packages/widgets-toolkit/src/index.ts +++ b/projects/packages/premium-analytics/packages/widgets-toolkit/src/index.ts @@ -264,6 +264,7 @@ export type { MetricKey, OrderMetricKey, OrderMetrics, OrdersSummary, DataFormat export { GeoChart, GlobalChartsProvider, + GoogleDataTableColumnRoleType, HeatmapChart, HeatmapChartUnresponsive, Sparkline, diff --git a/projects/packages/premium-analytics/widgets/locations/package.json b/projects/packages/premium-analytics/widgets/locations/package.json index aa077cd6defe..b9151c8445fb 100644 --- a/projects/packages/premium-analytics/widgets/locations/package.json +++ b/projects/packages/premium-analytics/widgets/locations/package.json @@ -6,6 +6,7 @@ "dependencies": { "@jetpack-premium-analytics/data": "link:../../packages/data", "@jetpack-premium-analytics/externals": "link:../../packages/externals", + "@jetpack-premium-analytics/formatters": "link:../../packages/formatters", "@jetpack-premium-analytics/icons": "link:../../packages/icons", "@jetpack-premium-analytics/widgets-toolkit": "link:../../packages/widgets-toolkit", "@wordpress/element": "8.3.0", diff --git a/projects/packages/premium-analytics/widgets/locations/render.tsx b/projects/packages/premium-analytics/widgets/locations/render.tsx index af8f5c3f501b..d9e676893de1 100644 --- a/projects/packages/premium-analytics/widgets/locations/render.tsx +++ b/projects/packages/premium-analytics/widgets/locations/render.tsx @@ -3,6 +3,7 @@ */ import { GeoChart, + GoogleDataTableColumnRoleType, LeaderboardChart, ReportLink, WIDGET_ROW_LIMIT, @@ -24,15 +25,16 @@ import { type LeaderboardChartData, type ReportParamsFieldAttributes, } from '@jetpack-premium-analytics/widgets-toolkit'; +import { formatMetricValue } from '@jetpack-premium-analytics/formatters'; import { location as locationIcon } from '@jetpack-premium-analytics/icons'; import { useCallback, useEffect, useMemo, useState } from '@wordpress/element'; -import { __, sprintf } from '@wordpress/i18n'; +import { __, _n, sprintf } from '@wordpress/i18n'; import { Stack } from '@jetpack-premium-analytics/externals'; /** * Internal dependencies */ import styles from './style.module.css'; -import useLocationViews, { type GeoMode } from './use-location-views'; +import useLocationViews, { type GeoMode, type LocationView } from './use-location-views'; import { type LocationsAttributes } from './widget'; /** * Types @@ -42,6 +44,11 @@ import type { WidgetRenderProps } from '@wordpress/widget-primitives'; type LocationsRenderAttributes = LocationsAttributes & Partial< ReportParamsFieldAttributes >; type LocationsWidgetProps = WidgetRenderProps< LocationsRenderAttributes >; type DrillDownCountry = { code: string; name: string }; +type CountrySummary = { + countryFull: string; + value: number; + locations: LocationView[]; +}; type GoogleChartsWindow = Window & { google?: { visualization?: { @@ -80,6 +87,35 @@ function getGeoChartCountryId( countryCode: string ): string { return countryCode.toUpperCase(); } +// A GeoChart tooltip is a single cell, so the rolled-up locations share one HTML +// string. The list is capped to keep a tooltip from overflowing the map. +const MAX_TOOLTIP_LOCATIONS = 10; + +function buildCountryTooltip( country: CountrySummary ): string { + const listed = country.locations.slice( 0, MAX_TOOLTIP_LOCATIONS ); + const lines = listed.map( + location => `${ location.label }: ${ formatMetricValue( location.value ) }` + ); + const remaining = country.locations.length - listed.length; + + if ( remaining > 0 ) { + lines.push( + sprintf( + /* translators: %d is the number of locations left out of the tooltip list. */ + _n( + '…and %d more location', + '…and %d more locations', + remaining, + 'jetpack-premium-analytics-pkg' + ), + remaining + ) + ); + } + + return lines.join( '
' ); +} + type LocationsInnerProps = { geoGranularity: NonNullable< LocationsAttributes[ 'geoGranularity' ] >; }; @@ -135,7 +171,7 @@ function LocationsInner( { geoGranularity }: LocationsInnerProps ) { const useCountrySummaryMap = geoMode === 'city' || ( geoMode === 'region' && ! activeSelectedCountry ); const countrySummaryRows = useMemo( () => { - const countryRows = new Map< string, { countryFull: string; value: number } >(); + const countryRows = new Map< string, CountrySummary >(); if ( ! useCountrySummaryMap ) { return []; @@ -147,6 +183,7 @@ function LocationsInner( { geoGranularity }: LocationsInnerProps ) { countryRows.set( countryCode, { countryFull: location.countryFull, value: ( current?.value ?? 0 ) + location.value, + locations: [ ...( current?.locations ?? [] ), location ], } ); } ); @@ -228,23 +265,39 @@ function LocationsInner( { geoGranularity }: LocationsInnerProps ) { } if ( useCountrySummaryMap ) { + // A summed country no longer names the regions behind its value, so it + // carries them in a tooltip. Cities keep GeoChart's default tooltip. + const withTooltips = geoMode === 'region'; + const summaryHeader: GoogleDataTableColumn[] = withTooltips + ? [ + ...header, + { + type: 'string', + role: GoogleDataTableColumnRoleType.tooltip, + p: { html: true }, + }, + ] + : header; + return [ - header, - ...countrySummaryRows.map( - ( [ countryCode, location ] ): GoogleDataTableRow => [ + summaryHeader, + ...countrySummaryRows.map( ( [ countryCode, country ] ): GoogleDataTableRow => { + const row: GoogleDataTableRow = [ { v: getGeoChartCountryId( countryCode ), - f: location.countryFull, + f: country.countryFull, }, - location.value, - ] - ), + country.value, + ]; + + return withTooltips ? [ ...row, buildCountryTooltip( country ) ] : row; + } ), ]; } const rows: GoogleDataTableRow[] = data.map( location => [ location.label, location.value ] ); return [ header, ...rows ]; - }, [ countrySummaryRows, data, fallbackCountry, useCountrySummaryMap, useProvinceMap ] ); + }, [ countrySummaryRows, data, fallbackCountry, geoMode, useCountrySummaryMap, useProvinceMap ] ); const leaderboardData = useMemo( () => { const maxValue = getCombinedPeriodMax( diff --git a/projects/packages/premium-analytics/widgets/locations/stories/locations-widget.stories.tsx b/projects/packages/premium-analytics/widgets/locations/stories/locations-widget.stories.tsx index 1cef524ac42c..9a52691f6d9f 100644 --- a/projects/packages/premium-analytics/widgets/locations/stories/locations-widget.stories.tsx +++ b/projects/packages/premium-analytics/widgets/locations/stories/locations-widget.stories.tsx @@ -121,8 +121,8 @@ export const WithComparison: StoryObj< LocationsStoryControls > = { decorators: [ withWidgetCanvas, withStoryRouter ], }; -// Regions mode — region rows worldwide in the leaderboard, aggregated by country -// on the map. +// Regions mode — region rows worldwide in the leaderboard, summed by country on +// the map, where each country tooltip lists the regions behind its total. export const RegionsMode: StoryObj< LocationsStoryControls > = { render: renderLocationsWidget, args: { withComparison: false, geoGranularity: 'region' }, diff --git a/projects/plugins/jetpack/changelog/wooa7s-1922-locations-regions b/projects/plugins/jetpack/changelog/wooa7s-1922-locations-regions new file mode 100644 index 000000000000..7f02534fd778 --- /dev/null +++ b/projects/plugins/jetpack/changelog/wooa7s-1922-locations-regions @@ -0,0 +1,4 @@ +Significance: minor +Type: enhancement + +Locations: Add a Regions view to the Locations widget. diff --git a/projects/plugins/mu-wpcom-plugin/changelog/wooa7s-1922-locations-regions b/projects/plugins/mu-wpcom-plugin/changelog/wooa7s-1922-locations-regions new file mode 100644 index 000000000000..35d750276d8d --- /dev/null +++ b/projects/plugins/mu-wpcom-plugin/changelog/wooa7s-1922-locations-regions @@ -0,0 +1,4 @@ +Significance: minor +Type: added + +Locations: Add a Regions view to the Locations widget. diff --git a/projects/plugins/premium-analytics/changelog/wooa7s-1922-locations-regions b/projects/plugins/premium-analytics/changelog/wooa7s-1922-locations-regions new file mode 100644 index 000000000000..35d750276d8d --- /dev/null +++ b/projects/plugins/premium-analytics/changelog/wooa7s-1922-locations-regions @@ -0,0 +1,4 @@ +Significance: minor +Type: added + +Locations: Add a Regions view to the Locations widget. diff --git a/projects/plugins/wpcomsh/changelog/wooa7s-1922-locations-regions b/projects/plugins/wpcomsh/changelog/wooa7s-1922-locations-regions new file mode 100644 index 000000000000..35d750276d8d --- /dev/null +++ b/projects/plugins/wpcomsh/changelog/wooa7s-1922-locations-regions @@ -0,0 +1,4 @@ +Significance: minor +Type: added + +Locations: Add a Regions view to the Locations widget. From 6c3d31450b5a3a7d9c0c76f0b6e3fdfd4ec7fc1c Mon Sep 17 00:00:00 2001 From: Nikhil Date: Mon, 17 Aug 2026 12:45:10 +0530 Subject: [PATCH 2/3] Premium Analytics: cover the Locations region rollup and tooltip The widget test mocked the data hook empty, so neither the country rollup nor the tooltip builder ever ran. --- .../changelog/wooa7s-1922-locations-regions | 2 +- .../changelog/wooa7s-1922-locations-regions | 2 +- .../locations/__tests__/locations.test.tsx | 88 ++++++++++++++++++- .../widgets/locations/render.tsx | 2 +- .../changelog/wooa7s-1922-locations-regions | 4 - .../changelog/wooa7s-1922-locations-regions | 4 - .../changelog/wooa7s-1922-locations-regions | 2 +- .../changelog/wooa7s-1922-locations-regions | 4 - 8 files changed, 90 insertions(+), 18 deletions(-) delete mode 100644 projects/plugins/jetpack/changelog/wooa7s-1922-locations-regions delete mode 100644 projects/plugins/mu-wpcom-plugin/changelog/wooa7s-1922-locations-regions delete mode 100644 projects/plugins/wpcomsh/changelog/wooa7s-1922-locations-regions diff --git a/projects/js-packages/charts/changelog/wooa7s-1922-locations-regions b/projects/js-packages/charts/changelog/wooa7s-1922-locations-regions index 7f9c665e34d1..4496a07e0d99 100644 --- a/projects/js-packages/charts/changelog/wooa7s-1922-locations-regions +++ b/projects/js-packages/charts/changelog/wooa7s-1922-locations-regions @@ -1,4 +1,4 @@ Significance: minor Type: added -Charts: Export GoogleDataTableColumnRoleType so consumers can build a GeoChart tooltip column. +Export GoogleDataTableColumnRoleType as a value, so a consumer can build a GeoChart tooltip column. diff --git a/projects/packages/premium-analytics/changelog/wooa7s-1922-locations-regions b/projects/packages/premium-analytics/changelog/wooa7s-1922-locations-regions index f3d7a008079b..e9148632d3d5 100644 --- a/projects/packages/premium-analytics/changelog/wooa7s-1922-locations-regions +++ b/projects/packages/premium-analytics/changelog/wooa7s-1922-locations-regions @@ -1,4 +1,4 @@ Significance: minor Type: added -Locations: Add a Regions view, at parity with the Locations report. +Locations: Name the regions behind each country total in the Regions map tooltip. diff --git a/projects/packages/premium-analytics/widgets/locations/__tests__/locations.test.tsx b/projects/packages/premium-analytics/widgets/locations/__tests__/locations.test.tsx index 6cb15c199a72..cdae23fd8a8c 100644 --- a/projects/packages/premium-analytics/widgets/locations/__tests__/locations.test.tsx +++ b/projects/packages/premium-analytics/widgets/locations/__tests__/locations.test.tsx @@ -1,6 +1,7 @@ /** * External dependencies */ +import { formatMetricValue } from '@jetpack-premium-analytics/formatters'; import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import type { AnchorHTMLAttributes, ReactNode } from 'react'; @@ -8,6 +9,7 @@ import type { AnchorHTMLAttributes, ReactNode } from 'react'; * Internal dependencies */ import LocationsWidget from '../render'; +import type { LocationView } from '../use-location-views'; type MockRouteLinkProps = { to: string; @@ -39,10 +41,13 @@ jest.mock( '@wordpress/route', () => ( { useSearch: () => ( {} ), } ) ); -// Google Charts loads asynchronously and is outside this widget's concern. +// Google Charts loads asynchronously and is outside this widget's concern. The +// map rows are an assertion target, so the stand-in carries its data prop. jest.mock( '@jetpack-premium-analytics/widgets-toolkit', () => ( { ...jest.requireActual( '@jetpack-premium-analytics/widgets-toolkit' ), - GeoChart: () =>
, + GeoChart: ( { data }: { data: unknown } ) => ( +
{ JSON.stringify( data ) }
+ ), } ) ); // Typed off the hook so the mocked state and the rows passed to @@ -66,6 +71,21 @@ jest.mock( '../use-location-views', () => ( { default: ( ...args: unknown[] ) => mockUseLocationViews( ...( args as [] ) ), } ) ); +function locationView( label: string, countryCode: string, countryFull: string, value: number ) { + return { key: `${ countryCode }:${ label }`, label, countryCode, countryFull, value, region: '' }; +} + +function viewsState( data: LocationView[] ): LocationViewsState { + return { ...LOADING_STATE, data, isLoading: false, isFetching: false, hasData: data.length > 0 }; +} + +/** + * Read the rows GeoChart was handed, as `[ header, ...rows ]`. + */ +function readGeoChartData() { + return JSON.parse( screen.getByTestId( 'geo-chart' ).textContent ?? '[]' ); +} + describe( 'LocationsWidget', () => { beforeEach( () => { mockUseLocationViews.mockReset(); @@ -149,4 +169,68 @@ describe( 'LocationsWidget', () => { expect.objectContaining( { geoMode: 'country', countryFilter: undefined } ) ); } ); + + describe( 'Regions view', () => { + it( 'sums each country regions onto one map row', () => { + mockUseLocationViews.mockReturnValue( + viewsState( [ + locationView( 'Maharashtra', 'IN', 'India', 5447 ), + locationView( 'Delhi', 'IN', 'India', 520 ), + locationView( 'Illinois', 'US', 'United States', 2 ), + ] ) + ); + + render( ); + const [ , ...rows ] = readGeoChartData(); + + expect( rows ).toHaveLength( 2 ); + expect( rows ).toContainEqual( [ { v: 'IN', f: 'India' }, 5967, expect.any( String ) ] ); + expect( rows ).toContainEqual( [ { v: 'US', f: 'United States' }, 2, expect.any( String ) ] ); + } ); + + it( 'lists a country regions in its tooltip', () => { + mockUseLocationViews.mockReturnValue( + viewsState( [ + locationView( 'Maharashtra', 'IN', 'India', 5447 ), + locationView( 'Delhi', 'IN', 'India', 520 ), + ] ) + ); + + render( ); + const [ header, row ] = readGeoChartData(); + + expect( header[ 2 ] ).toMatchObject( { role: 'tooltip', p: { html: true } } ); + expect( row[ 2 ] ).toBe( + `Maharashtra: ${ formatMetricValue( 5447 ) }
Delhi: ${ formatMetricValue( 520 ) }` + ); + } ); + + it( 'counts the regions it leaves out of a long tooltip', () => { + mockUseLocationViews.mockReturnValue( + viewsState( + Array.from( { length: 12 }, ( _, index ) => + locationView( `Region ${ index }`, 'IN', 'India', 12 - index ) + ) + ) + ); + + render( ); + const [ , row ] = readGeoChartData(); + + expect( row[ 2 ].split( '
' ) ).toHaveLength( 11 ); + expect( row[ 2 ] ).toContain( '…and 2 more locations' ); + } ); + } ); + + it( 'gives the Cities view no tooltip column', () => { + mockUseLocationViews.mockReturnValue( + viewsState( [ locationView( 'Mumbai', 'IN', 'India', 900 ) ] ) + ); + + render( ); + const [ header, row ] = readGeoChartData(); + + expect( header ).toHaveLength( 2 ); + expect( row ).toEqual( [ { v: 'IN', f: 'India' }, 900 ] ); + } ); } ); diff --git a/projects/packages/premium-analytics/widgets/locations/render.tsx b/projects/packages/premium-analytics/widgets/locations/render.tsx index d9e676893de1..43e4f053f53d 100644 --- a/projects/packages/premium-analytics/widgets/locations/render.tsx +++ b/projects/packages/premium-analytics/widgets/locations/render.tsx @@ -87,7 +87,7 @@ function getGeoChartCountryId( countryCode: string ): string { return countryCode.toUpperCase(); } -// A GeoChart tooltip is a single cell, so the rolled-up locations share one HTML +// A GeoChart tooltip is a single cell, so the summed locations share one HTML // string. The list is capped to keep a tooltip from overflowing the map. const MAX_TOOLTIP_LOCATIONS = 10; diff --git a/projects/plugins/jetpack/changelog/wooa7s-1922-locations-regions b/projects/plugins/jetpack/changelog/wooa7s-1922-locations-regions deleted file mode 100644 index 7f02534fd778..000000000000 --- a/projects/plugins/jetpack/changelog/wooa7s-1922-locations-regions +++ /dev/null @@ -1,4 +0,0 @@ -Significance: minor -Type: enhancement - -Locations: Add a Regions view to the Locations widget. diff --git a/projects/plugins/mu-wpcom-plugin/changelog/wooa7s-1922-locations-regions b/projects/plugins/mu-wpcom-plugin/changelog/wooa7s-1922-locations-regions deleted file mode 100644 index 35d750276d8d..000000000000 --- a/projects/plugins/mu-wpcom-plugin/changelog/wooa7s-1922-locations-regions +++ /dev/null @@ -1,4 +0,0 @@ -Significance: minor -Type: added - -Locations: Add a Regions view to the Locations widget. diff --git a/projects/plugins/premium-analytics/changelog/wooa7s-1922-locations-regions b/projects/plugins/premium-analytics/changelog/wooa7s-1922-locations-regions index 35d750276d8d..24edb8872145 100644 --- a/projects/plugins/premium-analytics/changelog/wooa7s-1922-locations-regions +++ b/projects/plugins/premium-analytics/changelog/wooa7s-1922-locations-regions @@ -1,4 +1,4 @@ Significance: minor Type: added -Locations: Add a Regions view to the Locations widget. +Locations: Hover a country in the Regions view to see the regions behind its total. diff --git a/projects/plugins/wpcomsh/changelog/wooa7s-1922-locations-regions b/projects/plugins/wpcomsh/changelog/wooa7s-1922-locations-regions deleted file mode 100644 index 35d750276d8d..000000000000 --- a/projects/plugins/wpcomsh/changelog/wooa7s-1922-locations-regions +++ /dev/null @@ -1,4 +0,0 @@ -Significance: minor -Type: added - -Locations: Add a Regions view to the Locations widget. From 698e261af5a476d8d03d5b4cafb107547086cbed Mon Sep 17 00:00:00 2001 From: Nikhil Date: Tue, 18 Aug 2026 11:05:48 +0530 Subject: [PATCH 3/3] Charts: keep a GeoChart HTML tooltip on one line per row Google gives its HTML tooltip no width, so the box shrink-to-fits against the room left beside the hovered feature. Opened near a map edge it broke even a short country name across lines, which the default SVG tooltip never did. --- .../charts/changelog/wooa7s-1922-geo-tooltip-width | 4 ++++ .../charts/src/charts/geo-chart/geo-chart.module.scss | 8 ++++++++ 2 files changed, 12 insertions(+) create mode 100644 projects/js-packages/charts/changelog/wooa7s-1922-geo-tooltip-width diff --git a/projects/js-packages/charts/changelog/wooa7s-1922-geo-tooltip-width b/projects/js-packages/charts/changelog/wooa7s-1922-geo-tooltip-width new file mode 100644 index 000000000000..d753b42a00de --- /dev/null +++ b/projects/js-packages/charts/changelog/wooa7s-1922-geo-tooltip-width @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +GeoChart: Stop an HTML tooltip breaking its lines when it opens near a map edge. diff --git a/projects/js-packages/charts/src/charts/geo-chart/geo-chart.module.scss b/projects/js-packages/charts/src/charts/geo-chart/geo-chart.module.scss index b4a51cf6b002..9301bdb10385 100644 --- a/projects/js-packages/charts/src/charts/geo-chart/geo-chart.module.scss +++ b/projects/js-packages/charts/src/charts/geo-chart/geo-chart.module.scss @@ -1,3 +1,11 @@ .container { position: relative; + + // Google gives its HTML tooltip no width, so the box shrink-to-fits against + // whatever room is left beside the hovered feature. Near a map edge that + // breaks even a short label across lines. Sizing to content keeps each line + // whole and grows the box instead. + :global(.google-visualization-tooltip) { + white-space: nowrap; + } }