@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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Group } from '@visx/group';
|
|
2
2
|
import { LegendItem, LegendLabel, LegendOrdinal, LegendShape } from '@visx/legend';
|
|
3
3
|
import { scaleOrdinal } from '@visx/scale';
|
|
4
|
+
import { Stack } from '@wordpress/ui';
|
|
4
5
|
import clsx from 'clsx';
|
|
5
6
|
import {
|
|
6
7
|
type RefAttributes,
|
|
@@ -16,10 +17,11 @@ import { valueOrIdentity, valueOrIdentityString, labelTransformFactory } from '.
|
|
|
16
17
|
import styles from './base-legend.module.scss';
|
|
17
18
|
import type { BaseLegendProps } from '../types';
|
|
18
19
|
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
const ALIGNMENT_TO_FLEX = {
|
|
21
|
+
start: 'flex-start',
|
|
22
|
+
center: 'center',
|
|
23
|
+
end: 'flex-end',
|
|
24
|
+
} as const;
|
|
23
25
|
|
|
24
26
|
// Component for legend text with truncation detection
|
|
25
27
|
// Moved outside BaseLegend to prevent recreation on every render
|
|
@@ -159,6 +161,8 @@ export const BaseLegend: ForwardRefExoticComponent<
|
|
|
159
161
|
[ interactive, handleLegendClick ]
|
|
160
162
|
);
|
|
161
163
|
|
|
164
|
+
const flexAlignment = ALIGNMENT_TO_FLEX[ alignment ] ?? 'center';
|
|
165
|
+
|
|
162
166
|
return render ? (
|
|
163
167
|
render( items )
|
|
164
168
|
) : (
|
|
@@ -168,20 +172,17 @@ export const BaseLegend: ForwardRefExoticComponent<
|
|
|
168
172
|
labelTransform={ labelTransform }
|
|
169
173
|
>
|
|
170
174
|
{ labels => (
|
|
171
|
-
<
|
|
175
|
+
<Stack
|
|
172
176
|
ref={ ref }
|
|
177
|
+
direction={ orientation === 'vertical' ? 'column' : 'row' }
|
|
178
|
+
gap={ orientation === 'vertical' ? 'sm' : 'lg' }
|
|
179
|
+
align={ orientation === 'vertical' ? flexAlignment : undefined }
|
|
180
|
+
justify={ orientation === 'horizontal' ? flexAlignment : undefined }
|
|
181
|
+
wrap={ orientation === 'horizontal' ? 'wrap' : undefined }
|
|
173
182
|
role="list"
|
|
174
183
|
data-testid={ `legend-${ orientation }` }
|
|
175
|
-
className={ clsx(
|
|
176
|
-
|
|
177
|
-
styles[ `legend--${ orientation }` ],
|
|
178
|
-
styles[ `legend--alignment-${ alignment }` ],
|
|
179
|
-
className
|
|
180
|
-
) }
|
|
181
|
-
style={ {
|
|
182
|
-
flexDirection: orientationToFlexDirection[ orientation ],
|
|
183
|
-
...theme.legend?.containerStyles,
|
|
184
|
-
} }
|
|
184
|
+
className={ clsx( styles.legend, className ) }
|
|
185
|
+
style={ theme.legend?.containerStyles }
|
|
185
186
|
>
|
|
186
187
|
{ labels.map( ( label, i ) => {
|
|
187
188
|
const visible = isSeriesVisible( label.text );
|
|
@@ -257,28 +258,29 @@ export const BaseLegend: ForwardRefExoticComponent<
|
|
|
257
258
|
labelClassName
|
|
258
259
|
) }
|
|
259
260
|
style={ {
|
|
260
|
-
justifyContent: labelJustifyContent,
|
|
261
261
|
flex: labelFlex,
|
|
262
262
|
margin: labelMargin,
|
|
263
263
|
...theme.legend?.labelStyles,
|
|
264
264
|
} }
|
|
265
265
|
>
|
|
266
|
-
<
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
{ '
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
266
|
+
<Stack align="center" gap="sm" justify={ labelJustifyContent }>
|
|
267
|
+
<LegendText
|
|
268
|
+
text={ label.text }
|
|
269
|
+
textOverflow={ textOverflow }
|
|
270
|
+
maxWidth={ maxWidth }
|
|
271
|
+
/>
|
|
272
|
+
{ matchedItem?.value != null && matchedItem.value !== '' && (
|
|
273
|
+
<span className={ styles[ 'legend-item-value' ] }>
|
|
274
|
+
{ '\u00A0' }
|
|
275
|
+
{ matchedItem.value }
|
|
276
|
+
</span>
|
|
277
|
+
) }
|
|
278
|
+
</Stack>
|
|
277
279
|
</LegendLabel>
|
|
278
280
|
</LegendItem>
|
|
279
281
|
);
|
|
280
282
|
} ) }
|
|
281
|
-
</
|
|
283
|
+
</Stack>
|
|
282
284
|
) }
|
|
283
285
|
</LegendOrdinal>
|
|
284
286
|
);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
.tooltip {
|
|
2
|
-
padding:
|
|
2
|
+
padding: var(--wpds-dimension-padding-sm, 8px);
|
|
3
3
|
background-color: rgba(0, 0, 0, 0.85);
|
|
4
4
|
color: #fff;
|
|
5
|
-
border-radius: 4px;
|
|
6
|
-
font-size: var(--wpds-font-size-md, 13px);
|
|
5
|
+
border-radius: var(--wpds-border-radius-md, 4px);
|
|
6
|
+
font-size: var(--wpds-typography-font-size-md, 13px);
|
|
7
7
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
|
|
8
8
|
position: absolute;
|
|
9
9
|
pointer-events: none;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
display: inline-flex;
|
|
3
3
|
align-items: center;
|
|
4
4
|
gap: 0.125em;
|
|
5
|
-
font-size: var(--wpds-font-size-md, 13px);
|
|
6
|
-
font-weight: var(--wpds-font-weight-medium, 499);
|
|
5
|
+
font-size: var(--wpds-typography-font-size-md, 13px);
|
|
6
|
+
font-weight: var(--wpds-typography-font-weight-medium, 499);
|
|
7
7
|
line-height: 1;
|
|
8
8
|
|
|
9
9
|
&--up {
|