@automattic/charts 4.5.0 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -2
- package/dist/index.cjs +4 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/charts/geo-chart/geo-chart.tsx +4 -0
- package/src/charts/geo-chart/index.ts +7 -1
- package/src/charts/geo-chart/test/geo-chart.test.tsx +8 -0
- package/src/charts/geo-chart/types.ts +12 -0
- package/src/index.ts +7 -1
package/package.json
CHANGED
|
@@ -130,6 +130,7 @@ function normalizeGeoChartError( eventArgs: unknown ): GeoChartError {
|
|
|
130
130
|
* @param props.height - Height of the chart in pixels
|
|
131
131
|
* @param props.region - Region to display ('world', 'US', or ISO 3166-1 alpha-2 code)
|
|
132
132
|
* @param props.resolution - Resolution level ('countries', 'provinces', or 'metros')
|
|
133
|
+
* @param props.displayMode - Plot rows as shaded areas ('regions') or markers ('markers')
|
|
133
134
|
* @param props.domain - Country code whose viewpoint sets the disputed borders
|
|
134
135
|
* @param props.onError - Optional callback for Google Charts errors
|
|
135
136
|
* @param props.className - Additional CSS class name for the chart container
|
|
@@ -143,6 +144,7 @@ const GeoChartInternal: FC< GeoChartProps > = ( {
|
|
|
143
144
|
height,
|
|
144
145
|
region = 'world',
|
|
145
146
|
resolution = 'countries',
|
|
147
|
+
displayMode = 'regions',
|
|
146
148
|
domain,
|
|
147
149
|
onError,
|
|
148
150
|
renderPlaceholder,
|
|
@@ -264,6 +266,7 @@ const GeoChartInternal: FC< GeoChartProps > = ( {
|
|
|
264
266
|
() => ( {
|
|
265
267
|
...( region !== 'world' && { region } ),
|
|
266
268
|
...( resolution !== 'countries' && { resolution } ),
|
|
269
|
+
...( displayMode !== 'regions' && { displayMode } ),
|
|
267
270
|
...( domain && { domain } ),
|
|
268
271
|
colorAxis: { colors: [ lightColorHex, fullColorHex ] },
|
|
269
272
|
backgroundColor: backgroundColorHex,
|
|
@@ -276,6 +279,7 @@ const GeoChartInternal: FC< GeoChartProps > = ( {
|
|
|
276
279
|
[
|
|
277
280
|
region,
|
|
278
281
|
resolution,
|
|
282
|
+
displayMode,
|
|
279
283
|
domain,
|
|
280
284
|
lightColorHex,
|
|
281
285
|
fullColorHex,
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
export { default as GeoChart, GeoChartUnresponsive } from './geo-chart';
|
|
2
|
-
export type {
|
|
2
|
+
export type {
|
|
3
|
+
GeoChartProps,
|
|
4
|
+
GeoRegion,
|
|
5
|
+
GeoResolution,
|
|
6
|
+
GeoDisplayMode,
|
|
7
|
+
GeoChartError,
|
|
8
|
+
} from './types';
|
|
@@ -224,6 +224,14 @@ describe( 'GeoChart', () => {
|
|
|
224
224
|
expect( options.domain ).toBe( 'IN' );
|
|
225
225
|
} );
|
|
226
226
|
|
|
227
|
+
test( 'passes the markers display mode so rows draw as points, not shaded areas', () => {
|
|
228
|
+
renderWithTheme( { displayMode: 'markers' } );
|
|
229
|
+
|
|
230
|
+
const options = JSON.parse( screen.getByTestId( 'chart-options' ).textContent || '{}' );
|
|
231
|
+
|
|
232
|
+
expect( options.displayMode ).toBe( 'markers' );
|
|
233
|
+
} );
|
|
234
|
+
|
|
227
235
|
test( 'does not include resolution in options when set to countries (default)', () => {
|
|
228
236
|
renderWithTheme();
|
|
229
237
|
|
|
@@ -15,6 +15,13 @@ export type GeoRegion = 'world' | ( string & {} );
|
|
|
15
15
|
*/
|
|
16
16
|
export type GeoResolution = 'countries' | 'provinces' | 'metros';
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* How the map plots its rows.
|
|
20
|
+
* - 'regions': Shades each area the rows name
|
|
21
|
+
* - 'markers': Draws a sized, colored circle per row; a row can name a place or give `[ latitude, longitude ]` as its first two columns
|
|
22
|
+
*/
|
|
23
|
+
export type GeoDisplayMode = 'regions' | 'markers';
|
|
24
|
+
|
|
18
25
|
export interface GeoChartError {
|
|
19
26
|
id?: string;
|
|
20
27
|
message?: string;
|
|
@@ -48,6 +55,11 @@ export interface GeoChartProps extends Pick<
|
|
|
48
55
|
* @default 'countries'
|
|
49
56
|
*/
|
|
50
57
|
resolution?: GeoResolution;
|
|
58
|
+
/**
|
|
59
|
+
* How the map plots its rows: shaded areas, or one marker per row.
|
|
60
|
+
* @default 'regions'
|
|
61
|
+
*/
|
|
62
|
+
displayMode?: GeoDisplayMode;
|
|
51
63
|
/**
|
|
52
64
|
* ISO 3166-1 alpha-2 code of the country whose viewpoint sets the disputed borders
|
|
53
65
|
* (e.g., 'IN' draws Kashmir as India shows it). Google's default borders apply when omitted.
|
package/src/index.ts
CHANGED
|
@@ -82,7 +82,13 @@ export type {
|
|
|
82
82
|
PieSemiCircleChartProps,
|
|
83
83
|
PieSemiCircleChartRenderTooltipParams,
|
|
84
84
|
} from './charts/pie-semi-circle-chart';
|
|
85
|
-
export type {
|
|
85
|
+
export type {
|
|
86
|
+
GeoChartProps,
|
|
87
|
+
GeoRegion,
|
|
88
|
+
GeoResolution,
|
|
89
|
+
GeoDisplayMode,
|
|
90
|
+
GeoChartError,
|
|
91
|
+
} from './charts/geo-chart';
|
|
86
92
|
export type { LegendValueDisplay, BaseLegendItem } from './components/legend';
|
|
87
93
|
export type { TrendIndicatorProps, TrendDirection } from './components/trend-indicator';
|
|
88
94
|
export type { LineStyles, GridStyles, EventHandlerParams } from '@visx/xychart';
|