@automattic/charts 1.0.2 → 1.1.1
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 +18 -0
- package/dist/{chunk-G3PMV62Z.js → chunk-5WRI5ZAA.js} +1 -6
- package/dist/{chunk-EMMSS5I5.cjs → chunk-DZUJEN5N.cjs} +2 -7
- package/dist/chunk-DZUJEN5N.cjs.map +1 -0
- package/dist/index.cjs +1571 -2377
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +31 -107
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1722 -2528
- package/dist/index.js.map +1 -1
- package/dist/visx/group/index.cjs +1 -1
- package/dist/visx/group/index.js +1 -1
- package/dist/visx/legend/index.cjs +1 -1
- package/dist/visx/legend/index.js +1 -1
- package/dist/visx/text/index.cjs +1 -1
- package/dist/visx/text/index.js +1 -1
- package/package.json +9 -8
- package/src/charts/conversion-funnel-chart/conversion-funnel-chart.module.scss +19 -47
- package/src/charts/conversion-funnel-chart/conversion-funnel-chart.tsx +17 -10
- 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 +1 -1
- package/src/charts/leaderboard-chart/leaderboard-chart.tsx +2 -2
- package/src/charts/line-chart/line-chart.module.scss +3 -13
- package/src/charts/line-chart/line-chart.tsx +9 -2
- package/src/charts/line-chart/private/line-chart-annotation-label-popover.tsx +5 -4
- package/src/charts/pie-chart/pie-chart.tsx +5 -3
- package/src/charts/pie-semi-circle-chart/pie-semi-circle-chart.module.scss +3 -3
- package/src/components/legend/private/base-legend.module.scss +2 -51
- package/src/components/legend/private/base-legend.tsx +30 -28
- package/src/components/tooltip/base-tooltip.module.scss +1 -1
- package/src/components/trend-indicator/trend-indicator.module.scss +2 -2
- package/src/hooks/use-chart-margin.tsx +1 -14
- package/src/providers/chart-context/themes.ts +7 -1
- package/src/types.ts +2 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/resolve-font-size.ts +37 -0
- package/src/utils/test/resolve-css-var.test.ts +3 -5
- package/src/utils/test/resolve-font-size.test.ts +66 -0
- package/dist/chunk-EMMSS5I5.cjs.map +0 -1
- /package/dist/{chunk-G3PMV62Z.js.map → chunk-5WRI5ZAA.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../../chunk-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../../chunk-DZUJEN5N.cjs');
|
|
2
2
|
|
|
3
3
|
// src/visx/group/index.ts
|
|
4
4
|
var _group = require('@visx/group');
|
package/dist/visx/group/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../../chunk-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../../chunk-DZUJEN5N.cjs');
|
|
2
2
|
|
|
3
3
|
// src/visx/legend/index.ts
|
|
4
4
|
var _legend = require('@visx/legend');
|
package/dist/visx/text/index.cjs
CHANGED
package/dist/visx/text/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automattic/charts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
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,8 +63,8 @@
|
|
|
63
63
|
"typecheck": "tsgo --noEmit"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@automattic/number-formatters": "^1.1.
|
|
67
|
-
"@babel/runtime": "7.
|
|
66
|
+
"@automattic/number-formatters": "^1.1.6",
|
|
67
|
+
"@babel/runtime": "7.29.2",
|
|
68
68
|
"@react-spring/web": "9.7.5",
|
|
69
69
|
"@visx/annotation": "^3.12.0",
|
|
70
70
|
"@visx/axis": "^3.12.0",
|
|
@@ -83,14 +83,14 @@
|
|
|
83
83
|
"@visx/vendor": "^3.12.0",
|
|
84
84
|
"@visx/xychart": "^3.12.0",
|
|
85
85
|
"@wordpress/i18n": "^6.0.0",
|
|
86
|
-
"@wordpress/
|
|
87
|
-
"@wordpress/
|
|
86
|
+
"@wordpress/icons": "^12.0.0",
|
|
87
|
+
"@wordpress/theme": "0.10.0",
|
|
88
|
+
"@wordpress/ui": "0.10.0",
|
|
88
89
|
"clsx": "2.1.1",
|
|
89
90
|
"date-fns": "^4.1.0",
|
|
90
91
|
"deepmerge": "4.3.1",
|
|
91
92
|
"dompurify": "^3.3.3",
|
|
92
93
|
"fast-deep-equal": "3.1.3",
|
|
93
|
-
"gridicons": "3.4.2",
|
|
94
94
|
"react-google-charts": "^5.2.1",
|
|
95
95
|
"tslib": "2.8.1"
|
|
96
96
|
},
|
|
@@ -110,8 +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.
|
|
113
|
+
"@wordpress/components": "32.5.0",
|
|
114
|
+
"@wordpress/element": "6.43.0",
|
|
115
|
+
"@wordpress/private-apis": "1.43.0",
|
|
115
116
|
"babel-jest": "30.3.0",
|
|
116
117
|
"babel-plugin-react-remove-properties": "^0.3.1",
|
|
117
118
|
"esbuild": "0.27.4",
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
.conversion-funnel-chart {
|
|
2
|
-
font-family: var(--funnel-font-family, "SF Pro Text");
|
|
3
2
|
|
|
4
3
|
&--loading {
|
|
5
4
|
opacity: 0.6;
|
|
@@ -8,10 +7,6 @@
|
|
|
8
7
|
}
|
|
9
8
|
|
|
10
9
|
.main-metric {
|
|
11
|
-
display: flex;
|
|
12
|
-
align-items: baseline;
|
|
13
|
-
gap: 8px;
|
|
14
|
-
margin-bottom: 24px;
|
|
15
10
|
height: 20px;
|
|
16
11
|
}
|
|
17
12
|
|
|
@@ -19,29 +14,24 @@
|
|
|
19
14
|
overflow: hidden;
|
|
20
15
|
color: #1e1e1e;
|
|
21
16
|
text-overflow: ellipsis;
|
|
22
|
-
font-
|
|
23
|
-
font-size: 18px;
|
|
17
|
+
font-size: var(--wpds-font-size-xl, 18px);
|
|
24
18
|
font-style: normal;
|
|
25
|
-
font-weight:
|
|
26
|
-
line-height: 20px;
|
|
19
|
+
font-weight: var(--wpds-font-weight-medium, 499);
|
|
20
|
+
line-height: var(--wpds-font-line-height-sm, 20px);
|
|
27
21
|
margin: 0;
|
|
28
22
|
}
|
|
29
23
|
|
|
30
24
|
.change-indicator {
|
|
31
25
|
overflow: hidden;
|
|
32
26
|
text-overflow: ellipsis;
|
|
33
|
-
font-
|
|
34
|
-
font-size: 13px;
|
|
27
|
+
font-size: var(--wpds-font-size-md, 13px);
|
|
35
28
|
font-style: normal;
|
|
36
|
-
font-weight:
|
|
37
|
-
line-height: 20px;
|
|
29
|
+
font-weight: var(--wpds-font-weight-medium, 499);
|
|
30
|
+
line-height: var(--wpds-font-line-height-sm, 20px);
|
|
38
31
|
margin: 0;
|
|
39
32
|
}
|
|
40
33
|
|
|
41
34
|
.funnel-container {
|
|
42
|
-
display: flex;
|
|
43
|
-
gap: 16px;
|
|
44
|
-
align-items: flex-end;
|
|
45
35
|
flex: 1;
|
|
46
36
|
min-height: 200px;
|
|
47
37
|
width: 100%;
|
|
@@ -50,8 +40,6 @@
|
|
|
50
40
|
.funnel-step {
|
|
51
41
|
flex: 1 1 0;
|
|
52
42
|
min-width: 0;
|
|
53
|
-
display: flex;
|
|
54
|
-
flex-direction: column;
|
|
55
43
|
height: 100%;
|
|
56
44
|
|
|
57
45
|
&--animated {
|
|
@@ -63,17 +51,12 @@
|
|
|
63
51
|
}
|
|
64
52
|
}
|
|
65
53
|
|
|
66
|
-
.step-header {
|
|
67
|
-
margin-bottom: 24px;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
54
|
.step-label {
|
|
71
55
|
color: #757575;
|
|
72
|
-
font-
|
|
73
|
-
font-size: 12px;
|
|
56
|
+
font-size: var(--wpds-font-size-sm, 12px);
|
|
74
57
|
font-style: normal;
|
|
75
|
-
font-weight: 400;
|
|
76
|
-
line-height: 16px;
|
|
58
|
+
font-weight: var(--wpds-font-weight-regular, 400);
|
|
59
|
+
line-height: var(--wpds-font-line-height-xs, 16px);
|
|
77
60
|
margin: 0 0 2px 0;
|
|
78
61
|
display: block;
|
|
79
62
|
overflow: hidden;
|
|
@@ -82,19 +65,16 @@
|
|
|
82
65
|
|
|
83
66
|
.step-rate {
|
|
84
67
|
color: #1e1e1e;
|
|
85
|
-
font-
|
|
86
|
-
font-size: 13px;
|
|
68
|
+
font-size: var(--wpds-font-size-md, 13px);
|
|
87
69
|
font-style: normal;
|
|
88
|
-
font-weight:
|
|
89
|
-
line-height: 20px;
|
|
70
|
+
font-weight: var(--wpds-font-weight-medium, 499);
|
|
71
|
+
line-height: var(--wpds-font-line-height-sm, 20px);
|
|
90
72
|
margin: 0;
|
|
91
73
|
display: block;
|
|
92
74
|
}
|
|
93
75
|
|
|
94
76
|
.bar-container {
|
|
95
77
|
flex: 1;
|
|
96
|
-
display: flex;
|
|
97
|
-
align-items: flex-end;
|
|
98
78
|
border-radius: 4px;
|
|
99
79
|
position: relative;
|
|
100
80
|
cursor: pointer;
|
|
@@ -121,12 +101,6 @@
|
|
|
121
101
|
}
|
|
122
102
|
|
|
123
103
|
.tooltip-wrapper {
|
|
124
|
-
display: inline-flex;
|
|
125
|
-
flex-direction: column;
|
|
126
|
-
justify-content: center;
|
|
127
|
-
align-items: flex-start;
|
|
128
|
-
gap: 4px;
|
|
129
|
-
|
|
130
104
|
border-bottom: 1px solid var(--Gray-Gray-5, #dcdcde);
|
|
131
105
|
background: var(--black-white-white, #fff);
|
|
132
106
|
|
|
@@ -139,25 +113,23 @@
|
|
|
139
113
|
|
|
140
114
|
.tooltip-title {
|
|
141
115
|
color: #1e1e1e;
|
|
142
|
-
font-
|
|
143
|
-
font-size: 12px;
|
|
116
|
+
font-size: var(--wpds-font-size-sm, 12px);
|
|
144
117
|
font-style: normal;
|
|
145
|
-
font-weight: 400;
|
|
146
|
-
line-height: 16px;
|
|
118
|
+
font-weight: var(--wpds-font-weight-regular, 400);
|
|
119
|
+
line-height: var(--wpds-font-line-height-xs, 16px);
|
|
147
120
|
}
|
|
148
121
|
|
|
149
122
|
.tooltip-content {
|
|
150
123
|
color: #1e1e1e;
|
|
151
|
-
font-
|
|
152
|
-
font-size: 13px;
|
|
124
|
+
font-size: var(--wpds-font-size-md, 13px);
|
|
153
125
|
font-style: normal;
|
|
154
|
-
font-weight:
|
|
155
|
-
line-height: 20px;
|
|
126
|
+
font-weight: var(--wpds-font-weight-medium, 499);
|
|
127
|
+
line-height: var(--wpds-font-line-height-sm, 20px);
|
|
156
128
|
}
|
|
157
129
|
|
|
158
130
|
.empty-state {
|
|
159
131
|
text-align: center;
|
|
160
132
|
padding: 48px 24px;
|
|
161
133
|
color: #6b7280;
|
|
162
|
-
font-size: 16px;
|
|
134
|
+
font-size: var(--wpds-font-size-lg, 16px);
|
|
163
135
|
}
|
|
@@ -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
|
|
@@ -322,6 +322,7 @@ const ConversionFunnelChartInternal: FC< ConversionFunnelChartProps > = ( {
|
|
|
322
322
|
<>
|
|
323
323
|
<Stack
|
|
324
324
|
direction="column"
|
|
325
|
+
gap="xl"
|
|
325
326
|
data-testid="conversion-funnel-chart"
|
|
326
327
|
ref={ node => {
|
|
327
328
|
// Set containerRef for @visx coordinate system
|
|
@@ -344,27 +345,31 @@ const ConversionFunnelChartInternal: FC< ConversionFunnelChartProps > = ( {
|
|
|
344
345
|
changeColor,
|
|
345
346
|
} )
|
|
346
347
|
) : (
|
|
347
|
-
<
|
|
348
|
+
<Stack direction="row" align="baseline" gap="sm" className={ styles[ 'main-metric' ] }>
|
|
349
|
+
{ renderDefaultMainMetric() }
|
|
350
|
+
</Stack>
|
|
348
351
|
) }
|
|
349
352
|
|
|
350
353
|
{ /* Funnel Steps */ }
|
|
351
|
-
<
|
|
354
|
+
<Stack direction="row" align="flex-end" gap="lg" className={ styles[ 'funnel-container' ] }>
|
|
352
355
|
{ steps.map( ( step, index ) => {
|
|
353
356
|
const barHeight = ( step.rate / maxRate ) * 100;
|
|
354
357
|
const { isBlurred } = getStepState( step.id );
|
|
355
358
|
|
|
356
359
|
return (
|
|
357
|
-
<
|
|
360
|
+
<Stack
|
|
358
361
|
key={ step.id }
|
|
362
|
+
direction="column"
|
|
359
363
|
data-testid="funnel-step"
|
|
360
364
|
className={ clsx(
|
|
361
365
|
styles[ 'funnel-step' ],
|
|
362
366
|
isColorPaletteResolved && styles[ 'funnel-step--animated' ],
|
|
363
367
|
isBlurred && styles[ 'funnel-step--blurred' ]
|
|
364
368
|
) }
|
|
369
|
+
gap="xl"
|
|
365
370
|
>
|
|
366
371
|
{ /* Step Label and Rate */ }
|
|
367
|
-
<div
|
|
372
|
+
<div>
|
|
368
373
|
{ renderStepLabel ? (
|
|
369
374
|
renderStepLabel( {
|
|
370
375
|
step,
|
|
@@ -388,7 +393,9 @@ const ConversionFunnelChartInternal: FC< ConversionFunnelChartProps > = ( {
|
|
|
388
393
|
</div>
|
|
389
394
|
|
|
390
395
|
{ /* Funnel Bar */ }
|
|
391
|
-
<
|
|
396
|
+
<Stack
|
|
397
|
+
direction="column"
|
|
398
|
+
justify="flex-end"
|
|
392
399
|
className={ styles[ 'bar-container' ] }
|
|
393
400
|
onClick={ stepHandlers.get( step.id )?.onClick }
|
|
394
401
|
onKeyDown={ stepHandlers.get( step.id )?.onKeyDown }
|
|
@@ -407,11 +414,11 @@ const ConversionFunnelChartInternal: FC< ConversionFunnelChartProps > = ( {
|
|
|
407
414
|
backgroundColor: barColor,
|
|
408
415
|
} }
|
|
409
416
|
/>
|
|
410
|
-
</
|
|
411
|
-
</
|
|
417
|
+
</Stack>
|
|
418
|
+
</Stack>
|
|
412
419
|
);
|
|
413
420
|
} ) }
|
|
414
|
-
</
|
|
421
|
+
</Stack>
|
|
415
422
|
</Stack>
|
|
416
423
|
|
|
417
424
|
{ /* 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
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* eslint-disable @wordpress/no-unsafe-wp-apis */
|
|
2
|
-
import { __experimentalGrid as Grid
|
|
2
|
+
import { __experimentalGrid as Grid } from '@wordpress/components';
|
|
3
3
|
import { Fragment } from '@wordpress/element';
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import { Stack } from '@wordpress/ui';
|
|
5
|
+
import { Stack, Text } from '@wordpress/ui';
|
|
6
6
|
import clsx from 'clsx';
|
|
7
7
|
import { useContext, useMemo, type FC } from 'react';
|
|
8
8
|
import { Legend } from '../../components/legend';
|
|
@@ -21,19 +21,16 @@
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
&__tooltip-date {
|
|
24
|
-
font-weight:
|
|
24
|
+
font-weight: var(--wpds-font-weight-medium, 499);
|
|
25
25
|
padding-bottom: 10px;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
&__tooltip-row {
|
|
29
|
-
display: flex;
|
|
30
|
-
align-items: center;
|
|
31
29
|
padding: 4px 0;
|
|
32
|
-
justify-content: space-between;
|
|
33
30
|
}
|
|
34
31
|
|
|
35
32
|
&__tooltip-label {
|
|
36
|
-
font-weight:
|
|
33
|
+
font-weight: var(--wpds-font-weight-medium, 499);
|
|
37
34
|
padding-right: 1rem;
|
|
38
35
|
}
|
|
39
36
|
|
|
@@ -65,7 +62,7 @@
|
|
|
65
62
|
background: #fff;
|
|
66
63
|
border: none;
|
|
67
64
|
border-radius: 4px;
|
|
68
|
-
font-size:
|
|
65
|
+
font-size: var(--wpds-font-size-md, 13px);
|
|
69
66
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
|
|
70
67
|
position: fixed;
|
|
71
68
|
margin: 0.5rem;
|
|
@@ -81,13 +78,6 @@
|
|
|
81
78
|
}
|
|
82
79
|
}
|
|
83
80
|
|
|
84
|
-
&__annotation-label-popover-header {
|
|
85
|
-
display: flex;
|
|
86
|
-
flex-direction: row;
|
|
87
|
-
justify-content: space-between;
|
|
88
|
-
align-items: start;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
81
|
&__annotation-label-popover-content {
|
|
92
82
|
padding: 0.5rem;
|
|
93
83
|
}
|
|
@@ -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,6 +1,7 @@
|
|
|
1
1
|
import { __ } from '@wordpress/i18n';
|
|
2
|
+
import { Icon, close } from '@wordpress/icons';
|
|
3
|
+
import { Stack } from '@wordpress/ui';
|
|
2
4
|
import clsx from 'clsx';
|
|
3
|
-
import Gridicon from 'gridicons';
|
|
4
5
|
import { useEffect, useId, useRef, useState } from 'react';
|
|
5
6
|
import { isSafari } from '../../../utils';
|
|
6
7
|
import styles from '../line-chart.module.scss';
|
|
@@ -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>
|
|
@@ -100,9 +101,9 @@ const LineChartAnnotationLabelWithPopover: FC< LineChartAnnotationLabelWithPopov
|
|
|
100
101
|
className={ styles[ 'line-chart__annotation-label-popover-close-button' ] }
|
|
101
102
|
aria-label={ __( 'Close', 'jetpack-charts' ) }
|
|
102
103
|
>
|
|
103
|
-
<
|
|
104
|
+
<Icon icon={ close } size={ 16 } />
|
|
104
105
|
</button>
|
|
105
|
-
</
|
|
106
|
+
</Stack>
|
|
106
107
|
</div>
|
|
107
108
|
</div>
|
|
108
109
|
);
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
useGlobalChartsTheme,
|
|
21
21
|
GlobalChartsContext,
|
|
22
22
|
} from '../../providers';
|
|
23
|
-
import { attachSubComponents } from '../../utils';
|
|
23
|
+
import { attachSubComponents, resolveFontSize } from '../../utils';
|
|
24
24
|
import { getStringWidth } from '../../visx/text';
|
|
25
25
|
import { ChartSVG, ChartHTML, useChartChildren } from '../private/chart-composition';
|
|
26
26
|
import { ChartLayout } from '../private/chart-layout';
|
|
@@ -441,10 +441,12 @@ const PieChartInternal = ( {
|
|
|
441
441
|
groupProps.onMouseLeave = onMouseLeave;
|
|
442
442
|
}
|
|
443
443
|
|
|
444
|
-
|
|
445
|
-
const fontSize = 12;
|
|
444
|
+
const svgLabelSmall = providerTheme.svgLabelSmall;
|
|
445
|
+
const fontSize = resolveFontSize( svgLabelSmall?.fontSize ) ?? 12;
|
|
446
446
|
const estimatedTextWidth = getStringWidth( arc.data.label, {
|
|
447
447
|
fontSize,
|
|
448
|
+
fontFamily: svgLabelSmall?.fontFamily,
|
|
449
|
+
fontWeight: svgLabelSmall?.fontWeight,
|
|
448
450
|
} );
|
|
449
451
|
const labelPadding = 6;
|
|
450
452
|
const backgroundWidth = estimatedTextWidth + labelPadding * 2;
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
.label {
|
|
14
|
-
font-weight:
|
|
15
|
-
font-size: 16px;
|
|
14
|
+
font-weight: var(--wpds-font-weight-medium, 499);
|
|
15
|
+
font-size: var(--wpds-font-size-lg, 16px);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
.note {
|
|
19
|
-
font-size:
|
|
19
|
+
font-size: var(--wpds-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: 0.875rem;
|
|
6
|
+
font-size: var(--wpds-font-size-md, 13px);
|
|
48
7
|
|
|
49
8
|
&--interactive {
|
|
50
9
|
cursor: pointer;
|
|
@@ -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:
|
|
55
|
+
font-weight: var(--wpds-font-weight-medium, 499);
|
|
105
56
|
flex-shrink: 0; // Prevent value from shrinking when text is ellipsized
|
|
106
57
|
}
|