@automattic/charts 1.12.0 → 2.0.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 +14 -0
- package/TOKENS.md +8 -1
- package/dist/index.cjs +4038 -5207
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +15 -18
- package/dist/index.d.cts +15 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.js +113 -1281
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/charts/area-chart/area-chart.tsx +3 -2
- package/src/charts/conversion-funnel-chart/conversion-funnel-chart.module.scss +7 -7
- package/src/charts/line-chart/line-chart.module.scss +3 -3
- package/src/charts/line-chart/line-chart.tsx +3 -2
- package/src/charts/line-chart/test/line-chart.test.tsx +44 -4
- package/src/charts/pie-semi-circle-chart/pie-semi-circle-chart.module.scss +1 -1
- package/src/charts/private/test/time-axis.test.ts +182 -0
- package/src/charts/private/time-axis.ts +84 -5
- package/src/charts/private/x-zoom/test/x-zoom.test.tsx +52 -7
- package/src/charts/private/x-zoom/x-zoom.module.scss +7 -15
- package/src/charts/private/x-zoom/x-zoom.tsx +29 -40
- package/src/components/legend/private/base-legend.module.scss +1 -1
- package/src/components/tooltip/base-tooltip.module.scss +1 -1
- package/src/components/trend-indicator/trend-indicator.module.scss +1 -1
- package/src/index.ts +1 -0
- package/src/types.ts +15 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DataContext } from '@visx/xychart';
|
|
2
2
|
import { __ } from '@wordpress/i18n';
|
|
3
|
-
import {
|
|
3
|
+
import { IconButton } from '@wordpress/ui';
|
|
4
4
|
import { useCallback, useContext, useMemo, useState } from 'react';
|
|
5
5
|
import styles from './x-zoom.module.scss';
|
|
6
6
|
import type { SingleChartRef } from '../single-chart-context';
|
|
@@ -172,14 +172,8 @@ export function ZoomClip( {
|
|
|
172
172
|
|
|
173
173
|
/**
|
|
174
174
|
* Visible icon-only reset control rendered as an HTML overlay on top of the
|
|
175
|
-
* chart container, using the WPDS `
|
|
176
|
-
* `position: relative` container so the button anchors correctly.
|
|
177
|
-
*
|
|
178
|
-
* `IconButton` would be the natural fit, but it renders a Base UI tooltip whose
|
|
179
|
-
* CommonJS `use-sync-external-store` dependency makes Rolldown emit a dynamic
|
|
180
|
-
* `require()` into `dist`, which throws on evaluation in WordPress Script
|
|
181
|
-
* Module consumers. `Button` gives the same treatment without that dependency;
|
|
182
|
-
* the tooltip is replaced by `aria-label` + `title`.
|
|
175
|
+
* chart container, using the WPDS `IconButton`. The host should wrap its SVG in
|
|
176
|
+
* a `position: relative` container so the button anchors correctly.
|
|
183
177
|
*
|
|
184
178
|
* @param props - Props.
|
|
185
179
|
* @param props.onClick - Click handler. Typically the `reset` from `useXZoom`.
|
|
@@ -194,44 +188,39 @@ export function ZoomResetButton( { onClick }: { onClick: () => void } ) {
|
|
|
194
188
|
event.stopPropagation();
|
|
195
189
|
}
|
|
196
190
|
}, [] );
|
|
197
|
-
const label = __( 'Reset zoom', 'jetpack-charts' );
|
|
198
191
|
return (
|
|
199
|
-
<
|
|
192
|
+
<IconButton
|
|
200
193
|
className={ styles[ 'x-zoom__reset' ] }
|
|
201
194
|
onKeyDown={ stopActivationKeys }
|
|
202
|
-
|
|
203
|
-
title={ label }
|
|
195
|
+
label={ __( 'Reset zoom', 'jetpack-charts' ) }
|
|
204
196
|
variant="outline"
|
|
205
197
|
tone="neutral"
|
|
206
198
|
size="small"
|
|
207
199
|
onClick={ onClick }
|
|
208
200
|
data-testid="chart-zoom-reset"
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
<
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}
|
|
234
|
-
/>
|
|
235
|
-
</Button>
|
|
201
|
+
icon={
|
|
202
|
+
<svg
|
|
203
|
+
viewBox="0 0 24 24"
|
|
204
|
+
fill="none"
|
|
205
|
+
stroke="currentColor"
|
|
206
|
+
strokeWidth="2"
|
|
207
|
+
strokeLinecap="round"
|
|
208
|
+
strokeLinejoin="round"
|
|
209
|
+
aria-hidden="true"
|
|
210
|
+
focusable="false"
|
|
211
|
+
>
|
|
212
|
+
{ /*
|
|
213
|
+
Icons render edge-to-edge at 24px, so inset the glyph the
|
|
214
|
+
way @wordpress/icons glyphs do (drawn within roughly 4-20
|
|
215
|
+
of the viewBox, ~1.5px effective stroke).
|
|
216
|
+
*/ }
|
|
217
|
+
<g transform="translate(2.4 2.4) scale(0.8)">
|
|
218
|
+
<circle cx="10" cy="10" r="6" />
|
|
219
|
+
<line x1="15" y1="15" x2="20" y2="20" />
|
|
220
|
+
<line x1="7" y1="10" x2="13" y2="10" />
|
|
221
|
+
</g>
|
|
222
|
+
</svg>
|
|
223
|
+
}
|
|
224
|
+
/>
|
|
236
225
|
);
|
|
237
226
|
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
color: #fff;
|
|
9
9
|
border-radius: var(--wpds-border-radius-md, 4px);
|
|
10
10
|
font-size: var(--wpds-typography-font-size-md, 13px);
|
|
11
|
-
box-shadow: var(--
|
|
11
|
+
box-shadow: var(--a8c-charts-elevation-sm, 0 1px 2px 0 #0000000d, 0 2px 3px 0 #0000000a, 0 6px 6px 0 #00000008, 0 8px 8px 0 #00000005);
|
|
12
12
|
position: absolute;
|
|
13
13
|
pointer-events: none;
|
|
14
14
|
transform: translate(-50%, -100%);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
align-items: center;
|
|
4
4
|
gap: 0.125em;
|
|
5
5
|
font-size: var(--wpds-typography-font-size-md, 13px);
|
|
6
|
-
font-weight: var(--wpds-typography-font-weight-
|
|
6
|
+
font-weight: var(--wpds-typography-font-weight-emphasis, 499);
|
|
7
7
|
line-height: 1;
|
|
8
8
|
|
|
9
9
|
// Trend colours use the --a8c-charts-color-trend-* catalog roles, falling back
|
package/src/index.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -462,6 +462,12 @@ export type CompleteChartTheme = Required< ChartTheme > & {
|
|
|
462
462
|
Pick< NonNullable< ChartTheme[ 'heatmapChart' ] >, 'primaryColor' >;
|
|
463
463
|
};
|
|
464
464
|
|
|
465
|
+
/**
|
|
466
|
+
* Bucket resolution of time-series data, as known by the caller (e.g. a
|
|
467
|
+
* granularity selector), for consumers that don't need to infer it.
|
|
468
|
+
*/
|
|
469
|
+
export type TickResolution = 'hour' | 'day' | 'week' | 'month' | 'year';
|
|
470
|
+
|
|
465
471
|
export type AxisOptions = {
|
|
466
472
|
orientation?: OrientationType;
|
|
467
473
|
numTicks?: number;
|
|
@@ -475,6 +481,15 @@ export type AxisOptions = {
|
|
|
475
481
|
labelClassName?: string;
|
|
476
482
|
tickClassName?: string;
|
|
477
483
|
tickFormat?: TickFormatter< ScaleInput< AxisScale > >;
|
|
484
|
+
/**
|
|
485
|
+
* Bucket resolution of the data on a time x-axis. When set, the automatic
|
|
486
|
+
* tick formatter derives tick formats from it directly instead of
|
|
487
|
+
* inferring the resolution from point spacing. The overall time span still
|
|
488
|
+
* constrains the choice — e.g. hourly buckets spanning more than a week
|
|
489
|
+
* get date ticks, since hour ticks would be unreadable at that span.
|
|
490
|
+
* Ignored when `tickFormat` is set.
|
|
491
|
+
*/
|
|
492
|
+
tickResolution?: TickResolution;
|
|
478
493
|
/**
|
|
479
494
|
* Whether to display this axis. Defaults to true.
|
|
480
495
|
*/
|