@automattic/charts 0.58.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/README.md +7 -54
- package/dist/index.cjs +9606 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +20 -25
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +1612 -33
- package/dist/index.d.ts +1612 -33
- package/dist/index.js +9640 -56
- package/dist/index.js.map +1 -1
- package/package.json +8 -125
- package/src/charts/bar-chart/bar-chart.module.scss +0 -5
- package/src/charts/bar-chart/bar-chart.tsx +131 -137
- package/src/charts/leaderboard-chart/leaderboard-chart.tsx +23 -40
- package/src/charts/line-chart/line-chart.module.scss +0 -5
- package/src/charts/line-chart/line-chart.tsx +190 -183
- package/src/charts/line-chart/private/line-chart-annotations-overlay.tsx +1 -2
- package/src/charts/pie-chart/pie-chart.module.scss +2 -10
- package/src/charts/pie-chart/pie-chart.tsx +198 -199
- package/src/charts/pie-chart/test/composition-api.test.tsx +3 -3
- package/src/charts/pie-chart/test/pie-chart.test.tsx +42 -35
- package/src/charts/pie-semi-circle-chart/pie-semi-circle-chart.module.scss +2 -8
- package/src/charts/pie-semi-circle-chart/pie-semi-circle-chart.tsx +155 -155
- package/src/charts/pie-semi-circle-chart/test/pie-semi-circle-chart.test.tsx +25 -25
- package/src/charts/private/chart-layout/chart-layout.module.scss +7 -0
- package/src/charts/private/chart-layout/chart-layout.tsx +106 -0
- package/src/charts/private/chart-layout/index.ts +2 -0
- package/src/charts/private/chart-layout/test/chart-layout.test.tsx +167 -0
- package/src/charts/private/single-chart-context/single-chart-context.tsx +2 -2
- package/src/charts/private/svg-empty-state/index.ts +1 -0
- package/src/charts/private/svg-empty-state/svg-empty-state.module.scss +7 -0
- package/src/charts/private/svg-empty-state/svg-empty-state.tsx +40 -0
- package/src/components/legend/hooks/test/use-chart-legend-items.test.tsx +12 -8
- package/src/components/legend/hooks/use-chart-legend-items.ts +12 -13
- package/src/components/legend/legend.tsx +33 -8
- package/src/components/legend/test/legend.test.tsx +93 -1
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-data-with-percentages.ts +24 -0
- package/src/hooks/use-interactive-legend-data.ts +18 -15
- package/src/index.ts +65 -2
- package/src/providers/chart-context/global-charts-provider.tsx +7 -1
- package/src/providers/chart-context/hooks/use-chart-registration.ts +2 -1
- package/src/providers/chart-context/types.ts +2 -2
- package/src/types.ts +27 -7
- package/src/utils/test/resolve-css-var.test.ts +2 -0
- package/dist/base-tooltip-DOq93wjU.d.cts +0 -38
- package/dist/base-tooltip-DOq93wjU.d.ts +0 -38
- package/dist/charts/bar-chart/index.cjs +0 -17
- package/dist/charts/bar-chart/index.cjs.map +0 -1
- package/dist/charts/bar-chart/index.css +0 -141
- package/dist/charts/bar-chart/index.css.map +0 -1
- package/dist/charts/bar-chart/index.d.cts +0 -36
- package/dist/charts/bar-chart/index.d.ts +0 -36
- package/dist/charts/bar-chart/index.js +0 -17
- package/dist/charts/bar-chart/index.js.map +0 -1
- package/dist/charts/bar-list-chart/index.cjs +0 -18
- package/dist/charts/bar-list-chart/index.cjs.map +0 -1
- package/dist/charts/bar-list-chart/index.css +0 -141
- package/dist/charts/bar-list-chart/index.css.map +0 -1
- package/dist/charts/bar-list-chart/index.d.cts +0 -92
- package/dist/charts/bar-list-chart/index.d.ts +0 -92
- package/dist/charts/bar-list-chart/index.js +0 -18
- package/dist/charts/bar-list-chart/index.js.map +0 -1
- package/dist/charts/conversion-funnel-chart/index.cjs +0 -11
- package/dist/charts/conversion-funnel-chart/index.cjs.map +0 -1
- package/dist/charts/conversion-funnel-chart/index.css +0 -157
- package/dist/charts/conversion-funnel-chart/index.css.map +0 -1
- package/dist/charts/conversion-funnel-chart/index.d.cts +0 -97
- package/dist/charts/conversion-funnel-chart/index.d.ts +0 -97
- package/dist/charts/conversion-funnel-chart/index.js +0 -11
- package/dist/charts/conversion-funnel-chart/index.js.map +0 -1
- package/dist/charts/geo-chart/index.cjs +0 -13
- package/dist/charts/geo-chart/index.cjs.map +0 -1
- package/dist/charts/geo-chart/index.css +0 -23
- package/dist/charts/geo-chart/index.css.map +0 -1
- package/dist/charts/geo-chart/index.d.cts +0 -67
- package/dist/charts/geo-chart/index.d.ts +0 -67
- package/dist/charts/geo-chart/index.js +0 -13
- package/dist/charts/geo-chart/index.js.map +0 -1
- package/dist/charts/leaderboard-chart/index.cjs +0 -21
- package/dist/charts/leaderboard-chart/index.cjs.map +0 -1
- package/dist/charts/leaderboard-chart/index.css +0 -160
- package/dist/charts/leaderboard-chart/index.css.map +0 -1
- package/dist/charts/leaderboard-chart/index.d.cts +0 -46
- package/dist/charts/leaderboard-chart/index.d.ts +0 -46
- package/dist/charts/leaderboard-chart/index.js +0 -21
- package/dist/charts/leaderboard-chart/index.js.map +0 -1
- package/dist/charts/line-chart/index.cjs +0 -17
- package/dist/charts/line-chart/index.cjs.map +0 -1
- package/dist/charts/line-chart/index.css +0 -213
- package/dist/charts/line-chart/index.css.map +0 -1
- package/dist/charts/line-chart/index.d.cts +0 -98
- package/dist/charts/line-chart/index.d.ts +0 -98
- package/dist/charts/line-chart/index.js +0 -17
- package/dist/charts/line-chart/index.js.map +0 -1
- package/dist/charts/pie-chart/index.cjs +0 -19
- package/dist/charts/pie-chart/index.cjs.map +0 -1
- package/dist/charts/pie-chart/index.css +0 -131
- package/dist/charts/pie-chart/index.css.map +0 -1
- package/dist/charts/pie-chart/index.d.cts +0 -91
- package/dist/charts/pie-chart/index.d.ts +0 -91
- package/dist/charts/pie-chart/index.js +0 -19
- package/dist/charts/pie-chart/index.js.map +0 -1
- package/dist/charts/pie-semi-circle-chart/index.cjs +0 -18
- package/dist/charts/pie-semi-circle-chart/index.cjs.map +0 -1
- package/dist/charts/pie-semi-circle-chart/index.css +0 -132
- package/dist/charts/pie-semi-circle-chart/index.css.map +0 -1
- package/dist/charts/pie-semi-circle-chart/index.d.cts +0 -88
- package/dist/charts/pie-semi-circle-chart/index.d.ts +0 -88
- package/dist/charts/pie-semi-circle-chart/index.js +0 -18
- package/dist/charts/pie-semi-circle-chart/index.js.map +0 -1
- package/dist/charts/sparkline/index.cjs +0 -18
- package/dist/charts/sparkline/index.cjs.map +0 -1
- package/dist/charts/sparkline/index.css +0 -230
- package/dist/charts/sparkline/index.css.map +0 -1
- package/dist/charts/sparkline/index.d.cts +0 -113
- package/dist/charts/sparkline/index.d.ts +0 -113
- package/dist/charts/sparkline/index.js +0 -18
- package/dist/charts/sparkline/index.js.map +0 -1
- package/dist/chunk-2A34OA5O.cjs +0 -51
- package/dist/chunk-2A34OA5O.cjs.map +0 -1
- package/dist/chunk-2I67QUIV.js +0 -895
- package/dist/chunk-2I67QUIV.js.map +0 -1
- package/dist/chunk-2ICEEQOC.js +0 -1071
- package/dist/chunk-2ICEEQOC.js.map +0 -1
- package/dist/chunk-4B7BL2DD.js +0 -120
- package/dist/chunk-4B7BL2DD.js.map +0 -1
- package/dist/chunk-4OXMTKAL.js +0 -401
- package/dist/chunk-4OXMTKAL.js.map +0 -1
- package/dist/chunk-ASLARV7L.cjs +0 -81
- package/dist/chunk-ASLARV7L.cjs.map +0 -1
- package/dist/chunk-B6NLZFRW.js +0 -617
- package/dist/chunk-B6NLZFRW.js.map +0 -1
- package/dist/chunk-BBAUQOW6.cjs +0 -120
- package/dist/chunk-BBAUQOW6.cjs.map +0 -1
- package/dist/chunk-BPYKWMI7.js +0 -194
- package/dist/chunk-BPYKWMI7.js.map +0 -1
- package/dist/chunk-CMMHCTBX.cjs +0 -373
- package/dist/chunk-CMMHCTBX.cjs.map +0 -1
- package/dist/chunk-CPPXJATQ.cjs +0 -1071
- package/dist/chunk-CPPXJATQ.cjs.map +0 -1
- package/dist/chunk-DKU775VC.js +0 -219
- package/dist/chunk-DKU775VC.js.map +0 -1
- package/dist/chunk-GRA7Y2ZG.cjs +0 -401
- package/dist/chunk-GRA7Y2ZG.cjs.map +0 -1
- package/dist/chunk-I2276W3I.cjs +0 -66
- package/dist/chunk-I2276W3I.cjs.map +0 -1
- package/dist/chunk-JJIMABHT.js +0 -351
- package/dist/chunk-JJIMABHT.js.map +0 -1
- package/dist/chunk-KJHWXOCZ.js +0 -421
- package/dist/chunk-KJHWXOCZ.js.map +0 -1
- package/dist/chunk-KRWGSOJ2.js +0 -91
- package/dist/chunk-KRWGSOJ2.js.map +0 -1
- package/dist/chunk-KXRWNFQJ.js +0 -51
- package/dist/chunk-KXRWNFQJ.js.map +0 -1
- package/dist/chunk-LTFH7SEG.js +0 -373
- package/dist/chunk-LTFH7SEG.js.map +0 -1
- package/dist/chunk-MUNOKLLE.js +0 -165
- package/dist/chunk-MUNOKLLE.js.map +0 -1
- package/dist/chunk-MXGLYWVP.cjs +0 -351
- package/dist/chunk-MXGLYWVP.cjs.map +0 -1
- package/dist/chunk-OP6PHB2U.js +0 -81
- package/dist/chunk-OP6PHB2U.js.map +0 -1
- package/dist/chunk-OYC34VTO.cjs +0 -3957
- package/dist/chunk-OYC34VTO.cjs.map +0 -1
- package/dist/chunk-PQL5I3F6.cjs +0 -421
- package/dist/chunk-PQL5I3F6.cjs.map +0 -1
- package/dist/chunk-REZTQ4PH.cjs +0 -488
- package/dist/chunk-REZTQ4PH.cjs.map +0 -1
- package/dist/chunk-TZRUHQOH.cjs +0 -91
- package/dist/chunk-TZRUHQOH.cjs.map +0 -1
- package/dist/chunk-UTYVIOWZ.js +0 -3957
- package/dist/chunk-UTYVIOWZ.js.map +0 -1
- package/dist/chunk-W2LDIX26.cjs +0 -165
- package/dist/chunk-W2LDIX26.cjs.map +0 -1
- package/dist/chunk-WSG64BVN.cjs +0 -219
- package/dist/chunk-WSG64BVN.cjs.map +0 -1
- package/dist/chunk-WTQYGUNF.js +0 -400
- package/dist/chunk-WTQYGUNF.js.map +0 -1
- package/dist/chunk-WYK7EL5R.cjs +0 -895
- package/dist/chunk-WYK7EL5R.cjs.map +0 -1
- package/dist/chunk-XC4KHJYX.cjs +0 -617
- package/dist/chunk-XC4KHJYX.cjs.map +0 -1
- package/dist/chunk-XVBH5XHE.cjs +0 -400
- package/dist/chunk-XVBH5XHE.cjs.map +0 -1
- package/dist/chunk-XWYZIFZW.js +0 -66
- package/dist/chunk-XWYZIFZW.js.map +0 -1
- package/dist/chunk-Y3NNQMAX.cjs +0 -194
- package/dist/chunk-Y3NNQMAX.cjs.map +0 -1
- package/dist/chunk-YAFQVVDI.js +0 -488
- package/dist/chunk-YAFQVVDI.js.map +0 -1
- package/dist/components/legend/index.cjs +0 -12
- package/dist/components/legend/index.cjs.map +0 -1
- package/dist/components/legend/index.css +0 -91
- package/dist/components/legend/index.css.map +0 -1
- package/dist/components/legend/index.d.cts +0 -37
- package/dist/components/legend/index.d.ts +0 -37
- package/dist/components/legend/index.js +0 -12
- package/dist/components/legend/index.js.map +0 -1
- package/dist/components/tooltip/index.cjs +0 -12
- package/dist/components/tooltip/index.cjs.map +0 -1
- package/dist/components/tooltip/index.css +0 -13
- package/dist/components/tooltip/index.css.map +0 -1
- package/dist/components/tooltip/index.d.cts +0 -71
- package/dist/components/tooltip/index.d.ts +0 -71
- package/dist/components/tooltip/index.js +0 -12
- package/dist/components/tooltip/index.js.map +0 -1
- package/dist/components/trend-indicator/index.cjs +0 -8
- package/dist/components/trend-indicator/index.cjs.map +0 -1
- package/dist/components/trend-indicator/index.css +0 -27
- package/dist/components/trend-indicator/index.css.map +0 -1
- package/dist/components/trend-indicator/index.d.cts +0 -44
- package/dist/components/trend-indicator/index.d.ts +0 -44
- package/dist/components/trend-indicator/index.js +0 -8
- package/dist/components/trend-indicator/index.js.map +0 -1
- package/dist/format-metric-value-MXm5DtQ_.d.cts +0 -24
- package/dist/format-metric-value-MXm5DtQ_.d.ts +0 -24
- package/dist/hooks/index.cjs +0 -29
- package/dist/hooks/index.cjs.map +0 -1
- package/dist/hooks/index.css +0 -9
- package/dist/hooks/index.css.map +0 -1
- package/dist/hooks/index.d.cts +0 -264
- package/dist/hooks/index.d.ts +0 -264
- package/dist/hooks/index.js +0 -29
- package/dist/hooks/index.js.map +0 -1
- package/dist/leaderboard-chart-BSbg0ufV.d.cts +0 -79
- package/dist/leaderboard-chart-odEYxxEC.d.ts +0 -79
- package/dist/legend-DFkosEvC.d.cts +0 -9
- package/dist/legend-DLswHhOk.d.ts +0 -9
- package/dist/providers/index.cjs +0 -21
- package/dist/providers/index.cjs.map +0 -1
- package/dist/providers/index.css +0 -9
- package/dist/providers/index.css.map +0 -1
- package/dist/providers/index.d.cts +0 -28
- package/dist/providers/index.d.ts +0 -28
- package/dist/providers/index.js +0 -21
- package/dist/providers/index.js.map +0 -1
- package/dist/themes-D0qc5JaW.d.cts +0 -67
- package/dist/themes-itO4Ht5g.d.ts +0 -67
- package/dist/types-B5f6XQ7Q.d.cts +0 -19
- package/dist/types-BsHooDbM.d.ts +0 -19
- package/dist/types-BuSrRM4p.d.ts +0 -49
- package/dist/types-ChOUI9-N.d.cts +0 -545
- package/dist/types-ChOUI9-N.d.ts +0 -545
- package/dist/types-Dfw9VOKI.d.cts +0 -49
- package/dist/utils/index.cjs +0 -44
- package/dist/utils/index.cjs.map +0 -1
- package/dist/utils/index.d.cts +0 -226
- package/dist/utils/index.d.ts +0 -226
- package/dist/utils/index.js +0 -44
- package/dist/utils/index.js.map +0 -1
- package/dist/with-responsive-CNfhzAUu.d.cts +0 -18
- package/dist/with-responsive-CNfhzAUu.d.ts +0 -18
|
@@ -1,545 +0,0 @@
|
|
|
1
|
-
import { CircleSubjectProps } from '@visx/annotation/lib/components/CircleSubject';
|
|
2
|
-
import { ConnectorProps } from '@visx/annotation/lib/components/Connector';
|
|
3
|
-
import { LabelProps } from '@visx/annotation/lib/components/Label';
|
|
4
|
-
import { LineSubjectProps } from '@visx/annotation/lib/components/LineSubject';
|
|
5
|
-
import { Orientation, TickFormatter, AxisScale, AxisRendererProps } from '@visx/axis';
|
|
6
|
-
import { LegendShape } from '@visx/legend/lib/types';
|
|
7
|
-
import { ScaleType, ScaleInput } from '@visx/scale';
|
|
8
|
-
import { TextProps } from '@visx/text/lib/Text';
|
|
9
|
-
import { EventHandlerParams, LineStyles, GridStyles, GlyphProps } from '@visx/xychart';
|
|
10
|
-
import { GapSize } from '@wordpress/theme';
|
|
11
|
-
import { PointerEvent, CSSProperties, ReactNode } from 'react';
|
|
12
|
-
import { GoogleDataTableColumn, GoogleDataTableRow } from 'react-google-charts';
|
|
13
|
-
|
|
14
|
-
type ValueOf<T> = T[keyof T];
|
|
15
|
-
type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
|
|
16
|
-
type OrientationType = ValueOf<typeof Orientation>;
|
|
17
|
-
type AnnotationStyles = {
|
|
18
|
-
circleSubject?: Omit<CircleSubjectProps, 'x' | 'y'> & {
|
|
19
|
-
fill?: string;
|
|
20
|
-
};
|
|
21
|
-
lineSubject?: Omit<LineSubjectProps, 'x' | 'y'>;
|
|
22
|
-
connector?: Omit<ConnectorProps, 'x' | 'y' | 'dx' | 'dy'>;
|
|
23
|
-
label?: Omit<LabelProps, 'title' | 'subtitle' | 'x' | 'y'> & {
|
|
24
|
-
x?: number | 'start' | 'end';
|
|
25
|
-
y?: number | 'start' | 'end';
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
type DataPoint = {
|
|
29
|
-
label: string;
|
|
30
|
-
value: number;
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Data format for GeoChart - uses Google Charts native data format for maximum flexibility.
|
|
34
|
-
* First element is the header row, subsequent elements are data rows.
|
|
35
|
-
*
|
|
36
|
-
* Country identifiers can be either full country names or ISO 3166-1 alpha-2 codes (e.g., 'United States' or 'US').
|
|
37
|
-
* Full names are recommended for better readability in tooltips.
|
|
38
|
-
*
|
|
39
|
-
* @example Basic usage with country names:
|
|
40
|
-
* [['Country', 'Value'], ['United States', 100], ['Canada', 50], ['United Kingdom', 75]]
|
|
41
|
-
*
|
|
42
|
-
* @example With custom HTML tooltips:
|
|
43
|
-
* [
|
|
44
|
-
* ['Country', 'Value', { type: 'string', role: 'tooltip', p: { html: true } }],
|
|
45
|
-
* ['United States', 100, '<b>United States</b><br/>100 visitors'],
|
|
46
|
-
* ['Canada', 50, '<b>Canada</b><br/>50 visitors']
|
|
47
|
-
* ]
|
|
48
|
-
*
|
|
49
|
-
* @example With formatted values (v = value, f = formatted):
|
|
50
|
-
* [
|
|
51
|
-
* ['Country', 'Value'],
|
|
52
|
-
* ['United States', { v: 100, f: '100 visitors' }],
|
|
53
|
-
* ['Canada', { v: 50, f: '50 visitors' }]
|
|
54
|
-
* ]
|
|
55
|
-
*
|
|
56
|
-
* @example With multiple columns:
|
|
57
|
-
* [
|
|
58
|
-
* ['Country', 'Population', 'Area'],
|
|
59
|
-
* ['United States', 331000000, 9834000],
|
|
60
|
-
* ['Canada', 38000000, 9985000]
|
|
61
|
-
* ]
|
|
62
|
-
*/
|
|
63
|
-
type GeoData = [GoogleDataTableColumn[], ...GoogleDataTableRow[]];
|
|
64
|
-
type DataPointDate = {
|
|
65
|
-
date?: Date;
|
|
66
|
-
/**
|
|
67
|
-
* Supported Formats:
|
|
68
|
-
* - YYYY-MM-DD (local)
|
|
69
|
-
* - YYYY-MM-DD HH:mm:ss (local)
|
|
70
|
-
* - YYYY-MM-DD HH:mm (local)
|
|
71
|
-
* - YYYY-MM-DDTHH:mm:ss (local)
|
|
72
|
-
* - YYYY-MM-DDTHH:mm:ss.SSS (local)
|
|
73
|
-
* - YYYY-MM-DDTHH:mm (local)
|
|
74
|
-
* - YYYY-MM-DDTHH:mm:ssZ (UTC → local)
|
|
75
|
-
* - YYYY-MM-DDTHH:mm:ss±HH:mm (offset → local)
|
|
76
|
-
*/
|
|
77
|
-
dateString?: string;
|
|
78
|
-
value: number | null;
|
|
79
|
-
label?: string;
|
|
80
|
-
};
|
|
81
|
-
type LeaderboardEntry = {
|
|
82
|
-
/**
|
|
83
|
-
* Unique internal key (e.g., 'key-direct')
|
|
84
|
-
*/
|
|
85
|
-
id: string;
|
|
86
|
-
/**
|
|
87
|
-
* Human-readable name (e.g., 'Direct') or a JSX element (e.g., <h4>Direct</h4>)
|
|
88
|
-
*/
|
|
89
|
-
label: string | JSX.Element;
|
|
90
|
-
/**
|
|
91
|
-
* Value of the entry
|
|
92
|
-
*/
|
|
93
|
-
currentValue: number;
|
|
94
|
-
/**
|
|
95
|
-
* Value of the entry in the previous period
|
|
96
|
-
*/
|
|
97
|
-
previousValue: number;
|
|
98
|
-
/**
|
|
99
|
-
* Width of current bar, as % of the current value
|
|
100
|
-
*/
|
|
101
|
-
currentShare: number;
|
|
102
|
-
/**
|
|
103
|
-
* Width of previous bar, as % of the current value
|
|
104
|
-
*/
|
|
105
|
-
previousShare: number;
|
|
106
|
-
/**
|
|
107
|
-
* Delta of the entry
|
|
108
|
-
*/
|
|
109
|
-
delta: number;
|
|
110
|
-
/**
|
|
111
|
-
* Optional color for the entry's image/icon
|
|
112
|
-
*/
|
|
113
|
-
imageColor?: string;
|
|
114
|
-
};
|
|
115
|
-
type GradientStop = {
|
|
116
|
-
offset: string;
|
|
117
|
-
color?: string;
|
|
118
|
-
opacity?: number;
|
|
119
|
-
};
|
|
120
|
-
type SeriesDataOptions = {
|
|
121
|
-
gradient?: {
|
|
122
|
-
from: string;
|
|
123
|
-
to: string;
|
|
124
|
-
fromOpacity?: number;
|
|
125
|
-
toOpacity?: number;
|
|
126
|
-
stops?: GradientStop[];
|
|
127
|
-
};
|
|
128
|
-
stroke?: string;
|
|
129
|
-
seriesLineStyle?: LineStyles;
|
|
130
|
-
legendShapeStyle?: CSSProperties;
|
|
131
|
-
type?: 'comparison';
|
|
132
|
-
};
|
|
133
|
-
type SeriesData = {
|
|
134
|
-
group?: string;
|
|
135
|
-
label: string;
|
|
136
|
-
data: DataPointDate[] | DataPoint[];
|
|
137
|
-
options?: SeriesDataOptions;
|
|
138
|
-
};
|
|
139
|
-
type MultipleDataPointsDate = {
|
|
140
|
-
label: string;
|
|
141
|
-
data: DataPointDate[];
|
|
142
|
-
};
|
|
143
|
-
type DataPointPercentage = {
|
|
144
|
-
/**
|
|
145
|
-
* Label for the data point
|
|
146
|
-
*/
|
|
147
|
-
label: string;
|
|
148
|
-
/**
|
|
149
|
-
* Numerical value
|
|
150
|
-
*/
|
|
151
|
-
value: number;
|
|
152
|
-
/**
|
|
153
|
-
* Formatted value for display
|
|
154
|
-
*/
|
|
155
|
-
valueDisplay?: string;
|
|
156
|
-
/**
|
|
157
|
-
* Percentage value
|
|
158
|
-
*/
|
|
159
|
-
percentage: number;
|
|
160
|
-
/**
|
|
161
|
-
* Color code for the segment, by default colours are taken from the theme but this property can overrides it
|
|
162
|
-
*/
|
|
163
|
-
color?: string;
|
|
164
|
-
/**
|
|
165
|
-
* Group for the data point, used to match color with groups on other charts
|
|
166
|
-
*/
|
|
167
|
-
group?: string;
|
|
168
|
-
};
|
|
169
|
-
/**
|
|
170
|
-
* Base theme configuration for chart components with optional properties
|
|
171
|
-
*/
|
|
172
|
-
type ChartTheme = {
|
|
173
|
-
/** Background color for chart components */
|
|
174
|
-
backgroundColor: string;
|
|
175
|
-
/** Background color for labels */
|
|
176
|
-
labelBackgroundColor?: string;
|
|
177
|
-
/** Text color for labels */
|
|
178
|
-
labelTextColor?: string;
|
|
179
|
-
/** Array of colors used for data visualization */
|
|
180
|
-
colors: string[];
|
|
181
|
-
/** Optional CSS styles for grid lines */
|
|
182
|
-
gridStyles?: GridStyles;
|
|
183
|
-
/** Length of axis ticks in pixels */
|
|
184
|
-
tickLength: number;
|
|
185
|
-
/** Color of the grid lines */
|
|
186
|
-
gridColor: string;
|
|
187
|
-
/** Color of the grid lines in dark mode */
|
|
188
|
-
gridColorDark: string;
|
|
189
|
-
/** Styles for x-axis tick lines */
|
|
190
|
-
xTickLineStyles?: LineStyles;
|
|
191
|
-
/** Styles for x-axis line */
|
|
192
|
-
xAxisLineStyles?: LineStyles;
|
|
193
|
-
/** Styles for series lines */
|
|
194
|
-
seriesLineStyles?: LineStyles[];
|
|
195
|
-
/** Array of render functions for glyphs */
|
|
196
|
-
glyphs?: Array<(<Datum extends object>(props: GlyphProps<Datum>) => ReactNode)>;
|
|
197
|
-
/** Legend specific settings */
|
|
198
|
-
legend?: {
|
|
199
|
-
/** Styles for legend shapes */
|
|
200
|
-
shapeStyles?: Record<string, unknown>[];
|
|
201
|
-
/** Styles for legend labels */
|
|
202
|
-
labelStyles?: CSSProperties;
|
|
203
|
-
/** Styles for legend container */
|
|
204
|
-
containerStyles?: CSSProperties;
|
|
205
|
-
};
|
|
206
|
-
/** Styles for small SVG text (eg. axis tick labels), passed through to the XYChart theme. */
|
|
207
|
-
svgLabelSmall?: TextProps;
|
|
208
|
-
annotationStyles?: AnnotationStyles;
|
|
209
|
-
/** GeoChart specific settings */
|
|
210
|
-
geoChart?: {
|
|
211
|
-
/** Default fill color for a geo chart feature (e.g. country) with no data */
|
|
212
|
-
featureFillColor?: string;
|
|
213
|
-
};
|
|
214
|
-
/** LeaderboardChart specific settings */
|
|
215
|
-
leaderboardChart?: {
|
|
216
|
-
/** Gap between rows in the leaderboard grid */
|
|
217
|
-
rowGap?: number;
|
|
218
|
-
/** Gap between columns in the leaderboard grid */
|
|
219
|
-
columnGap?: number;
|
|
220
|
-
/** Spacing between label and progress bars */
|
|
221
|
-
labelSpacing?: number;
|
|
222
|
-
/** Primary color for current period bars */
|
|
223
|
-
primaryColor?: string;
|
|
224
|
-
/** Secondary color for comparison period bars */
|
|
225
|
-
secondaryColor?: string;
|
|
226
|
-
/** Delta colors: [negative, neutral, positive] */
|
|
227
|
-
deltaColors?: [string, string, string];
|
|
228
|
-
};
|
|
229
|
-
/** ConversionFunnelChart specific settings */
|
|
230
|
-
conversionFunnelChart?: {
|
|
231
|
-
/** Primary color for funnel bars */
|
|
232
|
-
primaryColor?: string;
|
|
233
|
-
/** Background color for chart container */
|
|
234
|
-
backgroundColor?: string;
|
|
235
|
-
/** Color for positive change indicators */
|
|
236
|
-
positiveChangeColor?: string;
|
|
237
|
-
/** Color for negative change indicators */
|
|
238
|
-
negativeChangeColor?: string;
|
|
239
|
-
};
|
|
240
|
-
lineChart?: {
|
|
241
|
-
lineStyles?: Partial<Record<NonNullable<SeriesDataOptions['type']>, LineStyles>>;
|
|
242
|
-
};
|
|
243
|
-
/** Sparkline specific settings */
|
|
244
|
-
sparkline?: {
|
|
245
|
-
/** Margin around the sparkline chart */
|
|
246
|
-
margin?: {
|
|
247
|
-
top?: number;
|
|
248
|
-
right?: number;
|
|
249
|
-
bottom?: number;
|
|
250
|
-
left?: number;
|
|
251
|
-
};
|
|
252
|
-
/** Stroke width for the sparkline line */
|
|
253
|
-
strokeWidth?: number;
|
|
254
|
-
};
|
|
255
|
-
};
|
|
256
|
-
/**
|
|
257
|
-
* Theme configuration with all properties guaranteed to be defined.
|
|
258
|
-
* Useful for merged themes where defaults are provided for all optional properties.
|
|
259
|
-
*/
|
|
260
|
-
type CompleteChartTheme = Required<ChartTheme> & {
|
|
261
|
-
leaderboardChart: Omit<Required<NonNullable<ChartTheme['leaderboardChart']>>, 'primaryColor' | 'secondaryColor'> & Pick<NonNullable<ChartTheme['leaderboardChart']>, 'primaryColor' | 'secondaryColor'>;
|
|
262
|
-
conversionFunnelChart: Omit<Required<NonNullable<ChartTheme['conversionFunnelChart']>>, 'primaryColor'> & Pick<NonNullable<ChartTheme['conversionFunnelChart']>, 'primaryColor'>;
|
|
263
|
-
lineChart: {
|
|
264
|
-
lineStyles: Record<NonNullable<SeriesDataOptions['type']>, LineStyles>;
|
|
265
|
-
};
|
|
266
|
-
legend: Required<NonNullable<ChartTheme['legend']>>;
|
|
267
|
-
sparkline: Required<NonNullable<ChartTheme['sparkline']>> & {
|
|
268
|
-
margin: Required<NonNullable<ChartTheme['sparkline']>['margin']>;
|
|
269
|
-
};
|
|
270
|
-
};
|
|
271
|
-
declare type AxisOptions = {
|
|
272
|
-
orientation?: OrientationType;
|
|
273
|
-
numTicks?: number;
|
|
274
|
-
axisClassName?: string;
|
|
275
|
-
axisLineClassName?: string;
|
|
276
|
-
labelClassName?: string;
|
|
277
|
-
tickClassName?: string;
|
|
278
|
-
tickFormat?: TickFormatter<ScaleInput<AxisScale>>;
|
|
279
|
-
/**
|
|
280
|
-
* Whether to display this axis. Defaults to true.
|
|
281
|
-
*/
|
|
282
|
-
display?: boolean;
|
|
283
|
-
/**
|
|
284
|
-
* For more control over rendering or to add event handlers to datum, pass a function as children.
|
|
285
|
-
*/
|
|
286
|
-
children?: (renderProps: AxisRendererProps<AxisScale>) => ReactNode;
|
|
287
|
-
/**
|
|
288
|
-
* Controls tick label overflow (bar charts only):
|
|
289
|
-
*
|
|
290
|
-
* - 'ellipsis': Truncate with ellipsis and fit to available space. Labels show full text
|
|
291
|
-
* on hover via native tooltip. Note: A minimum width (20px) is enforced for readability.
|
|
292
|
-
* On very dense charts (bandwidth < 20px), adjacent labels may overlap. To mitigate, use `numTicks`
|
|
293
|
-
* to reduce labels or `tickFormat` to abbreviate text.
|
|
294
|
-
* - undefined: No truncation; labels may overlap.
|
|
295
|
-
*
|
|
296
|
-
* Default: No truncation; labels may overlap.
|
|
297
|
-
*/
|
|
298
|
-
labelOverflow?: 'ellipsis';
|
|
299
|
-
};
|
|
300
|
-
type ScaleOptions = {
|
|
301
|
-
type?: ScaleType;
|
|
302
|
-
zero?: boolean;
|
|
303
|
-
domain?: [number, number];
|
|
304
|
-
range?: [number, number];
|
|
305
|
-
/**
|
|
306
|
-
* For band scale, shortcut for setting `paddingInner` and `paddingOuter` to the same value.
|
|
307
|
-
*
|
|
308
|
-
* For point scale, the outer padding (spacing) at the ends of the range.
|
|
309
|
-
* This is similar to band scale's `paddingOuter`.
|
|
310
|
-
*
|
|
311
|
-
*/
|
|
312
|
-
padding?: number;
|
|
313
|
-
/**
|
|
314
|
-
* The inner padding (spacing) within each band step of band scales, as a fraction of the step size. This value must lie in the range [0,1].
|
|
315
|
-
*
|
|
316
|
-
*/
|
|
317
|
-
paddingInner?: number;
|
|
318
|
-
/**
|
|
319
|
-
* The outer padding (spacing) at the ends of the range of band and point scales,
|
|
320
|
-
* as a fraction of the step size. This value must lie in the range [0,1].
|
|
321
|
-
*
|
|
322
|
-
*/
|
|
323
|
-
paddingOuter?: number;
|
|
324
|
-
};
|
|
325
|
-
type LegendItemStyles = {
|
|
326
|
-
/** Margin around each legend item. */
|
|
327
|
-
margin?: CSSProperties['margin'];
|
|
328
|
-
/** Flex direction for items within each legend entry. */
|
|
329
|
-
flexDirection?: 'row' | 'row-reverse' | 'column' | 'column-reverse';
|
|
330
|
-
};
|
|
331
|
-
type LegendLabelStyles = Pick<CSSProperties, 'justifyContent' | 'flex' | 'margin'> & {
|
|
332
|
-
/**
|
|
333
|
-
* Maximum width for legend label text as a CSS value (e.g. '200px', '50%', '10rem').
|
|
334
|
-
* When set, text overflow behavior is controlled by textOverflow.
|
|
335
|
-
*/
|
|
336
|
-
maxWidth?: string;
|
|
337
|
-
/**
|
|
338
|
-
* Controls how text behaves when it exceeds maxWidth.
|
|
339
|
-
* - 'ellipsis': Truncate with ellipsis (ideal for widgets/small devices)
|
|
340
|
-
* - 'wrap': Wrap text to multiple lines (default, ideal for larger displays)
|
|
341
|
-
*/
|
|
342
|
-
textOverflow?: 'ellipsis' | 'wrap';
|
|
343
|
-
};
|
|
344
|
-
type LegendShapeStyles = {
|
|
345
|
-
/** Width of the legend shape in pixels. */
|
|
346
|
-
width?: number;
|
|
347
|
-
/** Height of the legend shape in pixels. */
|
|
348
|
-
height?: number;
|
|
349
|
-
/** Margin around the legend shape. */
|
|
350
|
-
margin?: CSSProperties['margin'];
|
|
351
|
-
};
|
|
352
|
-
/** Position of the legend relative to chart content. */
|
|
353
|
-
type LegendPosition = 'top' | 'bottom';
|
|
354
|
-
/**
|
|
355
|
-
* Configuration object for chart legend appearance and behavior.
|
|
356
|
-
* Consolidates all legend styling and layout props into a single structured object.
|
|
357
|
-
*/
|
|
358
|
-
type ChartLegendConfig<T = DataPoint | DataPointDate | LeaderboardEntry> = {
|
|
359
|
-
/**
|
|
360
|
-
* Layout direction of legend items.
|
|
361
|
-
*/
|
|
362
|
-
orientation?: 'horizontal' | 'vertical';
|
|
363
|
-
/**
|
|
364
|
-
* Position of the legend relative to the chart.
|
|
365
|
-
* TODO: Add 'left' | 'right' positioning support in future implementation
|
|
366
|
-
*/
|
|
367
|
-
position?: LegendPosition;
|
|
368
|
-
/**
|
|
369
|
-
* Alignment of the legend within its position.
|
|
370
|
-
*/
|
|
371
|
-
alignment?: 'start' | 'center' | 'end';
|
|
372
|
-
/**
|
|
373
|
-
* Shape of the legend marker icon.
|
|
374
|
-
*/
|
|
375
|
-
shape?: LegendShape<T, number>;
|
|
376
|
-
/**
|
|
377
|
-
* Enable interactive legend items that can toggle series visibility.
|
|
378
|
-
* Supported for all chart types that render series.
|
|
379
|
-
* Requires chartId and GlobalChartsProvider.
|
|
380
|
-
* For pie charts, percentages are recalculated so visible segments total 100%.
|
|
381
|
-
*/
|
|
382
|
-
interactive?: boolean;
|
|
383
|
-
/**
|
|
384
|
-
* Additional CSS class name for individual legend items.
|
|
385
|
-
*/
|
|
386
|
-
itemClassName?: string;
|
|
387
|
-
/**
|
|
388
|
-
* CSS styles for each legend item (margin, flexDirection).
|
|
389
|
-
*/
|
|
390
|
-
itemStyles?: LegendItemStyles;
|
|
391
|
-
/**
|
|
392
|
-
* CSS styles for legend labels (maxWidth, textOverflow, justifyContent, flex, margin).
|
|
393
|
-
*/
|
|
394
|
-
labelStyles?: LegendLabelStyles;
|
|
395
|
-
/**
|
|
396
|
-
* Styles for legend shapes (width, height, margin).
|
|
397
|
-
*/
|
|
398
|
-
shapeStyles?: LegendShapeStyles;
|
|
399
|
-
};
|
|
400
|
-
/**
|
|
401
|
-
* Base properties shared across all chart components
|
|
402
|
-
*/
|
|
403
|
-
type BaseChartProps<T = DataPoint | DataPointDate | LeaderboardEntry> = {
|
|
404
|
-
/**
|
|
405
|
-
* Array of data points to display in the chart
|
|
406
|
-
*/
|
|
407
|
-
data: T extends DataPoint | DataPointDate | LeaderboardEntry ? T[] : T;
|
|
408
|
-
/**
|
|
409
|
-
* Optional unique identifier for the chart (auto-generated if not provided)
|
|
410
|
-
*/
|
|
411
|
-
chartId?: string;
|
|
412
|
-
/**
|
|
413
|
-
* Additional CSS class name for the chart container
|
|
414
|
-
*/
|
|
415
|
-
className?: string;
|
|
416
|
-
/**
|
|
417
|
-
* Width of the chart container in pixels. When omitted, the chart fills its parent's width.
|
|
418
|
-
*/
|
|
419
|
-
width?: number;
|
|
420
|
-
/**
|
|
421
|
-
* Height of the chart container in pixels. When omitted, the chart fills its parent's height.
|
|
422
|
-
*/
|
|
423
|
-
height?: number;
|
|
424
|
-
/**
|
|
425
|
-
* Maximum diameter of the pie in pixels (pie and donut charts only).
|
|
426
|
-
* The pie will shrink if the container is smaller than this value.
|
|
427
|
-
* When omitted, the pie fills the available space.
|
|
428
|
-
*/
|
|
429
|
-
size?: number;
|
|
430
|
-
/**
|
|
431
|
-
* Chart margins
|
|
432
|
-
*/
|
|
433
|
-
margin?: {
|
|
434
|
-
top?: number;
|
|
435
|
-
right?: number;
|
|
436
|
-
bottom?: number;
|
|
437
|
-
left?: number;
|
|
438
|
-
};
|
|
439
|
-
/**
|
|
440
|
-
* Callback function for pointer down event
|
|
441
|
-
*/
|
|
442
|
-
onPointerDown?: (event: EventHandlerParams<DataPoint | DataPointDate>) => void;
|
|
443
|
-
/**
|
|
444
|
-
* Callback function for pointer up event
|
|
445
|
-
*/
|
|
446
|
-
onPointerUp?: (event: EventHandlerParams<DataPoint | DataPointDate>) => void;
|
|
447
|
-
/**
|
|
448
|
-
* Callback function for pointer move event
|
|
449
|
-
*/
|
|
450
|
-
onPointerMove?: (event: EventHandlerParams<DataPoint | DataPointDate>) => void;
|
|
451
|
-
/**
|
|
452
|
-
* Callback function for pointer out event
|
|
453
|
-
*/
|
|
454
|
-
onPointerOut?: (event: PointerEvent<Element>) => void;
|
|
455
|
-
/**
|
|
456
|
-
* Whether to show tooltips on hover. False by default.
|
|
457
|
-
*/
|
|
458
|
-
withTooltips?: boolean;
|
|
459
|
-
/**
|
|
460
|
-
* Whether to show legend
|
|
461
|
-
*/
|
|
462
|
-
showLegend?: boolean;
|
|
463
|
-
/**
|
|
464
|
-
* Legend configuration object for controlling legend appearance and behavior.
|
|
465
|
-
* Includes orientation, position, alignment, shape, styling, and interactivity options.
|
|
466
|
-
*/
|
|
467
|
-
legend?: ChartLegendConfig<T>;
|
|
468
|
-
/**
|
|
469
|
-
* Grid visibility. x is default when orientation is vertical. y is default when orientation is horizontal.
|
|
470
|
-
*/
|
|
471
|
-
gridVisibility?: 'x' | 'y' | 'xy' | 'none';
|
|
472
|
-
/**
|
|
473
|
-
* Whether to show chart animation on initial render or not
|
|
474
|
-
*/
|
|
475
|
-
animation?: boolean;
|
|
476
|
-
/**
|
|
477
|
-
* Gap between chart elements (SVG, legend, children).
|
|
478
|
-
* Uses WordPress design system tokens.
|
|
479
|
-
* @default 'md'
|
|
480
|
-
*/
|
|
481
|
-
gap?: GapSize;
|
|
482
|
-
/**
|
|
483
|
-
* More options for the chart.
|
|
484
|
-
*/
|
|
485
|
-
options?: {
|
|
486
|
-
yScale?: ScaleOptions;
|
|
487
|
-
xScale?: ScaleOptions;
|
|
488
|
-
axis?: {
|
|
489
|
-
x?: AxisOptions;
|
|
490
|
-
y?: AxisOptions;
|
|
491
|
-
};
|
|
492
|
-
};
|
|
493
|
-
};
|
|
494
|
-
/**
|
|
495
|
-
* Properties for grid components
|
|
496
|
-
*/
|
|
497
|
-
type GridProps = {
|
|
498
|
-
/**
|
|
499
|
-
* Width of the grid in pixels
|
|
500
|
-
*/
|
|
501
|
-
width: number;
|
|
502
|
-
/**
|
|
503
|
-
* Height of the grid in pixels
|
|
504
|
-
*/
|
|
505
|
-
height: number;
|
|
506
|
-
/**
|
|
507
|
-
* Grid visibility. x is default.
|
|
508
|
-
*/
|
|
509
|
-
gridVisibility?: 'x' | 'y' | 'xy' | 'none';
|
|
510
|
-
/**
|
|
511
|
-
* X-axis scale for the grid
|
|
512
|
-
* TODO: Fix any type after resolving visx scale type issues
|
|
513
|
-
*/
|
|
514
|
-
xScale: any;
|
|
515
|
-
/**
|
|
516
|
-
* Y-axis scale for the grid
|
|
517
|
-
* TODO: Fix any type after resolving visx scale type issues
|
|
518
|
-
*/
|
|
519
|
-
yScale: any;
|
|
520
|
-
/**
|
|
521
|
-
* Top offset for the grid
|
|
522
|
-
*/
|
|
523
|
-
top?: number;
|
|
524
|
-
};
|
|
525
|
-
/**
|
|
526
|
-
* Local type definitions for Popover API attributes and events
|
|
527
|
-
* These are used to avoid extending React module types while still getting type safety
|
|
528
|
-
* NOTE: These type definitions are only needed for React 18 and below.
|
|
529
|
-
* React 19+ includes Popover API types in the official React type definitions, so these can be removed when upgrading.
|
|
530
|
-
*/
|
|
531
|
-
interface PopoverButtonAttributes {
|
|
532
|
-
popovertarget?: string;
|
|
533
|
-
popovertargetaction?: 'hide' | 'show' | 'toggle';
|
|
534
|
-
}
|
|
535
|
-
interface PopoverElementAttributes {
|
|
536
|
-
popover?: 'auto' | 'manual' | '';
|
|
537
|
-
}
|
|
538
|
-
type ButtonWithPopover = PopoverButtonAttributes;
|
|
539
|
-
type PopoverElement = PopoverElementAttributes;
|
|
540
|
-
interface ToggleEvent extends Event {
|
|
541
|
-
newState: 'open' | 'closed';
|
|
542
|
-
oldState: 'open' | 'closed';
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
export type { AnnotationStyles as A, BaseChartProps as B, ChartLegendConfig as C, DataPoint as D, GeoData as G, LeaderboardEntry as L, MultipleDataPointsDate as M, Optional as O, PopoverButtonAttributes as P, ScaleOptions as S, ToggleEvent as T, ButtonWithPopover as a, ChartTheme as b, CompleteChartTheme as c, DataPointDate as d, DataPointPercentage as e, GradientStop as f, GridProps as g, LegendItemStyles as h, LegendLabelStyles as i, LegendPosition as j, LegendShapeStyles as k, OrientationType as l, PopoverElement as m, PopoverElementAttributes as n, SeriesData as o, SeriesDataOptions as p };
|