@automattic/charts 1.1.0 → 1.2.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/AGENTS.md +14 -1
- package/CHANGELOG.md +13 -0
- package/dist/index.cjs +1238 -1155
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +50 -123
- package/dist/index.css.map +1 -1
- package/dist/index.js +1273 -1190
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
- package/src/charts/conversion-funnel-chart/conversion-funnel-chart.module.scss +25 -52
- package/src/charts/conversion-funnel-chart/conversion-funnel-chart.tsx +20 -11
- package/src/charts/geo-chart/geo-chart.module.scss +0 -3
- package/src/charts/geo-chart/geo-chart.tsx +9 -4
- package/src/charts/leaderboard-chart/leaderboard-chart.module.scss +7 -3
- package/src/charts/line-chart/line-chart.module.scss +13 -20
- package/src/charts/line-chart/line-chart.tsx +9 -2
- package/src/charts/line-chart/private/line-chart-annotation-label-popover.tsx +3 -2
- package/src/charts/pie-semi-circle-chart/pie-semi-circle-chart.module.scss +3 -3
- package/src/charts/private/svg-empty-state/svg-empty-state.module.scss +1 -1
- package/src/components/legend/private/base-legend.module.scss +3 -52
- package/src/components/legend/private/base-legend.tsx +30 -28
- package/src/components/tooltip/base-tooltip.module.scss +3 -3
- package/src/components/trend-indicator/trend-indicator.module.scss +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automattic/charts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Display charts within Automattic products.",
|
|
5
5
|
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/charts/#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"typecheck": "tsgo --noEmit"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@automattic/number-formatters": "^1.1.
|
|
66
|
+
"@automattic/number-formatters": "^1.1.6",
|
|
67
67
|
"@babel/runtime": "7.29.2",
|
|
68
68
|
"@react-spring/web": "9.7.5",
|
|
69
69
|
"@visx/annotation": "^3.12.0",
|
|
@@ -84,8 +84,8 @@
|
|
|
84
84
|
"@visx/xychart": "^3.12.0",
|
|
85
85
|
"@wordpress/i18n": "^6.0.0",
|
|
86
86
|
"@wordpress/icons": "^12.0.0",
|
|
87
|
-
"@wordpress/theme": "0.
|
|
88
|
-
"@wordpress/ui": "0.
|
|
87
|
+
"@wordpress/theme": "0.11.0",
|
|
88
|
+
"@wordpress/ui": "0.11.0",
|
|
89
89
|
"clsx": "2.1.1",
|
|
90
90
|
"date-fns": "^4.1.0",
|
|
91
91
|
"deepmerge": "4.3.1",
|
|
@@ -99,8 +99,8 @@
|
|
|
99
99
|
"@babel/core": "7.29.0",
|
|
100
100
|
"@babel/preset-react": "7.28.5",
|
|
101
101
|
"@babel/preset-typescript": "7.28.5",
|
|
102
|
-
"@storybook/addon-docs": "10.3.
|
|
103
|
-
"@storybook/react": "10.3.
|
|
102
|
+
"@storybook/addon-docs": "10.3.5",
|
|
103
|
+
"@storybook/react": "10.3.5",
|
|
104
104
|
"@testing-library/dom": "^10.0.0",
|
|
105
105
|
"@testing-library/jest-dom": "^6.0.0",
|
|
106
106
|
"@testing-library/react": "^16.0.0",
|
|
@@ -110,9 +110,9 @@
|
|
|
110
110
|
"@types/react-dom": "18.3.7",
|
|
111
111
|
"@typescript/native-preview": "7.0.0-dev.20260225.1",
|
|
112
112
|
"@visx/glyph": "3.12.0",
|
|
113
|
-
"@wordpress/components": "32.
|
|
114
|
-
"@wordpress/element": "6.
|
|
115
|
-
"@wordpress/private-apis": "1.
|
|
113
|
+
"@wordpress/components": "32.6.0",
|
|
114
|
+
"@wordpress/element": "6.44.0",
|
|
115
|
+
"@wordpress/private-apis": "1.44.0",
|
|
116
116
|
"babel-jest": "30.3.0",
|
|
117
117
|
"babel-plugin-react-remove-properties": "^0.3.1",
|
|
118
118
|
"esbuild": "0.27.4",
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
"react": "18.3.1",
|
|
127
127
|
"react-dom": "18.3.1",
|
|
128
128
|
"sass-embedded": "1.97.3",
|
|
129
|
-
"storybook": "10.3.
|
|
129
|
+
"storybook": "10.3.5",
|
|
130
130
|
"tsup": "8.5.1",
|
|
131
131
|
"typescript": "5.9.3"
|
|
132
132
|
},
|
|
@@ -7,10 +7,6 @@
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
.main-metric {
|
|
10
|
-
display: flex;
|
|
11
|
-
align-items: baseline;
|
|
12
|
-
gap: 8px;
|
|
13
|
-
margin-bottom: 24px;
|
|
14
10
|
height: 20px;
|
|
15
11
|
}
|
|
16
12
|
|
|
@@ -18,27 +14,24 @@
|
|
|
18
14
|
overflow: hidden;
|
|
19
15
|
color: #1e1e1e;
|
|
20
16
|
text-overflow: ellipsis;
|
|
21
|
-
font-size: var(--wpds-font-size-xl, 18px);
|
|
17
|
+
font-size: var(--wpds-typography-font-size-xl, 18px);
|
|
22
18
|
font-style: normal;
|
|
23
|
-
font-weight: var(--wpds-font-weight-medium, 499);
|
|
24
|
-
line-height: var(--wpds-
|
|
19
|
+
font-weight: var(--wpds-typography-font-weight-medium, 499);
|
|
20
|
+
line-height: var(--wpds-typography-line-height-sm, 20px);
|
|
25
21
|
margin: 0;
|
|
26
22
|
}
|
|
27
23
|
|
|
28
24
|
.change-indicator {
|
|
29
25
|
overflow: hidden;
|
|
30
26
|
text-overflow: ellipsis;
|
|
31
|
-
font-size: var(--wpds-font-size-md, 13px);
|
|
27
|
+
font-size: var(--wpds-typography-font-size-md, 13px);
|
|
32
28
|
font-style: normal;
|
|
33
|
-
font-weight: var(--wpds-font-weight-medium, 499);
|
|
34
|
-
line-height: var(--wpds-
|
|
29
|
+
font-weight: var(--wpds-typography-font-weight-medium, 499);
|
|
30
|
+
line-height: var(--wpds-typography-line-height-sm, 20px);
|
|
35
31
|
margin: 0;
|
|
36
32
|
}
|
|
37
33
|
|
|
38
34
|
.funnel-container {
|
|
39
|
-
display: flex;
|
|
40
|
-
gap: 16px;
|
|
41
|
-
align-items: flex-end;
|
|
42
35
|
flex: 1;
|
|
43
36
|
min-height: 200px;
|
|
44
37
|
width: 100%;
|
|
@@ -47,8 +40,6 @@
|
|
|
47
40
|
.funnel-step {
|
|
48
41
|
flex: 1 1 0;
|
|
49
42
|
min-width: 0;
|
|
50
|
-
display: flex;
|
|
51
|
-
flex-direction: column;
|
|
52
43
|
height: 100%;
|
|
53
44
|
|
|
54
45
|
&--animated {
|
|
@@ -60,37 +51,26 @@
|
|
|
60
51
|
}
|
|
61
52
|
}
|
|
62
53
|
|
|
63
|
-
.step-header {
|
|
64
|
-
margin-bottom: 24px;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
54
|
.step-label {
|
|
68
55
|
color: #757575;
|
|
69
|
-
font-size: var(--wpds-font-size-sm, 12px);
|
|
70
|
-
font-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
margin: 0 0 2px 0;
|
|
74
|
-
display: block;
|
|
56
|
+
font-size: var(--wpds-typography-font-size-sm, 12px);
|
|
57
|
+
font-weight: var(--wpds-typography-font-weight-regular, 400);
|
|
58
|
+
line-height: var(--wpds-typography-line-height-xs, 16px);
|
|
59
|
+
white-space: nowrap;
|
|
75
60
|
overflow: hidden;
|
|
76
61
|
text-overflow: ellipsis;
|
|
77
62
|
}
|
|
78
63
|
|
|
79
64
|
.step-rate {
|
|
80
65
|
color: #1e1e1e;
|
|
81
|
-
font-size: var(--wpds-font-size-md, 13px);
|
|
82
|
-
font-
|
|
83
|
-
|
|
84
|
-
line-height: var(--wpds-font-line-height-sm, 20px);
|
|
85
|
-
margin: 0;
|
|
86
|
-
display: block;
|
|
66
|
+
font-size: var(--wpds-typography-font-size-md, 13px);
|
|
67
|
+
font-weight: var(--wpds-typography-font-weight-medium, 499);
|
|
68
|
+
line-height: var(--wpds-typography-line-height-xs, 16px);
|
|
87
69
|
}
|
|
88
70
|
|
|
89
71
|
.bar-container {
|
|
90
72
|
flex: 1;
|
|
91
|
-
|
|
92
|
-
align-items: flex-end;
|
|
93
|
-
border-radius: 4px;
|
|
73
|
+
border-radius: var(--wpds-border-radius-md, 4px);
|
|
94
74
|
position: relative;
|
|
95
75
|
cursor: pointer;
|
|
96
76
|
}
|
|
@@ -98,7 +78,7 @@
|
|
|
98
78
|
.funnel-bar {
|
|
99
79
|
width: 100%;
|
|
100
80
|
min-height: 4px;
|
|
101
|
-
border-radius: 4px 4px 0 0;
|
|
81
|
+
border-radius: var(--wpds-border-radius-md, 4px) var(--wpds-border-radius-md, 4px) 0 0;
|
|
102
82
|
|
|
103
83
|
&--animated {
|
|
104
84
|
transform-origin: bottom;
|
|
@@ -116,41 +96,34 @@
|
|
|
116
96
|
}
|
|
117
97
|
|
|
118
98
|
.tooltip-wrapper {
|
|
119
|
-
|
|
120
|
-
flex-direction: column;
|
|
121
|
-
justify-content: center;
|
|
122
|
-
align-items: flex-start;
|
|
123
|
-
gap: 4px;
|
|
124
|
-
|
|
125
|
-
border-bottom: 1px solid var(--Gray-Gray-5, #dcdcde);
|
|
99
|
+
border-bottom: var(--wpds-border-width-xs, 1px) solid var(--Gray-Gray-5, #dcdcde);
|
|
126
100
|
background: var(--black-white-white, #fff);
|
|
127
101
|
|
|
128
102
|
// Override .visx-tooltip inline styles.
|
|
129
|
-
border-radius: 4px !important;
|
|
130
|
-
padding: 12px !important;
|
|
103
|
+
border-radius: var(--wpds-border-radius-md, 4px) !important;
|
|
104
|
+
padding: var(--wpds-dimension-padding-md, 12px) !important;
|
|
131
105
|
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.15), 0 3px 9px 0 rgba(0, 0, 0, 0.12) !important;
|
|
132
106
|
|
|
133
107
|
}
|
|
134
108
|
|
|
135
109
|
.tooltip-title {
|
|
136
110
|
color: #1e1e1e;
|
|
137
|
-
font-size: var(--wpds-font-size-sm, 12px);
|
|
111
|
+
font-size: var(--wpds-typography-font-size-sm, 12px);
|
|
138
112
|
font-style: normal;
|
|
139
|
-
font-weight: var(--wpds-font-weight-regular, 400);
|
|
140
|
-
line-height: var(--wpds-
|
|
113
|
+
font-weight: var(--wpds-typography-font-weight-regular, 400);
|
|
114
|
+
line-height: var(--wpds-typography-line-height-xs, 16px);
|
|
141
115
|
}
|
|
142
116
|
|
|
143
117
|
.tooltip-content {
|
|
144
118
|
color: #1e1e1e;
|
|
145
|
-
font-size: var(--wpds-font-size-md, 13px);
|
|
119
|
+
font-size: var(--wpds-typography-font-size-md, 13px);
|
|
146
120
|
font-style: normal;
|
|
147
|
-
font-weight: var(--wpds-font-weight-medium, 499);
|
|
148
|
-
line-height: var(--wpds-
|
|
121
|
+
font-weight: var(--wpds-typography-font-weight-medium, 499);
|
|
122
|
+
line-height: var(--wpds-typography-line-height-sm, 20px);
|
|
149
123
|
}
|
|
150
124
|
|
|
151
125
|
.empty-state {
|
|
152
126
|
text-align: center;
|
|
153
|
-
padding: 48px 24px;
|
|
154
127
|
color: #6b7280;
|
|
155
|
-
font-size: var(--wpds-font-size-lg, 16px);
|
|
128
|
+
font-size: var(--wpds-typography-font-size-lg, 16px);
|
|
156
129
|
}
|
|
@@ -263,13 +263,13 @@ const ConversionFunnelChartInternal: FC< ConversionFunnelChartProps > = ( {
|
|
|
263
263
|
|
|
264
264
|
// Default tooltip rendering function
|
|
265
265
|
const renderDefaultTooltip = ( step: FunnelStep ) => (
|
|
266
|
-
|
|
266
|
+
<Stack direction="column" align="flex-start" gap="xs">
|
|
267
267
|
<div className={ styles[ 'tooltip-title' ] }>{ step.label }</div>
|
|
268
268
|
<div className={ styles[ 'tooltip-content' ] }>
|
|
269
269
|
{ formatPercentage( step.rate ) }
|
|
270
270
|
{ ` • ${ step.count ?? 'no' } items` }
|
|
271
271
|
</div>
|
|
272
|
-
|
|
272
|
+
</Stack>
|
|
273
273
|
);
|
|
274
274
|
|
|
275
275
|
// Validate data
|
|
@@ -300,6 +300,8 @@ const ConversionFunnelChartInternal: FC< ConversionFunnelChartProps > = ( {
|
|
|
300
300
|
return (
|
|
301
301
|
<Stack
|
|
302
302
|
direction="column"
|
|
303
|
+
align="center"
|
|
304
|
+
justify="center"
|
|
303
305
|
data-testid="conversion-funnel-chart"
|
|
304
306
|
className={ clsx(
|
|
305
307
|
styles[ 'conversion-funnel-chart' ],
|
|
@@ -322,6 +324,7 @@ const ConversionFunnelChartInternal: FC< ConversionFunnelChartProps > = ( {
|
|
|
322
324
|
<>
|
|
323
325
|
<Stack
|
|
324
326
|
direction="column"
|
|
327
|
+
gap="xl"
|
|
325
328
|
data-testid="conversion-funnel-chart"
|
|
326
329
|
ref={ node => {
|
|
327
330
|
// Set containerRef for @visx coordinate system
|
|
@@ -344,27 +347,31 @@ const ConversionFunnelChartInternal: FC< ConversionFunnelChartProps > = ( {
|
|
|
344
347
|
changeColor,
|
|
345
348
|
} )
|
|
346
349
|
) : (
|
|
347
|
-
<
|
|
350
|
+
<Stack direction="row" align="baseline" gap="sm" className={ styles[ 'main-metric' ] }>
|
|
351
|
+
{ renderDefaultMainMetric() }
|
|
352
|
+
</Stack>
|
|
348
353
|
) }
|
|
349
354
|
|
|
350
355
|
{ /* Funnel Steps */ }
|
|
351
|
-
<
|
|
356
|
+
<Stack direction="row" align="flex-end" gap="lg" className={ styles[ 'funnel-container' ] }>
|
|
352
357
|
{ steps.map( ( step, index ) => {
|
|
353
358
|
const barHeight = ( step.rate / maxRate ) * 100;
|
|
354
359
|
const { isBlurred } = getStepState( step.id );
|
|
355
360
|
|
|
356
361
|
return (
|
|
357
|
-
<
|
|
362
|
+
<Stack
|
|
358
363
|
key={ step.id }
|
|
364
|
+
direction="column"
|
|
359
365
|
data-testid="funnel-step"
|
|
360
366
|
className={ clsx(
|
|
361
367
|
styles[ 'funnel-step' ],
|
|
362
368
|
isColorPaletteResolved && styles[ 'funnel-step--animated' ],
|
|
363
369
|
isBlurred && styles[ 'funnel-step--blurred' ]
|
|
364
370
|
) }
|
|
371
|
+
gap="xl"
|
|
365
372
|
>
|
|
366
373
|
{ /* Step Label and Rate */ }
|
|
367
|
-
<
|
|
374
|
+
<Stack direction="column" gap="xs">
|
|
368
375
|
{ renderStepLabel ? (
|
|
369
376
|
renderStepLabel( {
|
|
370
377
|
step,
|
|
@@ -385,10 +392,12 @@ const ConversionFunnelChartInternal: FC< ConversionFunnelChartProps > = ( {
|
|
|
385
392
|
{ formatPercentage( step.rate ) }
|
|
386
393
|
</span>
|
|
387
394
|
) }
|
|
388
|
-
</
|
|
395
|
+
</Stack>
|
|
389
396
|
|
|
390
397
|
{ /* Funnel Bar */ }
|
|
391
|
-
<
|
|
398
|
+
<Stack
|
|
399
|
+
direction="column"
|
|
400
|
+
justify="flex-end"
|
|
392
401
|
className={ styles[ 'bar-container' ] }
|
|
393
402
|
onClick={ stepHandlers.get( step.id )?.onClick }
|
|
394
403
|
onKeyDown={ stepHandlers.get( step.id )?.onKeyDown }
|
|
@@ -407,11 +416,11 @@ const ConversionFunnelChartInternal: FC< ConversionFunnelChartProps > = ( {
|
|
|
407
416
|
backgroundColor: barColor,
|
|
408
417
|
} }
|
|
409
418
|
/>
|
|
410
|
-
</
|
|
411
|
-
</
|
|
419
|
+
</Stack>
|
|
420
|
+
</Stack>
|
|
412
421
|
);
|
|
413
422
|
} ) }
|
|
414
|
-
</
|
|
423
|
+
</Stack>
|
|
415
424
|
</Stack>
|
|
416
425
|
|
|
417
426
|
{ /* Tooltip Portal */ }
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { Stack } from '@wordpress/ui';
|
|
5
6
|
import clsx from 'clsx';
|
|
6
7
|
import { FC, useContext, useMemo } from 'react';
|
|
7
8
|
import { Chart, type GoogleChartOptions } from 'react-google-charts';
|
|
@@ -57,13 +58,15 @@ const GeoChartInternal: FC< GeoChartProps > = ( {
|
|
|
57
58
|
|
|
58
59
|
// Render loading placeholder
|
|
59
60
|
const loadingPlaceholder = (
|
|
60
|
-
<
|
|
61
|
+
<Stack
|
|
62
|
+
align="center"
|
|
63
|
+
justify="center"
|
|
61
64
|
className={ clsx( 'geo-chart', styles.container, className ) }
|
|
62
65
|
data-testid="geo-chart-loading"
|
|
63
66
|
style={ { width, height } }
|
|
64
67
|
>
|
|
65
68
|
{ renderPlaceholder ? renderPlaceholder() : __( 'Loading map', 'jetpack-charts' ) }
|
|
66
|
-
</
|
|
69
|
+
</Stack>
|
|
67
70
|
);
|
|
68
71
|
|
|
69
72
|
// Google charts doesn't accept CSS variables, so we need to convert them to hex colors
|
|
@@ -144,7 +147,9 @@ const GeoChartInternal: FC< GeoChartProps > = ( {
|
|
|
144
147
|
);
|
|
145
148
|
|
|
146
149
|
return (
|
|
147
|
-
<
|
|
150
|
+
<Stack
|
|
151
|
+
align="center"
|
|
152
|
+
justify="center"
|
|
148
153
|
className={ clsx( 'geo-chart', styles.container, className ) }
|
|
149
154
|
data-testid="geo-chart"
|
|
150
155
|
style={ { width, height, backgroundColor } }
|
|
@@ -157,7 +162,7 @@ const GeoChartInternal: FC< GeoChartProps > = ( {
|
|
|
157
162
|
options={ options }
|
|
158
163
|
loader={ loadingPlaceholder }
|
|
159
164
|
/>
|
|
160
|
-
</
|
|
165
|
+
</Stack>
|
|
161
166
|
);
|
|
162
167
|
};
|
|
163
168
|
|
|
@@ -21,6 +21,10 @@
|
|
|
21
21
|
display: grid;
|
|
22
22
|
align-items: center;
|
|
23
23
|
grid-template-columns: 1fr;
|
|
24
|
+
// Outlier: not tokenized. The leaderboard's compact bar + gap + bar
|
|
25
|
+
// rhythm (6px bar, 6px row-gap, 6px bar) is intentional and does not
|
|
26
|
+
// map to any WPDS dimension token — gap-sm (8px) breaks the visual
|
|
27
|
+
// balance between the rows and the bars.
|
|
24
28
|
row-gap: 6px;
|
|
25
29
|
isolation: isolate;
|
|
26
30
|
|
|
@@ -34,7 +38,7 @@
|
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
.label {
|
|
37
|
-
padding-left: 8px;
|
|
41
|
+
padding-left: var(--wpds-dimension-padding-sm, 8px);
|
|
38
42
|
}
|
|
39
43
|
}
|
|
40
44
|
|
|
@@ -70,9 +74,9 @@
|
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
.emptyState {
|
|
73
|
-
padding: 32px 16px;
|
|
77
|
+
padding: var(--wpds-dimension-padding-3xl, 32px) var(--wpds-dimension-padding-lg, 16px);
|
|
74
78
|
text-align: center;
|
|
75
79
|
color: #666;
|
|
76
|
-
font-size: var(--wpds-font-size-md, 13px);
|
|
80
|
+
font-size: var(--wpds-typography-font-size-md, 13px);
|
|
77
81
|
font-style: italic;
|
|
78
82
|
}
|
|
@@ -17,24 +17,21 @@
|
|
|
17
17
|
&__tooltip,
|
|
18
18
|
&__annotation-label-popover {
|
|
19
19
|
background: #fff;
|
|
20
|
-
padding:
|
|
20
|
+
padding: var(--wpds-dimension-padding-sm, 8px);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
&__tooltip-date {
|
|
24
|
-
font-weight: var(--wpds-font-weight-medium, 499);
|
|
25
|
-
padding-bottom:
|
|
24
|
+
font-weight: var(--wpds-typography-font-weight-medium, 499);
|
|
25
|
+
padding-bottom: var(--wpds-dimension-padding-md, 12px);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
&__tooltip-row {
|
|
29
|
-
|
|
30
|
-
align-items: center;
|
|
31
|
-
padding: 4px 0;
|
|
32
|
-
justify-content: space-between;
|
|
29
|
+
padding: var(--wpds-dimension-padding-xs, 4px) 0;
|
|
33
30
|
}
|
|
34
31
|
|
|
35
32
|
&__tooltip-label {
|
|
36
|
-
font-weight: var(--wpds-font-weight-medium, 499);
|
|
37
|
-
padding-right:
|
|
33
|
+
font-weight: var(--wpds-typography-font-weight-medium, 499);
|
|
34
|
+
padding-right: var(--wpds-dimension-padding-lg, 16px);
|
|
38
35
|
}
|
|
39
36
|
|
|
40
37
|
&__annotations-overlay {
|
|
@@ -64,11 +61,14 @@
|
|
|
64
61
|
min-width: 125px;
|
|
65
62
|
background: #fff;
|
|
66
63
|
border: none;
|
|
67
|
-
border-radius: 4px;
|
|
68
|
-
font-size: var(--wpds-font-size-md, 13px);
|
|
64
|
+
border-radius: var(--wpds-border-radius-md, 4px);
|
|
65
|
+
font-size: var(--wpds-typography-font-size-md, 13px);
|
|
69
66
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
|
|
70
67
|
position: fixed;
|
|
71
|
-
margin:
|
|
68
|
+
// Without margin set, the popover has margin:auto which upsets the
|
|
69
|
+
// positioning relative to the trigger button. A gap token is appropriate
|
|
70
|
+
// because it creates a gap to the trigger button.
|
|
71
|
+
margin: var(--wpds-dimension-gap-sm, 8px);
|
|
72
72
|
visibility: hidden;
|
|
73
73
|
|
|
74
74
|
&--visible {
|
|
@@ -81,15 +81,8 @@
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
&__annotation-label-popover-header {
|
|
85
|
-
display: flex;
|
|
86
|
-
flex-direction: row;
|
|
87
|
-
justify-content: space-between;
|
|
88
|
-
align-items: start;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
84
|
&__annotation-label-popover-content {
|
|
92
|
-
padding:
|
|
85
|
+
padding: var(--wpds-dimension-padding-sm, 8px);
|
|
93
86
|
}
|
|
94
87
|
|
|
95
88
|
&__annotation-label-popover-close-button {
|
|
@@ -4,6 +4,7 @@ import { LinearGradient } from '@visx/gradient';
|
|
|
4
4
|
import { scaleTime } from '@visx/scale';
|
|
5
5
|
import { XYChart, AreaSeries, Grid, Axis, DataContext } from '@visx/xychart';
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
|
+
import { Stack } from '@wordpress/ui';
|
|
7
8
|
import clsx from 'clsx';
|
|
8
9
|
import { differenceInHours, differenceInYears } from 'date-fns';
|
|
9
10
|
import {
|
|
@@ -103,12 +104,18 @@ const renderDefaultTooltip = ( params: RenderTooltipParams< DataPointDate > ) =>
|
|
|
103
104
|
{ nearestDatum.date?.toLocaleDateString() }
|
|
104
105
|
</div>
|
|
105
106
|
{ tooltipPoints.map( point => (
|
|
106
|
-
<
|
|
107
|
+
<Stack
|
|
108
|
+
key={ point.key }
|
|
109
|
+
direction="row"
|
|
110
|
+
align="center"
|
|
111
|
+
justify="space-between"
|
|
112
|
+
className={ styles[ 'line-chart__tooltip-row' ] }
|
|
113
|
+
>
|
|
107
114
|
<span className={ styles[ 'line-chart__tooltip-label' ] }>{ point.key }:</span>
|
|
108
115
|
<span className={ styles[ 'line-chart__tooltip-value' ] }>
|
|
109
116
|
{ formatNumber( point.value ) }
|
|
110
117
|
</span>
|
|
111
|
-
</
|
|
118
|
+
</Stack>
|
|
112
119
|
) ) }
|
|
113
120
|
</div>
|
|
114
121
|
);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __ } from '@wordpress/i18n';
|
|
2
2
|
import { Icon, close } from '@wordpress/icons';
|
|
3
|
+
import { Stack } from '@wordpress/ui';
|
|
3
4
|
import clsx from 'clsx';
|
|
4
5
|
import { useEffect, useId, useRef, useState } from 'react';
|
|
5
6
|
import { isSafari } from '../../../utils';
|
|
@@ -88,7 +89,7 @@ const LineChartAnnotationLabelWithPopover: FC< LineChartAnnotationLabelWithPopov
|
|
|
88
89
|
) }
|
|
89
90
|
data-testid="line-chart-annotation-label-popover"
|
|
90
91
|
>
|
|
91
|
-
<
|
|
92
|
+
<Stack direction="row" align="flex-start" justify="space-between">
|
|
92
93
|
<div className={ styles[ 'line-chart__annotation-label-popover-content' ] }>
|
|
93
94
|
{ renderLabelPopover( { title, subtitle } ) }
|
|
94
95
|
</div>
|
|
@@ -102,7 +103,7 @@ const LineChartAnnotationLabelWithPopover: FC< LineChartAnnotationLabelWithPopov
|
|
|
102
103
|
>
|
|
103
104
|
<Icon icon={ close } size={ 16 } />
|
|
104
105
|
</button>
|
|
105
|
-
</
|
|
106
|
+
</Stack>
|
|
106
107
|
</div>
|
|
107
108
|
</div>
|
|
108
109
|
);
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
.label {
|
|
14
|
-
font-weight: var(--wpds-font-weight-medium, 499);
|
|
15
|
-
font-size: var(--wpds-font-size-lg, 16px);
|
|
14
|
+
font-weight: var(--wpds-typography-font-weight-medium, 499);
|
|
15
|
+
font-size: var(--wpds-typography-font-size-lg, 16px);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
.note {
|
|
19
|
-
font-size: var(--wpds-font-size-md, 13px);
|
|
19
|
+
font-size: var(--wpds-typography-font-size-md, 13px);
|
|
20
20
|
}
|
|
21
21
|
}
|
|
@@ -1,50 +1,9 @@
|
|
|
1
1
|
.legend {
|
|
2
2
|
align-self: stretch;
|
|
3
|
-
|
|
4
|
-
&--horizontal {
|
|
5
|
-
display: flex;
|
|
6
|
-
flex-direction: row;
|
|
7
|
-
flex-wrap: wrap;
|
|
8
|
-
gap: 16px;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
&--vertical {
|
|
12
|
-
display: flex;
|
|
13
|
-
flex-direction: column;
|
|
14
|
-
gap: 8px;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
&--alignment-start {
|
|
18
|
-
justify-content: flex-start;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
&--alignment-center {
|
|
22
|
-
justify-content: center;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
&--alignment-end {
|
|
26
|
-
justify-content: flex-end;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Vertical legends align on the cross-axis instead
|
|
30
|
-
&--vertical.legend--alignment-start {
|
|
31
|
-
align-items: flex-start;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
&--vertical.legend--alignment-center {
|
|
35
|
-
align-items: center;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
&--vertical.legend--alignment-end {
|
|
39
|
-
align-items: flex-end;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
3
|
}
|
|
43
4
|
|
|
44
5
|
.legend-item {
|
|
45
|
-
|
|
46
|
-
align-items: center;
|
|
47
|
-
font-size: var(--wpds-font-size-md, 13px);
|
|
6
|
+
font-size: var(--wpds-typography-font-size-md, 13px);
|
|
48
7
|
|
|
49
8
|
&--interactive {
|
|
50
9
|
cursor: pointer;
|
|
@@ -58,7 +17,7 @@
|
|
|
58
17
|
&:focus {
|
|
59
18
|
outline: 2px solid currentColor;
|
|
60
19
|
outline-offset: 2px;
|
|
61
|
-
border-radius: 4px;
|
|
20
|
+
border-radius: var(--wpds-border-radius-md, 4px);
|
|
62
21
|
}
|
|
63
22
|
|
|
64
23
|
&:focus:not(:focus-visible) {
|
|
@@ -75,14 +34,6 @@
|
|
|
75
34
|
}
|
|
76
35
|
}
|
|
77
36
|
|
|
78
|
-
.legend-item-label {
|
|
79
|
-
display: flex;
|
|
80
|
-
align-items: center;
|
|
81
|
-
gap: 0.5rem;
|
|
82
|
-
|
|
83
|
-
/* Text wrapping is handled at the text level, not the label container */
|
|
84
|
-
}
|
|
85
|
-
|
|
86
37
|
.legend-item-text {
|
|
87
38
|
|
|
88
39
|
&--wrap {
|
|
@@ -101,6 +52,6 @@
|
|
|
101
52
|
}
|
|
102
53
|
|
|
103
54
|
.legend-item-value {
|
|
104
|
-
font-weight: var(--wpds-font-weight-medium, 499);
|
|
55
|
+
font-weight: var(--wpds-typography-font-weight-medium, 499);
|
|
105
56
|
flex-shrink: 0; // Prevent value from shrinking when text is ellipsized
|
|
106
57
|
}
|