panelui-native 0.86.1 → 0.87.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/README.md +4 -2
- package/lib/module/components/bubble-chart/index.js +1266 -0
- package/lib/module/components/bubble-chart/index.js.map +1 -0
- package/lib/module/components/pyramid-chart/index.js +1143 -0
- package/lib/module/components/pyramid-chart/index.js.map +1 -0
- package/lib/module/components/search-bar/index.js +399 -16
- package/lib/module/components/search-bar/index.js.map +1 -1
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/chart.js +24 -0
- package/lib/module/utils/chart.js.map +1 -1
- package/lib/typescript/src/components/bubble-chart/index.d.ts +338 -0
- package/lib/typescript/src/components/bubble-chart/index.d.ts.map +1 -0
- package/lib/typescript/src/components/pyramid-chart/index.d.ts +328 -0
- package/lib/typescript/src/components/pyramid-chart/index.d.ts.map +1 -0
- package/lib/typescript/src/components/search-bar/index.d.ts +215 -6
- package/lib/typescript/src/components/search-bar/index.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +3 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/chart.d.ts +14 -0
- package/lib/typescript/src/utils/chart.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/bubble-chart/index.tsx +1527 -0
- package/src/components/pyramid-chart/index.tsx +1360 -0
- package/src/components/search-bar/index.tsx +496 -38
- package/src/index.ts +45 -1
- package/src/utils/chart.ts +27 -0
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BubbleChart — one labelled circle per row, on two measured axes, with a third
|
|
3
|
+
* quantity on each circle's area.
|
|
4
|
+
*
|
|
5
|
+
* ```tsx
|
|
6
|
+
* <BubbleChart data={teams} xDataKey="efficiency" yDataKey="performance"
|
|
7
|
+
* sizeKey="headcount" labelKey="team">
|
|
8
|
+
* <BubbleChart.Grid />
|
|
9
|
+
* <BubbleChart.Bubbles />
|
|
10
|
+
* <BubbleChart.Labels />
|
|
11
|
+
* <BubbleChart.XAxis />
|
|
12
|
+
* <BubbleChart.YAxis />
|
|
13
|
+
* <BubbleChart.Tooltip />
|
|
14
|
+
* </BubbleChart>
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* ## When this and not a scatter plot
|
|
18
|
+
*
|
|
19
|
+
* `ScatterChart` also maps a third quantity onto point area, through `sizeKey`,
|
|
20
|
+
* and it is the right component for a *series* of observations: many points of
|
|
21
|
+
* one colour, where the shape of the cloud is the finding and no single dot
|
|
22
|
+
* needs a name.
|
|
23
|
+
*
|
|
24
|
+
* This one is for a handful of named things. Each row is its own circle with
|
|
25
|
+
* its own colour and its own label written inside it, so the chart can be read
|
|
26
|
+
* entity by entity rather than as a distribution. Eight teams, twelve products,
|
|
27
|
+
* six regions — where the reader wants to find one of them and see where it
|
|
28
|
+
* sits.
|
|
29
|
+
*
|
|
30
|
+
* ## Area, not radius
|
|
31
|
+
*
|
|
32
|
+
* `sizeKey` maps to a circle's area. Doubling a radius quadruples the ink, so a
|
|
33
|
+
* chart that scaled the radius would show a doubled value as four times the
|
|
34
|
+
* size, and the reader would believe the picture. The scale runs over the whole
|
|
35
|
+
* data set, so one bubble's size means the same thing as another's.
|
|
36
|
+
*
|
|
37
|
+
* ## Labels are text, not SVG
|
|
38
|
+
*
|
|
39
|
+
* The names inside the bubbles are React Native `Text` in a layer over the
|
|
40
|
+
* plot, so they follow the theme's font and the platform's text scaling — SVG
|
|
41
|
+
* text does neither. A bubble too small to hold its own label is left without
|
|
42
|
+
* one rather than given an unreadable one; the readout still names it.
|
|
43
|
+
*/
|
|
44
|
+
import { type ReactNode } from 'react';
|
|
45
|
+
import { type ViewProps } from 'react-native';
|
|
46
|
+
import { type ChartAccessibilityProps } from '../../primitives/chart-accessibility.js';
|
|
47
|
+
type Layer = 'svg' | 'overlay' | 'header' | 'footer';
|
|
48
|
+
export type BubbleChartStatus = 'loading' | 'ready';
|
|
49
|
+
export type BubbleChartDatum = Record<string, string | number | null | undefined>;
|
|
50
|
+
/** One bubble, resolved back to the row it came from. */
|
|
51
|
+
export interface BubbleChartPoint {
|
|
52
|
+
/** Index into `data`. */
|
|
53
|
+
index: number;
|
|
54
|
+
x: number;
|
|
55
|
+
y: number;
|
|
56
|
+
/** The value behind the area, when `sizeKey` is set. */
|
|
57
|
+
size: number | null;
|
|
58
|
+
/** The name written inside the circle, when `labelKey` is set. */
|
|
59
|
+
label: string;
|
|
60
|
+
/** The colour it was drawn in. */
|
|
61
|
+
color: string;
|
|
62
|
+
datum: BubbleChartDatum;
|
|
63
|
+
}
|
|
64
|
+
/** A bubble with its geometry resolved. Shared by every part. */
|
|
65
|
+
interface ResolvedBubble extends BubbleChartPoint {
|
|
66
|
+
/** Radius in points, off the area scale. */
|
|
67
|
+
r: number;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The bubble under the finger, for something rendered *inside* the chart. A
|
|
71
|
+
* readout in the card's header is outside this provider — use
|
|
72
|
+
* `onActivePointChange` for that.
|
|
73
|
+
*/
|
|
74
|
+
export declare function useBubbleChart(): {
|
|
75
|
+
activeIndex: number;
|
|
76
|
+
activePoint: ResolvedBubble | null;
|
|
77
|
+
};
|
|
78
|
+
export interface BubbleChartProps extends ViewProps, ChartAccessibilityProps<BubbleChartDatum> {
|
|
79
|
+
className?: string;
|
|
80
|
+
/** The rows. One bubble each. */
|
|
81
|
+
data: BubbleChartDatum[];
|
|
82
|
+
/** Key holding the horizontal value. */
|
|
83
|
+
xDataKey?: string;
|
|
84
|
+
/** Key holding the vertical value. */
|
|
85
|
+
yDataKey?: string;
|
|
86
|
+
/**
|
|
87
|
+
* Key holding the third quantity, mapped to each bubble's *area*. Without it
|
|
88
|
+
* every bubble is drawn at the middle of `sizeRange` and the chart is a
|
|
89
|
+
* scatter plot with names on it.
|
|
90
|
+
*/
|
|
91
|
+
sizeKey?: string;
|
|
92
|
+
/** Key holding the name written inside the circle. */
|
|
93
|
+
labelKey?: string;
|
|
94
|
+
/**
|
|
95
|
+
* Key holding a colour for the row — either a CSS colour or a number from 1
|
|
96
|
+
* to 5 naming a `--color-chart-*` token. Without it the ramp cycles by row.
|
|
97
|
+
*/
|
|
98
|
+
colorKey?: string;
|
|
99
|
+
/**
|
|
100
|
+
* Smallest and largest radius `sizeKey` maps onto, in points. The largest is
|
|
101
|
+
* also what the plot holds back at every edge, so raising it costs room.
|
|
102
|
+
*/
|
|
103
|
+
sizeRange?: [number, number];
|
|
104
|
+
/**
|
|
105
|
+
* `loading` shows a still field of muted circles and dissolves it as the real
|
|
106
|
+
* bubbles grow in. One component throughout, rather than a spinner swapped
|
|
107
|
+
* for a chart — swapping loses the transition. Add a `BubbleChart.Skeleton`
|
|
108
|
+
* for something to stand in the plot meanwhile.
|
|
109
|
+
*/
|
|
110
|
+
status?: BubbleChartStatus;
|
|
111
|
+
/** Width ÷ height. `1` is the square shape a bubble field reads best in. */
|
|
112
|
+
aspectRatio?: number;
|
|
113
|
+
/** Milliseconds for the bubbles to grow in on mount. */
|
|
114
|
+
animationDuration?: number;
|
|
115
|
+
/** Milliseconds for the axes to settle after the data changes. */
|
|
116
|
+
domainDuration?: number;
|
|
117
|
+
/** Fix the horizontal axis instead of deriving it. */
|
|
118
|
+
xDomain?: [number, number];
|
|
119
|
+
/** Fix the vertical axis instead of deriving it. */
|
|
120
|
+
yDomain?: [number, number];
|
|
121
|
+
/** The bubble under the finger, and `null` when it lifts. */
|
|
122
|
+
onActivePointChange?: (point: BubbleChartPoint | null) => void;
|
|
123
|
+
children?: ReactNode;
|
|
124
|
+
}
|
|
125
|
+
/** Imperative handle: re-run the grow-in, for a "replay" control. */
|
|
126
|
+
export interface BubbleChartHandle {
|
|
127
|
+
replay: () => void;
|
|
128
|
+
}
|
|
129
|
+
export interface BubbleChartGridProps {
|
|
130
|
+
/** Horizontal rules across the plot. */
|
|
131
|
+
rows?: number;
|
|
132
|
+
/** Vertical rules up it. Both axes are measured, so both earn lines. */
|
|
133
|
+
columns?: number;
|
|
134
|
+
color?: string;
|
|
135
|
+
opacity?: number;
|
|
136
|
+
}
|
|
137
|
+
/** Reference lines both ways, so a bubble can be placed against two numbers. */
|
|
138
|
+
declare function BubbleChartGrid({ rows, columns, color, opacity, }: BubbleChartGridProps): import("react").JSX.Element;
|
|
139
|
+
declare namespace BubbleChartGrid {
|
|
140
|
+
var displayName: string;
|
|
141
|
+
var layer: Layer;
|
|
142
|
+
}
|
|
143
|
+
export interface BubbleChartBubblesProps {
|
|
144
|
+
/**
|
|
145
|
+
* Fill opacity. Below 1 by default so that overlapping bubbles read as
|
|
146
|
+
* denser rather than hiding each other — in a crowded corner that overlap
|
|
147
|
+
* *is* the finding, and opaque circles erase it.
|
|
148
|
+
*/
|
|
149
|
+
opacity?: number;
|
|
150
|
+
/** One colour for every bubble, overriding the per-row ramp. */
|
|
151
|
+
color?: string;
|
|
152
|
+
}
|
|
153
|
+
/** The circles. */
|
|
154
|
+
declare function BubbleChartBubbles({ opacity, color }: BubbleChartBubblesProps): import("react").JSX.Element | null;
|
|
155
|
+
declare namespace BubbleChartBubbles {
|
|
156
|
+
var displayName: string;
|
|
157
|
+
var layer: Layer;
|
|
158
|
+
}
|
|
159
|
+
export interface BubbleChartSkeletonProps {
|
|
160
|
+
/** How many placeholder circles to scatter. */
|
|
161
|
+
count?: number;
|
|
162
|
+
color?: string;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* The loading state: a still field of muted circles where the data will be.
|
|
166
|
+
*
|
|
167
|
+
* Deliberately still. A shimmer over a field of circles reads as them *moving*,
|
|
168
|
+
* which is the one thing this chart must never appear to do — position is the
|
|
169
|
+
* entire message, and a loading state that implies it is changing is a loading
|
|
170
|
+
* state that lies.
|
|
171
|
+
*
|
|
172
|
+
* The layout is deterministic rather than random, so it does not reshuffle on
|
|
173
|
+
* every render of a component that may re-render several times while waiting.
|
|
174
|
+
* It dissolves as the real bubbles grow in, and outlives the status change by
|
|
175
|
+
* exactly that long: cut at the frame the data lands, the placeholder would
|
|
176
|
+
* disappear before anything had replaced it.
|
|
177
|
+
*/
|
|
178
|
+
declare function BubbleChartSkeleton({ count, color }: BubbleChartSkeletonProps): import("react").JSX.Element | null;
|
|
179
|
+
declare namespace BubbleChartSkeleton {
|
|
180
|
+
var displayName: string;
|
|
181
|
+
var layer: Layer;
|
|
182
|
+
}
|
|
183
|
+
export interface BubbleChartLabelsProps {
|
|
184
|
+
/**
|
|
185
|
+
* Smallest radius a bubble may have and still be given its label. Below it
|
|
186
|
+
* the name is wider than the circle it names.
|
|
187
|
+
*/
|
|
188
|
+
minRadius?: number;
|
|
189
|
+
/** Turn a bubble into its label. Defaults to the value at `labelKey`. */
|
|
190
|
+
format?: (point: BubbleChartPoint) => string;
|
|
191
|
+
className?: string;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* The names, written inside the circles.
|
|
195
|
+
*
|
|
196
|
+
* Real text over the plot rather than SVG text, so they follow the theme's font
|
|
197
|
+
* and the platform's text scaling. Each one rides the same domain tweens the
|
|
198
|
+
* circle under it does, so a label never lags the bubble it belongs to.
|
|
199
|
+
*
|
|
200
|
+
* A bubble too small to hold its name is left without one. Shrinking the text
|
|
201
|
+
* to fit would make it unreadable on exactly the bubbles the reader is
|
|
202
|
+
* squinting at already; the readout names those instead.
|
|
203
|
+
*/
|
|
204
|
+
declare function BubbleChartLabels({ minRadius, format, className, }: BubbleChartLabelsProps): import("react").JSX.Element | null;
|
|
205
|
+
declare namespace BubbleChartLabels {
|
|
206
|
+
var displayName: string;
|
|
207
|
+
var layer: Layer;
|
|
208
|
+
}
|
|
209
|
+
export interface BubbleChartXAxisProps {
|
|
210
|
+
/** How many intervals to divide the axis into. Yields `ticks + 1` labels. */
|
|
211
|
+
ticks?: number;
|
|
212
|
+
/** Turn a value into its label. Defaults to a compact number. */
|
|
213
|
+
format?: (value: number) => string;
|
|
214
|
+
className?: string;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* The x labels, evenly along the axis.
|
|
218
|
+
*
|
|
219
|
+
* Evenly spaced, because this axis is a continuous scale rather than a list of
|
|
220
|
+
* rows. There is no bubble for a label to sit under.
|
|
221
|
+
*/
|
|
222
|
+
declare function BubbleChartXAxis({ ticks, format, className }: BubbleChartXAxisProps): import("react").JSX.Element;
|
|
223
|
+
declare namespace BubbleChartXAxis {
|
|
224
|
+
var displayName: string;
|
|
225
|
+
var layer: Layer;
|
|
226
|
+
}
|
|
227
|
+
export interface BubbleChartYAxisProps {
|
|
228
|
+
/** How many intervals to divide the axis into. Yields `ticks + 1` labels. */
|
|
229
|
+
ticks?: number;
|
|
230
|
+
/** Turn a value into its label. Defaults to a compact number. */
|
|
231
|
+
format?: (value: number) => string;
|
|
232
|
+
className?: string;
|
|
233
|
+
}
|
|
234
|
+
/** Value labels down the side, one per grid line. Reserves its own gutter. */
|
|
235
|
+
declare function BubbleChartYAxis({ ticks, format, className }: BubbleChartYAxisProps): import("react").JSX.Element;
|
|
236
|
+
declare namespace BubbleChartYAxis {
|
|
237
|
+
var displayName: string;
|
|
238
|
+
var layer: Layer;
|
|
239
|
+
var axis: "y";
|
|
240
|
+
}
|
|
241
|
+
export interface BubbleChartTooltipProps {
|
|
242
|
+
/** Float a small readout beside the selected bubble. On by default. */
|
|
243
|
+
showLabel?: boolean;
|
|
244
|
+
/** Format the x value for the readout. Defaults to a compact number. */
|
|
245
|
+
formatX?: (value: number) => string;
|
|
246
|
+
/** Format the y value for the readout. Defaults to a compact number. */
|
|
247
|
+
formatY?: (value: number) => string;
|
|
248
|
+
/** Format the size value for the readout. Defaults to a compact number. */
|
|
249
|
+
formatSize?: (value: number) => string;
|
|
250
|
+
/** Floor on the touch target, for a chart whose smallest bubbles are tiny. */
|
|
251
|
+
hitRadius?: number;
|
|
252
|
+
className?: string;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* The touch target, the selection it drives, and the readout that follows it.
|
|
256
|
+
*
|
|
257
|
+
* A touch picks the nearest bubble whose own circle — or the `hitRadius` floor,
|
|
258
|
+
* whichever is larger — reaches the finger. Nearest rather than topmost,
|
|
259
|
+
* because where bubbles overlap the one drawn last is not the one being aimed
|
|
260
|
+
* at.
|
|
261
|
+
*
|
|
262
|
+
* The search runs on the UI thread over flat arrays of already-projected
|
|
263
|
+
* coordinates, and only the *index* of the winner crosses back into JS, and
|
|
264
|
+
* only when it changes. A drag across the plot therefore costs a handful of
|
|
265
|
+
* re-renders rather than one per frame.
|
|
266
|
+
*
|
|
267
|
+
* Distances are compared squared. The nearest bubble by distance is the nearest
|
|
268
|
+
* by distance-squared, and a square root per bubble per frame buys nothing.
|
|
269
|
+
*/
|
|
270
|
+
declare function BubbleChartTooltip({ showLabel, formatX, formatY, formatSize, hitRadius, className, }: BubbleChartTooltipProps): import("react").JSX.Element | null;
|
|
271
|
+
declare namespace BubbleChartTooltip {
|
|
272
|
+
var displayName: string;
|
|
273
|
+
var layer: Layer;
|
|
274
|
+
}
|
|
275
|
+
export interface BubbleChartLegendProps extends ViewProps {
|
|
276
|
+
className?: string;
|
|
277
|
+
/** Cap on how many bubbles are named. The rest are left to the readout. */
|
|
278
|
+
limit?: number;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* A swatch and a name per bubble, for a chart whose circles are too small to
|
|
282
|
+
* carry their own labels.
|
|
283
|
+
*
|
|
284
|
+
* Drawn **under** the plot rather than floating in a corner of it. A key that
|
|
285
|
+
* overlays the drawing area competes with the bubbles for the space they are
|
|
286
|
+
* plotted in, and on a square chart there is no corner that is reliably empty —
|
|
287
|
+
* the position of a bubble is the data, so nowhere can be reserved for it.
|
|
288
|
+
*
|
|
289
|
+
* It lists rows rather than series, because in this chart a row *is* a
|
|
290
|
+
* category. Use it instead of `BubbleChart.Labels`, not beside it — the same
|
|
291
|
+
* names twice is the legend telling the reader what the plot already says.
|
|
292
|
+
*/
|
|
293
|
+
declare function BubbleChartLegend({ className, limit, ...props }: BubbleChartLegendProps): import("react").JSX.Element | null;
|
|
294
|
+
declare namespace BubbleChartLegend {
|
|
295
|
+
var displayName: string;
|
|
296
|
+
var layer: Layer;
|
|
297
|
+
}
|
|
298
|
+
export interface BubbleChartHeaderProps extends ViewProps {
|
|
299
|
+
className?: string;
|
|
300
|
+
/** Small line above the value — what the chart is of. */
|
|
301
|
+
title?: string;
|
|
302
|
+
/** The readout. The largest thing on the card, and the first thing read. */
|
|
303
|
+
value?: string;
|
|
304
|
+
/** One muted line under the value — what the area means, usually. */
|
|
305
|
+
caption?: string;
|
|
306
|
+
/** Trailing slot — a control, a badge, a range picker. */
|
|
307
|
+
children?: ReactNode;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* The strip above the plot: what the chart is of, what it currently reads, and
|
|
311
|
+
* what the size of a circle means.
|
|
312
|
+
*
|
|
313
|
+
* The caption earns its place here more than on most charts. Two axes and an
|
|
314
|
+
* area is three quantities, and a reader who is not told what the area is has
|
|
315
|
+
* no way to work it out from the picture.
|
|
316
|
+
*
|
|
317
|
+
* The value is not derived here. A readout that follows the finger belongs to
|
|
318
|
+
* whoever owns the data — take it from `onActivePointChange` and pass the
|
|
319
|
+
* formatted string down.
|
|
320
|
+
*/
|
|
321
|
+
declare function BubbleChartHeader({ className, title, value, caption, children, ...props }: BubbleChartHeaderProps): import("react").JSX.Element;
|
|
322
|
+
declare namespace BubbleChartHeader {
|
|
323
|
+
var displayName: string;
|
|
324
|
+
var layer: Layer;
|
|
325
|
+
}
|
|
326
|
+
export declare const BubbleChart: import("react").ForwardRefExoticComponent<BubbleChartProps & import("react").RefAttributes<BubbleChartHandle>> & {
|
|
327
|
+
Header: typeof BubbleChartHeader;
|
|
328
|
+
Grid: typeof BubbleChartGrid;
|
|
329
|
+
Bubbles: typeof BubbleChartBubbles;
|
|
330
|
+
Labels: typeof BubbleChartLabels;
|
|
331
|
+
Skeleton: typeof BubbleChartSkeleton;
|
|
332
|
+
XAxis: typeof BubbleChartXAxis;
|
|
333
|
+
YAxis: typeof BubbleChartYAxis;
|
|
334
|
+
Tooltip: typeof BubbleChartTooltip;
|
|
335
|
+
Legend: typeof BubbleChartLegend;
|
|
336
|
+
};
|
|
337
|
+
export {};
|
|
338
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/bubble-chart/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,OAAO,EAWL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,EAA4C,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAgBxF,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,yCAAsC,CAAC;AAqF9C,KAAK,KAAK,GAAG,KAAK,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAErD,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,OAAO,CAAC;AAEpD,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;AAElF,yDAAyD;AACzD,MAAM,WAAW,gBAAgB;IAC/B,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,wDAAwD;IACxD,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,kEAAkE;IAClE,KAAK,EAAE,MAAM,CAAC;IACd,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,gBAAgB,CAAC;CACzB;AAED,iEAAiE;AACjE,UAAU,cAAe,SAAQ,gBAAgB;IAC/C,4CAA4C;IAC5C,CAAC,EAAE,MAAM,CAAC;CACX;AAkCD;;;;GAIG;AACH,wBAAgB,cAAc;;;EAI7B;AAkBD,MAAM,WAAW,gBACf,SAAQ,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,EAAE,GAAG,KAAK,EAAE,EAAE,sBAAsB,sCA2BpF;kBA3BQ,iBAAiB;;;;AAmC1B,MAAM,WAAW,sBAAuB,SAAQ,SAAS;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;;;;;;;;;GAWG;AACH,iBAAS,iBAAiB,CAAC,EACzB,SAAS,EACT,KAAK,EACL,KAAK,EACL,OAAO,EACP,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,sBAAsB,+BA6BxB;kBApCQ,iBAAiB;;;;AAwC1B,eAAO,MAAM,WAAW;;;;;;;;;;CAUtB,CAAC"}
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PyramidChart — two series mirrored about a centre line, drawn and animated on
|
|
3
|
+
* the UI thread.
|
|
4
|
+
*
|
|
5
|
+
* ```tsx
|
|
6
|
+
* <PyramidChart data={penguins} xDataKey="species">
|
|
7
|
+
* <PyramidChart.Grid />
|
|
8
|
+
* <PyramidChart.Bar dataKey="male" side="start" />
|
|
9
|
+
* <PyramidChart.Bar dataKey="female" side="end" />
|
|
10
|
+
* <PyramidChart.XAxis />
|
|
11
|
+
* <PyramidChart.YAxis />
|
|
12
|
+
* <PyramidChart.Tooltip />
|
|
13
|
+
* </PyramidChart>
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* ## The two wings share one scale
|
|
17
|
+
*
|
|
18
|
+
* This is the whole contract, and everything else here follows from it. The
|
|
19
|
+
* domain is derived from the larger of the two series' extents and used by
|
|
20
|
+
* both, so a bar twice as long as the one facing it means twice as much.
|
|
21
|
+
* Scaling each side to its own maximum produces a chart whose halves cannot be
|
|
22
|
+
* compared — which is the only thing a pyramid is for.
|
|
23
|
+
*
|
|
24
|
+
* For the same reason the centre is zero and stays there. There is no `yDomain`
|
|
25
|
+
* that starts anywhere else, because a wing cropped at its base is a length
|
|
26
|
+
* that lies.
|
|
27
|
+
*
|
|
28
|
+
* ## Lengths, not signed values
|
|
29
|
+
*
|
|
30
|
+
* Which side a series is on comes from `side`, not from the sign of its
|
|
31
|
+
* numbers, so a value is a distance outward from the centre. A negative one has
|
|
32
|
+
* no direction left to grow in and is drawn as nothing; it still appears in the
|
|
33
|
+
* readout, so a data error shows up as a gap rather than as a bar pointing the
|
|
34
|
+
* wrong way.
|
|
35
|
+
*
|
|
36
|
+
* ## Where the category names go
|
|
37
|
+
*
|
|
38
|
+
* `labelPlacement="above"`, the default, gives each row a line of its own over
|
|
39
|
+
* its pair of bars. That leaves the two wings meeting in the middle with
|
|
40
|
+
* nothing standing between them, and puts the name where it is read before the
|
|
41
|
+
* lengths it belongs to rather than beside them.
|
|
42
|
+
*
|
|
43
|
+
* `"center"` puts the names in a gutter between the wings instead — taken off
|
|
44
|
+
* the bars rather than off the edges, so both wings stay equal — and `"start"`
|
|
45
|
+
* puts them down the left, for a chart with room to spare on that side.
|
|
46
|
+
*
|
|
47
|
+
* ## Every series is one path
|
|
48
|
+
*
|
|
49
|
+
* A `Bar` draws all its rectangles as subpaths of a single animated path, split
|
|
50
|
+
* in two so the row under the finger keeps full ink while the rest fade. Thirty
|
|
51
|
+
* rows is two animated props a frame rather than thirty.
|
|
52
|
+
*/
|
|
53
|
+
import { type ReactNode } from 'react';
|
|
54
|
+
import { type ViewProps } from 'react-native';
|
|
55
|
+
import { type ChartAccessibilityProps } from '../../primitives/chart-accessibility.js';
|
|
56
|
+
import { type SeriesColorIndex } from '../../utils/chart.js';
|
|
57
|
+
type Layer = 'svg' | 'overlay' | 'header';
|
|
58
|
+
export type PyramidChartStatus = 'loading' | 'ready';
|
|
59
|
+
/** Which wing a series grows into. */
|
|
60
|
+
export type PyramidChartSide = 'start' | 'end';
|
|
61
|
+
/** Where the category names sit. */
|
|
62
|
+
export type PyramidChartLabelPlacement = 'above' | 'center' | 'start';
|
|
63
|
+
export type PyramidChartDatum = Record<string, string | number | null | undefined>;
|
|
64
|
+
/**
|
|
65
|
+
* The row under the finger, for something rendered *inside* the chart. A
|
|
66
|
+
* readout in the card's header is outside this provider — use
|
|
67
|
+
* `onActiveIndexChange` for that.
|
|
68
|
+
*/
|
|
69
|
+
export declare function usePyramidChart(): {
|
|
70
|
+
activeIndex: number;
|
|
71
|
+
activePoint: PyramidChartDatum | null;
|
|
72
|
+
xDataKey: string;
|
|
73
|
+
};
|
|
74
|
+
export interface PyramidChartProps extends ViewProps, ChartAccessibilityProps<PyramidChartDatum> {
|
|
75
|
+
className?: string;
|
|
76
|
+
/** The rows. Each one is a band across the chart, with a wing either side. */
|
|
77
|
+
data: PyramidChartDatum[];
|
|
78
|
+
/** Key holding the category label. Used by the axis and the readout. */
|
|
79
|
+
xDataKey?: string;
|
|
80
|
+
/**
|
|
81
|
+
* `loading` holds the bars at the centre and grows them out into the real
|
|
82
|
+
* ones when it turns `ready`. One component throughout, rather than a spinner
|
|
83
|
+
* swapped for a chart — swapping loses the transition. Add a
|
|
84
|
+
* `PyramidChart.Skeleton` for something to stand in the plot meanwhile.
|
|
85
|
+
*/
|
|
86
|
+
status?: PyramidChartStatus;
|
|
87
|
+
/** Width ÷ height. `1.2` suits three or four rows in a card. */
|
|
88
|
+
aspectRatio?: number;
|
|
89
|
+
/** Milliseconds for the bars to grow out on mount. */
|
|
90
|
+
animationDuration?: number;
|
|
91
|
+
/** Milliseconds for the scale to settle after the data changes. */
|
|
92
|
+
domainDuration?: number;
|
|
93
|
+
/**
|
|
94
|
+
* Fix the far end of the shared scale instead of deriving it. The near end is
|
|
95
|
+
* zero either way — a pyramid measures outward from its centre.
|
|
96
|
+
*/
|
|
97
|
+
maxValue?: number;
|
|
98
|
+
/**
|
|
99
|
+
* Where the category names sit. `above`, the default, gives each row a line
|
|
100
|
+
* of its own over its pair of bars, so the two wings meet in the middle with
|
|
101
|
+
* nothing standing between them. `center` puts the names in a gutter between
|
|
102
|
+
* the wings instead, and `start` down the left edge.
|
|
103
|
+
*/
|
|
104
|
+
labelPlacement?: PyramidChartLabelPlacement;
|
|
105
|
+
/**
|
|
106
|
+
* Fraction of each band left empty, `0` to `1`. A fraction rather than a
|
|
107
|
+
* pixel gap so the proportions hold at any height.
|
|
108
|
+
*/
|
|
109
|
+
barGap?: number;
|
|
110
|
+
/** Fixed bar thickness in points. Derived from the band when omitted. */
|
|
111
|
+
barWidth?: number;
|
|
112
|
+
/** Corner radius on the outward end of a bar. */
|
|
113
|
+
cornerRadius?: number;
|
|
114
|
+
/**
|
|
115
|
+
* Smallest length a non-zero bar is drawn at, in points. A value that rounds
|
|
116
|
+
* to nothing still happened, and a bar of zero length says it did not.
|
|
117
|
+
*/
|
|
118
|
+
minBarLength?: number;
|
|
119
|
+
/** Opacity of the rows that are not under the finger. */
|
|
120
|
+
fadedOpacity?: number;
|
|
121
|
+
/**
|
|
122
|
+
* The row under the finger as it moves, and `-1`/`null` when it lifts.
|
|
123
|
+
* Fires when the index changes, not per frame.
|
|
124
|
+
*/
|
|
125
|
+
onActiveIndexChange?: (index: number, datum: PyramidChartDatum | null) => void;
|
|
126
|
+
children?: ReactNode;
|
|
127
|
+
}
|
|
128
|
+
/** Imperative handle: re-run the grow-out, for a "replay" control. */
|
|
129
|
+
export interface PyramidChartHandle {
|
|
130
|
+
replay: () => void;
|
|
131
|
+
}
|
|
132
|
+
export interface PyramidChartGridProps {
|
|
133
|
+
/** How many lines to draw per wing, not counting the centre. */
|
|
134
|
+
columns?: number;
|
|
135
|
+
color?: string;
|
|
136
|
+
dashArray?: string;
|
|
137
|
+
opacity?: number;
|
|
138
|
+
/** Draw the solid line down the middle the wings are measured from. */
|
|
139
|
+
centreLine?: boolean;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Lines up the value axis, mirrored, so a bar can be read against a number
|
|
143
|
+
* rather than only against the bar facing it.
|
|
144
|
+
*
|
|
145
|
+
* The centre line is drawn solid and undashed where the others are dashed: it
|
|
146
|
+
* is not a tick, it is the zero both wings are measured from.
|
|
147
|
+
*/
|
|
148
|
+
declare function PyramidChartGrid({ columns, color, dashArray, opacity, centreLine, }: PyramidChartGridProps): import("react").JSX.Element;
|
|
149
|
+
declare namespace PyramidChartGrid {
|
|
150
|
+
var displayName: string;
|
|
151
|
+
var layer: Layer;
|
|
152
|
+
}
|
|
153
|
+
export interface PyramidChartBarProps {
|
|
154
|
+
/** Column in the data holding this series' values. */
|
|
155
|
+
dataKey: string;
|
|
156
|
+
/** Which wing it grows into. */
|
|
157
|
+
side?: PyramidChartSide;
|
|
158
|
+
/** Explicit colour. Defaults to the `--color-chart-*` token for `colorIndex`. */
|
|
159
|
+
color?: string;
|
|
160
|
+
/**
|
|
161
|
+
* Which of the five chart tokens to take. Defaults to a different one per
|
|
162
|
+
* side, so two bars declared with nothing but a `dataKey` and a `side` are
|
|
163
|
+
* already told apart.
|
|
164
|
+
*/
|
|
165
|
+
colorIndex?: SeriesColorIndex;
|
|
166
|
+
/** Corner radius, overriding the chart's. */
|
|
167
|
+
cornerRadius?: number;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* One wing.
|
|
171
|
+
*
|
|
172
|
+
* Drawn as two paths rather than one rectangle per row: the row under the
|
|
173
|
+
* finger, and everything else. That is the fewest animated props that can still
|
|
174
|
+
* dim the rest — one path could not, since a path has one opacity, and a view
|
|
175
|
+
* per bar would be one animated prop per bar for the same picture.
|
|
176
|
+
*/
|
|
177
|
+
declare function PyramidChartBar({ dataKey, side, color, colorIndex, cornerRadius, }: PyramidChartBarProps): import("react").JSX.Element;
|
|
178
|
+
declare namespace PyramidChartBar {
|
|
179
|
+
var displayName: string;
|
|
180
|
+
var layer: Layer;
|
|
181
|
+
}
|
|
182
|
+
export interface PyramidChartSkeletonProps {
|
|
183
|
+
/**
|
|
184
|
+
* How many placeholder rows to draw. Defaults to one per row of data, and to
|
|
185
|
+
* five when the data has not arrived — the count is the one thing a loading
|
|
186
|
+
* chart can be honest about only if it already has the rows.
|
|
187
|
+
*/
|
|
188
|
+
rows?: number;
|
|
189
|
+
/** Milliseconds for one pass of the sweep. */
|
|
190
|
+
duration?: number;
|
|
191
|
+
color?: string;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* The loading state: equal stubs either side of the centre, with a highlight
|
|
195
|
+
* travelling across them.
|
|
196
|
+
*
|
|
197
|
+
* Equal on purpose. Placeholder wings of differing lengths are a distribution
|
|
198
|
+
* the reader has no way to tell from the real one until it changes under them,
|
|
199
|
+
* so these say only how many rows there will be and where the centre is.
|
|
200
|
+
*/
|
|
201
|
+
declare function PyramidChartSkeleton({ rows, duration, color }: PyramidChartSkeletonProps): import("react").JSX.Element | null;
|
|
202
|
+
declare namespace PyramidChartSkeleton {
|
|
203
|
+
var displayName: string;
|
|
204
|
+
var layer: Layer;
|
|
205
|
+
}
|
|
206
|
+
export interface PyramidChartXAxisProps {
|
|
207
|
+
/** How many labels per wing, not counting the zero in the middle. */
|
|
208
|
+
ticks?: number;
|
|
209
|
+
/** Format a value for its label. Defaults to a compact number. */
|
|
210
|
+
format?: (value: number) => string;
|
|
211
|
+
className?: string;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* The value labels along the bottom, mirrored either side of a zero in the
|
|
215
|
+
* middle — the same magnitudes twice, because both wings are read outward from
|
|
216
|
+
* the centre rather than along one continuous axis.
|
|
217
|
+
*
|
|
218
|
+
* Real text rather than SVG text, so the labels follow the theme's font and the
|
|
219
|
+
* platform's text scaling. SVG text does neither.
|
|
220
|
+
*/
|
|
221
|
+
declare function PyramidChartXAxis({ ticks, format, className }: PyramidChartXAxisProps): import("react").JSX.Element | null;
|
|
222
|
+
declare namespace PyramidChartXAxis {
|
|
223
|
+
var displayName: string;
|
|
224
|
+
var layer: Layer;
|
|
225
|
+
}
|
|
226
|
+
export interface PyramidChartYAxisProps {
|
|
227
|
+
/** Turn a row into its label. Defaults to the value at `xDataKey`. */
|
|
228
|
+
format?: (datum: PyramidChartDatum, index: number) => string;
|
|
229
|
+
className?: string;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* The category names, one per row.
|
|
233
|
+
*
|
|
234
|
+
* `above` puts each name on its own line over the pair of bars it belongs to,
|
|
235
|
+
* which leaves the two wings meeting in the middle — the name is read first and
|
|
236
|
+
* the bars are then read outward from a centre nothing is standing in.
|
|
237
|
+
*
|
|
238
|
+
* One box per band rather than a spaced column, in every placement: a row owns
|
|
239
|
+
* a *band*, so names spread evenly would be half a band out at the top and
|
|
240
|
+
* bottom.
|
|
241
|
+
*/
|
|
242
|
+
declare function PyramidChartYAxis({ format, className }: PyramidChartYAxisProps): import("react").JSX.Element | null;
|
|
243
|
+
declare namespace PyramidChartYAxis {
|
|
244
|
+
var displayName: string;
|
|
245
|
+
var layer: Layer;
|
|
246
|
+
var axis: "y";
|
|
247
|
+
}
|
|
248
|
+
export interface PyramidChartTooltipProps {
|
|
249
|
+
/** Format one series' value. Defaults to a compact number. */
|
|
250
|
+
formatValue?: (value: number, key: string) => string;
|
|
251
|
+
/** Format the readout's heading from the row. Defaults to the value at xDataKey. */
|
|
252
|
+
formatX?: (datum: PyramidChartDatum) => string;
|
|
253
|
+
className?: string;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* The readout, and the gesture that drives it.
|
|
257
|
+
*
|
|
258
|
+
* There is no crosshair. A bar is already the thing being pointed at, so
|
|
259
|
+
* highlighting its row and dimming the rest says the same thing without drawing
|
|
260
|
+
* a line through the chart.
|
|
261
|
+
*
|
|
262
|
+
* The hit area is the whole plot. A readout you have to land on the bar to
|
|
263
|
+
* summon is a readout nobody finds.
|
|
264
|
+
*/
|
|
265
|
+
declare function PyramidChartTooltip({ formatValue, formatX, className, }: PyramidChartTooltipProps): import("react").JSX.Element | null;
|
|
266
|
+
declare namespace PyramidChartTooltip {
|
|
267
|
+
var displayName: string;
|
|
268
|
+
var layer: Layer;
|
|
269
|
+
}
|
|
270
|
+
export interface PyramidChartLegendProps extends ViewProps {
|
|
271
|
+
className?: string;
|
|
272
|
+
/** Prettier names for the series keys. */
|
|
273
|
+
labels?: Record<string, string>;
|
|
274
|
+
}
|
|
275
|
+
/** A swatch and a name per series, in the order the series were declared. */
|
|
276
|
+
declare function PyramidChartLegend({ className, labels, ...props }: PyramidChartLegendProps): import("react").JSX.Element | null;
|
|
277
|
+
declare namespace PyramidChartLegend {
|
|
278
|
+
var displayName: string;
|
|
279
|
+
var layer: Layer;
|
|
280
|
+
}
|
|
281
|
+
export interface PyramidChartHeaderProps extends ViewProps {
|
|
282
|
+
className?: string;
|
|
283
|
+
/** Small line above the value — what the chart is of. */
|
|
284
|
+
title?: string;
|
|
285
|
+
/** The readout. The largest thing on the card, and the first thing read. */
|
|
286
|
+
value?: string;
|
|
287
|
+
/** One muted line under the value — a period, a comparison, a total. */
|
|
288
|
+
caption?: string;
|
|
289
|
+
/** Prettier names for the series keys, as the legend takes. */
|
|
290
|
+
labels?: Record<string, string>;
|
|
291
|
+
/**
|
|
292
|
+
* Draw a swatch and a name per series along the trailing edge. Prefer this to
|
|
293
|
+
* `PyramidChart.Legend` on a chart that has a header: the legend floats over
|
|
294
|
+
* the plot, where it competes with the bars for the same corner.
|
|
295
|
+
*/
|
|
296
|
+
legend?: boolean;
|
|
297
|
+
/** Trailing slot — a control, a badge, a range picker. Wins over `legend`. */
|
|
298
|
+
children?: ReactNode;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* The strip above the plot: what the chart is of, what it currently reads, and
|
|
302
|
+
* what the two colours mean.
|
|
303
|
+
*
|
|
304
|
+
* It belongs to the chart rather than to the card around it because it is about
|
|
305
|
+
* the *plot* — the number changes as a finger moves down the rows, and the
|
|
306
|
+
* legend is the series list the chart itself is holding.
|
|
307
|
+
*
|
|
308
|
+
* The value is not derived here. A readout that follows the finger belongs to
|
|
309
|
+
* whoever owns the data — take it from `onActiveIndexChange` and pass the
|
|
310
|
+
* formatted string down.
|
|
311
|
+
*/
|
|
312
|
+
declare function PyramidChartHeader({ className, title, value, caption, labels, legend, children, ...props }: PyramidChartHeaderProps): import("react").JSX.Element;
|
|
313
|
+
declare namespace PyramidChartHeader {
|
|
314
|
+
var displayName: string;
|
|
315
|
+
var layer: Layer;
|
|
316
|
+
}
|
|
317
|
+
export declare const PyramidChart: import("react").ForwardRefExoticComponent<PyramidChartProps & import("react").RefAttributes<PyramidChartHandle>> & {
|
|
318
|
+
Header: typeof PyramidChartHeader;
|
|
319
|
+
Grid: typeof PyramidChartGrid;
|
|
320
|
+
Bar: typeof PyramidChartBar;
|
|
321
|
+
Skeleton: typeof PyramidChartSkeleton;
|
|
322
|
+
XAxis: typeof PyramidChartXAxis;
|
|
323
|
+
YAxis: typeof PyramidChartYAxis;
|
|
324
|
+
Tooltip: typeof PyramidChartTooltip;
|
|
325
|
+
Legend: typeof PyramidChartLegend;
|
|
326
|
+
};
|
|
327
|
+
export {};
|
|
328
|
+
//# sourceMappingURL=index.d.ts.map
|