@automattic/charts 3.2.0 → 4.1.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 +47 -0
- package/SECURITY.md +1 -0
- package/TOKENS.md +53 -58
- package/dist/index.cjs +1483 -664
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +93 -29
- package/dist/index.d.cts +233 -247
- package/dist/index.d.ts +233 -247
- package/dist/index.js +1484 -667
- package/dist/index.js.map +1 -1
- package/package.json +7 -6
- package/src/charts/area-chart/area-chart.tsx +39 -25
- package/src/charts/area-chart/test/area-chart.test.tsx +4 -33
- package/src/charts/area-chart/test/tick-placement.test.tsx +55 -0
- package/src/charts/area-chart/test/tooltip-resolution-branches.test.tsx +86 -0
- package/src/charts/area-chart/test/tooltip-resolution.test.tsx +69 -0
- package/src/charts/area-chart/types.ts +4 -7
- package/src/charts/bar-chart/bar-chart.tsx +2 -1
- package/src/charts/bar-chart/private/test/use-bar-chart-options-formatting.test.tsx +69 -0
- package/src/charts/bar-chart/private/use-bar-chart-options.ts +27 -15
- package/src/charts/bar-list-chart/bar-list-chart.tsx +5 -0
- package/src/charts/conversion-funnel-chart/conversion-funnel-chart.module.scss +33 -23
- package/src/charts/conversion-funnel-chart/conversion-funnel-chart.tsx +138 -182
- package/src/charts/conversion-funnel-chart/test/conversion-funnel-chart.test.tsx +46 -0
- package/src/charts/geo-chart/geo-chart.module.scss +1 -0
- package/src/charts/geo-chart/geo-chart.tsx +5 -10
- package/src/charts/geo-chart/test/geo-chart.test.tsx +2 -2
- package/src/charts/heatmap-chart/heatmap-chart.module.scss +52 -16
- package/src/charts/heatmap-chart/heatmap-chart.tsx +89 -37
- package/src/charts/heatmap-chart/index.ts +2 -1
- package/src/charts/heatmap-chart/private/build-calendar-data.ts +126 -89
- package/src/charts/heatmap-chart/private/civil-day.ts +174 -0
- package/src/charts/heatmap-chart/private/heatmap-legend.tsx +11 -4
- package/src/charts/heatmap-chart/private/index.ts +1 -1
- package/src/charts/heatmap-chart/private/use-heatmap-colors.ts +5 -1
- package/src/charts/heatmap-chart/test/build-calendar-data.test.ts +3 -0
- package/src/charts/heatmap-chart/test/civil-day.test.ts +70 -0
- package/src/charts/heatmap-chart/test/heatmap-chart.test.tsx +142 -12
- package/src/charts/heatmap-chart/test/use-calendar-heatmap-data.test.tsx +118 -0
- package/src/charts/heatmap-chart/test/use-heatmap-colors.test.ts +8 -0
- package/src/charts/heatmap-chart/test/zoned-calendar-data.test.ts +248 -0
- package/src/charts/heatmap-chart/types.ts +8 -2
- package/src/charts/heatmap-chart/use-calendar-heatmap-data.ts +42 -0
- package/src/charts/leaderboard-chart/hooks/use-fitted-row-count.ts +2 -2
- package/src/charts/leaderboard-chart/hooks/use-leaderboard-legend-items.ts +3 -5
- package/src/charts/leaderboard-chart/leaderboard-chart.module.scss +31 -19
- package/src/charts/leaderboard-chart/leaderboard-chart.tsx +27 -17
- package/src/charts/leaderboard-chart/test/leaderboard-chart.test.tsx +14 -0
- package/src/charts/leaderboard-chart/test/use-leaderboard-legend-items.test.tsx +2 -9
- package/src/charts/leaderboard-chart/types.ts +2 -2
- package/src/charts/line-chart/line-chart.module.scss +10 -18
- package/src/charts/line-chart/line-chart.tsx +128 -26
- package/src/charts/line-chart/private/line-chart-annotation.tsx +18 -19
- package/src/charts/line-chart/test/crosshair-style-types.test.ts +31 -0
- package/src/charts/line-chart/test/default-tooltip-formatting.test.tsx +74 -0
- package/src/charts/line-chart/test/line-chart.test.tsx +174 -41
- package/src/charts/line-chart/test/tick-placement.test.tsx +84 -0
- package/src/charts/line-chart/test/tooltip-resolution.test.tsx +140 -0
- package/src/charts/line-chart/test/zoned-date-string.test.tsx +37 -0
- package/src/charts/line-chart/types.ts +17 -3
- package/src/charts/pie-chart/pie-chart.module.scss +13 -1
- package/src/charts/pie-chart/pie-chart.tsx +30 -40
- package/src/charts/pie-chart/test/pie-chart.test.tsx +59 -12
- package/src/charts/pie-semi-circle-chart/pie-semi-circle-chart.module.scss +8 -3
- package/src/charts/pie-semi-circle-chart/pie-semi-circle-chart.tsx +23 -37
- package/src/charts/pie-semi-circle-chart/test/pie-semi-circle-chart.test.tsx +50 -0
- package/src/charts/private/chart-layout/chart-layout.module.scss +3 -2
- package/src/charts/private/svg-empty-state/svg-empty-state.module.scss +1 -1
- package/src/charts/private/test/axis-formatting.test.tsx +85 -0
- package/src/charts/private/test/time-axis-formatting.test.ts +109 -0
- package/src/charts/private/test/time-axis-options.test.ts +267 -0
- package/src/charts/private/test/time-axis-tick-invariants.test.ts +153 -0
- package/src/charts/private/test/time-axis-tick-values.test.ts +280 -0
- package/src/charts/private/test/time-axis.test.ts +9 -69
- package/src/charts/private/time-axis-options.ts +106 -0
- package/src/charts/private/time-axis.ts +318 -136
- package/src/charts/private/x-zoom/x-zoom.module.scss +3 -3
- package/src/charts/private/xy-plot/xy-plot.module.scss +8 -0
- package/src/charts/sparkline/test/sparkline.test.tsx +29 -56
- package/src/charts/sparkline/types.ts +1 -1
- package/src/components/legend/private/base-legend.module.scss +9 -5
- package/src/components/tooltip/accessible-tooltip.tsx +21 -17
- package/src/components/tooltip/base-tooltip.module.scss +3 -3
- package/src/components/tooltip/private/bounded-tooltip.tsx +227 -0
- package/src/components/tooltip/test/accessible-tooltip.test.tsx +30 -4
- package/src/components/tooltip/test/bounded-tooltip.test.tsx +225 -0
- package/src/components/tooltip/test/xy-chart-tooltip.test.tsx +379 -0
- package/src/components/tooltip/xy-chart-tooltip.tsx +326 -0
- package/src/components/trend-indicator/trend-indicator.module.scss +2 -2
- package/src/hooks/test/use-chart-data-transform-zone.test.tsx +36 -0
- package/src/hooks/test/use-chart-margin.test.tsx +173 -3
- package/src/hooks/test/use-xychart-theme.test.tsx +16 -3
- package/src/hooks/use-chart-data-transform.ts +10 -3
- package/src/hooks/use-chart-margin.tsx +54 -9
- package/src/hooks/use-xychart-theme.ts +25 -9
- package/src/index.ts +8 -0
- package/src/providers/chart-context/global-charts-provider.tsx +37 -38
- package/src/providers/chart-context/hooks/use-chart-formatting.ts +22 -0
- package/src/providers/chart-context/index.ts +1 -0
- package/src/providers/chart-context/private/catalog-pointers.ts +42 -0
- package/src/providers/chart-context/private/series-palette.ts +3 -13
- package/src/providers/chart-context/test/{sparse-theme.test.ts → catalog-pointers.test.ts} +22 -10
- package/src/providers/chart-context/test/chart-context.test.tsx +177 -792
- package/src/providers/chart-context/test/use-global-charts-theme.test.tsx +7 -25
- package/src/providers/chart-context/themes.ts +7 -52
- package/src/providers/chart-context/types.ts +3 -0
- package/src/styles/chart-scope.scss +39 -62
- package/src/styles/test/chart-scope.test.ts +19 -47
- package/src/test-utils/series-fixtures.ts +31 -0
- package/src/test-utils/zoned-parsing-suite.ts +90 -0
- package/src/types.ts +79 -166
- package/src/utils/bucket-info.ts +87 -0
- package/src/utils/color-utils.ts +0 -27
- package/src/utils/date-formatting.ts +157 -0
- package/src/utils/date-parsing.ts +103 -52
- package/src/utils/get-edge-tick-widths.ts +33 -0
- package/src/utils/index.ts +4 -0
- package/src/utils/test/bucket-info.test.ts +185 -0
- package/src/utils/test/color-utils.test.ts +1 -48
- package/src/utils/test/date-formatting.test.ts +89 -0
- package/src/utils/test/date-parsing.auckland.test.ts +6 -0
- package/src/utils/test/date-parsing.santiago.test.ts +6 -0
- package/src/utils/test/date-parsing.test.ts +16 -1
- package/src/utils/test/get-edge-tick-widths.test.ts +55 -0
- package/src/utils/test/get-styles.test.ts +10 -7
- package/src/utils/test/merge-themes.test.ts +18 -46
- package/src/utils/warn-once.ts +23 -0
- package/src/visx/types.ts +56 -5
- package/src/hooks/test/use-xychart-theme-provider-override.test.tsx +0 -28
- package/src/providers/chart-context/private/theme-override-vars.ts +0 -131
- package/src/providers/chart-context/private/with-catalog-pointers.ts +0 -93
- package/src/providers/chart-context/test/theme-override-vars-guard.test.tsx +0 -29
- package/src/providers/chart-context/test/theme-override-vars.test.ts +0 -183
- package/src/providers/chart-context/test/with-catalog-pointers.test.ts +0 -104
- package/src/styles/test/wpds-fallbacks.test.ts +0 -131
package/dist/index.d.cts
CHANGED
|
@@ -60,27 +60,32 @@ type GoogleDataTableRow = GoogleDataTableCell[];
|
|
|
60
60
|
type ChartType = 'area' | 'bar' | 'conversion-funnel' | 'leaderboard' | 'line' | 'pie' | 'pie-semi-circle';
|
|
61
61
|
type OrientationType = ValueOf<typeof Orientation>;
|
|
62
62
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
63
|
+
* Styling for one annotation, as its `styles` prop. Colors belong here because
|
|
64
|
+
* `--a8c-charts-color-annotation` moves every annotation on the page at once and no
|
|
65
|
+
* selector narrows it to one.
|
|
66
66
|
*/
|
|
67
67
|
type AnnotationStyles = {
|
|
68
68
|
circleSubject?: Omit<CircleSubjectProps, 'x' | 'y' | 'fill'> & {
|
|
69
|
-
/** @deprecated Set the `--a8c-charts-color-annotation` custom property inside the provider tree instead. See `TOKENS.md`. */
|
|
70
69
|
fill?: string;
|
|
71
70
|
};
|
|
72
71
|
lineSubject?: Omit<LineSubjectProps, 'x' | 'y'>;
|
|
73
|
-
connector?: Omit<ConnectorProps, 'x' | 'y' | 'dx' | 'dy'
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
connector?: Omit<ConnectorProps, 'x' | 'y' | 'dx' | 'dy'>;
|
|
73
|
+
label?: Omit<LabelProps, 'title' | 'subtitle' | 'x' | 'y'> & {
|
|
74
|
+
x?: number | 'start' | 'end';
|
|
75
|
+
y?: number | 'start' | 'end';
|
|
76
76
|
};
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Annotation styling on the theme: geometry only. Colors come from
|
|
80
|
+
* `--a8c-charts-color-annotation` and `--a8c-charts-color-surface`.
|
|
81
|
+
*/
|
|
82
|
+
type ThemeAnnotationStyles = {
|
|
83
|
+
circleSubject?: Omit<CircleSubjectProps, 'x' | 'y' | 'fill' | 'stroke'>;
|
|
84
|
+
lineSubject?: Omit<LineSubjectProps, 'x' | 'y' | 'stroke'>;
|
|
85
|
+
connector?: Omit<ConnectorProps, 'x' | 'y' | 'dx' | 'dy' | 'stroke'>;
|
|
77
86
|
label?: Omit<LabelProps, 'title' | 'subtitle' | 'x' | 'y' | 'anchorLineStroke' | 'backgroundFill'> & {
|
|
78
87
|
x?: number | 'start' | 'end';
|
|
79
88
|
y?: number | 'start' | 'end';
|
|
80
|
-
/** @deprecated Set the `--a8c-charts-color-annotation` custom property inside the provider tree instead. See `TOKENS.md`. */
|
|
81
|
-
anchorLineStroke?: LabelProps['anchorLineStroke'];
|
|
82
|
-
/** @deprecated Set the `--a8c-charts-color-surface` custom property inside the provider tree instead. See `TOKENS.md`. */
|
|
83
|
-
backgroundFill?: LabelProps['backgroundFill'];
|
|
84
89
|
};
|
|
85
90
|
};
|
|
86
91
|
type DataPoint = {
|
|
@@ -271,167 +276,53 @@ type DataPointPercentageCalculated = DataPointPercentage & {
|
|
|
271
276
|
percentage: number;
|
|
272
277
|
};
|
|
273
278
|
/**
|
|
274
|
-
* Base theme configuration for chart components
|
|
279
|
+
* Base theme configuration for chart components: shape and spacing. Chart colors are
|
|
280
|
+
* `--a8c-charts-color-*` roles set in CSS inside the provider tree, catalogued in
|
|
281
|
+
* `TOKENS.md`.
|
|
275
282
|
*/
|
|
276
283
|
type ChartTheme = {
|
|
277
|
-
/**
|
|
278
|
-
|
|
279
|
-
*
|
|
280
|
-
* Still resolved in JS — gradient stops, the glyph stroke and `GeoChart`'s Google Charts config each need a concrete string — but that is about where the value is *consumed*, not where it is *set*. `withCatalogPointers` parks a consumer's value in the catalog role and restores the pointer, so the field is only ever a carrier for `--a8c-charts-color-background`, and setting the role directly does the same job.
|
|
281
|
-
*
|
|
282
|
-
* Optional so the deprecation is actionable: a consumer writing a full theme literal can now stop setting it. `CompleteChartTheme` is `Required< ChartTheme >`, so `defaultTheme` must still carry one.
|
|
283
|
-
*
|
|
284
|
-
* @deprecated Set the `--a8c-charts-color-background` custom property inside the provider tree instead. See `TOKENS.md`.
|
|
285
|
-
*/
|
|
286
|
-
backgroundColor?: string;
|
|
287
|
-
/**
|
|
288
|
-
* Background color for labels.
|
|
289
|
-
*
|
|
290
|
-
* @deprecated Set the `--a8c-charts-color-label-background` custom property inside the provider tree instead. See `TOKENS.md`.
|
|
291
|
-
*/
|
|
292
|
-
labelBackgroundColor?: string;
|
|
293
|
-
/**
|
|
294
|
-
* Text color for labels.
|
|
295
|
-
*
|
|
296
|
-
* @deprecated Set the `--a8c-charts-color-label-on-fill` custom property inside the provider tree instead. See `TOKENS.md`.
|
|
297
|
-
*/
|
|
298
|
-
labelTextColor?: string;
|
|
299
|
-
/**
|
|
300
|
-
* Series palette seeds. Entry N publishes `--a8c-charts-color-series-{N+1}`; entries past the fifth are ignored.
|
|
301
|
-
*
|
|
302
|
-
* Optional so the deprecation is actionable: a consumer writing a full theme literal can now stop setting it. `CompleteChartTheme` is `Required< ChartTheme >`, so `defaultTheme` must still carry one.
|
|
303
|
-
*
|
|
304
|
-
* @deprecated Set the `--a8c-charts-color-series-1` … `-5` custom properties inside the provider tree instead, or `options.stroke` on a series for a single one. See `TOKENS.md`.
|
|
305
|
-
*/
|
|
306
|
-
colors?: string[];
|
|
307
|
-
/**
|
|
308
|
-
* Optional CSS styles for grid lines.
|
|
309
|
-
*
|
|
310
|
-
* `stroke` is deprecated on its own, not the whole field: `strokeWidth` has no CSS role behind it and still applies. The same shape is used for the other fields whose color moved to CSS — annotating the field itself would strike through the half that stays.
|
|
311
|
-
*/
|
|
312
|
-
gridStyles?: Omit<GridStyles$1, 'stroke'> & {
|
|
313
|
-
/** @deprecated Set the `--a8c-charts-color-grid` custom property inside the provider tree instead. See `TOKENS.md`. */
|
|
314
|
-
stroke?: GridStyles$1['stroke'];
|
|
315
|
-
};
|
|
284
|
+
/** Optional CSS styles for grid lines. */
|
|
285
|
+
gridStyles?: Omit<GridStyles$1, 'stroke'>;
|
|
316
286
|
/** Length of axis ticks in pixels */
|
|
317
287
|
tickLength: number;
|
|
318
|
-
/**
|
|
319
|
-
* Set `--a8c-charts-color-grid` for the gridlines.
|
|
320
|
-
*
|
|
321
|
-
* @deprecated Do not drop this field without replacing it. Nothing in this package consults it, but `buildChartTheme` seeds `y.left/right.axisLine.stroke` and `y.*.tickLine.stroke` from it, and `defaultTheme`'s empty string is the only thing leaving the y axis unpainted — deleting the field hands those a black `#222` instead. CHARTS-263 replaces it with visx's own `yAxisLineStyles`/`yTickLineStyles` and a pair of catalog roles.
|
|
322
|
-
*/
|
|
323
|
-
gridColor?: string;
|
|
324
|
-
/**
|
|
325
|
-
* @deprecated Paints nothing, and unlike `gridColor` is safe to delete: `buildChartTheme` seeds `x.*.axisLine.stroke` from it, but spreads `xAxisLineStyles` over the top and `defaultTheme` always carries that stroke. Charts follow the host's theme through the catalog rather than a dark-mode field of their own.
|
|
326
|
-
*/
|
|
327
|
-
gridColorDark?: string;
|
|
328
288
|
/** Styles for x-axis tick lines */
|
|
329
|
-
xTickLineStyles?: Omit<LineStyles$1, 'stroke'
|
|
330
|
-
/** @deprecated Set the `--a8c-charts-color-tick` custom property inside the provider tree instead. See `TOKENS.md`. */
|
|
331
|
-
stroke?: LineStyles$1['stroke'];
|
|
332
|
-
};
|
|
289
|
+
xTickLineStyles?: Omit<LineStyles$1, 'stroke'>;
|
|
333
290
|
/** Styles for x-axis line */
|
|
334
|
-
xAxisLineStyles?: Omit<LineStyles$1, 'stroke'
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
291
|
+
xAxisLineStyles?: Omit<LineStyles$1, 'stroke'>;
|
|
292
|
+
/**
|
|
293
|
+
* Per-series line styling — dash pattern, width, cap. These spread on top of the
|
|
294
|
+
* palette-derived stroke, so a color here would override it; a single series takes
|
|
295
|
+
* one through `options.seriesLineStyle`.
|
|
296
|
+
*/
|
|
297
|
+
seriesLineStyles?: Array<Omit<LineStyles$1, 'stroke'>>;
|
|
340
298
|
/** Array of render functions for glyphs */
|
|
341
299
|
glyphs?: Array<(<Datum extends object>(props: GlyphProps<Datum>) => ReactNode)>;
|
|
342
300
|
/** Legend specific settings */
|
|
343
301
|
legend?: {
|
|
344
302
|
/** Styles for legend shapes */
|
|
345
303
|
shapeStyles?: Record<string, unknown>[];
|
|
346
|
-
/**
|
|
347
|
-
|
|
348
|
-
*
|
|
349
|
-
* `color` is deprecated on its own, not the whole field: everything else a consumer sets here — font size, weight, spacing — has no catalog role behind it and still applies.
|
|
350
|
-
*/
|
|
351
|
-
labelStyles?: Omit<CSSProperties, 'color'> & {
|
|
352
|
-
/** @deprecated Set the `--a8c-charts-color-label` custom property inside the provider tree instead. See `TOKENS.md`. */
|
|
353
|
-
color?: CSSProperties['color'];
|
|
354
|
-
};
|
|
304
|
+
/** Styles for legend labels. */
|
|
305
|
+
labelStyles?: Omit<CSSProperties, 'color'>;
|
|
355
306
|
/** Styles for legend container */
|
|
356
307
|
containerStyles?: CSSProperties;
|
|
357
308
|
};
|
|
358
309
|
/**
|
|
359
310
|
* Styles for small SVG text (eg. axis tick labels), passed through to the XYChart theme.
|
|
360
311
|
*
|
|
361
|
-
* `fontFamily: 'inherit'` is load-bearing here — it overrides the font stack
|
|
312
|
+
* `fontFamily: 'inherit'` is load-bearing here — it overrides the font stack
|
|
313
|
+
* `buildChartTheme` injects inline on SVG `<text>`.
|
|
362
314
|
*/
|
|
363
|
-
svgLabelSmall?: Omit<TextProps, 'fill'
|
|
364
|
-
/** @deprecated Set the `--a8c-charts-color-label-axis` custom property inside the provider tree instead, or `--a8c-charts-color-label` to move every label at once. See `TOKENS.md`. */
|
|
365
|
-
fill?: TextProps['fill'];
|
|
366
|
-
};
|
|
315
|
+
svgLabelSmall?: Omit<TextProps, 'fill'>;
|
|
367
316
|
/** Styles for large SVG text (eg. axis titles), passed through to the XYChart theme. */
|
|
368
317
|
svgLabelBig?: TextProps;
|
|
369
|
-
annotationStyles?:
|
|
370
|
-
/** GeoChart specific settings */
|
|
371
|
-
geoChart?: {
|
|
372
|
-
/**
|
|
373
|
-
* Default fill color for a geo chart feature (e.g. country) with no data.
|
|
374
|
-
*
|
|
375
|
-
* @deprecated Set the `--a8c-charts-color-surface-secondary` custom property inside the provider tree instead. Google Charts still takes a resolved hex, but the value is read from the role. See `TOKENS.md`.
|
|
376
|
-
*/
|
|
377
|
-
featureFillColor?: string;
|
|
378
|
-
};
|
|
318
|
+
annotationStyles?: ThemeAnnotationStyles;
|
|
379
319
|
/** LeaderboardChart specific settings */
|
|
380
320
|
leaderboardChart?: {
|
|
381
|
-
/** Gap between rows in the leaderboard grid */
|
|
382
|
-
rowGap?: number;
|
|
383
|
-
/** Gap between columns in the leaderboard grid */
|
|
384
|
-
columnGap?: number;
|
|
385
321
|
/** Spacing between label and progress bars */
|
|
386
322
|
labelSpacing?: GapSize;
|
|
387
|
-
/**
|
|
388
|
-
* Primary color for current period bars.
|
|
389
|
-
*
|
|
390
|
-
* @deprecated Use the `primaryColor` prop on `LeaderboardChart` for one chart, or set `--a8c-charts-color-series-1` to move the palette this falls back to. See `TOKENS.md`.
|
|
391
|
-
*/
|
|
392
|
-
primaryColor?: string;
|
|
393
|
-
/**
|
|
394
|
-
* Secondary color for comparison period bars.
|
|
395
|
-
*
|
|
396
|
-
* @deprecated Use the `secondaryColor` prop on `LeaderboardChart` for one chart, or set `--a8c-charts-color-series-2` to move the palette this falls back to. See `TOKENS.md`.
|
|
397
|
-
*/
|
|
398
|
-
secondaryColor?: string;
|
|
399
|
-
/**
|
|
400
|
-
* Delta colors: [negative, neutral, positive].
|
|
401
|
-
*
|
|
402
|
-
* @deprecated Set the `--a8c-charts-color-trend-down`, `-trend-neutral` and `-trend-up` custom properties inside the provider tree instead. See `TOKENS.md`.
|
|
403
|
-
*/
|
|
404
|
-
deltaColors?: [string, string, string];
|
|
405
|
-
};
|
|
406
|
-
/** ConversionFunnelChart specific settings */
|
|
407
|
-
conversionFunnelChart?: {
|
|
408
|
-
/**
|
|
409
|
-
* Primary color for funnel bars.
|
|
410
|
-
*
|
|
411
|
-
* @deprecated Set `--a8c-charts-color-series-1` to move the palette this falls back to. See `TOKENS.md`.
|
|
412
|
-
*/
|
|
413
|
-
primaryColor?: string;
|
|
414
|
-
/**
|
|
415
|
-
* Background color for chart container.
|
|
416
|
-
*
|
|
417
|
-
* @deprecated Set the `--a8c-charts-color-surface-secondary` custom property inside the provider tree instead. See `TOKENS.md`.
|
|
418
|
-
*/
|
|
419
|
-
backgroundColor?: string;
|
|
420
|
-
/**
|
|
421
|
-
* Color for positive change indicators.
|
|
422
|
-
*
|
|
423
|
-
* @deprecated Set the `--a8c-charts-color-trend-up` custom property inside the provider tree instead. See `TOKENS.md`.
|
|
424
|
-
*/
|
|
425
|
-
positiveChangeColor?: string;
|
|
426
|
-
/**
|
|
427
|
-
* Color for negative change indicators.
|
|
428
|
-
*
|
|
429
|
-
* @deprecated Set the `--a8c-charts-color-trend-down` custom property inside the provider tree instead. See `TOKENS.md`.
|
|
430
|
-
*/
|
|
431
|
-
negativeChangeColor?: string;
|
|
432
323
|
};
|
|
433
324
|
lineChart?: {
|
|
434
|
-
lineStyles?: Partial<Record<NonNullable<SeriesDataOptions['type']>, LineStyles$1
|
|
325
|
+
lineStyles?: Partial<Record<NonNullable<SeriesDataOptions['type']>, Omit<LineStyles$1, 'stroke'>>>;
|
|
435
326
|
};
|
|
436
327
|
barChart?: {
|
|
437
328
|
barStyles?: Partial<Record<NonNullable<SeriesDataOptions['type']>, BarStyles>>;
|
|
@@ -450,16 +341,9 @@ type ChartTheme = {
|
|
|
450
341
|
};
|
|
451
342
|
/**
|
|
452
343
|
* HeatmapChart settings. Cell gap, radius, value size and the selection ring come from
|
|
453
|
-
* WPDS tokens in CSS, so only the
|
|
344
|
+
* WPDS tokens in CSS, so only the compact sizing lives here.
|
|
454
345
|
*/
|
|
455
346
|
heatmapChart?: {
|
|
456
|
-
/**
|
|
457
|
-
* Color the cell scale interpolates toward at the highest value (prop > this >
|
|
458
|
-
* palette `colors[0]`), fed to CSS `color-mix`. Omit to use the palette color.
|
|
459
|
-
*
|
|
460
|
-
* @deprecated Use the `primaryColor` prop on `HeatmapChart` for one chart, or set `--a8c-charts-color-series-1` to move the palette this falls back to. See `TOKENS.md`.
|
|
461
|
-
*/
|
|
462
|
-
primaryColor?: string;
|
|
463
347
|
/** Gap in px between cells in compact mode */
|
|
464
348
|
compactCellGap?: number;
|
|
465
349
|
/** Fixed square cell size in px for compact mode */
|
|
@@ -471,10 +355,9 @@ type ChartTheme = {
|
|
|
471
355
|
* Useful for merged themes where defaults are provided for all optional properties.
|
|
472
356
|
*/
|
|
473
357
|
type CompleteChartTheme = Required<ChartTheme> & {
|
|
474
|
-
leaderboardChart:
|
|
475
|
-
conversionFunnelChart: Omit<Required<NonNullable<ChartTheme['conversionFunnelChart']>>, 'primaryColor'> & Pick<NonNullable<ChartTheme['conversionFunnelChart']>, 'primaryColor'>;
|
|
358
|
+
leaderboardChart: Required<NonNullable<ChartTheme['leaderboardChart']>>;
|
|
476
359
|
lineChart: {
|
|
477
|
-
lineStyles: Record<NonNullable<SeriesDataOptions['type']>, LineStyles$1
|
|
360
|
+
lineStyles: Record<NonNullable<SeriesDataOptions['type']>, Omit<LineStyles$1, 'stroke'>>;
|
|
478
361
|
};
|
|
479
362
|
barChart: {
|
|
480
363
|
barStyles: Record<NonNullable<SeriesDataOptions['type']>, BarStyles>;
|
|
@@ -483,13 +366,47 @@ type CompleteChartTheme = Required<ChartTheme> & {
|
|
|
483
366
|
sparkline: Required<NonNullable<ChartTheme['sparkline']>> & {
|
|
484
367
|
margin: Required<NonNullable<ChartTheme['sparkline']>['margin']>;
|
|
485
368
|
};
|
|
486
|
-
heatmapChart:
|
|
369
|
+
heatmapChart: Required<NonNullable<ChartTheme['heatmapChart']>>;
|
|
487
370
|
};
|
|
488
371
|
/**
|
|
489
372
|
* Bucket resolution of time-series data, as known by the caller (e.g. a
|
|
490
373
|
* granularity selector), for consumers that don't need to infer it.
|
|
491
374
|
*/
|
|
492
375
|
type TickResolution = 'hour' | 'day' | 'week' | 'month' | 'year';
|
|
376
|
+
/**
|
|
377
|
+
* How a chart classified the buckets of the data it's drawing.
|
|
378
|
+
*/
|
|
379
|
+
type BucketInfo = {
|
|
380
|
+
/**
|
|
381
|
+
* The bucket the series has. Only reports `'week'` when declared: seven-day
|
|
382
|
+
* spacing is indistinguishable from sparse daily data.
|
|
383
|
+
*/
|
|
384
|
+
bucket: TickResolution;
|
|
385
|
+
/** The classification tick formats are keyed on. `'week'` reads as `'day'`. */
|
|
386
|
+
displayResolution: Exclude<TickResolution, 'week'>;
|
|
387
|
+
};
|
|
388
|
+
/**
|
|
389
|
+
* The locale and time zone the time axis and the built-in tooltips render dates
|
|
390
|
+
* in, set once by the host on `GlobalChartsProvider`.
|
|
391
|
+
*
|
|
392
|
+
* Both halves are plain strings the host resolves for itself, so a non-WordPress
|
|
393
|
+
* consumer needs no WordPress package to supply them. Both are optional and
|
|
394
|
+
* default to the JavaScript runtime's own — the viewer's browser locale and
|
|
395
|
+
* browser time zone — which is what every version before this one used
|
|
396
|
+
* unconditionally.
|
|
397
|
+
*
|
|
398
|
+
* `timeZone` re-dates the instants the host supplies, so a value that is really a
|
|
399
|
+
* calendar day shifts under it: `new Date( '2026-08-02' )` is UTC midnight and
|
|
400
|
+
* labels as Aug 1 in `America/Los_Angeles`. Supply true instants alongside a
|
|
401
|
+
* `timeZone`, or set only `locale` for day-bucketed data. `buildCalendarHeatmapData`
|
|
402
|
+
* is the exception: it reads a bare `yyyy-MM-dd` as the day it names.
|
|
403
|
+
*/
|
|
404
|
+
type ChartFormatting = {
|
|
405
|
+
/** BCP-47 language tag, e.g. `de-DE`. Defaults to the runtime's locale. */
|
|
406
|
+
locale?: string;
|
|
407
|
+
/** IANA time zone name, e.g. `Asia/Tokyo`. Defaults to the runtime's zone. */
|
|
408
|
+
timeZone?: string;
|
|
409
|
+
};
|
|
493
410
|
type AxisOptions = {
|
|
494
411
|
orientation?: OrientationType;
|
|
495
412
|
numTicks?: number;
|
|
@@ -875,20 +792,63 @@ interface RenderTooltipGlyphProps<Datum extends object> extends GlyphProps<Datum
|
|
|
875
792
|
glyphStyle?: SVGProps<SVGCircleElement>;
|
|
876
793
|
isNearestDatum: boolean;
|
|
877
794
|
}
|
|
795
|
+
type TooltipPlacement = 'auto' | 'below-axis';
|
|
796
|
+
type CrosshairPaintProperty = 'stroke' | 'strokeWidth' | 'strokeOpacity' | 'strokeDasharray' | 'strokeLinecap' | 'opacity';
|
|
797
|
+
type CrosshairStyle = Pick<SVGProps<SVGLineElement>, CrosshairPaintProperty> & {
|
|
798
|
+
className?: string;
|
|
799
|
+
style?: Pick<CSSProperties, CrosshairPaintProperty>;
|
|
800
|
+
};
|
|
878
801
|
type XyChartTooltipProps<Datum extends object> = {
|
|
879
802
|
renderTooltip: (params: RenderTooltipParams<Datum>) => ReactNode;
|
|
880
803
|
renderGlyph?: (params: RenderTooltipGlyphProps<Datum>) => ReactNode;
|
|
804
|
+
/**
|
|
805
|
+
* Keep the panel below the x-axis label band, centered at the datum x and horizontally clamped.
|
|
806
|
+
* Vertical bounds do not move this placement; clipping ancestors can still cut it off.
|
|
807
|
+
* @default 'auto'
|
|
808
|
+
*/
|
|
809
|
+
tooltipPlacement?: TooltipPlacement;
|
|
810
|
+
/** Merge overrides with the default box styles; use `unstyled` to strip the box styling. */
|
|
811
|
+
style?: TooltipProps$1['style'];
|
|
881
812
|
snapTooltipToDatumX?: boolean;
|
|
882
813
|
snapTooltipToDatumY?: boolean;
|
|
883
814
|
showVerticalCrosshair?: boolean;
|
|
884
815
|
showHorizontalCrosshair?: boolean;
|
|
885
816
|
showDatumGlyph?: boolean;
|
|
886
817
|
showSeriesGlyphs?: boolean;
|
|
887
|
-
verticalCrosshairStyle?:
|
|
888
|
-
horizontalCrosshairStyle?:
|
|
818
|
+
verticalCrosshairStyle?: CrosshairStyle;
|
|
819
|
+
horizontalCrosshairStyle?: CrosshairStyle;
|
|
889
820
|
glyphStyle?: SVGProps<SVGCircleElement>;
|
|
821
|
+
/**
|
|
822
|
+
* Flip and clamp the tooltip box so it stays inside the nearest ancestor
|
|
823
|
+
* that clips its overflow, or the viewport when there is none. The box may
|
|
824
|
+
* leave the chart wrapper. (It used to keep a body-level portal inside the
|
|
825
|
+
* viewport.)
|
|
826
|
+
* Ignored by `below-axis`.
|
|
827
|
+
* @default true
|
|
828
|
+
*/
|
|
829
|
+
detectBounds?: boolean;
|
|
830
|
+
/**
|
|
831
|
+
* Stacking order of the tooltip box inside the chart wrapper, which isolates
|
|
832
|
+
* its stacking context: the value never competes with page chrome outside
|
|
833
|
+
* the chart.
|
|
834
|
+
* @default 3
|
|
835
|
+
*/
|
|
836
|
+
zIndex?: number;
|
|
837
|
+
/**
|
|
838
|
+
* @deprecated Accepted and ignored. The box renders inside the chart wrapper
|
|
839
|
+
* and moves with it, so it needs no scroll tracking.
|
|
840
|
+
*/
|
|
841
|
+
scroll?: boolean;
|
|
842
|
+
/**
|
|
843
|
+
* @deprecated Accepted and ignored. Nothing measures the box any more, so
|
|
844
|
+
* there is no measurement to debounce.
|
|
845
|
+
*/
|
|
846
|
+
debounce?: number;
|
|
847
|
+
/**
|
|
848
|
+
* @deprecated Accepted and ignored. No ResizeObserver is used.
|
|
849
|
+
*/
|
|
890
850
|
resizeObserverPolyfill?: UseTooltipPortalOptions['polyfill'];
|
|
891
|
-
} & Omit<TooltipProps$1, 'left' | 'top' | 'children'
|
|
851
|
+
} & Omit<TooltipProps$1, 'left' | 'top' | 'children' | 'applyPositionStyle'>;
|
|
892
852
|
//#endregion
|
|
893
853
|
//#region src/charts/line-chart/types.d.ts
|
|
894
854
|
type LineChartAnnotationProps = {
|
|
@@ -920,7 +880,18 @@ interface LineChartProps extends BaseChartProps<SeriesData[]>, SeriesVisibilityP
|
|
|
920
880
|
withGradientFill: boolean;
|
|
921
881
|
smoothing?: boolean;
|
|
922
882
|
curveType?: CurveType;
|
|
923
|
-
renderTooltip?: (params: RenderTooltipParams<DataPointDate>
|
|
883
|
+
renderTooltip?: (params: RenderTooltipParams<DataPointDate> & {
|
|
884
|
+
bucketInfo?: BucketInfo;
|
|
885
|
+
}) => ReactNode;
|
|
886
|
+
/**
|
|
887
|
+
* Place the panel below the x-axis tick labels with a pointer at the datum x; horizontal bounds still apply.
|
|
888
|
+
* @default 'auto'
|
|
889
|
+
*/
|
|
890
|
+
tooltipPlacement?: XyChartTooltipProps<DataPointDate>['tooltipPlacement'];
|
|
891
|
+
/**
|
|
892
|
+
* Inline container styles; see Below-Axis Tooltips in stories/index.docs.mdx for content color overrides.
|
|
893
|
+
*/
|
|
894
|
+
tooltipStyle?: CSSProperties;
|
|
924
895
|
withStartGlyphs?: boolean;
|
|
925
896
|
withEndGlyphs?: boolean;
|
|
926
897
|
renderGlyph?: <Datum extends object>(props: GlyphProps<Datum>) => ReactNode;
|
|
@@ -929,6 +900,8 @@ interface LineChartProps extends BaseChartProps<SeriesData[]>, SeriesVisibilityP
|
|
|
929
900
|
withTooltipCrosshairs?: {
|
|
930
901
|
showVertical?: boolean;
|
|
931
902
|
showHorizontal?: boolean;
|
|
903
|
+
verticalStyle?: CrosshairStyle;
|
|
904
|
+
horizontalStyle?: CrosshairStyle;
|
|
932
905
|
};
|
|
933
906
|
/**
|
|
934
907
|
* Enable drag-to-zoom on the X axis. The user drags horizontally to
|
|
@@ -983,7 +956,9 @@ interface AreaChartProps extends BaseChartProps<SeriesData[]>, SeriesVisibilityP
|
|
|
983
956
|
/**
|
|
984
957
|
* Custom tooltip renderer.
|
|
985
958
|
*/
|
|
986
|
-
renderTooltip?: (params: RenderTooltipParams<DataPointDate>
|
|
959
|
+
renderTooltip?: (params: RenderTooltipParams<DataPointDate> & {
|
|
960
|
+
bucketInfo?: BucketInfo;
|
|
961
|
+
}) => ReactNode;
|
|
987
962
|
/**
|
|
988
963
|
* Whether to show crosshair lines in the tooltip.
|
|
989
964
|
*/
|
|
@@ -1015,12 +990,6 @@ interface AreaChartProps extends BaseChartProps<SeriesData[]>, SeriesVisibilityP
|
|
|
1015
990
|
* @default true
|
|
1016
991
|
*/
|
|
1017
992
|
rescaleYOnVisibilityChange?: boolean;
|
|
1018
|
-
/**
|
|
1019
|
-
* @deprecated Use `rescaleYOnVisibilityChange`. The behaviour keys off series
|
|
1020
|
-
* visibility changing, not specifically a legend toggle. Still honoured when
|
|
1021
|
-
* `rescaleYOnVisibilityChange` is not set.
|
|
1022
|
-
*/
|
|
1023
|
-
rescaleYOnLegendToggle?: boolean;
|
|
1024
993
|
children?: ReactNode;
|
|
1025
994
|
}
|
|
1026
995
|
//#endregion
|
|
@@ -1320,6 +1289,12 @@ type HeatmapColumn = {
|
|
|
1320
1289
|
/** x-axis label for this column. Empty/omitted renders blank. */
|
|
1321
1290
|
label?: string;
|
|
1322
1291
|
data: HeatmapCell[];
|
|
1292
|
+
/**
|
|
1293
|
+
* A per-row roll-up such as a total or an average. Left out of the color
|
|
1294
|
+
* scale, drawn unfilled with its figure always printed, on an `auto` track
|
|
1295
|
+
* one gap apart from the data beside it. The chart never computes it.
|
|
1296
|
+
*/
|
|
1297
|
+
summary?: boolean;
|
|
1323
1298
|
};
|
|
1324
1299
|
type HeatmapTooltipData = {
|
|
1325
1300
|
value: number | null;
|
|
@@ -1358,8 +1333,8 @@ interface HeatmapChartProps extends Omit<BaseChartProps<HeatmapColumn[]>, 'showL
|
|
|
1358
1333
|
/** Floor a cell's height (px) in non-compact mode; see `minCellWidth`. */
|
|
1359
1334
|
minCellHeight?: number;
|
|
1360
1335
|
/**
|
|
1361
|
-
* Color the cell scale interpolates toward at the highest value
|
|
1362
|
-
*
|
|
1336
|
+
* Color the cell scale interpolates toward at the highest value. Defaults to the
|
|
1337
|
+
* first series palette slot, `--a8c-charts-color-series-1`.
|
|
1363
1338
|
*/
|
|
1364
1339
|
primaryColor?: string;
|
|
1365
1340
|
renderTooltip?: (data: HeatmapTooltipData) => ReactNode;
|
|
@@ -1371,29 +1346,40 @@ type CalendarHeatmapResult = {
|
|
|
1371
1346
|
data: HeatmapColumn[];
|
|
1372
1347
|
rowLabels: string[];
|
|
1373
1348
|
};
|
|
1374
|
-
|
|
1349
|
+
type CalendarHeatmapOptions = {
|
|
1375
1350
|
weekStartsOn?: 0 | 1;
|
|
1376
1351
|
/**
|
|
1377
|
-
* Mark the days completing the first
|
|
1378
|
-
*
|
|
1379
|
-
*
|
|
1380
|
-
* blank cells even when the series has no entry for them.
|
|
1352
|
+
* Mark the days completing the first and last week outside the series' span as
|
|
1353
|
+
* hidden cells rather than blank ones, giving the calendar ragged edges. Days
|
|
1354
|
+
* inside the span stay blank even where the series has no entry.
|
|
1381
1355
|
*/
|
|
1382
1356
|
hideOutOfRangeDays?: boolean;
|
|
1383
1357
|
/**
|
|
1384
|
-
* Draw the grid over this span (`yyyy-MM-dd` bounds) instead of the
|
|
1385
|
-
*
|
|
1386
|
-
*
|
|
1387
|
-
*
|
|
1388
|
-
* measured. A start bound is drawn from the beginning of its week, so
|
|
1389
|
-
* the grid always opens on a whole column. Bounds narrower than the
|
|
1390
|
-
* series are ignored — the grid never drops a day that carries data.
|
|
1358
|
+
* Draw the grid over this span (`yyyy-MM-dd` bounds) instead of the series' own.
|
|
1359
|
+
* Days inside the grid but outside the series become placeholder cells: painted,
|
|
1360
|
+
* but reporting nothing, since they were never measured. A start bound opens from
|
|
1361
|
+
* the beginning of its week, and bounds narrower than the series are ignored.
|
|
1391
1362
|
*/
|
|
1392
1363
|
gridSpan?: {
|
|
1393
1364
|
start?: string;
|
|
1394
1365
|
end?: string;
|
|
1395
1366
|
};
|
|
1396
|
-
|
|
1367
|
+
/** BCP-47 tag the labels are written in. Defaults to the runtime's locale. */
|
|
1368
|
+
locale?: string;
|
|
1369
|
+
/**
|
|
1370
|
+
* IANA zone the series' instants are bucketed into days in. Defaults to the
|
|
1371
|
+
* runtime's zone. A `dateString` carrying no offset is taken as written.
|
|
1372
|
+
*/
|
|
1373
|
+
timeZone?: string;
|
|
1374
|
+
};
|
|
1375
|
+
/**
|
|
1376
|
+
* Lay a day-bucketed series out as calendar columns.
|
|
1377
|
+
*
|
|
1378
|
+
* @param series - Points to bucket.
|
|
1379
|
+
* @param options - Grid shape, plus the locale and zone to read days in.
|
|
1380
|
+
* @return Columns and row labels for `HeatmapChart`.
|
|
1381
|
+
*/
|
|
1382
|
+
declare const buildCalendarHeatmapData: (series: DataPointDate[], options?: CalendarHeatmapOptions) => CalendarHeatmapResult;
|
|
1397
1383
|
//#endregion
|
|
1398
1384
|
//#region src/charts/heatmap-chart/private/heatmap-legend.d.ts
|
|
1399
1385
|
interface HeatmapLegendProps {
|
|
@@ -1411,6 +1397,17 @@ interface HeatmapChartSubComponents {
|
|
|
1411
1397
|
declare const HeatmapChart: FC<HeatmapChartProps> & HeatmapChartSubComponents;
|
|
1412
1398
|
declare const HeatmapChartResponsive: FC<HeatmapChartProps & ResponsiveConfig> & HeatmapChartSubComponents;
|
|
1413
1399
|
//#endregion
|
|
1400
|
+
//#region src/charts/heatmap-chart/use-calendar-heatmap-data.d.ts
|
|
1401
|
+
/**
|
|
1402
|
+
* `buildCalendarHeatmapData` with the locale and zone taken from
|
|
1403
|
+
* `GlobalChartsProvider` where the caller names neither.
|
|
1404
|
+
*
|
|
1405
|
+
* @param series - Points to bucket. Held by reference, so a caller that rebuilds it each render defeats the memo.
|
|
1406
|
+
* @param options - As for `buildCalendarHeatmapData`; `locale` and `timeZone` win over the provider.
|
|
1407
|
+
* @return Columns and row labels for `HeatmapChart`.
|
|
1408
|
+
*/
|
|
1409
|
+
declare const useCalendarHeatmapData: (series: DataPointDate[], options?: CalendarHeatmapOptions) => CalendarHeatmapResult;
|
|
1410
|
+
//#endregion
|
|
1414
1411
|
//#region src/charts/leaderboard-chart/types.d.ts
|
|
1415
1412
|
interface LeaderboardChartProps extends Pick<BaseChartProps<LeaderboardEntry>, 'className' | 'data' | 'showLegend' | 'legend' | 'chartId' | 'width' | 'height' | 'size' | 'gap' | 'animation'> {
|
|
1416
1413
|
/**
|
|
@@ -1430,9 +1427,9 @@ interface LeaderboardChartProps extends Pick<BaseChartProps<LeaderboardEntry>, '
|
|
|
1430
1427
|
*/
|
|
1431
1428
|
secondaryColor?: string;
|
|
1432
1429
|
/**
|
|
1433
|
-
* Formatter for values
|
|
1430
|
+
* Formatter for values. May return an element, e.g. to attach a tooltip.
|
|
1434
1431
|
*/
|
|
1435
|
-
valueFormatter?: (value: number) =>
|
|
1432
|
+
valueFormatter?: (value: number) => ReactNode;
|
|
1436
1433
|
/**
|
|
1437
1434
|
* Formatter for delta values
|
|
1438
1435
|
*/
|
|
@@ -1493,64 +1490,34 @@ declare const LeaderboardChartResponsive: (({ resizeDebounceTime, maxWidth, aspe
|
|
|
1493
1490
|
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
1494
1491
|
};
|
|
1495
1492
|
//#endregion
|
|
1496
|
-
//#region src/utils/
|
|
1493
|
+
//#region src/utils/bucket-info.d.ts
|
|
1497
1494
|
/**
|
|
1498
|
-
*
|
|
1499
|
-
*
|
|
1500
|
-
* This module provides utilities for parsing various date string formats and converting
|
|
1501
|
-
* them to local timezone dates using the battle-tested date-fns library. For formats
|
|
1502
|
-
* without timezone info, they're treated as local. For formats with timezone info,
|
|
1503
|
-
* they're converted to the equivalent local time.
|
|
1495
|
+
* How this data was classified, for consumers that render their own labels.
|
|
1504
1496
|
*
|
|
1505
|
-
*
|
|
1506
|
-
*
|
|
1507
|
-
*
|
|
1508
|
-
* - All parsed dates are in local timezone
|
|
1509
|
-
* - Converts timezone-aware strings to local equivalent
|
|
1510
|
-
* - Robust input validation and error handling using date-fns
|
|
1511
|
-
* - TypeScript type safety
|
|
1512
|
-
* - Much smaller codebase than custom parsing
|
|
1513
|
-
*
|
|
1514
|
-
* Supported Formats:
|
|
1515
|
-
* - YYYY-MM-DD (treated as local)
|
|
1516
|
-
* - YYYY-MM-DD HH:mm:ss (treated as local)
|
|
1517
|
-
* - YYYY-MM-DD HH:mm (treated as local)
|
|
1518
|
-
* - YYYY-MM-DDTHH:mm:ss (treated as local)
|
|
1519
|
-
* - YYYY-MM-DDTHH:mm:ss.SSS (treated as local)
|
|
1520
|
-
* - YYYY-MM-DDTHH:mm (treated as local)
|
|
1521
|
-
* - YYYY-MM-DDTHH:mm:ssZ (converted to local)
|
|
1522
|
-
* - YYYY-MM-DDTHH:mm:ss±HH:mm (converted to local)
|
|
1523
|
-
*
|
|
1524
|
-
* @example
|
|
1525
|
-
* ```typescript
|
|
1526
|
-
* parseAsLocalDate("2025-01-01"); // Local timezone
|
|
1527
|
-
* parseAsLocalDate("2025-01-01 14:30:00"); // Local timezone
|
|
1528
|
-
* parseAsLocalDate("2025-01-01 14:30"); // Local timezone
|
|
1529
|
-
* parseAsLocalDate("2025-01-01T14:30:45.123"); // Local timezone
|
|
1530
|
-
* parseAsLocalDate("2025-01-01T14:30:00Z"); // UTC 14:30 → Local equivalent
|
|
1531
|
-
* parseAsLocalDate("2025-01-01T14:30:00+05:00"); // +05:00 14:30 → Local equivalent
|
|
1532
|
-
* ```
|
|
1497
|
+
* @param data - The series the chart draws, in any order, dated by `date` or `dateString`.
|
|
1498
|
+
* @param tickResolution - Caller-declared bucket resolution, when known.
|
|
1499
|
+
* @return The declared or inferred bucket, and the resolution formats key on.
|
|
1533
1500
|
*/
|
|
1501
|
+
declare const getBucketInfo: (data: SeriesData[], tickResolution?: TickResolution) => BucketInfo;
|
|
1502
|
+
//#endregion
|
|
1503
|
+
//#region src/utils/date-parsing.d.ts
|
|
1534
1504
|
/**
|
|
1535
|
-
* Parses any supported date string format
|
|
1505
|
+
* Parses any supported date string format into an instant, dated in `timeZone` or the runtime's own
|
|
1506
|
+
*
|
|
1507
|
+
* Uses date-fns for robust parsing and validation. A string carrying timezone info
|
|
1508
|
+
* is already an instant and is returned as one, whatever `timeZone` says. A string
|
|
1509
|
+
* without it is a wall-clock reading, dated in `timeZone` when one is supplied and
|
|
1510
|
+
* in the runtime's own zone when none is.
|
|
1536
1511
|
*
|
|
1537
|
-
*
|
|
1538
|
-
*
|
|
1539
|
-
*
|
|
1512
|
+
* A wall clock a DST gap deleted is moved forward past the gap; one a fall-back repeated
|
|
1513
|
+
* resolves to a single instant. Neither policy is selectable. A zone `Intl` rejects falls
|
|
1514
|
+
* back to the runtime's own, and warns once outside production.
|
|
1540
1515
|
*
|
|
1541
|
-
*
|
|
1542
|
-
*
|
|
1543
|
-
*
|
|
1544
|
-
* - YYYY-MM-DD HH:mm (local)
|
|
1545
|
-
* - YYYY-MM-DDTHH:mm:ss (local)
|
|
1546
|
-
* - YYYY-MM-DDTHH:mm:ss.SSS (local)
|
|
1547
|
-
* - YYYY-MM-DDTHH:mm (local)
|
|
1548
|
-
* - YYYY-MM-DDTHH:mm:ssZ (UTC → local)
|
|
1549
|
-
* - YYYY-MM-DDTHH:mm:ss±HH:mm (offset → local)
|
|
1550
|
-
* @param {string} dateString - The date string to parse into a local timezone date
|
|
1551
|
-
* @return {Date} A Date object representing the parsed date in local timezone, or an invalid Date if parsing fails
|
|
1516
|
+
* @param {string} dateString - The date string to parse into a date
|
|
1517
|
+
* @param {string} [timeZone] - IANA zone a naive string is read in; the runtime's own when absent, and ignored by a string that carries its own offset
|
|
1518
|
+
* @return {Date} A Date object representing the parsed instant, or an invalid Date if parsing fails
|
|
1552
1519
|
*/
|
|
1553
|
-
declare const parseAsLocalDate: (dateString: string) => Date;
|
|
1520
|
+
declare const parseAsLocalDate: (dateString: string, timeZone?: string) => Date;
|
|
1554
1521
|
//#endregion
|
|
1555
1522
|
//#region src/utils/format-metric-value.d.ts
|
|
1556
1523
|
/**
|
|
@@ -1635,14 +1602,6 @@ declare const getColorDistance: (hsl1: [number, number, number], hsl2: [number,
|
|
|
1635
1602
|
* @return HSL tuple [h, s, l] or null if invalid
|
|
1636
1603
|
*/
|
|
1637
1604
|
declare const parseHslString: (hslString: string) => [number, number, number] | null;
|
|
1638
|
-
/**
|
|
1639
|
-
* Parse an RGB string like 'rgb(255, 0, 0)' into a hex color.
|
|
1640
|
-
*
|
|
1641
|
-
* @deprecated Use normalizeColorToHex() instead, which handles all color formats including rgb() and rgba().
|
|
1642
|
-
* @param rgbString - RGB color string (not RGBA)
|
|
1643
|
-
* @return hex color string or null if invalid
|
|
1644
|
-
*/
|
|
1645
|
-
declare const parseRgbString: (rgbString: string) => string | null;
|
|
1646
1605
|
/**
|
|
1647
1606
|
* Normalize any CSS color value to a hex color string.
|
|
1648
1607
|
* Handles hex, HSL, HSLA, RGB, RGBA, named CSS colors, and CSS variables.
|
|
@@ -1915,7 +1874,7 @@ type GradientConfig = {
|
|
|
1915
1874
|
*/
|
|
1916
1875
|
from?: string;
|
|
1917
1876
|
/**
|
|
1918
|
-
* End color for gradient (defaults to
|
|
1877
|
+
* End color for gradient (defaults to `--a8c-charts-color-background`)
|
|
1919
1878
|
*/
|
|
1920
1879
|
to?: string;
|
|
1921
1880
|
/**
|
|
@@ -2157,6 +2116,8 @@ interface GlobalChartsContextValue {
|
|
|
2157
2116
|
unregisterChart: (id: string) => void;
|
|
2158
2117
|
getChartData: (id: string) => ChartRegistration | undefined;
|
|
2159
2118
|
theme: CompleteChartTheme;
|
|
2119
|
+
/** Locale and time zone every date the charts print is rendered in. */
|
|
2120
|
+
formatting: ChartFormatting;
|
|
2160
2121
|
getElementStyles: (params: GetElementStylesParams) => ElementStyles;
|
|
2161
2122
|
toggleSeriesVisibility: (chartId: string, seriesLabel: string) => void;
|
|
2162
2123
|
setSeriesVisibility: (chartId: string, seriesLabel: string, visible: boolean) => void;
|
|
@@ -2175,6 +2136,16 @@ declare const GlobalChartsContext: import("react").Context<GlobalChartsContextVa
|
|
|
2175
2136
|
interface GlobalChartsProviderProps {
|
|
2176
2137
|
children: ReactNode;
|
|
2177
2138
|
theme?: Partial<ChartTheme>;
|
|
2139
|
+
/**
|
|
2140
|
+
* BCP-47 language tag every date label is rendered in, e.g. `de-DE`.
|
|
2141
|
+
* Defaults to the viewer's browser locale.
|
|
2142
|
+
*/
|
|
2143
|
+
locale?: string;
|
|
2144
|
+
/**
|
|
2145
|
+
* IANA time zone every date label is dated in, e.g. `Asia/Tokyo`.
|
|
2146
|
+
* Defaults to the viewer's browser time zone.
|
|
2147
|
+
*/
|
|
2148
|
+
timeZone?: string;
|
|
2178
2149
|
}
|
|
2179
2150
|
declare const GlobalChartsProvider: FC<GlobalChartsProviderProps>;
|
|
2180
2151
|
//#endregion
|
|
@@ -2198,9 +2169,24 @@ declare const useChartRegistration: ({ chartId, legendItems, chartType, isDataVa
|
|
|
2198
2169
|
*/
|
|
2199
2170
|
declare const useGlobalChartsTheme: () => CompleteChartTheme;
|
|
2200
2171
|
//#endregion
|
|
2172
|
+
//#region src/providers/chart-context/hooks/use-chart-formatting.d.ts
|
|
2173
|
+
/**
|
|
2174
|
+
* The locale and time zone dates are rendered in, as set on `GlobalChartsProvider`.
|
|
2175
|
+
*
|
|
2176
|
+
* Falls back to the runtime's own rather than throwing: charts render outside a
|
|
2177
|
+
* provider, and a host that sets neither gets exactly the browser-default
|
|
2178
|
+
* behavior this package had before the context existed.
|
|
2179
|
+
*
|
|
2180
|
+
* @return The host's formatting context.
|
|
2181
|
+
*/
|
|
2182
|
+
declare const useChartFormatting: () => ChartFormatting;
|
|
2183
|
+
//#endregion
|
|
2201
2184
|
//#region src/providers/chart-context/themes.d.ts
|
|
2202
2185
|
/**
|
|
2203
|
-
* Default theme configuration
|
|
2186
|
+
* Default theme configuration: the shape and spacing a consumer can override.
|
|
2187
|
+
*
|
|
2188
|
+
* For a color, set the matching `--a8c-charts-color-*` role in CSS instead; the `var()`
|
|
2189
|
+
* chains that deliver those live in `private/catalog-pointers.ts`.
|
|
2204
2190
|
*/
|
|
2205
2191
|
declare const defaultTheme: CompleteChartTheme;
|
|
2206
2192
|
//#endregion
|
|
@@ -2212,5 +2198,5 @@ declare const defaultTheme: CompleteChartTheme;
|
|
|
2212
2198
|
*/
|
|
2213
2199
|
declare const useChartScopeElement: () => HTMLElement | null;
|
|
2214
2200
|
//#endregion
|
|
2215
|
-
export { AccessibleTooltip, type AnnotationStyles, type ArcData, AreaChartResponsive as AreaChart, type AreaChartProps, AreaChart as AreaChartUnresponsive, type AxisOptions, BarChartResponsive as BarChart, type BarChartProps, BarChart as BarChartUnresponsive, BarListChartResponsive as BarListChart, type BarListChartProps, BarListChart as BarListChartUnresponsive, type BaseChartProps, type BaseLegendItem, type BaseLegendProps, BaseTooltip, type BaseTooltipProps, type CalendarHeatmapResult, type ChartLegendConfig, type ChartLegendOptions, type ChartTheme, type CompleteChartTheme, ConversionFunnelChartWithProvider as ConversionFunnelChart, type ConversionFunnelChartProps, type CurveType, type DataPoint, type DataPointDate, type DataPointPercentage, type EventHandlerParams, type FunnelStep, GeoChartResponsive as GeoChart, type GeoChartError, type GeoChartProps, GeoChartWithProvider as GeoChartUnresponsive, type GeoData, type GeoRegion, type GeoResolution, GlobalChartsContext, GlobalChartsProvider, GlobalChartsProvider as ThemeProvider, type GoogleDataTableColumn, GoogleDataTableColumnRoleType, type GoogleDataTableRow, type GradientConfig, type GradientStop, type GridStyles, type HeatmapCell, HeatmapChartResponsive as HeatmapChart, type HeatmapChartProps, HeatmapChart as HeatmapChartUnresponsive, type HeatmapColumn, type HeatmapTooltipData, LeaderboardChartResponsive as LeaderboardChart, type LeaderboardChartProps, LeaderboardChart as LeaderboardChartUnresponsive, type LeaderboardEntry, Legend, type LegendItemStyles, type LegendLabelStyles, type LegendPosition, type LegendProps, type LegendShape, type LegendShapeLabel, type LegendShapeRenderProps, type LegendShapeStyles, type LegendValueDisplay, LineChartResponsive as LineChart, type LineChartAnnotationProps, type LineChartProps, LineChart as LineChartUnresponsive, type LineStyles, type MainMetricRenderProps, type MetricValueType, type MultipleDataPointsDate, type Optional, type OrientationType, PieChartResponsive as PieChart, type PieChartProps, type PieChartRenderTooltipParams, PieChart as PieChartUnresponsive, PieSemiCircleChartResponsive as PieSemiCircleChart, type PieSemiCircleChartProps, type PieSemiCircleChartRenderTooltipParams, PieSemiCircleChart as PieSemiCircleChartUnresponsive, type RenderLabelProps, type RenderLineGlyphProps, type RenderTooltipGlyphProps, type RenderTooltipParams, type RenderValueProps, type ScaleOptions, type SeriesChartLegendConfig, type SeriesData, type SeriesDataOptions, type SeriesVisibilityProps, Sparkline, type SparklineDataPoint, type SparklineProps, SparklineUnresponsive, type StepLabelRenderProps, type StepRateRenderProps, type TickResolution, type TooltipData, type TooltipDatum, type TooltipProps, type TooltipRenderProps, type TrendDirection, TrendIndicator, type TrendIndicatorProps, type XyChartTooltipProps, buildCalendarHeatmapData, defaultTheme, formatMetricValue, formatPercentage, getColorDistance, hexToRgba, isValidHexColor, lightenHexColor, mergeThemes, mixHexColors, normalizeColorToHex, parseAsLocalDate, parseHslString,
|
|
2201
|
+
export { AccessibleTooltip, type AnnotationStyles, type ArcData, AreaChartResponsive as AreaChart, type AreaChartProps, AreaChart as AreaChartUnresponsive, type AxisOptions, BarChartResponsive as BarChart, type BarChartProps, BarChart as BarChartUnresponsive, BarListChartResponsive as BarListChart, type BarListChartProps, BarListChart as BarListChartUnresponsive, type BaseChartProps, type BaseLegendItem, type BaseLegendProps, BaseTooltip, type BaseTooltipProps, type BucketInfo, type CalendarHeatmapOptions, type CalendarHeatmapResult, type ChartFormatting, type ChartLegendConfig, type ChartLegendOptions, type ChartTheme, type CompleteChartTheme, ConversionFunnelChartWithProvider as ConversionFunnelChart, type ConversionFunnelChartProps, type CrosshairStyle, type CurveType, type DataPoint, type DataPointDate, type DataPointPercentage, type EventHandlerParams, type FunnelStep, GeoChartResponsive as GeoChart, type GeoChartError, type GeoChartProps, GeoChartWithProvider as GeoChartUnresponsive, type GeoData, type GeoRegion, type GeoResolution, GlobalChartsContext, GlobalChartsProvider, GlobalChartsProvider as ThemeProvider, type GoogleDataTableColumn, GoogleDataTableColumnRoleType, type GoogleDataTableRow, type GradientConfig, type GradientStop, type GridStyles, type HeatmapCell, HeatmapChartResponsive as HeatmapChart, type HeatmapChartProps, HeatmapChart as HeatmapChartUnresponsive, type HeatmapColumn, type HeatmapTooltipData, LeaderboardChartResponsive as LeaderboardChart, type LeaderboardChartProps, LeaderboardChart as LeaderboardChartUnresponsive, type LeaderboardEntry, Legend, type LegendItemStyles, type LegendLabelStyles, type LegendPosition, type LegendProps, type LegendShape, type LegendShapeLabel, type LegendShapeRenderProps, type LegendShapeStyles, type LegendValueDisplay, LineChartResponsive as LineChart, type LineChartAnnotationProps, type LineChartProps, LineChart as LineChartUnresponsive, type LineStyles, type MainMetricRenderProps, type MetricValueType, type MultipleDataPointsDate, type Optional, type OrientationType, PieChartResponsive as PieChart, type PieChartProps, type PieChartRenderTooltipParams, PieChart as PieChartUnresponsive, PieSemiCircleChartResponsive as PieSemiCircleChart, type PieSemiCircleChartProps, type PieSemiCircleChartRenderTooltipParams, PieSemiCircleChart as PieSemiCircleChartUnresponsive, type RenderLabelProps, type RenderLineGlyphProps, type RenderTooltipGlyphProps, type RenderTooltipParams, type RenderValueProps, type ScaleOptions, type SeriesChartLegendConfig, type SeriesData, type SeriesDataOptions, type SeriesVisibilityProps, Sparkline, type SparklineDataPoint, type SparklineProps, SparklineUnresponsive, type StepLabelRenderProps, type StepRateRenderProps, type TickResolution, type TooltipData, type TooltipDatum, type TooltipPlacement, type TooltipProps, type TooltipRenderProps, type TrendDirection, TrendIndicator, type TrendIndicatorProps, type XyChartTooltipProps, buildCalendarHeatmapData, defaultTheme, formatMetricValue, formatPercentage, getBucketInfo, getColorDistance, hexToRgba, isValidHexColor, lightenHexColor, mergeThemes, mixHexColors, normalizeColorToHex, parseAsLocalDate, parseHslString, prefersLightText, relativeLuminance, resolveCssVariable, useCalendarHeatmapData, useChartFormatting, useChartLegendItems, useChartRegistration, useChartScopeElement, useGlobalChartsContext, useGlobalChartsTheme, useLeaderboardLegendItems, validateHexColor };
|
|
2216
2202
|
//# sourceMappingURL=index.d.cts.map
|