@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,135 @@
1
+ /**
2
+ * `polarAreaChart`: a rose of equal-angle wedges whose radius carries the
3
+ * value.
4
+ *
5
+ * The wedges draw as one path batch (each item the native outline of a
6
+ * `sector`, with its own fill); per-wedge picking and accessible names
7
+ * go through its items. Wedge labels stay `label` nodes. Inside a chart the
8
+ * layer reports its series (for the legend) and its transition (for the
9
+ * staging); it fits no axes.
10
+ */
11
+ import type { ColorInput } from "@sophistry/core";
12
+ import type { BandKey, Point } from "@sophistry/core/geometry";
13
+ import type { Channel, ColorChannel, RequiredUnless } from "../data/channels.js";
14
+ import type { KeyedTransitionProps, RevealProps } from "../props.js";
15
+ /** @category Charts */
16
+ export interface PolarAreaChartBaseProps<T> extends KeyedTransitionProps<T>, RevealProps {
17
+ /** One wedge per datum. */
18
+ data: readonly T[];
19
+ /**
20
+ * The wedge'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 wedge).
22
+ */
23
+ value?: Channel<T, number>;
24
+ /**
25
+ * The wedge'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 wedge is announced as `"<ariaLabel>: <wedge label>"`.
31
+ * Omitted, wedges are not exposed to assistive technology.
32
+ */
33
+ ariaLabel?: string;
34
+ /** Centre of the chart. Defaults to the origin. */
35
+ center?: Point;
36
+ /**
37
+ * Radius a value of `maxValue` reaches.
38
+ * @default 1
39
+ */
40
+ radius?: number;
41
+ /**
42
+ * The value that reaches `radius`. Pin it to keep the scale fixed as `data` changes. Defaults
43
+ * to the greatest value in `data`.
44
+ */
45
+ maxValue?: number;
46
+ /**
47
+ * Angle the first wedge begins at, in radians from +x. The default is 12 o'clock.
48
+ * @default Math.PI / 2
49
+ */
50
+ startAngle?: number;
51
+ /**
52
+ * Whether wedges run clockwise.
53
+ * @default true
54
+ */
55
+ clockwise?: boolean;
56
+ /**
57
+ * Reveal, 0..1: one sweep round the chart from `startAngle`, uncovering wedges in data order.
58
+ * @default 1
59
+ * @see https://sophistry.dev/guides/chart-animation/#reveals
60
+ */
61
+ progress?: number;
62
+ /**
63
+ * Fraction of the reveal spent staggering wedge after wedge, 0..0.95; 0 opens every wedge
64
+ * together. Defaults to one continuous sweep, `(n − 1) / n`.
65
+ */
66
+ stagger?: number;
67
+ /**
68
+ * The category of each wedge: colours wedges through the chart's shared colour scale and
69
+ * legend. `color` and `colors` win.
70
+ */
71
+ series?: Channel<T, BandKey>;
72
+ /** One colour for every wedge, or `(d, i) => colour`. Wins over `colors` and `series`. */
73
+ color?: ColorChannel<T>;
74
+ /**
75
+ * Colours cycled across the wedges by index. Wins over `series`. Defaults to the `series`
76
+ * colours, else the theme's categorical colours.
77
+ */
78
+ colors?: readonly ColorInput[];
79
+ /**
80
+ * Whether to draw wedge labels.
81
+ * @default true
82
+ */
83
+ labels?: boolean;
84
+ /** Label font size. */
85
+ labelFontSize?: number;
86
+ /** Label colour. Defaults to the theme background. */
87
+ labelColor?: ColorInput;
88
+ /**
89
+ * Each wedge's identity across transitions. See {@link KeyedTransitionProps}. Defaults to
90
+ * `label`, else the place within its `series`, else the index.
91
+ */
92
+ key?: Channel<T, BandKey>;
93
+ /**
94
+ * The data to transition to, matched to `data` by `key`: wedges reach out or draw in to their
95
+ * new value; leaving wedges narrow away and new ones open up as the rest make room. See {@link
96
+ * KeyedTransitionProps}.
97
+ * @see https://sophistry.dev/guides/chart-animation/#data-transitions
98
+ */
99
+ to?: readonly T[];
100
+ /** Wedge outline. Defaults to the theme background. */
101
+ stroke?: ColorInput;
102
+ /**
103
+ * Outline width.
104
+ * @default 0.02
105
+ */
106
+ strokeWidth?: number;
107
+ /** Fill opacity of the wedges, 0..1. */
108
+ fillOpacity?: number;
109
+ /** Paint order. */
110
+ zIndex?: number;
111
+ /** Set to false to hide the chart. */
112
+ visible?: boolean;
113
+ }
114
+ /**
115
+ * Props of {@link polarAreaChart}: `value` is required unless `data` is `number[]`.
116
+ *
117
+ * @category Charts
118
+ */
119
+ export type PolarAreaChartProps<T> = PolarAreaChartBaseProps<T> & RequiredUnless<T, number, "value">;
120
+ /**
121
+ * A polar area (rose) chart: wedges of equal angle whose radius carries the value, linear
122
+ * against `maxValue`. Draws in scene units; zero-value wedges are skipped. The wedges are one
123
+ * path batch. See {@link polarAreaSlices} for the wedge math alone.
124
+ *
125
+ * @example
126
+ * ```ts
127
+ * import { polarAreaChart } from "@sophistry/charts";
128
+ *
129
+ * polarAreaChart.create({ data: [4, 2, 3, 1], labels: false, stagger: 0.4 });
130
+ * ```
131
+ *
132
+ * @see https://sophistry.dev/reference/chart-catalogue/#pie-polar-area-and-radar
133
+ * @category Charts
134
+ */
135
+ export declare const polarAreaChart: import("@sophistry/core").Definition<PolarAreaChartBaseProps<any>, import("@sophistry/core/internal").CompositeNode<PolarAreaChartBaseProps<any>>, keyof PolarAreaChartBaseProps<any>>;
@@ -0,0 +1,176 @@
1
+ /**
2
+ * `radarChart`: one polygon per series on evenly spaced axes, over a grid of
3
+ * rings and spokes, with axis names outside.
4
+ *
5
+ * The series polygons draw as one path batch (each item a series' outline
6
+ * with its own fill and stroke colour; fill opacity and stroke width
7
+ * shared). Under `reveal="sweep"` the clip groups are one wedge that
8
+ * clips every series while the series' reveal plays, and a series coming or
9
+ * going (each series, under a staggered sweep) is clipped to its own wedge
10
+ * inside it. A path batch has one clip, so the series split into runs, each
11
+ * run a batch under its own pair of groups: one run (one batch) when no
12
+ * series has a wedge of its own. The grid rings and spokes stay
13
+ * `polygon` / `line` nodes: they reveal by tracing their stroke
14
+ * (`progress`), which a path batch does not do per item, and there are a
15
+ * handful of them. Axis names are `label` nodes.
16
+ */
17
+ import type { ColorInput } from "@sophistry/core";
18
+ import type { BandKey, ClosedCurveKind, Point } from "@sophistry/core/geometry";
19
+ import type { Channel, ColorChannel, RequiredUnless } from "../data/channels.js";
20
+ import type { KeyedTransitionProps, RadialReveal, RevealProps, StaggerOrder } from "../props.js";
21
+ /** @category Charts */
22
+ export interface RadarChartBaseProps<T> extends KeyedTransitionProps<T>, RevealProps {
23
+ /** One polygon per datum (a series), all read against the same axes and `maxValue`. */
24
+ data: readonly T[];
25
+ /**
26
+ * The series' value on each axis, one entry per axis. Defaults to the datum when `data` is
27
+ * `number[][]`; required otherwise.
28
+ */
29
+ axisValues?: Channel<T, readonly number[]>;
30
+ /**
31
+ * One name per axis, drawn outside the rings; when given, every non-empty group must have
32
+ * exactly that many values or the chart throws. `false` draws no names; `true` draws them even
33
+ * when only `toAxisLabels` names the axes.
34
+ */
35
+ axisLabels?: boolean | readonly string[];
36
+ /** Centre of the chart. Defaults to the origin. */
37
+ center?: Point;
38
+ /**
39
+ * Radius a value of `maxValue` reaches.
40
+ * @default 1
41
+ */
42
+ radius?: number;
43
+ /**
44
+ * The value that reaches `radius`. Pin it to keep the scale fixed as `data` changes. Defaults
45
+ * to the greatest value across every series.
46
+ */
47
+ maxValue?: number;
48
+ /**
49
+ * Angle of the first axis, in radians from +x. The default is 12 o'clock.
50
+ * @default Math.PI / 2
51
+ */
52
+ startAngle?: number;
53
+ /**
54
+ * Whether axes run clockwise.
55
+ * @default true
56
+ */
57
+ clockwise?: boolean;
58
+ /**
59
+ * The category of each polygon: colours polygons through the chart's shared colour scale and
60
+ * legend. `color` and `colors` win.
61
+ */
62
+ series?: Channel<T, BandKey>;
63
+ /**
64
+ * Each polygon's identity across data changes and transitions. See {@link
65
+ * KeyedTransitionProps}. Defaults to the datum's place within its `series`, else its index.
66
+ */
67
+ key?: Channel<T, BandKey>;
68
+ /** One colour for every series, or `(d, i) => colour`. Wins over `colors` and `series`. */
69
+ color?: ColorChannel<T>;
70
+ /**
71
+ * Colours cycled across the series by index. Wins over `series`. Defaults to the `series`
72
+ * colours, else the theme's categorical colours.
73
+ */
74
+ colors?: readonly ColorInput[];
75
+ /**
76
+ * Fill opacity of each polygon.
77
+ * @default 0.25
78
+ */
79
+ fillOpacity?: number;
80
+ /**
81
+ * Outline width of each polygon.
82
+ * @default 0.02
83
+ */
84
+ strokeWidth?: number;
85
+ /**
86
+ * Number of concentric grid rings under the data.
87
+ * @default 4
88
+ */
89
+ gridRings?: number;
90
+ /**
91
+ * Whether to draw the grid rings and spokes.
92
+ * @default true
93
+ */
94
+ grid?: boolean;
95
+ /**
96
+ * Axis name font size.
97
+ * @default 0.28
98
+ */
99
+ labelFontSize?: number;
100
+ /**
101
+ * Space between the outer ring and each axis name, which is anchored by its side facing the
102
+ * chart.
103
+ * @default 0.12
104
+ */
105
+ labelGap?: number;
106
+ /** Colour of the grid rings and spokes. Defaults to the theme's grid colour. */
107
+ gridColor?: ColorInput;
108
+ /**
109
+ * Reveal, 0..1: grid and names first, then the series, which grow out of the centre
110
+ * (`reveal="grow"`) or are uncovered by a clockwise sweep (`"sweep"`).
111
+ * @default 1
112
+ * @see https://sophistry.dev/guides/chart-animation/#reveals
113
+ */
114
+ progress?: number;
115
+ reveal?: RadialReveal;
116
+ /**
117
+ * How each polygon runs between vertices: `"linear"` straight edges or `"catmull-rom"` a smooth
118
+ * closed spline. The grid stays polygonal.
119
+ * @default "linear"
120
+ */
121
+ curve?: ClosedCurveKind;
122
+ /**
123
+ * Fraction of the series' reveal spent staggering polygon after polygon in data order, 0..0.95.
124
+ * @default 0
125
+ */
126
+ stagger?: number;
127
+ /**
128
+ * The order `stagger` and `enterStagger` take. See {@link StaggerOrder}.
129
+ * @default "position"
130
+ */
131
+ staggerOrder?: StaggerOrder;
132
+ /**
133
+ * The data to transition to, matched to `data` by `key`: each vertex moves along its axis to
134
+ * its new value. Axes are joined by name (`axisLabels`/`toAxisLabels`), else by position; axes
135
+ * that come and go fold in and out. See {@link KeyedTransitionProps}.
136
+ * @see https://sophistry.dev/guides/chart-animation/#data-transitions
137
+ */
138
+ to?: readonly T[];
139
+ /** `to`'s axis names, one per value of each `to` group. Defaults to `axisLabels`. */
140
+ toAxisLabels?: readonly string[];
141
+ /** Paint order. */
142
+ zIndex?: number;
143
+ /** Set to false to hide the chart. */
144
+ visible?: boolean;
145
+ }
146
+ /**
147
+ * Props of {@link radarChart}: `axisValues` is required unless `data` is `number[][]`.
148
+ *
149
+ * @category Charts
150
+ */
151
+ export type RadarChartProps<T> = RadarChartBaseProps<T> & RequiredUnless<T, readonly number[], "axisValues">;
152
+ /**
153
+ * A radar (spider) chart: one polygon per series, its values on evenly spaced axes around a
154
+ * full turn, over a grid of rings and spokes. Draws in scene units; needs at least 3 axes.
155
+ * Pass `maxValue` when the data can change, so the scale stays fixed. The polygons are one
156
+ * path batch.
157
+ *
158
+ * @example
159
+ * ```ts
160
+ * import { radarChart } from "@sophistry/charts";
161
+ *
162
+ * radarChart.create({
163
+ * data: [
164
+ * { team: "a", v: [3, 4, 5, 2] },
165
+ * { team: "b", v: [4, 2, 3, 5] },
166
+ * ],
167
+ * axisValues: "v",
168
+ * series: "team",
169
+ * axisLabels: ["Speed", "Power", "Range", "Cost"],
170
+ * });
171
+ * ```
172
+ *
173
+ * @see https://sophistry.dev/reference/chart-catalogue/#pie-polar-area-and-radar
174
+ * @category Charts
175
+ */
176
+ export declare const radarChart: import("@sophistry/core").Definition<RadarChartBaseProps<any>, import("@sophistry/core/internal").CompositeNode<RadarChartBaseProps<any>>, keyof RadarChartBaseProps<any>>;
@@ -0,0 +1,116 @@
1
+ /**
2
+ * `radialBarChart`: concentric ring bars, one per datum, the first outermost.
3
+ *
4
+ * Two path batches: the faint full-length tracks (one shared paint, faded in
5
+ * together) and the value arcs (each its own fill; hover, taps, tooltips
6
+ * and accessible names per ring through `event.item` and `itemLabel`). Ring
7
+ * names stay `label` nodes.
8
+ */
9
+ import type { ColorInput } from "@sophistry/core";
10
+ import type { BandKey, Point } from "@sophistry/core/geometry";
11
+ import type { Channel, ColorChannel, RequiredUnless } from "../data/channels.js";
12
+ import type { TooltipSpec } from "../tooltip.js";
13
+ /** @category Charts */
14
+ export interface RadialBarChartBaseProps<T> {
15
+ /** One ring per datum, the first outermost. */
16
+ data: readonly T[];
17
+ /**
18
+ * The ring's value. Defaults to the datum when `data` is `number[]`; required otherwise.
19
+ * Negative and non-finite values count as 0 (an empty ring).
20
+ */
21
+ value?: Channel<T, number>;
22
+ /** The ring's name, written at its start. */
23
+ label?: Channel<T, string>;
24
+ /**
25
+ * The value that fills a ring's whole `sweep`; larger values are drawn full. Defaults to the
26
+ * greatest value.
27
+ */
28
+ maxValue?: number;
29
+ /** Centre of the chart. Defaults to the origin. */
30
+ center?: Point;
31
+ /**
32
+ * Outer radius of the outermost ring.
33
+ * @default 1
34
+ */
35
+ radius?: number;
36
+ /** Inner radius of the innermost ring. Defaults to 0.3 × `radius`. */
37
+ innerRadius?: number;
38
+ /** Gap between rings. Defaults to a quarter of a ring's width. */
39
+ ringGap?: number;
40
+ /**
41
+ * Radians a ring of `maxValue` turns through, clockwise from 12 o'clock. The default, 270°,
42
+ * leaves the top-left quadrant for labels.
43
+ * @default 3 * Math.PI / 2
44
+ */
45
+ sweep?: number;
46
+ /**
47
+ * The category of each ring: colours rings through the chart's shared colour scale and legend.
48
+ * `color` and `colors` win.
49
+ */
50
+ series?: Channel<T, BandKey>;
51
+ /** One colour for every ring, or `(d, i) => colour`. Wins over `colors` and `series`. */
52
+ color?: ColorChannel<T>;
53
+ /**
54
+ * Colours cycled across the rings by index. Wins over `series`. Defaults to the `series`
55
+ * colours, else the theme's categorical colours.
56
+ */
57
+ colors?: readonly ColorInput[];
58
+ /**
59
+ * Colour of the faint full-length track behind each ring. Defaults to the theme's grid colour.
60
+ */
61
+ trackColor?: ColorInput;
62
+ /**
63
+ * Write each ring's `label` at its start.
64
+ * @default true
65
+ */
66
+ labels?: boolean;
67
+ /** Label font size. Defaults to 0.7 × a ring's width, at most 0.26. */
68
+ labelFontSize?: number;
69
+ /**
70
+ * Reveal, 0..1: tracks and labels fade in, then each ring sweeps clockwise, outermost first.
71
+ * @default 1
72
+ * @see https://sophistry.dev/guides/chart-animation/#reveals
73
+ */
74
+ progress?: number;
75
+ /**
76
+ * Fraction of the bars' reveal spent staggering ring after ring, outer to inner, 0..0.95.
77
+ * @default 0.3
78
+ */
79
+ stagger?: number;
80
+ /** Hover tooltip: `true` for "label: value", or `(d, i) => string`. */
81
+ tooltip?: TooltipSpec<T>;
82
+ /** Paint order; higher draws later. */
83
+ zIndex?: number;
84
+ visible?: boolean;
85
+ }
86
+ /**
87
+ * Props of {@link radialBarChart}: `value` is required unless `data` is `number[]`.
88
+ *
89
+ * @category Charts
90
+ */
91
+ export type RadialBarChartProps<T> = RadialBarChartBaseProps<T> & RequiredUnless<T, number, "value">;
92
+ /**
93
+ * Concentric ring bars: a bar chart bent round a centre, one ring per datum (the first
94
+ * outermost), each arc its value over `maxValue`. Outer rings are longer at the same value, so
95
+ * compare angles, not lengths. Draws in scene units; needs no `chart`.
96
+ *
97
+ * @example
98
+ * ```ts
99
+ * import { radialBarChart } from "@sophistry/charts";
100
+ *
101
+ * radialBarChart.create({
102
+ * data: [
103
+ * { goal: "Move", pct: 80 },
104
+ * { goal: "Stand", pct: 50 },
105
+ * ],
106
+ * value: "pct",
107
+ * label: "goal",
108
+ * maxValue: 100,
109
+ * tooltip: true,
110
+ * });
111
+ * ```
112
+ *
113
+ * @see https://sophistry.dev/reference/chart-catalogue/#gauges-bullets-waffles-mosaics-and-radial-bars
114
+ * @category Charts
115
+ */
116
+ export declare const radialBarChart: import("@sophistry/core").Definition<RadialBarChartBaseProps<any>, import("@sophistry/core/internal").CompositeNode<RadialBarChartBaseProps<any>>, keyof RadialBarChartBaseProps<any>>;
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Helpers shared by the radial charts (pie, polar area, radar, radial bars,
3
+ * gauge, chord, waffle): wedge outlines as path batch items, a per-key item
4
+ * cache (so an unchanged wedge keeps its prepared outline), keyed label
5
+ * lists, the far end's colour scale across a keyed transition, and the
6
+ * standalone tooltip state. Internal to the family.
7
+ */
8
+ import type { CompositeContext, LabelProps, PathBatchItem, SceneNode } from "@sophistry/core";
9
+ import type { Theme } from "@sophistry/core/themes";
10
+ import type { OrdinalColorScale } from "../math/ordinal.js";
11
+ import type { Category } from "../series.js";
12
+ import type { TooltipState } from "../tooltip.js";
13
+ /** Smallest sweep worth drawing, in radians: what `sector` and `annularSector` skip. */
14
+ export declare const NO_SWEEP = 1e-9;
15
+ /** What a wedge's outline is made from. */
16
+ export interface WedgeShape {
17
+ cx: number;
18
+ cy: number;
19
+ /** 0 for a plain pie slice (`sector`), else a ring slice (`annularSector`). */
20
+ innerRadius: number;
21
+ outerRadius: number;
22
+ startAngle: number;
23
+ /** Signed sweep, radians; positive is counter-clockwise. */
24
+ angle: number;
25
+ }
26
+ /**
27
+ * A wedge as a path batch item: the same native curve geometry `sector` (no
28
+ * hole) or `annularSector` (a hole) build, so each item outlines exactly
29
+ * what the per-datum shape does. Undefined when the sweep is too small
30
+ * to draw (as those shapes draw nothing).
31
+ *
32
+ * @param annular - Draw a ring slice even when `innerRadius` is 0.
33
+ */
34
+ export declare function wedgeItem(shape: WedgeShape, paints: Omit<PathBatchItem, "closed" | "polylines" | "curvePaths">, annular?: boolean): PathBatchItem | undefined;
35
+ /**
36
+ * A per-key cache of path batch items: hands back last update's item while
37
+ * its inputs are equal (shallowly), so the batch reuses its prepared outline.
38
+ * Call `sweep()` after an update to forget keys that were not asked for.
39
+ */
40
+ export declare function createItemCache<I>(): {
41
+ get(key: unknown, inputs: readonly unknown[], make: () => I): I;
42
+ sweep(): void;
43
+ };
44
+ /** One label of a keyed list: its key and the label's props. */
45
+ export interface KeyedLabel {
46
+ key: unknown;
47
+ props: LabelProps;
48
+ }
49
+ /**
50
+ * Keyed `label` nodes for one list (`slot`): a node per key, created once
51
+ * and updated in place (equal values are no-ops on the node), disposed when
52
+ * its key leaves.
53
+ */
54
+ export declare function labelList<P>(ctx: CompositeContext<P>, slot: string, labels: readonly KeyedLabel[]): SceneNode[];
55
+ /**
56
+ * The colour scale `to`'s series colour through, across a keyed transition:
57
+ * the chart's shared scale inside a chart (`own`), else one over `to`'s own
58
+ * categories, as its plain chart has. Call once, in
59
+ * `setup`.
60
+ */
61
+ export declare function createFarScale(): (inChart: boolean, toOf: readonly Category[] | undefined, own: OrdinalColorScale, theme: Theme) => OrdinalColorScale;
62
+ /**
63
+ * The tooltip a standalone radial chart shows through: the enclosing
64
+ * chart's, else its own. Call once,
65
+ * in `setup`, and read the result in each `update`.
66
+ *
67
+ * Outside a chart the state is kept (handlers, accessible names, the item
68
+ * walked by the keys) and `overlay(ctx)` returns the panel drawing it, a
69
+ * {@link tooltipOverlay} bound to the scene's pointer and view: append it to the composite's children. Inside a
70
+ * chart it returns nothing, the frame's overlay draws the tooltip.
71
+ */
72
+ export declare function createOwnTooltip(): OwnTooltip;
73
+ /** What {@link createOwnTooltip} returns: the state, and its standalone panel. */
74
+ export interface OwnTooltip {
75
+ <P>(ctx: CompositeContext<P>): TooltipState;
76
+ /** The panel to append to the children outside a chart; empty inside one. */
77
+ overlay<P>(ctx: CompositeContext<P>): SceneNode[];
78
+ }
@@ -0,0 +1,130 @@
1
+ /**
2
+ * `waffle`: a grid of unit cells coloured by category.
3
+ *
4
+ * Two instances nodes of `square`: the empty grid (one shared fill, faded
5
+ * in together) and the filled cells (keyed by their place in the grid, each
6
+ * its own fill; a cell grows from its centre as its turn in the fill
7
+ * comes). Hover,
8
+ * taps and tooltips resolve per cell (`event.item`), each telling its
9
+ * category. The legend's swatches and labels are single nodes.
10
+ */
11
+ import type { ColorInput } from "@sophistry/core";
12
+ import type { Point } from "@sophistry/core/geometry";
13
+ import type { Channel, ColorChannel, RequiredUnless } from "../data/channels.js";
14
+ import type { TooltipSpec } from "../tooltip.js";
15
+ /** @category Charts */
16
+ export interface WaffleBaseProps<T> {
17
+ /** One category per datum, filling cells in data order. */
18
+ data: readonly T[];
19
+ /**
20
+ * The category's value; only shares matter. Defaults to the datum when `data` is `number[]`;
21
+ * required otherwise. Negative and non-finite values count as 0.
22
+ */
23
+ value?: Channel<T, number>;
24
+ /** The category's name, for the legend and tooltips. */
25
+ label?: Channel<T, string>;
26
+ /**
27
+ * Rows of cells.
28
+ * @default 10
29
+ */
30
+ rows?: number;
31
+ /**
32
+ * Columns of cells.
33
+ * @default 10
34
+ */
35
+ columns?: number;
36
+ /**
37
+ * Width of the box the grid fits in; cells are the largest squares that fit with `height`.
38
+ * Ignored when `cellSize` is given.
39
+ */
40
+ width?: number;
41
+ /** Height of the box the grid fits in. */
42
+ height?: number;
43
+ /** Side of one cell. Wins over `width`/`height`. Defaults to 0.3 when none is given. */
44
+ cellSize?: number;
45
+ /**
46
+ * Space between cells.
47
+ * @default 0.05
48
+ */
49
+ gap?: number;
50
+ /** Centre of the grid (not counting the legend). Defaults to the origin. */
51
+ center?: Point;
52
+ /** One colour for every category, or `(d, i) => colour`. Wins over `colors`. */
53
+ color?: ColorChannel<T>;
54
+ /**
55
+ * Colours cycled across the categories by index. Defaults to the theme's categorical colours.
56
+ */
57
+ colors?: readonly ColorInput[];
58
+ /**
59
+ * Draw the empty grid behind the cells.
60
+ * @default true
61
+ */
62
+ track?: boolean;
63
+ /** Colour of the empty grid. Defaults to the theme's grid colour. */
64
+ trackColor?: ColorInput;
65
+ /**
66
+ * A row of swatches with each category's label and percentage.
67
+ * @default false
68
+ */
69
+ legend?: boolean;
70
+ /**
71
+ * Where the legend sits: under the grid or in a column to its right.
72
+ * @default "bottom"
73
+ */
74
+ legendPosition?: "bottom" | "right";
75
+ /**
76
+ * Legend font size.
77
+ * @default 0.22
78
+ */
79
+ legendFontSize?: number;
80
+ /**
81
+ * Reveal, 0..1: the empty grid fades in, then cells grow one after another in fill order.
82
+ * @default 1
83
+ * @see https://sophistry.dev/guides/chart-animation/#reveals
84
+ */
85
+ progress?: number;
86
+ /**
87
+ * Fraction of the cells' reveal spent staggering cell after cell, 0..0.95.
88
+ * @default 0.9
89
+ */
90
+ stagger?: number;
91
+ /**
92
+ * Hover tooltip over the cell under the pointer: `true` for "label: value (pct)", or `(d, i) =>
93
+ * string` for its category.
94
+ */
95
+ tooltip?: TooltipSpec<T>;
96
+ /** Paint order; higher draws later. */
97
+ zIndex?: number;
98
+ visible?: boolean;
99
+ }
100
+ /**
101
+ * Props of {@link waffle}: `value` is required unless `data` is `number[]`.
102
+ *
103
+ * @category Charts
104
+ */
105
+ export type WaffleProps<T> = WaffleBaseProps<T> & RequiredUnless<T, number, "value">;
106
+ /**
107
+ * A waffle chart: a grid of unit cells (10 × 10 by default, one cell per percent) coloured by
108
+ * category in proportion to each value, filling row by row from the bottom-left. Counts are
109
+ * rounded so they always fill the grid exactly. Draws in scene units; needs no `chart`. The
110
+ * cells are one instances node. See {@link waffleCells} for the cell assignment alone.
111
+ *
112
+ * @example
113
+ * ```ts
114
+ * import { waffle } from "@sophistry/charts";
115
+ *
116
+ * waffle.create({
117
+ * data: [
118
+ * { name: "Yes", n: 62 },
119
+ * { name: "No", n: 38 },
120
+ * ],
121
+ * value: "n",
122
+ * label: "name",
123
+ * legend: true,
124
+ * });
125
+ * ```
126
+ *
127
+ * @see https://sophistry.dev/reference/chart-catalogue/#gauges-bullets-waffles-mosaics-and-radial-bars
128
+ * @category Charts
129
+ */
130
+ export declare const waffle: import("@sophistry/core").Definition<WaffleBaseProps<any>, import("@sophistry/core/internal").CompositeNode<WaffleBaseProps<any>>, keyof WaffleBaseProps<any>>;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Gridded colour layers as one image rather than one rectangle per cell.
3
+ *
4
+ * A 1000 × 1000 `<Imshow>` is a million cells. As shapes that is a million
5
+ * nodes; as an image it is one `drawImage` that the camera moves for free. The
6
+ * colours go through a 256-step lookup table of the layer's ramp (what
7
+ * matplotlib's colormaps are, too), so a million cells cost a million table
8
+ * reads instead of a million CSS colour strings.
9
+ */
10
+ import type { CoordinateSystem, ImageGeometry } from "@sophistry/core";
11
+ import type { Point } from "@sophistry/core/geometry";
12
+ /** `LUT_SIZE` RGBA entries sampling `colorAt` over 0..1. */
13
+ export declare function rampTable(colorAt: (unit: number) => string): Uint8ClampedArray;
14
+ /**
15
+ * Colours a grid of values into RGBA pixels, row 0 first. Values off the norm
16
+ * (non-finite, or non-positive under a log norm) are transparent, the way
17
+ * those cells are not drawn as shapes.
18
+ */
19
+ export declare function rasterize(values: readonly (readonly number[])[], ncols: number, unitOf: (value: number) => number, table: Uint8ClampedArray): Uint8ClampedArray;
20
+ /**
21
+ * The scene frame of an axis-aligned data rectangle, if the coordinate system
22
+ * maps it affinely (linear axes): pixel corner `(0, 0)` at data `(x0, y0)`, the
23
+ * first row running to `x1`, the first column to `y1`. Null under a log or
24
+ * other non-linear axis, where an image would put cells in the wrong places —
25
+ * the caller then draws cells as shapes.
26
+ */
27
+ export declare function affineFrame(coords: Pick<CoordinateSystem, "coordsToPoint">, x0: number, y0: number, x1: number, y1: number): Omit<ImageGeometry, "pixels"> | null;
28
+ /**
29
+ * Projects many data points into scene units at once, into `out` (interleaved
30
+ * `x, y`). Under linear axes the coordinate system is an affine map, found
31
+ * from three probes and checked at a fourth, and every point is two multiply-
32
+ * adds; otherwise each point goes through `coordsToPoint`.
33
+ *
34
+ * @param xs - Data x per point.
35
+ * @param ys - Data y per point.
36
+ * @param out - Receives `2 * xs.length` numbers.
37
+ */
38
+ export declare function projectPoints(coords: CoordinateSystem, xs: ArrayLike<number>, ys: ArrayLike<number>, out: Float64Array): void;
39
+ /**
40
+ * Projects one run of data points into scene points: the run-of-objects
41
+ * counterpart of {@link projectPoints}, with the same affine fast path.
42
+ */
43
+ export declare function projectRun(coords: Pick<CoordinateSystem, "coordsToPoint">, run: readonly Point[]): Point[];