@sophistry/charts 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (220) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +32 -2
  3. package/dist/3d/bar-chart3d.d.ts +55 -0
  4. package/dist/3d/definitions.d.ts +37 -0
  5. package/dist/3d/definitions.js +14 -0
  6. package/dist/3d/forward.d.ts +64 -0
  7. package/dist/3d/index.d.ts +30 -0
  8. package/dist/3d/index.js +1 -0
  9. package/dist/3d/quiver3d.d.ts +52 -0
  10. package/dist/3d/scatter3d.d.ts +44 -0
  11. package/dist/3d/stem3d.d.ts +45 -0
  12. package/dist/3d/surface-grid3d.d.ts +33 -0
  13. package/dist/3d/tri-surface3d.d.ts +45 -0
  14. package/dist/3d/voxels3d.d.ts +25 -0
  15. package/dist/3d/wireframe3d.d.ts +30 -0
  16. package/dist/band.d.ts +20 -0
  17. package/dist/bars/bar-chart.d.ts +143 -0
  18. package/dist/bars/bar-labels.d.ts +116 -0
  19. package/dist/bars/bars.d.ts +223 -0
  20. package/dist/bars/bullet.d.ts +157 -0
  21. package/dist/bars/candlestick.d.ts +97 -0
  22. package/dist/bars/funnel.d.ts +90 -0
  23. package/dist/bars/histogram.d.ts +108 -0
  24. package/dist/bars/index.d.ts +22 -0
  25. package/dist/bars/race.d.ts +28 -0
  26. package/dist/bars/rules.d.ts +121 -0
  27. package/dist/bars/shared.d.ts +41 -0
  28. package/dist/bars/transforms.d.ts +249 -0
  29. package/dist/bars/waterfall.d.ts +106 -0
  30. package/dist/batch.d.ts +142 -0
  31. package/dist/channels-_Xf-p6Lx.js +56 -0
  32. package/dist/chart.d.ts +87 -0
  33. package/dist/color-norm.d.ts +90 -0
  34. package/dist/context.d.ts +111 -0
  35. package/dist/curves/density.d.ts +125 -0
  36. package/dist/curves/ecdf.d.ts +72 -0
  37. package/dist/curves/fill-between.d.ts +100 -0
  38. package/dist/curves/index.d.ts +15 -0
  39. package/dist/curves/line-plot.d.ts +104 -0
  40. package/dist/curves/regression.d.ts +124 -0
  41. package/dist/curves/shared.d.ts +52 -0
  42. package/dist/curves/stack-plot.d.ts +140 -0
  43. package/dist/curves/stairs.d.ts +170 -0
  44. package/dist/data/channels.d.ts +170 -0
  45. package/dist/end-space.d.ts +81 -0
  46. package/dist/entries/definitions.d.ts +20 -0
  47. package/dist/entries/definitions.js +6 -0
  48. package/dist/frame/band-axis.d.ts +42 -0
  49. package/dist/frame/coords.d.ts +111 -0
  50. package/dist/frame/fit.d.ts +170 -0
  51. package/dist/frame/format.d.ts +40 -0
  52. package/dist/frame/guide-metrics.d.ts +36 -0
  53. package/dist/frame/guides.d.ts +67 -0
  54. package/dist/frame/keys.d.ts +96 -0
  55. package/dist/frame/layout.d.ts +145 -0
  56. package/dist/frame/registry.d.ts +31 -0
  57. package/dist/frame/reports.d.ts +53 -0
  58. package/dist/frame/secondary-axes.d.ts +73 -0
  59. package/dist/frame/secondary.d.ts +56 -0
  60. package/dist/frame/tooltip-overlay.d.ts +64 -0
  61. package/dist/frame/types.d.ts +658 -0
  62. package/dist/grids/barbs.d.ts +51 -0
  63. package/dist/grids/cell-rects.d.ts +37 -0
  64. package/dist/grids/cells.d.ts +130 -0
  65. package/dist/grids/contour-f.d.ts +80 -0
  66. package/dist/grids/contour-shared.d.ts +53 -0
  67. package/dist/grids/contour.d.ts +84 -0
  68. package/dist/grids/dendrogram.d.ts +104 -0
  69. package/dist/grids/heatmap.d.ts +163 -0
  70. package/dist/grids/hex-bin.d.ts +93 -0
  71. package/dist/grids/hist2d.d.ts +107 -0
  72. package/dist/grids/imshow.d.ts +84 -0
  73. package/dist/grids/index.d.ts +26 -0
  74. package/dist/grids/pcolormesh.d.ts +90 -0
  75. package/dist/grids/ramp-cells.d.ts +66 -0
  76. package/dist/grids/tri-contour.d.ts +120 -0
  77. package/dist/grids/tri-shared.d.ts +61 -0
  78. package/dist/grids/tripcolor.d.ts +73 -0
  79. package/dist/guides/colorbar.d.ts +110 -0
  80. package/dist/guides/index.d.ts +11 -0
  81. package/dist/guides/legend.d.ts +118 -0
  82. package/dist/guides/nodes.d.ts +13 -0
  83. package/dist/guides/size-legend.d.ts +233 -0
  84. package/dist/hierarchy/breadcrumbs.d.ts +133 -0
  85. package/dist/hierarchy/circle-pack.d.ts +72 -0
  86. package/dist/hierarchy/drill.d.ts +245 -0
  87. package/dist/hierarchy/frame.d.ts +67 -0
  88. package/dist/hierarchy/icicle.d.ts +76 -0
  89. package/dist/hierarchy/index.d.ts +20 -0
  90. package/dist/hierarchy/labels.d.ts +24 -0
  91. package/dist/hierarchy/mosaic.d.ts +130 -0
  92. package/dist/hierarchy/own-tooltip.d.ts +12 -0
  93. package/dist/hierarchy/props.d.ts +13 -0
  94. package/dist/hierarchy/sankey.d.ts +132 -0
  95. package/dist/hierarchy/shared.d.ts +247 -0
  96. package/dist/hierarchy/sunburst.d.ts +74 -0
  97. package/dist/hierarchy/tree.d.ts +124 -0
  98. package/dist/hierarchy/treemap.d.ts +76 -0
  99. package/dist/index.d.ts +29 -0
  100. package/dist/index.js +5 -0
  101. package/dist/item-tooltip.d.ts +33 -0
  102. package/dist/join.d.ts +223 -0
  103. package/dist/math/3d/bar3d.d.ts +27 -0
  104. package/dist/math/3d/quiver3d.d.ts +26 -0
  105. package/dist/math/3d/scatter3d.d.ts +15 -0
  106. package/dist/math/3d/stem3d.d.ts +22 -0
  107. package/dist/math/3d/surfaceGrid3d.d.ts +33 -0
  108. package/dist/math/3d/trisurface.d.ts +11 -0
  109. package/dist/math/3d/voxels.d.ts +17 -0
  110. package/dist/math/aggregate.d.ts +68 -0
  111. package/dist/math/bar.d.ts +31 -0
  112. package/dist/math/barLabels.d.ts +83 -0
  113. package/dist/math/barbs.d.ts +36 -0
  114. package/dist/math/boxplot.d.ts +36 -0
  115. package/dist/math/breadcrumbs.d.ts +128 -0
  116. package/dist/math/bubble.d.ts +38 -0
  117. package/dist/math/bullet.d.ts +110 -0
  118. package/dist/math/chord.d.ts +103 -0
  119. package/dist/math/cluster.d.ts +88 -0
  120. package/dist/math/contour.d.ts +48 -0
  121. package/dist/math/contourf.d.ts +50 -0
  122. package/dist/math/dodge.d.ts +36 -0
  123. package/dist/math/ecdf.d.ts +41 -0
  124. package/dist/math/errorbar.d.ts +27 -0
  125. package/dist/math/eventplot.d.ts +26 -0
  126. package/dist/math/facet.d.ts +90 -0
  127. package/dist/math/fillBetween.d.ts +28 -0
  128. package/dist/math/gauge.d.ts +71 -0
  129. package/dist/math/hexbin.d.ts +20 -0
  130. package/dist/math/hierarchy.d.ts +179 -0
  131. package/dist/math/hierarchyJoin.d.ts +59 -0
  132. package/dist/math/histogram.d.ts +36 -0
  133. package/dist/math/histogram2d.d.ts +44 -0
  134. package/dist/math/imshow.d.ts +26 -0
  135. package/dist/math/index.d.ts +139 -0
  136. package/dist/math/index.js +3 -0
  137. package/dist/math/jitter.d.ts +16 -0
  138. package/dist/math/join.d.ts +135 -0
  139. package/dist/math/keyframes.d.ts +127 -0
  140. package/dist/math/legend.d.ts +120 -0
  141. package/dist/math/line.d.ts +53 -0
  142. package/dist/math/morph.d.ts +81 -0
  143. package/dist/math/mosaic.d.ts +119 -0
  144. package/dist/math/ordinal.d.ts +79 -0
  145. package/dist/math/parallel.d.ts +38 -0
  146. package/dist/math/pcolormesh.d.ts +22 -0
  147. package/dist/math/pie.d.ts +105 -0
  148. package/dist/math/polarArea.d.ts +34 -0
  149. package/dist/math/radar.d.ts +110 -0
  150. package/dist/math/range.d.ts +98 -0
  151. package/dist/math/regression.d.ts +109 -0
  152. package/dist/math/reveal.d.ts +63 -0
  153. package/dist/math/sankey.d.ts +154 -0
  154. package/dist/math/scatter.d.ts +14 -0
  155. package/dist/math/shared/binning.d.ts +23 -0
  156. package/dist/math/shared/gridCells.d.ts +41 -0
  157. package/dist/math/shared/gridExtent.d.ts +5 -0
  158. package/dist/math/shared/pairs.d.ts +2 -0
  159. package/dist/math/shared/polar.d.ts +23 -0
  160. package/dist/math/stack.d.ts +69 -0
  161. package/dist/math/stackplot.d.ts +35 -0
  162. package/dist/math/stairs.d.ts +17 -0
  163. package/dist/math/stem.d.ts +21 -0
  164. package/dist/math/symbol.d.ts +25 -0
  165. package/dist/math/tree.d.ts +117 -0
  166. package/dist/math/tricontour.d.ts +76 -0
  167. package/dist/math/violin.d.ts +99 -0
  168. package/dist/math/waffle.d.ts +48 -0
  169. package/dist/math/waterfall.d.ts +28 -0
  170. package/dist/math-CSHNpGej.js +3648 -0
  171. package/dist/mix.d.ts +24 -0
  172. package/dist/multiview/brush.d.ts +165 -0
  173. package/dist/multiview/chart-group.d.ts +265 -0
  174. package/dist/multiview/chart-link.d.ts +188 -0
  175. package/dist/multiview/chart-zoom.d.ts +144 -0
  176. package/dist/multiview/facet.d.ts +238 -0
  177. package/dist/multiview/group-guides.d.ts +99 -0
  178. package/dist/multiview/index.d.ts +17 -0
  179. package/dist/multiview/joint-plot.d.ts +114 -0
  180. package/dist/multiview/pair-plot.d.ts +153 -0
  181. package/dist/multiview/panels.d.ts +22 -0
  182. package/dist/multiview/parallel-coordinates.d.ts +109 -0
  183. package/dist/points/event-plot.d.ts +67 -0
  184. package/dist/points/index.d.ts +19 -0
  185. package/dist/points/labels.d.ts +70 -0
  186. package/dist/points/links.d.ts +123 -0
  187. package/dist/points/rects.d.ts +80 -0
  188. package/dist/points/rug.d.ts +72 -0
  189. package/dist/points/scatter.d.ts +169 -0
  190. package/dist/points/segment-marks.d.ts +39 -0
  191. package/dist/points/shared.d.ts +34 -0
  192. package/dist/points/stem.d.ts +75 -0
  193. package/dist/points/strip.d.ts +145 -0
  194. package/dist/points/symbol-marker.d.ts +33 -0
  195. package/dist/points/ticks.d.ts +102 -0
  196. package/dist/props.d.ts +126 -0
  197. package/dist/radial/chord.d.ts +148 -0
  198. package/dist/radial/gauge.d.ts +126 -0
  199. package/dist/radial/index.d.ts +15 -0
  200. package/dist/radial/pie-chart.d.ts +143 -0
  201. package/dist/radial/polar-area-chart.d.ts +135 -0
  202. package/dist/radial/radar-chart.d.ts +176 -0
  203. package/dist/radial/radial-bar-chart.d.ts +116 -0
  204. package/dist/radial/shared.d.ts +78 -0
  205. package/dist/radial/waffle.d.ts +130 -0
  206. package/dist/raster.d.ts +43 -0
  207. package/dist/series.d.ts +71 -0
  208. package/dist/src-CwGo1bes.js +19221 -0
  209. package/dist/stagger.d.ts +54 -0
  210. package/dist/statistics/box-plot.d.ts +151 -0
  211. package/dist/statistics/error-bar.d.ts +148 -0
  212. package/dist/statistics/groups.d.ts +140 -0
  213. package/dist/statistics/index.d.ts +7 -0
  214. package/dist/statistics/violin-plot.d.ts +143 -0
  215. package/dist/text-width.d.ts +9 -0
  216. package/dist/tooltip.d.ts +276 -0
  217. package/dist/util.d.ts +33 -0
  218. package/dist/voxels-9lJ2TZS4.js +235 -0
  219. package/dist/wireframe3d-D157GZAq.js +345 -0
  220. package/package.json +86 -3
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Props shared by chart marks, documented once here: the data transition
3
+ * (`to`, `blend`, `staging`, `enterStagger`, `key`), the staggered reveal
4
+ * (`stagger`) and the named reveal styles. A mark re-declares a prop only
5
+ * where its meaning is narrower.
6
+ */
7
+ import type { BandKey } from "@sophistry/core/geometry";
8
+ import type { Channel } from "./data/channels.js";
9
+ import type { JoinStaging } from "./math/join.js";
10
+ /**
11
+ * Order for `stagger` and `enterStagger`: `"position"` follows the mark's own
12
+ * layout (along x, by value, by category); `"random"` shuffles by a hash of
13
+ * each datum's `key`, the same every frame, so it scrubs.
14
+ *
15
+ * @see https://sophistry.dev/guides/chart-animation/#reveals
16
+ * @category Charts
17
+ */
18
+ export type StaggerOrder = "position" | "random";
19
+ /**
20
+ * How a curve-like mark (`<LinePlot>`, `<Ecdf>`, `<Stairs>`, `<FillBetween>`)
21
+ * reveals: `"x"` sweeps left to right, `"length"` draws along its arc length.
22
+ *
23
+ * @see https://sophistry.dev/guides/chart-animation/#reveals
24
+ * @category Charts
25
+ */
26
+ export type CurveReveal = "x" | "length";
27
+ /** How `<Density>` reveals: `"x"` sweeps in along x, `"grow"` rises from the baseline. @category Charts */
28
+ export type DensityReveal = "x" | "grow";
29
+ /** How `<StackPlot>` reveals: `"grow"` from the baseline, `"x"` along x, `"length"` by arc length. @category Charts */
30
+ export type StackReveal = "grow" | "x" | "length";
31
+ /** How bars reveal: `"grow"` out of their foot, `"stack"` scaled about zero together, `"fade"` in place. @category Charts */
32
+ export type BarReveal = "grow" | "stack" | "fade";
33
+ /** How a radial mark (`<PieChart>`, `<RadarChart>`) reveals: `"grow"` out from the centre, `"sweep"` round the turn. @category Charts */
34
+ export type RadialReveal = "grow" | "sweep";
35
+ /** How a frame's layers reveal: `"layers"` each its own way, `"x"` behind one shared front. @category Charts */
36
+ export type LayersReveal = "layers" | "x";
37
+ /**
38
+ * A mark's data transition from `data` to `to`, driven by `blend`.
39
+ *
40
+ * @see https://sophistry.dev/guides/chart-animation/#data-transitions
41
+ * @category Charts
42
+ */
43
+ export interface TransitionProps<T> {
44
+ /**
45
+ * The data to transition to. Marks in both `data` and `to` move, marks only
46
+ * in `to` enter, marks only in `data` exit. At `blend` 0 the chart shows
47
+ * `data`, at 1 it shows `to`.
48
+ */
49
+ to?: readonly T[];
50
+ /** Transition progress from `data` (0) to `to` (1). @default 0 */
51
+ blend?: number;
52
+ /**
53
+ * How `blend` is spent: `"staged"` runs exit, then move, then enter, each
54
+ * eased (so drive `blend` linearly); `"together"` runs all at once, linearly.
55
+ * @default "staged"
56
+ */
57
+ staging?: JoinStaging;
58
+ /**
59
+ * Fraction of the enter stage spent staggering entering marks in `to`'s
60
+ * order, 0..0.95; 0 enters them together. Moves and exits never stagger.
61
+ * @default 0
62
+ */
63
+ enterStagger?: number;
64
+ }
65
+ /**
66
+ * {@link TransitionProps} for a per-datum mark, matching data between the
67
+ * two ends by `key`.
68
+ *
69
+ * @see https://sophistry.dev/guides/chart-animation/#data-transitions
70
+ * @category Charts
71
+ */
72
+ export interface KeyedTransitionProps<T> extends TransitionProps<T> {
73
+ /**
74
+ * Each mark's identity: a key of `T` or `(d, i) => key`. A datum with the
75
+ * same key keeps its mark across updates and transitions. Defaults to the datum's index.
76
+ */
77
+ key?: Channel<T, BandKey>;
78
+ }
79
+ /**
80
+ * {@link TransitionProps} for a mark drawing one shape per `series` (lines,
81
+ * curves, areas): shapes are matched by `series` and morphed.
82
+ *
83
+ * @see https://sophistry.dev/guides/chart-animation/#data-transitions
84
+ * @category Charts
85
+ */
86
+ export interface SeriesTransitionProps<T> extends TransitionProps<T> {
87
+ /** As {@link TransitionProps.staging}, with series morphing in the move stage. @default "staged" */
88
+ staging?: JoinStaging;
89
+ /**
90
+ * Fraction of the enter stage spent staggering entering series in `to`'s
91
+ * order, 0..0.95; each sweeps in over its own share. Moves and exits never
92
+ * stagger.
93
+ * @default 0
94
+ */
95
+ enterStagger?: number;
96
+ }
97
+ /**
98
+ * A mark's staggered reveal.
99
+ *
100
+ * @see https://sophistry.dev/guides/chart-animation/#reveals
101
+ * @category Charts
102
+ */
103
+ export interface RevealProps {
104
+ /**
105
+ * Fraction of the reveal spent staggering one mark after the next, 0..0.95;
106
+ * 0 reveals all marks together.
107
+ * @default 0
108
+ */
109
+ stagger?: number;
110
+ }
111
+ /** Checks at compile time that a key list names every key of `P` and nothing else. */
112
+ export declare const TRANSITION_KEYS: readonly ["to", "blend", "staging", "enterStagger"];
113
+ /** {@link KeyedTransitionProps}' keys. */
114
+ export declare const KEYED_TRANSITION_KEYS: readonly ["to", "blend", "staging", "enterStagger", "key"];
115
+ /** {@link RevealProps}' keys. */
116
+ export declare const REVEAL_KEYS: readonly ["stagger"];
117
+ /**
118
+ * The datum type chart definitions are declared over. A definition is one
119
+ * value (`scatter`), not a generic function, so its props cannot follow the
120
+ * type of `data`; over `any`, a channel key is any string and a channel
121
+ * function receives the datum untyped. Annotate the function's parameter
122
+ * (`(d: Row) => d.sales`) for checked reads.
123
+ *
124
+ * @category Channels
125
+ */
126
+ export type AnyDatum = any;
@@ -0,0 +1,148 @@
1
+ /**
2
+ * `chord`: flows between groups round a circle.
3
+ *
4
+ * Two path batches: the ribbons (each its own fill and fade, paint order
5
+ * under the ring) and the group arcs (each its own fill). Hover, taps,
6
+ * tooltips and accessible names resolve per ribbon and per arc through
7
+ * `event.item` / `itemLabel`. Group names are anchored `label` nodes.
8
+ */
9
+ import type { ColorInput } from "@sophistry/core";
10
+ import type { Point } from "@sophistry/core/geometry";
11
+ import type { Channel, ColorChannel, RequiredUnless } from "../data/channels.js";
12
+ import type { SankeyId } from "../math/sankey.js";
13
+ import type { TooltipSpec } from "../tooltip.js";
14
+ /** @category Charts */
15
+ export interface ChordBaseProps<L, N> {
16
+ /** The flows, one per datum; flows between the same two groups (same direction) add up. */
17
+ data: readonly L[];
18
+ /** The group a flow leaves. */
19
+ source: Channel<L, SankeyId>;
20
+ /** The group a flow enters. */
21
+ target: Channel<L, SankeyId>;
22
+ /** The flow's size; non-finite and negative values count as 0. */
23
+ value: Channel<L, number>;
24
+ /**
25
+ * The groups, in the order they go round the circle and are coloured. Every id a flow names
26
+ * must be here (else throws). Defaults to the flows' endpoints in first-seen order.
27
+ */
28
+ nodes?: readonly N[];
29
+ /**
30
+ * A group's id, matched against `source`/`target`. Defaults to the datum itself, when `nodes`
31
+ * is `(string | number)[]`.
32
+ */
33
+ nodeId?: Channel<N, SankeyId>;
34
+ /** The text beside a group's arc. Defaults to its id. */
35
+ nodeLabel?: Channel<N, string>;
36
+ /** Centre of the diagram. Defaults to the origin. */
37
+ center?: Point;
38
+ /**
39
+ * Outer radius of the ring; labels sit outside it.
40
+ * @default 2
41
+ */
42
+ radius?: number;
43
+ /** Thickness of the ring. Defaults to 0.08 × `radius`. */
44
+ thickness?: number;
45
+ /**
46
+ * Gap between neighbouring groups, in radians.
47
+ * @default 0.04
48
+ */
49
+ padAngle?: number;
50
+ /**
51
+ * Angle the first group begins at, in radians from +x. The default is 12 o'clock.
52
+ * @default Math.PI / 2
53
+ */
54
+ startAngle?: number;
55
+ /**
56
+ * Go round clockwise.
57
+ * @default true
58
+ */
59
+ clockwise?: boolean;
60
+ /**
61
+ * One chord per flow direction, and arcs sized by inflow plus outflow, so a group that only
62
+ * receives still shows. Otherwise one chord per pair of groups, arcs sized by outflow.
63
+ * @default false
64
+ */
65
+ directed?: boolean;
66
+ /**
67
+ * With `directed`: draw each chord's receiving end as an arrowhead.
68
+ * @default false
69
+ */
70
+ arrows?: boolean;
71
+ /** Length of an arrowhead. Defaults to 0.08 × `radius`. */
72
+ arrowSize?: number;
73
+ /** Group colours, cycled by group order. Defaults to the theme's categorical colours. */
74
+ colors?: readonly ColorInput[];
75
+ /**
76
+ * A chord's colour: its `"source"` group's (the larger end, or the sender when `directed`), its
77
+ * `"target"` group's, or a colour channel given the chord's first flow.
78
+ * @default "source"
79
+ */
80
+ ribbonColor?: "source" | "target" | ColorChannel<L>;
81
+ /**
82
+ * Fill opacity of the chords, 0..1.
83
+ * @default 0.55
84
+ */
85
+ ribbonOpacity?: number;
86
+ /**
87
+ * Draw group labels.
88
+ * @default true
89
+ */
90
+ labels?: boolean;
91
+ /**
92
+ * Font size of group labels.
93
+ * @default 0.22
94
+ */
95
+ labelFontSize?: number;
96
+ /**
97
+ * Reveal, 0..1: the ring sweeps round from `startAngle` with its labels, then the chords fade
98
+ * in.
99
+ * @default 1
100
+ * @see https://sophistry.dev/guides/chart-animation/#reveals
101
+ */
102
+ progress?: number;
103
+ /**
104
+ * Fraction of the chords' reveal spent staggering them, 0..0.95.
105
+ * @default 0.5
106
+ */
107
+ stagger?: number;
108
+ /**
109
+ * Hover tooltip: `true` shows "A → B: value" on a chord and "name: value" on a group; a
110
+ * function replaces the chord text, given its first flow.
111
+ */
112
+ tooltip?: TooltipSpec<L>;
113
+ /** Paint order of the chords; the ring paints above them. */
114
+ zIndex?: number;
115
+ visible?: boolean;
116
+ }
117
+ /**
118
+ * Props of {@link chord}: `nodeId` is required when `nodes` holds records.
119
+ *
120
+ * @category Charts
121
+ */
122
+ export type ChordProps<L, N = SankeyId> = ChordBaseProps<L, N> & RequiredUnless<N, SankeyId, "nodeId">;
123
+ /**
124
+ * A chord diagram: flows between groups round a circle. Each group is an arc as long as its
125
+ * total, and each pair with any flow is joined by a ribbon as wide as the flow each way. Takes
126
+ * `source`/`target`/`value` like `sankey`; draws in scene units. Ribbons and arcs are one path
127
+ * batch each. See {@link chordLayout} and {@link chordRibbon} for the geometry alone.
128
+ *
129
+ * @example
130
+ * ```ts
131
+ * import { chord } from "@sophistry/charts";
132
+ *
133
+ * chord.create({
134
+ * data: [
135
+ * { from: "north", to: "south", n: 5 },
136
+ * { from: "south", to: "north", n: 3 },
137
+ * ],
138
+ * source: "from",
139
+ * target: "to",
140
+ * value: "n",
141
+ * tooltip: true,
142
+ * });
143
+ * ```
144
+ *
145
+ * @see https://sophistry.dev/reference/chart-catalogue/#flows
146
+ * @category Charts
147
+ */
148
+ export declare const chord: import("@sophistry/core").Definition<ChordBaseProps<any, any>, import("@sophistry/core/internal").CompositeNode<ChordBaseProps<any, any>>, keyof ChordBaseProps<any, any>>;
@@ -0,0 +1,126 @@
1
+ /**
2
+ * `gauge`: one value on an arc with a centre readout.
3
+ *
4
+ * One reading, so mostly single nodes: the track and the value arc
5
+ * (`annularSector`), the needle and its hub, the counting readout
6
+ * (`decimalNumber`) and the captions. The threshold bands, one outline each,
7
+ * draw as one path batch. Nodes are made once and shown or hidden; none is
8
+ * rebuilt while the reveal plays.
9
+ */
10
+ import type { ColorInput } from "@sophistry/core";
11
+ import type { Point } from "@sophistry/core/geometry";
12
+ import type { TooltipSpec } from "../tooltip.js";
13
+ /**
14
+ * One threshold zone of a {@link gauge}, given by where it *ends*.
15
+ *
16
+ * @category Charts
17
+ */
18
+ export interface GaugeBand {
19
+ /**
20
+ * The value this band runs up to, in data units, starting where the previous band ends (or at
21
+ * `min`). `Infinity` means "to `max`".
22
+ */
23
+ to: number;
24
+ /** The band's colour. Defaults to the theme's categorical colours, by band index. */
25
+ color?: ColorInput;
26
+ }
27
+ /** @category Charts */
28
+ export interface GaugeProps {
29
+ /**
30
+ * The reading, in data units. Drawn clamped to `[min, max]`; the readout shows it unclamped.
31
+ */
32
+ value: number;
33
+ /**
34
+ * The value at the start of the arc.
35
+ * @default 0
36
+ */
37
+ min?: number;
38
+ /**
39
+ * The value at the end of the arc.
40
+ * @default 100
41
+ */
42
+ max?: number;
43
+ /** Centre of the gauge. Defaults to the origin. */
44
+ center?: Point;
45
+ /**
46
+ * Outer radius of the arc.
47
+ * @default 1
48
+ */
49
+ radius?: number;
50
+ /** Radial thickness of the arc. Defaults to 0.18 × `radius`. */
51
+ thickness?: number;
52
+ /**
53
+ * Where `min` sits, in radians from +x (counter-clockwise positive, as on `arc`). The default
54
+ * is 210°: with the default `endAngle`, a 240° arc open at the bottom.
55
+ * @default 7 * Math.PI / 6
56
+ */
57
+ startAngle?: number;
58
+ /**
59
+ * Where `max` sits, in radians from +x; less than `startAngle` reads clockwise.
60
+ * @default -Math.PI / 6
61
+ */
62
+ endAngle?: number;
63
+ /**
64
+ * Threshold zones in ascending order (`[{ to: 60 }, { to: 85 }, { to: 100 }]`), drawn as a thin
65
+ * track inside the arc. Unless `color` is given, the value arc takes its band's colour.
66
+ */
67
+ bands?: readonly GaugeBand[];
68
+ /**
69
+ * Colour of the value arc. Defaults to the value's band colour, else the theme's first series
70
+ * colour.
71
+ */
72
+ color?: ColorInput;
73
+ /** Colour of the empty track behind the value arc. Defaults to the theme's grid colour. */
74
+ trackColor?: ColorInput;
75
+ /**
76
+ * Draw a needle from the centre to the value.
77
+ * @default false
78
+ */
79
+ needle?: boolean;
80
+ /**
81
+ * Decimal places of the readout (and tooltip).
82
+ * @default 0
83
+ */
84
+ decimalPlaces?: number;
85
+ /** Suffix on the readout, e.g. `"%"` or `" ms"`. */
86
+ unit?: string;
87
+ /** Readout font size. Defaults to 0.36 × `radius`. */
88
+ valueFontSize?: number;
89
+ /** Caption under the readout. */
90
+ label?: string;
91
+ /** Font size of `label` and the range labels. Defaults to 0.14 × `radius`. */
92
+ labelFontSize?: number;
93
+ /**
94
+ * Write `min` and `max` at the ends of the arc.
95
+ * @default true
96
+ */
97
+ rangeLabels?: boolean;
98
+ /**
99
+ * Reveal, 0..1: track and bands sweep in first, then the value arc sweeps to the value while
100
+ * the readout counts up.
101
+ * @default 1
102
+ * @see https://sophistry.dev/guides/chart-animation/#reveals
103
+ */
104
+ progress?: number;
105
+ /** Hover tooltip on the value arc: `true` for "label: value", or `(value) => string`. */
106
+ tooltip?: TooltipSpec<number>;
107
+ /** Paint order; higher draws later. */
108
+ zIndex?: number;
109
+ visible?: boolean;
110
+ }
111
+ /**
112
+ * A gauge: one value on an arc with a centre readout, the KPI dial of a dashboard. Optional
113
+ * threshold `bands` colour the value by zone; `needle` adds a pointer. Draws in scene units;
114
+ * needs no `chart`.
115
+ *
116
+ * @example
117
+ * ```ts
118
+ * import { gauge } from "@sophistry/charts";
119
+ *
120
+ * gauge.create({ value: 72, unit: "%", label: "CPU", bands: [{ to: 60 }, { to: 85 }, { to: 100 }] });
121
+ * ```
122
+ *
123
+ * @see https://sophistry.dev/reference/chart-catalogue/#gauges-bullets-waffles-mosaics-and-radial-bars
124
+ * @category Charts
125
+ */
126
+ export declare const gauge: import("@sophistry/core").Definition<GaugeProps, import("@sophistry/core/internal").CompositeNode<GaugeProps>, keyof GaugeProps>;
@@ -0,0 +1,15 @@
1
+ /** Family barrel: radial. Owned by its family; re-exported from the package entry. */
2
+ export type { ChordBaseProps, ChordProps } from "./chord.js";
3
+ export { chord } from "./chord.js";
4
+ export type { GaugeBand, GaugeProps } from "./gauge.js";
5
+ export { gauge } from "./gauge.js";
6
+ export type { PieChartBaseProps, PieChartProps } from "./pie-chart.js";
7
+ export { pieChart } from "./pie-chart.js";
8
+ export type { PolarAreaChartBaseProps, PolarAreaChartProps, } from "./polar-area-chart.js";
9
+ export { polarAreaChart } from "./polar-area-chart.js";
10
+ export type { RadarChartBaseProps, RadarChartProps } from "./radar-chart.js";
11
+ export { radarChart } from "./radar-chart.js";
12
+ export type { RadialBarChartBaseProps, RadialBarChartProps, } from "./radial-bar-chart.js";
13
+ export { radialBarChart } from "./radial-bar-chart.js";
14
+ export type { WaffleBaseProps, WaffleProps } from "./waffle.js";
15
+ export { waffle } from "./waffle.js";
@@ -0,0 +1,143 @@
1
+ /**
2
+ * `pieChart`: a pie (or doughnut) of one wedge per datum.
3
+ *
4
+ * The wedges draw as one path batch: each item is the native curve outline
5
+ * of a `sector` (or `annularSector`, with a hole), with its own
6
+ * fill; the stroke, its width and the fill opacity are shared. Per-wedge
7
+ * picking and accessible names go through the batch's items (`event.item`,
8
+ * `itemLabel`). Slice labels stay `label` nodes, one per present slice.
9
+ */
10
+ import type { ColorInput } from "@sophistry/core";
11
+ import type { BandKey, Point } from "@sophistry/core/geometry";
12
+ import type { Channel, ColorChannel, RequiredUnless } from "../data/channels.js";
13
+ import type { KeyedJoin } from "../math/join.js";
14
+ import type { KeyedTransitionProps, RadialReveal } from "../props.js";
15
+ /** @category Charts */
16
+ export interface PieChartBaseProps<T> extends KeyedTransitionProps<T> {
17
+ /** One slice per datum. */
18
+ data: readonly T[];
19
+ /**
20
+ * The slice's value, in data units. Defaults to the datum when `data` is `number[]`; required
21
+ * otherwise. Negative and non-finite values count as 0 (an empty slice).
22
+ */
23
+ value?: Channel<T, number>;
24
+ /**
25
+ * The slice's visible label. Omitted, a rounded percentage. See `ariaLabel` for the accessible
26
+ * name.
27
+ */
28
+ label?: Channel<T, string>;
29
+ /**
30
+ * The chart's accessible name; each slice is announced as `"<ariaLabel>: <slice label>"`.
31
+ * Omitted, slices are not exposed to assistive technology.
32
+ */
33
+ ariaLabel?: string;
34
+ /** Centre of the chart. Defaults to the origin. */
35
+ center?: Point;
36
+ /**
37
+ * Outer radius.
38
+ * @default 1
39
+ */
40
+ radius?: number;
41
+ /**
42
+ * Radius of a hole through the centre, making a doughnut chart. `0` draws a plain pie.
43
+ * @default 0
44
+ */
45
+ innerRadius?: number;
46
+ /**
47
+ * Reveal, 0..1: `reveal="grow"` opens every slice at once, keeping their true ratio, until they
48
+ * close the circle; `"sweep"` wipes round the pie, uncovering slices in data order.
49
+ * @default 1
50
+ * @see https://sophistry.dev/guides/chart-animation/#reveals
51
+ */
52
+ progress?: number;
53
+ reveal?: RadialReveal;
54
+ /**
55
+ * Angle the first slice begins at, in radians from +x. The default is 12 o'clock.
56
+ * @default Math.PI / 2
57
+ */
58
+ startAngle?: number;
59
+ /**
60
+ * Whether slices run clockwise.
61
+ * @default true
62
+ */
63
+ clockwise?: boolean;
64
+ /** One colour for every slice, or `(d, i) => colour`. Wins over `colors`. */
65
+ color?: ColorChannel<T>;
66
+ /** Colours cycled across the slices by index. Defaults to the theme's categorical colours. */
67
+ colors?: readonly ColorInput[];
68
+ /**
69
+ * Whether to draw slice labels.
70
+ * @default true
71
+ */
72
+ labels?: boolean;
73
+ /** Label font size. */
74
+ labelFontSize?: number;
75
+ /** Label colour. Defaults to the theme background. */
76
+ labelColor?: ColorInput;
77
+ /**
78
+ * Each slice's identity across transitions. See {@link KeyedTransitionProps}. Defaults to
79
+ * `label`, else the index.
80
+ */
81
+ key?: Channel<T, BandKey>;
82
+ /**
83
+ * The data to transition to, matched to `data` by `key`: values blend and the pie is re-laid
84
+ * out every frame, so the slices always fill the turn; leaving slices shrink away, new ones
85
+ * open up. See {@link KeyedTransitionProps}.
86
+ * @see https://sophistry.dev/guides/chart-animation/#data-transitions
87
+ */
88
+ to?: readonly T[];
89
+ /** Slice outline. Defaults to the theme background. */
90
+ stroke?: ColorInput;
91
+ /**
92
+ * Outline width.
93
+ * @default 0.02
94
+ */
95
+ strokeWidth?: number;
96
+ /** Fill opacity of the slices, 0..1. */
97
+ fillOpacity?: number;
98
+ /** Paint order. */
99
+ zIndex?: number;
100
+ /** Set to false to hide the chart. */
101
+ visible?: boolean;
102
+ }
103
+ /**
104
+ * Props of {@link pieChart}: `value` is required unless `data` is `number[]`.
105
+ *
106
+ * @category Charts
107
+ */
108
+ export type PieChartProps<T> = PieChartBaseProps<T> & RequiredUnless<T, number, "value">;
109
+ /**
110
+ * A pie chart, or a doughnut with `innerRadius`: one slice per value, sized by its share of
111
+ * the total, separated by a thin background-coloured outline. Draws in scene units; nothing is
112
+ * drawn if every value is 0. The slices are one path batch (`event.item` is the slice's place
113
+ * among the drawn ones). See {@link pieSlices} for the angle math alone.
114
+ *
115
+ * @example
116
+ * ```ts
117
+ * import { pieChart } from "@sophistry/charts";
118
+ *
119
+ * pieChart.create({
120
+ * data: [
121
+ * { lang: "Rust", share: 3 },
122
+ * { lang: "Go", share: 2 },
123
+ * ],
124
+ * value: "share",
125
+ * label: "lang",
126
+ * innerRadius: 0.4,
127
+ * });
128
+ * ```
129
+ *
130
+ * @see https://sophistry.dev/reference/chart-catalogue/#pie-polar-area-and-radar
131
+ * @category Charts
132
+ */
133
+ export declare const pieChart: import("@sophistry/core").Definition<PieChartBaseProps<any>, import("@sophistry/core/internal").CompositeNode<PieChartBaseProps<any>>, keyof PieChartBaseProps<any>>;
134
+ /** Both ends' ring orders. */
135
+ export interface RingOrders {
136
+ from: readonly BandKey[];
137
+ to: readonly BandKey[];
138
+ }
139
+ /**
140
+ * The ring order at each end: one order unless the keys both ends have are
141
+ * reordered. Memoise it on the join (kept by identity while the keys hold).
142
+ */
143
+ export declare function ringOrders(join: KeyedJoin | undefined, keys: readonly BandKey[]): RingOrders;