@automattic/charts 4.9.0 → 4.10.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/dist/index.cjs +159 -66
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +14 -0
- package/dist/index.d.cts +27 -22
- package/dist/index.d.ts +27 -22
- package/dist/index.js +159 -66
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/charts/area-chart/area-chart.tsx +2 -1
- package/src/charts/area-chart/test/area-chart.test.tsx +0 -8
- package/src/charts/area-chart/types.ts +0 -2
- package/src/charts/bar-chart/bar-chart.tsx +7 -2
- package/src/charts/bar-chart/test/bar-chart.test.tsx +0 -8
- package/src/charts/bar-chart/types.ts +0 -2
- package/src/charts/bar-list-chart/bar-list-chart.tsx +3 -0
- package/src/charts/conversion-funnel-chart/conversion-funnel-chart.tsx +23 -7
- package/src/charts/conversion-funnel-chart/test/conversion-funnel-chart.test.tsx +22 -0
- package/src/charts/conversion-funnel-chart/types.ts +1 -1
- package/src/charts/geo-chart/geo-chart.tsx +17 -2
- package/src/charts/geo-chart/test/geo-chart.test.tsx +9 -4
- package/src/charts/geo-chart/types.ts +1 -1
- package/src/charts/heatmap-chart/test/heatmap-chart.test.tsx +0 -6
- package/src/charts/heatmap-chart/types.ts +0 -2
- package/src/charts/leaderboard-chart/hooks/use-fitted-row-count.ts +2 -2
- package/src/charts/leaderboard-chart/leaderboard-chart.module.scss +6 -0
- package/src/charts/leaderboard-chart/leaderboard-chart.tsx +34 -19
- package/src/charts/leaderboard-chart/test/leaderboard-chart.test.tsx +27 -1
- package/src/charts/leaderboard-chart/types.ts +1 -0
- package/src/charts/line-chart/line-chart.tsx +3 -0
- package/src/charts/line-chart/test/line-chart.test.tsx +0 -8
- package/src/charts/line-chart/types.ts +0 -2
- package/src/charts/pie-chart/pie-chart.module.scss +3 -0
- package/src/charts/pie-chart/pie-chart.tsx +0 -5
- package/src/charts/pie-chart/test/pie-chart.test.tsx +4 -8
- package/src/charts/pie-semi-circle-chart/pie-semi-circle-chart.module.scss +3 -0
- package/src/charts/pie-semi-circle-chart/pie-semi-circle-chart.tsx +0 -5
- package/src/charts/private/pie-keyboard-navigation/pie-tooltip.tsx +8 -3
- package/src/charts/test/accessible-name.test.tsx +181 -0
- package/src/components/legend/hooks/test/use-chart-legend-items.test.tsx +63 -3
- package/src/components/legend/hooks/use-chart-legend-items.ts +63 -1
- package/src/components/legend/private/base-legend.tsx +27 -15
- package/src/components/legend/test/legend.test.tsx +42 -0
- package/src/components/legend/types.ts +2 -0
- package/src/hooks/test/use-xychart-theme.test.tsx +22 -0
- package/src/hooks/use-xychart-theme.ts +33 -2
- package/src/index.ts +1 -0
- package/src/types.ts +19 -1
- package/src/utils/resolve-font-size.ts +9 -10
- package/src/utils/test/resolve-font-size.test.ts +11 -2
package/dist/index.css
CHANGED
|
@@ -770,6 +770,12 @@
|
|
|
770
770
|
inset: 0;
|
|
771
771
|
}
|
|
772
772
|
|
|
773
|
+
.a8ccharts-GovfoW-rowItem {
|
|
774
|
+
grid-column: 1 / -1;
|
|
775
|
+
grid-template-columns: subgrid;
|
|
776
|
+
display: grid;
|
|
777
|
+
}
|
|
778
|
+
|
|
773
779
|
.a8ccharts-GovfoW-row {
|
|
774
780
|
grid-column: 1 / -1;
|
|
775
781
|
grid-template-columns: subgrid;
|
|
@@ -890,6 +896,10 @@
|
|
|
890
896
|
stroke: var(--wpds-color-stroke-focus, var(--wp-admin-theme-color, #3858e9));
|
|
891
897
|
stroke-width: calc(2 * var(--wpds-border-width-focus, var(--wp-admin-border-width-focus, 2px)));
|
|
892
898
|
}
|
|
899
|
+
.a8ccharts-gnszbG-pie-chart {
|
|
900
|
+
isolation: isolate;
|
|
901
|
+
}
|
|
902
|
+
|
|
893
903
|
.a8ccharts-gnszbG-pie-chart__plot {
|
|
894
904
|
position: relative;
|
|
895
905
|
}
|
|
@@ -918,6 +928,10 @@
|
|
|
918
928
|
.a8ccharts-gnszbG-pie-chart__label-text--white {
|
|
919
929
|
fill: #fff;
|
|
920
930
|
}
|
|
931
|
+
.a8ccharts-YtTOxW-pie-semi-circle-chart {
|
|
932
|
+
isolation: isolate;
|
|
933
|
+
}
|
|
934
|
+
|
|
921
935
|
.a8ccharts-YtTOxW-pie-semi-circle-chart__plot {
|
|
922
936
|
position: relative;
|
|
923
937
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -328,9 +328,15 @@ type ChartTheme = {
|
|
|
328
328
|
*
|
|
329
329
|
* `fontFamily: 'inherit'` is load-bearing here — it overrides the font stack
|
|
330
330
|
* `buildChartTheme` injects inline on SVG `<text>`.
|
|
331
|
+
*
|
|
332
|
+
* Give `fontSize` in pixels (`12` or `'12px'`). Margins and pie labels cannot measure `rem`, `em`, `%` or `var()`, so they use the default size and labels can clip (CHARTS-303). An invalid size is dropped.
|
|
331
333
|
*/
|
|
332
334
|
svgLabelSmall?: Omit<TextProps, 'fill'>;
|
|
333
|
-
/**
|
|
335
|
+
/**
|
|
336
|
+
* Styles for large SVG text (eg. axis titles), passed through to the XYChart theme.
|
|
337
|
+
*
|
|
338
|
+
* Give `fontSize` in pixels, as for `svgLabelSmall`.
|
|
339
|
+
*/
|
|
334
340
|
svgLabelBig?: TextProps;
|
|
335
341
|
annotationStyles?: ThemeAnnotationStyles;
|
|
336
342
|
/** LeaderboardChart specific settings */
|
|
@@ -574,6 +580,8 @@ type ChartLegendConfig<T = DataPoint | DataPointDate | LeaderboardEntry> = {
|
|
|
574
580
|
*/
|
|
575
581
|
shapeStyles?: LegendShapeStyles;
|
|
576
582
|
};
|
|
583
|
+
/** Names a comparison series' legend item after the label of the series it is compared with. */
|
|
584
|
+
type ComparisonItemLabel = (seriesLabel: string) => string;
|
|
577
585
|
/**
|
|
578
586
|
* Legend config for charts built from `SeriesData` (line, bar, area). Adds `collapseGroups` on top
|
|
579
587
|
* of the shared config. It is intentionally absent from the base `ChartLegendConfig` so point-based
|
|
@@ -594,6 +602,11 @@ type SeriesChartLegendConfig = ChartLegendConfig<SeriesData[]> & {
|
|
|
594
602
|
* Pass a string to replace the default label.
|
|
595
603
|
*/
|
|
596
604
|
comparisonItem?: boolean | string;
|
|
605
|
+
/**
|
|
606
|
+
* Append one static item per comparison series instead, named by calling this with the label
|
|
607
|
+
* of the series it is compared with, and left out while that series is hidden.
|
|
608
|
+
*/
|
|
609
|
+
comparisonSeriesItems?: ComparisonItemLabel;
|
|
597
610
|
};
|
|
598
611
|
/**
|
|
599
612
|
* Initial visibility options for charts built from labelled series.
|
|
@@ -622,6 +635,10 @@ type BaseChartProps<T = DataPoint | DataPointDate | LeaderboardEntry> = {
|
|
|
622
635
|
* Additional CSS class name for the chart container
|
|
623
636
|
*/
|
|
624
637
|
className?: string;
|
|
638
|
+
/**
|
|
639
|
+
* Accessible name of the chart. Name it after what it shows, and give each chart on a page a different name. Each chart type has a localized default, such as "Line chart".
|
|
640
|
+
*/
|
|
641
|
+
ariaLabel?: string;
|
|
625
642
|
/**
|
|
626
643
|
* Width of the chart container in pixels. When omitted, the chart fills its parent's width.
|
|
627
644
|
*/
|
|
@@ -761,6 +778,8 @@ type BaseLegendItem = {
|
|
|
761
778
|
seriesLabels?: string[];
|
|
762
779
|
/** Set to false for a static item that cannot be toggled or dimmed. */
|
|
763
780
|
interactive?: boolean;
|
|
781
|
+
/** Label of the series this static item describes; the item is left out while it is hidden. */
|
|
782
|
+
describesSeries?: string;
|
|
764
783
|
};
|
|
765
784
|
//#endregion
|
|
766
785
|
//#region src/components/legend/legend.d.ts
|
|
@@ -788,7 +807,9 @@ interface ChartLegendOptions {
|
|
|
788
807
|
* `options.type === 'comparison'`. Skipped when that series already has its own
|
|
789
808
|
* item. Pass a string to replace the default label.
|
|
790
809
|
*/
|
|
791
|
-
comparisonItem?:
|
|
810
|
+
comparisonItem?: SeriesChartLegendConfig['comparisonItem'];
|
|
811
|
+
/** One static item per comparison series instead; see `SeriesChartLegendConfig`. */
|
|
812
|
+
comparisonSeriesItems?: SeriesChartLegendConfig['comparisonSeriesItems'];
|
|
792
813
|
}
|
|
793
814
|
/**
|
|
794
815
|
* Hook to transform chart data into legend items
|
|
@@ -908,8 +929,6 @@ type RenderLineGlyphProps<Datum extends object> = GlyphProps<Datum> & {
|
|
|
908
929
|
position?: 'start' | 'end';
|
|
909
930
|
};
|
|
910
931
|
interface LineChartProps extends BaseChartProps<SeriesData[]>, SeriesVisibilityProps {
|
|
911
|
-
/** Accessible name of the chart. Defaults to a localized "Line chart". */
|
|
912
|
-
ariaLabel?: string;
|
|
913
932
|
/**
|
|
914
933
|
* Legend configuration. Supports `collapseGroups` on top of the shared options.
|
|
915
934
|
*/
|
|
@@ -965,8 +984,6 @@ type TooltipDatum = {
|
|
|
965
984
|
//#endregion
|
|
966
985
|
//#region src/charts/area-chart/types.d.ts
|
|
967
986
|
interface AreaChartProps extends BaseChartProps<SeriesData[]>, SeriesVisibilityProps {
|
|
968
|
-
/** Accessible name of the chart. Defaults to a localized "Area chart". */
|
|
969
|
-
ariaLabel?: string;
|
|
970
987
|
/**
|
|
971
988
|
* Legend configuration. Supports `collapseGroups` on top of the shared options.
|
|
972
989
|
*/
|
|
@@ -1076,8 +1093,6 @@ type BandHighlightSelection = {
|
|
|
1076
1093
|
height: number;
|
|
1077
1094
|
};
|
|
1078
1095
|
interface BarChartProps extends BaseChartProps<SeriesData[]>, SeriesVisibilityProps {
|
|
1079
|
-
/** Accessible name of the chart. Defaults to a localized "Bar chart". */
|
|
1080
|
-
ariaLabel?: string;
|
|
1081
1096
|
/**
|
|
1082
1097
|
* Legend configuration. Supports `collapseGroups` on top of the shared options.
|
|
1083
1098
|
*/
|
|
@@ -1234,7 +1249,7 @@ interface TooltipRenderProps {
|
|
|
1234
1249
|
/**
|
|
1235
1250
|
* Props for the ConversionFunnelChart component
|
|
1236
1251
|
*/
|
|
1237
|
-
interface ConversionFunnelChartProps extends Pick<BaseChartProps, 'className' | 'chartId' | 'animation'> {
|
|
1252
|
+
interface ConversionFunnelChartProps extends Pick<BaseChartProps, 'className' | 'chartId' | 'animation' | 'ariaLabel'> {
|
|
1238
1253
|
/** Main conversion rate to highlight */
|
|
1239
1254
|
mainRate: number;
|
|
1240
1255
|
/** Change indicator (e.g., +2%, -1.5%) */
|
|
@@ -1294,7 +1309,7 @@ interface GeoChartError {
|
|
|
1294
1309
|
detailedMessage?: string;
|
|
1295
1310
|
options?: Record<string, unknown>;
|
|
1296
1311
|
}
|
|
1297
|
-
interface GeoChartProps extends Pick<BaseChartProps, 'className' | 'chartId' | 'width' | 'height'> {
|
|
1312
|
+
interface GeoChartProps extends Pick<BaseChartProps, 'className' | 'chartId' | 'ariaLabel' | 'width' | 'height'> {
|
|
1298
1313
|
/**
|
|
1299
1314
|
* Data in Google Charts native format for maximum flexibility.
|
|
1300
1315
|
* First row contains column headers, subsequent rows contain data.
|
|
@@ -1413,8 +1428,6 @@ interface HeatmapChartProps extends Omit<BaseChartProps<HeatmapColumn[]>, 'showL
|
|
|
1413
1428
|
* group past the edge, Page Up/Down by one group. Default `grid`.
|
|
1414
1429
|
*/
|
|
1415
1430
|
keyboardNavigation?: 'grid' | 'calendar';
|
|
1416
|
-
/** Accessible name of the grid. Defaults to a localized "Heatmap chart". */
|
|
1417
|
-
ariaLabel?: string;
|
|
1418
1431
|
/** Compact mode: hide in-cell values, tighten gap, thin axis labels. Default false. */
|
|
1419
1432
|
compact?: boolean;
|
|
1420
1433
|
/** Compact mode only: grow the cells to fill the chart's box, wrapping the column groups onto more rows when that makes them larger. Default false. */
|
|
@@ -1571,7 +1584,7 @@ declare const useCalendarHeatmapData: (series: DataPointDate[], options?: Calend
|
|
|
1571
1584
|
declare const useMonthCalendarHeatmapData: (valueByDay: Record<string, number | null>, range: MonthCalendarHeatmapRange, options?: MonthCalendarHeatmapOptions) => MonthCalendarHeatmapResult;
|
|
1572
1585
|
//#endregion
|
|
1573
1586
|
//#region src/charts/leaderboard-chart/types.d.ts
|
|
1574
|
-
interface LeaderboardChartProps extends Pick<BaseChartProps<LeaderboardEntry>, 'className' | 'showLegend' | 'legend' | 'chartId' | 'width' | 'height' | 'size' | 'gap' | 'animation'> {
|
|
1587
|
+
interface LeaderboardChartProps extends Pick<BaseChartProps<LeaderboardEntry>, 'className' | 'showLegend' | 'legend' | 'chartId' | 'width' | 'height' | 'size' | 'gap' | 'animation' | 'ariaLabel'> {
|
|
1575
1588
|
/**
|
|
1576
1589
|
* Entries to display. Declared here rather than picked, since the base type
|
|
1577
1590
|
* would split the entry union into one array type per member.
|
|
@@ -1962,10 +1975,6 @@ interface PieChartProps extends BaseChartProps<DataPointPercentage[]> {
|
|
|
1962
1975
|
* When provided, replaces the default `label: value` tooltip with custom content.
|
|
1963
1976
|
*/
|
|
1964
1977
|
renderTooltip?: (params: PieChartRenderTooltipParams) => ReactNode;
|
|
1965
|
-
/**
|
|
1966
|
-
* Accessible name of the chart. Defaults to a localized "Pie chart".
|
|
1967
|
-
*/
|
|
1968
|
-
ariaLabel?: string;
|
|
1969
1978
|
}
|
|
1970
1979
|
type PieChartBaseProps = Optional<PieChartProps, 'size'>;
|
|
1971
1980
|
type PieChartComponent = ChartComponentWithComposition<PieChartBaseProps>;
|
|
@@ -2032,10 +2041,6 @@ interface PieSemiCircleChartProps extends BaseChartProps<DataPointPercentage[]>
|
|
|
2032
2041
|
* When provided, replaces the default `label: value` tooltip with custom content.
|
|
2033
2042
|
*/
|
|
2034
2043
|
renderTooltip?: (params: PieSemiCircleChartRenderTooltipParams) => ReactNode;
|
|
2035
|
-
/**
|
|
2036
|
-
* Accessible name of the chart. Defaults to a localized "Semi-circle chart".
|
|
2037
|
-
*/
|
|
2038
|
-
ariaLabel?: string;
|
|
2039
2044
|
}
|
|
2040
2045
|
type PieSemiCircleChartBaseProps = Optional<PieSemiCircleChartProps, 'width'>;
|
|
2041
2046
|
type PieSemiCircleChartComponent = ChartComponentWithComposition<PieSemiCircleChartBaseProps>;
|
|
@@ -2415,5 +2420,5 @@ declare const defaultTheme: CompleteChartTheme;
|
|
|
2415
2420
|
*/
|
|
2416
2421
|
declare const useChartScopeElement: () => HTMLElement | null;
|
|
2417
2422
|
//#endregion
|
|
2418
|
-
export { AccessibleTooltip, type AnnotationStyles, type ArcData, AreaChartResponsive as AreaChart, type AreaChartProps, AreaChart as AreaChartUnresponsive, type AxisOptions, type BandHighlightSelection, 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 GeoDisplayMode, 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 HeatmapColumnGroup, 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 MonthCalendarHeatmapOptions, type MonthCalendarHeatmapRange, type MonthCalendarHeatmapResult, 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, TooltipBox, type TooltipBoxProps, type TooltipData, type TooltipDatum, type TooltipPlacement, type TooltipProps, type TooltipRenderProps, type TrendDirection, TrendIndicator, type TrendIndicatorProps, XYChartTooltip, type XyChartTooltipProps, buildCalendarHeatmapData, buildMonthCalendarHeatmapData, defaultTheme, formatMetricValue, formatPercentage, getBucketInfo, getColorDistance, hexToRgba, isValidHexColor, lightenHexColor, mergeThemes, mixHexColors, normalizeColorToHex, parseAsLocalDate, parseHslString, prefersLightText, relativeLuminance, resolveCssVariable, useCalendarHeatmapData, useChartFormatting, useChartLegendItems, useChartRegistration, useChartScopeElement, useGlobalChartsContext, useGlobalChartsTheme, useLeaderboardLegendItems, useMonthCalendarHeatmapData, validateHexColor };
|
|
2423
|
+
export { AccessibleTooltip, type AnnotationStyles, type ArcData, AreaChartResponsive as AreaChart, type AreaChartProps, AreaChart as AreaChartUnresponsive, type AxisOptions, type BandHighlightSelection, 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 ComparisonItemLabel, 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 GeoDisplayMode, 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 HeatmapColumnGroup, 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 MonthCalendarHeatmapOptions, type MonthCalendarHeatmapRange, type MonthCalendarHeatmapResult, 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, TooltipBox, type TooltipBoxProps, type TooltipData, type TooltipDatum, type TooltipPlacement, type TooltipProps, type TooltipRenderProps, type TrendDirection, TrendIndicator, type TrendIndicatorProps, XYChartTooltip, type XyChartTooltipProps, buildCalendarHeatmapData, buildMonthCalendarHeatmapData, defaultTheme, formatMetricValue, formatPercentage, getBucketInfo, getColorDistance, hexToRgba, isValidHexColor, lightenHexColor, mergeThemes, mixHexColors, normalizeColorToHex, parseAsLocalDate, parseHslString, prefersLightText, relativeLuminance, resolveCssVariable, useCalendarHeatmapData, useChartFormatting, useChartLegendItems, useChartRegistration, useChartScopeElement, useGlobalChartsContext, useGlobalChartsTheme, useLeaderboardLegendItems, useMonthCalendarHeatmapData, validateHexColor };
|
|
2419
2424
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -328,9 +328,15 @@ type ChartTheme = {
|
|
|
328
328
|
*
|
|
329
329
|
* `fontFamily: 'inherit'` is load-bearing here — it overrides the font stack
|
|
330
330
|
* `buildChartTheme` injects inline on SVG `<text>`.
|
|
331
|
+
*
|
|
332
|
+
* Give `fontSize` in pixels (`12` or `'12px'`). Margins and pie labels cannot measure `rem`, `em`, `%` or `var()`, so they use the default size and labels can clip (CHARTS-303). An invalid size is dropped.
|
|
331
333
|
*/
|
|
332
334
|
svgLabelSmall?: Omit<TextProps, 'fill'>;
|
|
333
|
-
/**
|
|
335
|
+
/**
|
|
336
|
+
* Styles for large SVG text (eg. axis titles), passed through to the XYChart theme.
|
|
337
|
+
*
|
|
338
|
+
* Give `fontSize` in pixels, as for `svgLabelSmall`.
|
|
339
|
+
*/
|
|
334
340
|
svgLabelBig?: TextProps;
|
|
335
341
|
annotationStyles?: ThemeAnnotationStyles;
|
|
336
342
|
/** LeaderboardChart specific settings */
|
|
@@ -574,6 +580,8 @@ type ChartLegendConfig<T = DataPoint | DataPointDate | LeaderboardEntry> = {
|
|
|
574
580
|
*/
|
|
575
581
|
shapeStyles?: LegendShapeStyles;
|
|
576
582
|
};
|
|
583
|
+
/** Names a comparison series' legend item after the label of the series it is compared with. */
|
|
584
|
+
type ComparisonItemLabel = (seriesLabel: string) => string;
|
|
577
585
|
/**
|
|
578
586
|
* Legend config for charts built from `SeriesData` (line, bar, area). Adds `collapseGroups` on top
|
|
579
587
|
* of the shared config. It is intentionally absent from the base `ChartLegendConfig` so point-based
|
|
@@ -594,6 +602,11 @@ type SeriesChartLegendConfig = ChartLegendConfig<SeriesData[]> & {
|
|
|
594
602
|
* Pass a string to replace the default label.
|
|
595
603
|
*/
|
|
596
604
|
comparisonItem?: boolean | string;
|
|
605
|
+
/**
|
|
606
|
+
* Append one static item per comparison series instead, named by calling this with the label
|
|
607
|
+
* of the series it is compared with, and left out while that series is hidden.
|
|
608
|
+
*/
|
|
609
|
+
comparisonSeriesItems?: ComparisonItemLabel;
|
|
597
610
|
};
|
|
598
611
|
/**
|
|
599
612
|
* Initial visibility options for charts built from labelled series.
|
|
@@ -622,6 +635,10 @@ type BaseChartProps<T = DataPoint | DataPointDate | LeaderboardEntry> = {
|
|
|
622
635
|
* Additional CSS class name for the chart container
|
|
623
636
|
*/
|
|
624
637
|
className?: string;
|
|
638
|
+
/**
|
|
639
|
+
* Accessible name of the chart. Name it after what it shows, and give each chart on a page a different name. Each chart type has a localized default, such as "Line chart".
|
|
640
|
+
*/
|
|
641
|
+
ariaLabel?: string;
|
|
625
642
|
/**
|
|
626
643
|
* Width of the chart container in pixels. When omitted, the chart fills its parent's width.
|
|
627
644
|
*/
|
|
@@ -761,6 +778,8 @@ type BaseLegendItem = {
|
|
|
761
778
|
seriesLabels?: string[];
|
|
762
779
|
/** Set to false for a static item that cannot be toggled or dimmed. */
|
|
763
780
|
interactive?: boolean;
|
|
781
|
+
/** Label of the series this static item describes; the item is left out while it is hidden. */
|
|
782
|
+
describesSeries?: string;
|
|
764
783
|
};
|
|
765
784
|
//#endregion
|
|
766
785
|
//#region src/components/legend/legend.d.ts
|
|
@@ -788,7 +807,9 @@ interface ChartLegendOptions {
|
|
|
788
807
|
* `options.type === 'comparison'`. Skipped when that series already has its own
|
|
789
808
|
* item. Pass a string to replace the default label.
|
|
790
809
|
*/
|
|
791
|
-
comparisonItem?:
|
|
810
|
+
comparisonItem?: SeriesChartLegendConfig['comparisonItem'];
|
|
811
|
+
/** One static item per comparison series instead; see `SeriesChartLegendConfig`. */
|
|
812
|
+
comparisonSeriesItems?: SeriesChartLegendConfig['comparisonSeriesItems'];
|
|
792
813
|
}
|
|
793
814
|
/**
|
|
794
815
|
* Hook to transform chart data into legend items
|
|
@@ -908,8 +929,6 @@ type RenderLineGlyphProps<Datum extends object> = GlyphProps<Datum> & {
|
|
|
908
929
|
position?: 'start' | 'end';
|
|
909
930
|
};
|
|
910
931
|
interface LineChartProps extends BaseChartProps<SeriesData[]>, SeriesVisibilityProps {
|
|
911
|
-
/** Accessible name of the chart. Defaults to a localized "Line chart". */
|
|
912
|
-
ariaLabel?: string;
|
|
913
932
|
/**
|
|
914
933
|
* Legend configuration. Supports `collapseGroups` on top of the shared options.
|
|
915
934
|
*/
|
|
@@ -965,8 +984,6 @@ type TooltipDatum = {
|
|
|
965
984
|
//#endregion
|
|
966
985
|
//#region src/charts/area-chart/types.d.ts
|
|
967
986
|
interface AreaChartProps extends BaseChartProps<SeriesData[]>, SeriesVisibilityProps {
|
|
968
|
-
/** Accessible name of the chart. Defaults to a localized "Area chart". */
|
|
969
|
-
ariaLabel?: string;
|
|
970
987
|
/**
|
|
971
988
|
* Legend configuration. Supports `collapseGroups` on top of the shared options.
|
|
972
989
|
*/
|
|
@@ -1076,8 +1093,6 @@ type BandHighlightSelection = {
|
|
|
1076
1093
|
height: number;
|
|
1077
1094
|
};
|
|
1078
1095
|
interface BarChartProps extends BaseChartProps<SeriesData[]>, SeriesVisibilityProps {
|
|
1079
|
-
/** Accessible name of the chart. Defaults to a localized "Bar chart". */
|
|
1080
|
-
ariaLabel?: string;
|
|
1081
1096
|
/**
|
|
1082
1097
|
* Legend configuration. Supports `collapseGroups` on top of the shared options.
|
|
1083
1098
|
*/
|
|
@@ -1234,7 +1249,7 @@ interface TooltipRenderProps {
|
|
|
1234
1249
|
/**
|
|
1235
1250
|
* Props for the ConversionFunnelChart component
|
|
1236
1251
|
*/
|
|
1237
|
-
interface ConversionFunnelChartProps extends Pick<BaseChartProps, 'className' | 'chartId' | 'animation'> {
|
|
1252
|
+
interface ConversionFunnelChartProps extends Pick<BaseChartProps, 'className' | 'chartId' | 'animation' | 'ariaLabel'> {
|
|
1238
1253
|
/** Main conversion rate to highlight */
|
|
1239
1254
|
mainRate: number;
|
|
1240
1255
|
/** Change indicator (e.g., +2%, -1.5%) */
|
|
@@ -1294,7 +1309,7 @@ interface GeoChartError {
|
|
|
1294
1309
|
detailedMessage?: string;
|
|
1295
1310
|
options?: Record<string, unknown>;
|
|
1296
1311
|
}
|
|
1297
|
-
interface GeoChartProps extends Pick<BaseChartProps, 'className' | 'chartId' | 'width' | 'height'> {
|
|
1312
|
+
interface GeoChartProps extends Pick<BaseChartProps, 'className' | 'chartId' | 'ariaLabel' | 'width' | 'height'> {
|
|
1298
1313
|
/**
|
|
1299
1314
|
* Data in Google Charts native format for maximum flexibility.
|
|
1300
1315
|
* First row contains column headers, subsequent rows contain data.
|
|
@@ -1413,8 +1428,6 @@ interface HeatmapChartProps extends Omit<BaseChartProps<HeatmapColumn[]>, 'showL
|
|
|
1413
1428
|
* group past the edge, Page Up/Down by one group. Default `grid`.
|
|
1414
1429
|
*/
|
|
1415
1430
|
keyboardNavigation?: 'grid' | 'calendar';
|
|
1416
|
-
/** Accessible name of the grid. Defaults to a localized "Heatmap chart". */
|
|
1417
|
-
ariaLabel?: string;
|
|
1418
1431
|
/** Compact mode: hide in-cell values, tighten gap, thin axis labels. Default false. */
|
|
1419
1432
|
compact?: boolean;
|
|
1420
1433
|
/** Compact mode only: grow the cells to fill the chart's box, wrapping the column groups onto more rows when that makes them larger. Default false. */
|
|
@@ -1571,7 +1584,7 @@ declare const useCalendarHeatmapData: (series: DataPointDate[], options?: Calend
|
|
|
1571
1584
|
declare const useMonthCalendarHeatmapData: (valueByDay: Record<string, number | null>, range: MonthCalendarHeatmapRange, options?: MonthCalendarHeatmapOptions) => MonthCalendarHeatmapResult;
|
|
1572
1585
|
//#endregion
|
|
1573
1586
|
//#region src/charts/leaderboard-chart/types.d.ts
|
|
1574
|
-
interface LeaderboardChartProps extends Pick<BaseChartProps<LeaderboardEntry>, 'className' | 'showLegend' | 'legend' | 'chartId' | 'width' | 'height' | 'size' | 'gap' | 'animation'> {
|
|
1587
|
+
interface LeaderboardChartProps extends Pick<BaseChartProps<LeaderboardEntry>, 'className' | 'showLegend' | 'legend' | 'chartId' | 'width' | 'height' | 'size' | 'gap' | 'animation' | 'ariaLabel'> {
|
|
1575
1588
|
/**
|
|
1576
1589
|
* Entries to display. Declared here rather than picked, since the base type
|
|
1577
1590
|
* would split the entry union into one array type per member.
|
|
@@ -1962,10 +1975,6 @@ interface PieChartProps extends BaseChartProps<DataPointPercentage[]> {
|
|
|
1962
1975
|
* When provided, replaces the default `label: value` tooltip with custom content.
|
|
1963
1976
|
*/
|
|
1964
1977
|
renderTooltip?: (params: PieChartRenderTooltipParams) => ReactNode;
|
|
1965
|
-
/**
|
|
1966
|
-
* Accessible name of the chart. Defaults to a localized "Pie chart".
|
|
1967
|
-
*/
|
|
1968
|
-
ariaLabel?: string;
|
|
1969
1978
|
}
|
|
1970
1979
|
type PieChartBaseProps = Optional<PieChartProps, 'size'>;
|
|
1971
1980
|
type PieChartComponent = ChartComponentWithComposition<PieChartBaseProps>;
|
|
@@ -2032,10 +2041,6 @@ interface PieSemiCircleChartProps extends BaseChartProps<DataPointPercentage[]>
|
|
|
2032
2041
|
* When provided, replaces the default `label: value` tooltip with custom content.
|
|
2033
2042
|
*/
|
|
2034
2043
|
renderTooltip?: (params: PieSemiCircleChartRenderTooltipParams) => ReactNode;
|
|
2035
|
-
/**
|
|
2036
|
-
* Accessible name of the chart. Defaults to a localized "Semi-circle chart".
|
|
2037
|
-
*/
|
|
2038
|
-
ariaLabel?: string;
|
|
2039
2044
|
}
|
|
2040
2045
|
type PieSemiCircleChartBaseProps = Optional<PieSemiCircleChartProps, 'width'>;
|
|
2041
2046
|
type PieSemiCircleChartComponent = ChartComponentWithComposition<PieSemiCircleChartBaseProps>;
|
|
@@ -2415,5 +2420,5 @@ declare const defaultTheme: CompleteChartTheme;
|
|
|
2415
2420
|
*/
|
|
2416
2421
|
declare const useChartScopeElement: () => HTMLElement | null;
|
|
2417
2422
|
//#endregion
|
|
2418
|
-
export { AccessibleTooltip, type AnnotationStyles, type ArcData, AreaChartResponsive as AreaChart, type AreaChartProps, AreaChart as AreaChartUnresponsive, type AxisOptions, type BandHighlightSelection, 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 GeoDisplayMode, 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 HeatmapColumnGroup, 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 MonthCalendarHeatmapOptions, type MonthCalendarHeatmapRange, type MonthCalendarHeatmapResult, 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, TooltipBox, type TooltipBoxProps, type TooltipData, type TooltipDatum, type TooltipPlacement, type TooltipProps, type TooltipRenderProps, type TrendDirection, TrendIndicator, type TrendIndicatorProps, XYChartTooltip, type XyChartTooltipProps, buildCalendarHeatmapData, buildMonthCalendarHeatmapData, defaultTheme, formatMetricValue, formatPercentage, getBucketInfo, getColorDistance, hexToRgba, isValidHexColor, lightenHexColor, mergeThemes, mixHexColors, normalizeColorToHex, parseAsLocalDate, parseHslString, prefersLightText, relativeLuminance, resolveCssVariable, useCalendarHeatmapData, useChartFormatting, useChartLegendItems, useChartRegistration, useChartScopeElement, useGlobalChartsContext, useGlobalChartsTheme, useLeaderboardLegendItems, useMonthCalendarHeatmapData, validateHexColor };
|
|
2423
|
+
export { AccessibleTooltip, type AnnotationStyles, type ArcData, AreaChartResponsive as AreaChart, type AreaChartProps, AreaChart as AreaChartUnresponsive, type AxisOptions, type BandHighlightSelection, 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 ComparisonItemLabel, 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 GeoDisplayMode, 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 HeatmapColumnGroup, 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 MonthCalendarHeatmapOptions, type MonthCalendarHeatmapRange, type MonthCalendarHeatmapResult, 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, TooltipBox, type TooltipBoxProps, type TooltipData, type TooltipDatum, type TooltipPlacement, type TooltipProps, type TooltipRenderProps, type TrendDirection, TrendIndicator, type TrendIndicatorProps, XYChartTooltip, type XyChartTooltipProps, buildCalendarHeatmapData, buildMonthCalendarHeatmapData, defaultTheme, formatMetricValue, formatPercentage, getBucketInfo, getColorDistance, hexToRgba, isValidHexColor, lightenHexColor, mergeThemes, mixHexColors, normalizeColorToHex, parseAsLocalDate, parseHslString, prefersLightText, relativeLuminance, resolveCssVariable, useCalendarHeatmapData, useChartFormatting, useChartLegendItems, useChartRegistration, useChartScopeElement, useGlobalChartsContext, useGlobalChartsTheme, useLeaderboardLegendItems, useMonthCalendarHeatmapData, validateHexColor };
|
|
2419
2424
|
//# sourceMappingURL=index.d.ts.map
|