@pibbl/core 0.0.2 → 0.0.3-alpha.85.1

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 (233) hide show
  1. package/THIRD_PARTY_NOTICES.txt +81 -0
  2. package/dist/features/textures/index.d.ts +12 -2
  3. package/dist/features/textures/index.js +33 -1
  4. package/dist/features/textures/index.js.map +2 -2
  5. package/dist/features/textures/lib/chemical-field.d.ts +56 -0
  6. package/dist/features/textures/lib/chemical-field.js +154 -0
  7. package/dist/features/textures/lib/chemical-field.js.map +7 -0
  8. package/dist/features/textures/lib/chemical-recipes.d.ts +119 -0
  9. package/dist/features/textures/lib/chemical-recipes.js +275 -0
  10. package/dist/features/textures/lib/chemical-recipes.js.map +7 -0
  11. package/dist/features/textures/lib/definitions.d.ts +3 -18
  12. package/dist/features/textures/lib/definitions.js +15 -20
  13. package/dist/features/textures/lib/definitions.js.map +2 -2
  14. package/dist/features/textures/lib/geometric-patterns.d.ts +149 -0
  15. package/dist/features/textures/lib/geometric-patterns.js +305 -0
  16. package/dist/features/textures/lib/geometric-patterns.js.map +7 -0
  17. package/dist/features/textures/lib/gray-scott.d.ts +55 -0
  18. package/dist/features/textures/lib/gray-scott.js +39 -0
  19. package/dist/features/textures/lib/gray-scott.js.map +7 -0
  20. package/dist/features/textures/lib/patterns.d.ts +123 -0
  21. package/dist/features/textures/lib/patterns.js +344 -0
  22. package/dist/features/textures/lib/patterns.js.map +7 -0
  23. package/dist/features/textures/lib/reaction-diffusion.d.ts +3 -2
  24. package/dist/features/textures/lib/reaction-diffusion.js +9 -20
  25. package/dist/features/textures/lib/reaction-diffusion.js.map +2 -2
  26. package/dist/features/textures/lib/simulation.d.ts +10 -4
  27. package/dist/features/textures/lib/simulation.js +23 -13
  28. package/dist/features/textures/lib/simulation.js.map +2 -2
  29. package/dist/features/viz/index.d.ts +55 -6
  30. package/dist/features/viz/index.js +107 -2
  31. package/dist/features/viz/index.js.map +2 -2
  32. package/dist/features/viz/inspection/bar.d.ts +79 -0
  33. package/dist/features/viz/inspection/bar.js +49 -0
  34. package/dist/features/viz/inspection/bar.js.map +7 -0
  35. package/dist/features/viz/inspection/candle.d.ts +156 -0
  36. package/dist/features/viz/inspection/candle.js +120 -0
  37. package/dist/features/viz/inspection/candle.js.map +7 -0
  38. package/dist/features/viz/inspection/capture-types.d.ts +65 -0
  39. package/dist/features/viz/inspection/capture.d.ts +16 -0
  40. package/dist/features/viz/inspection/capture.js +49 -0
  41. package/dist/features/viz/inspection/capture.js.map +7 -0
  42. package/dist/features/viz/inspection/handler.d.ts +36 -0
  43. package/dist/features/viz/inspection/handler.js +91 -0
  44. package/dist/features/viz/inspection/handler.js.map +7 -0
  45. package/dist/features/viz/inspection/ohlc-bar.d.ts +132 -0
  46. package/dist/features/viz/inspection/ohlc-bar.js +118 -0
  47. package/dist/features/viz/inspection/ohlc-bar.js.map +7 -0
  48. package/dist/features/viz/inspection/owned-ref.d.ts +16 -0
  49. package/dist/features/viz/inspection/owned-ref.js +99 -0
  50. package/dist/features/viz/inspection/owned-ref.js.map +7 -0
  51. package/dist/features/viz/inspection/painted-point.d.ts +22 -0
  52. package/dist/features/viz/inspection/painted-point.js +29 -0
  53. package/dist/features/viz/inspection/painted-point.js.map +7 -0
  54. package/dist/features/viz/inspection/queries.d.ts +100 -0
  55. package/dist/features/viz/inspection/queries.js +192 -0
  56. package/dist/features/viz/inspection/queries.js.map +7 -0
  57. package/dist/features/viz/inspection/query-types.d.ts +177 -0
  58. package/dist/features/viz/inspection/volume.d.ts +104 -0
  59. package/dist/features/viz/inspection/volume.js +95 -0
  60. package/dist/features/viz/inspection/volume.js.map +7 -0
  61. package/dist/features/viz/inspection.d.ts +19 -0
  62. package/dist/features/viz/inspection.js +54 -0
  63. package/dist/features/viz/inspection.js.map +7 -0
  64. package/dist/features/viz/inspection.mjs +1 -0
  65. package/dist/features/viz/lib/area-series.d.ts +62 -0
  66. package/dist/features/viz/lib/area-series.js +120 -0
  67. package/dist/features/viz/lib/area-series.js.map +7 -0
  68. package/dist/features/viz/lib/axis.js +1 -1
  69. package/dist/features/viz/lib/axis.js.map +2 -2
  70. package/dist/features/viz/lib/bar-series.d.ts +3 -1
  71. package/dist/features/viz/lib/bar-series.js +16 -1
  72. package/dist/features/viz/lib/bar-series.js.map +2 -2
  73. package/dist/features/viz/lib/baseline-series.d.ts +55 -0
  74. package/dist/features/viz/lib/baseline-series.js +136 -0
  75. package/dist/features/viz/lib/baseline-series.js.map +7 -0
  76. package/dist/features/viz/lib/candlestick-series.d.ts +62 -0
  77. package/dist/features/viz/lib/candlestick-series.js +150 -0
  78. package/dist/features/viz/lib/candlestick-series.js.map +7 -0
  79. package/dist/features/viz/lib/censored-point-series.d.ts +71 -0
  80. package/dist/features/viz/lib/censored-point-series.js +129 -0
  81. package/dist/features/viz/lib/censored-point-series.js.map +7 -0
  82. package/dist/features/viz/lib/color-context.d.ts +4 -0
  83. package/dist/features/viz/lib/color-context.js +41 -0
  84. package/dist/features/viz/lib/color-context.js.map +7 -0
  85. package/dist/features/viz/lib/color-math.d.ts +4 -0
  86. package/dist/features/viz/lib/color-math.js +31 -0
  87. package/dist/features/viz/lib/color-math.js.map +7 -0
  88. package/dist/features/viz/lib/color-types.d.ts +53 -0
  89. package/dist/features/viz/lib/curve-definition.d.ts +49 -0
  90. package/dist/features/viz/lib/curve-definition.js +148 -0
  91. package/dist/features/viz/lib/curve-definition.js.map +7 -0
  92. package/dist/features/viz/lib/diverging-color-scale.d.ts +11 -0
  93. package/dist/features/viz/lib/diverging-color-scale.js +51 -0
  94. package/dist/features/viz/lib/diverging-color-scale.js.map +7 -0
  95. package/dist/features/viz/lib/domain-navigation.d.ts +40 -0
  96. package/dist/features/viz/lib/domain-navigation.js +77 -0
  97. package/dist/features/viz/lib/domain-navigation.js.map +7 -0
  98. package/dist/features/viz/lib/editable-chart-elements.d.ts +178 -0
  99. package/dist/features/viz/lib/editable-chart-elements.js +733 -0
  100. package/dist/features/viz/lib/editable-chart-elements.js.map +7 -0
  101. package/dist/features/viz/lib/financial-aggregation.d.ts +127 -0
  102. package/dist/features/viz/lib/financial-aggregation.js +116 -0
  103. package/dist/features/viz/lib/financial-aggregation.js.map +7 -0
  104. package/dist/features/viz/lib/financial-autoscale.d.ts +64 -0
  105. package/dist/features/viz/lib/financial-autoscale.js +61 -0
  106. package/dist/features/viz/lib/financial-autoscale.js.map +7 -0
  107. package/dist/features/viz/lib/financial-comparison.d.ts +62 -0
  108. package/dist/features/viz/lib/financial-comparison.js +98 -0
  109. package/dist/features/viz/lib/financial-comparison.js.map +7 -0
  110. package/dist/features/viz/lib/financial-geometry.d.ts +77 -0
  111. package/dist/features/viz/lib/financial-geometry.js +67 -0
  112. package/dist/features/viz/lib/financial-geometry.js.map +7 -0
  113. package/dist/features/viz/lib/financial-indicators.d.ts +114 -0
  114. package/dist/features/viz/lib/financial-indicators.js +135 -0
  115. package/dist/features/viz/lib/financial-indicators.js.map +7 -0
  116. package/dist/features/viz/lib/financial-oscillators.d.ts +171 -0
  117. package/dist/features/viz/lib/financial-oscillators.js +265 -0
  118. package/dist/features/viz/lib/financial-oscillators.js.map +7 -0
  119. package/dist/features/viz/lib/hover-data.d.ts +1 -1
  120. package/dist/features/viz/lib/hover-data.js +5 -2
  121. package/dist/features/viz/lib/hover-data.js.map +2 -2
  122. package/dist/features/viz/lib/interval-band-series.d.ts +49 -0
  123. package/dist/features/viz/lib/interval-band-series.js +136 -0
  124. package/dist/features/viz/lib/interval-band-series.js.map +7 -0
  125. package/dist/features/viz/lib/interval-diamond-series.d.ts +43 -0
  126. package/dist/features/viz/lib/interval-diamond-series.js +124 -0
  127. package/dist/features/viz/lib/interval-diamond-series.js.map +7 -0
  128. package/dist/features/viz/lib/interval-series.d.ts +79 -0
  129. package/dist/features/viz/lib/interval-series.js +158 -0
  130. package/dist/features/viz/lib/interval-series.js.map +7 -0
  131. package/dist/features/viz/lib/line-series.d.ts +1 -1
  132. package/dist/features/viz/lib/line-series.js +47 -28
  133. package/dist/features/viz/lib/line-series.js.map +2 -2
  134. package/dist/features/viz/lib/linear-scale.js +1 -1
  135. package/dist/features/viz/lib/linear-scale.js.map +2 -2
  136. package/dist/features/viz/lib/monotone-curve.d.ts +11 -0
  137. package/dist/features/viz/lib/monotone-curve.js +63 -0
  138. package/dist/features/viz/lib/monotone-curve.js.map +7 -0
  139. package/dist/features/viz/lib/numeric-range-interpolation.d.ts +15 -0
  140. package/dist/features/viz/lib/numeric-range-interpolation.js +36 -0
  141. package/dist/features/viz/lib/numeric-range-interpolation.js.map +7 -0
  142. package/dist/features/viz/lib/ohlc-bar-series.d.ts +55 -0
  143. package/dist/features/viz/lib/ohlc-bar-series.js +168 -0
  144. package/dist/features/viz/lib/ohlc-bar-series.js.map +7 -0
  145. package/dist/features/viz/lib/paired-series.d.ts +44 -0
  146. package/dist/features/viz/lib/paired-series.js +93 -0
  147. package/dist/features/viz/lib/paired-series.js.map +7 -0
  148. package/dist/features/viz/lib/plot-series.js +11 -6
  149. package/dist/features/viz/lib/plot-series.js.map +2 -2
  150. package/dist/features/viz/lib/plot-types.d.ts +4 -3
  151. package/dist/features/viz/lib/point-series.d.ts +1 -1
  152. package/dist/features/viz/lib/point-series.js +36 -9
  153. package/dist/features/viz/lib/point-series.js.map +2 -2
  154. package/dist/features/viz/lib/point-types.d.ts +5 -2
  155. package/dist/features/viz/lib/scale-context.d.ts +1 -1
  156. package/dist/features/viz/lib/scale-ticks.js +21 -6
  157. package/dist/features/viz/lib/scale-ticks.js.map +2 -2
  158. package/dist/features/viz/lib/sequential-color-scale.d.ts +11 -0
  159. package/dist/features/viz/lib/sequential-color-scale.js +49 -0
  160. package/dist/features/viz/lib/sequential-color-scale.js.map +7 -0
  161. package/dist/features/viz/lib/series-position.d.ts +12 -0
  162. package/dist/features/viz/lib/series-position.js +44 -0
  163. package/dist/features/viz/lib/series-position.js.map +7 -0
  164. package/dist/features/viz/lib/step-curves.d.ts +19 -0
  165. package/dist/features/viz/lib/step-curves.js +53 -0
  166. package/dist/features/viz/lib/step-curves.js.map +7 -0
  167. package/dist/features/viz/lib/threshold-color-scale.d.ts +43 -0
  168. package/dist/features/viz/lib/threshold-color-scale.js +59 -0
  169. package/dist/features/viz/lib/threshold-color-scale.js.map +7 -0
  170. package/dist/features/viz/lib/trading-time-mapping.d.ts +32 -0
  171. package/dist/features/viz/lib/trading-time-mapping.js +89 -0
  172. package/dist/features/viz/lib/trading-time-mapping.js.map +7 -0
  173. package/dist/features/viz/lib/trading-time-scale.d.ts +83 -0
  174. package/dist/features/viz/lib/trading-time-scale.js +96 -0
  175. package/dist/features/viz/lib/trading-time-scale.js.map +7 -0
  176. package/dist/features/viz/lib/trajectory-series.d.ts +71 -0
  177. package/dist/features/viz/lib/trajectory-series.js +111 -0
  178. package/dist/features/viz/lib/trajectory-series.js.map +7 -0
  179. package/dist/features/viz/lib/types.d.ts +20 -4
  180. package/dist/features/viz/lib/use-continuous-scale.js +6 -1
  181. package/dist/features/viz/lib/use-continuous-scale.js.map +2 -2
  182. package/dist/features/viz/lib/volume-series.d.ts +59 -0
  183. package/dist/features/viz/lib/volume-series.js +117 -0
  184. package/dist/features/viz/lib/volume-series.js.map +7 -0
  185. package/dist/features/viz/lib/weighted-point-series.d.ts +71 -0
  186. package/dist/features/viz/lib/weighted-point-series.js +169 -0
  187. package/dist/features/viz/lib/weighted-point-series.js.map +7 -0
  188. package/dist/filters/emboss-gpu.d.ts +4 -0
  189. package/dist/filters/emboss-gpu.js +39 -0
  190. package/dist/filters/emboss-gpu.js.map +7 -0
  191. package/dist/filters/emboss.d.ts +32 -0
  192. package/dist/filters/emboss.js +106 -0
  193. package/dist/filters/emboss.js.map +7 -0
  194. package/dist/filters/reflection-gpu.d.ts +3 -1
  195. package/dist/filters/reflection-gpu.js +5 -2
  196. package/dist/filters/reflection-gpu.js.map +2 -2
  197. package/dist/filters/render-emboss-boundary.d.ts +13 -0
  198. package/dist/filters/render-emboss-boundary.js +131 -0
  199. package/dist/filters/render-emboss-boundary.js.map +7 -0
  200. package/dist/filters.d.ts +2 -0
  201. package/dist/filters.js +2 -0
  202. package/dist/filters.js.map +2 -2
  203. package/dist/index.d.ts +2 -0
  204. package/dist/index.js +3 -0
  205. package/dist/index.js.map +2 -2
  206. package/dist/internal.d.ts +2 -0
  207. package/dist/internal.js +4 -0
  208. package/dist/internal.js.map +2 -2
  209. package/dist/lib/events/event-facade.d.ts +13 -0
  210. package/dist/lib/events/event-facade.js +23 -0
  211. package/dist/lib/events/event-facade.js.map +2 -2
  212. package/dist/lib/events/propagation.js +19 -14
  213. package/dist/lib/events/propagation.js.map +2 -2
  214. package/dist/lib/execute-render.js +13 -0
  215. package/dist/lib/execute-render.js.map +2 -2
  216. package/dist/lib/recording/recording.d.ts +43 -0
  217. package/dist/lib/recording/recording.js +555 -0
  218. package/dist/lib/recording/recording.js.map +7 -0
  219. package/dist/lib/recording/types.d.ts +118 -0
  220. package/dist/lib/recording/wasm-bytes.d.ts +1 -0
  221. package/dist/lib/recording/wasm-bytes.js +5 -0
  222. package/dist/lib/recording/wasm-bytes.js.map +7 -0
  223. package/dist/lib/recording/worker-source.d.ts +1 -0
  224. package/dist/lib/recording/worker-source.js +5 -0
  225. package/dist/lib/recording/worker-source.js.map +7 -0
  226. package/dist/lib/render-transaction.d.ts +5 -2
  227. package/dist/lib/render-transaction.js +23 -1
  228. package/dist/lib/render-transaction.js.map +2 -2
  229. package/dist/lib/series-inspection-frame.d.ts +18 -0
  230. package/dist/lib/series-inspection-frame.js +70 -0
  231. package/dist/lib/series-inspection-frame.js.map +7 -0
  232. package/dist/lib/types.d.ts +6 -0
  233. package/package.json +10 -2
@@ -0,0 +1,44 @@
1
+ import type { PibblEventHandlers, PibblEventParticipationOptions, SignalValue } from "@pibbl/core";
2
+ import type { SignalStyle } from "@pibbl/core/internal";
3
+ import type { LineAccessor, ScaleId, SeriesCoordinate } from "./types.js";
4
+ import type { TrajectorySeriesStyle } from "./trajectory-series.js";
5
+ /** Shared connector appearance for {@link PairedSeries}. */
6
+ export type PairedSeriesStyle = TrajectorySeriesStyle;
7
+ /** Authored wide-record inputs for {@link PairedSeries}. */
8
+ export interface PairedSeriesProps<D> extends PibblEventHandlers, PibblEventParticipationOptions {
9
+ /** Source records or a signal containing them. */
10
+ readonly data: SignalValue<readonly D[]>;
11
+ /** Numeric baseline or first-observation value. */
12
+ readonly before: LineAccessor<D>;
13
+ /** Numeric follow-up or second-observation value. */
14
+ readonly after: LineAccessor<D>;
15
+ /** Fixed x coordinate used for every `before` endpoint. */
16
+ readonly beforeX: SeriesCoordinate;
17
+ /** Fixed x coordinate used for every `after` endpoint. */
18
+ readonly afterX: SeriesCoordinate;
19
+ /** Scale mapping the two endpoint coordinates. */
20
+ readonly xScale: ScaleId;
21
+ /** Numeric scale mapping both endpoint values. */
22
+ readonly yScale: ScaleId;
23
+ /**
24
+ * Excludes a record before before/after accessors run.
25
+ * @param datum - Candidate source datum.
26
+ * @param index - Zero-based source index.
27
+ * @param data - Complete source data array.
28
+ * @returns Whether this record contributes a connector.
29
+ */
30
+ readonly defined?: (datum: D, index: number, data: readonly D[]) => boolean;
31
+ /** Shared connector style, including whole-object and shallow field signals. */
32
+ readonly style?: SignalValue<SignalStyle<PairedSeriesStyle>>;
33
+ }
34
+ /**
35
+ * Draws a connector for each complete wide-record before/after pair.
36
+ *
37
+ * The component does not manufacture point marks, calculate change, select a
38
+ * baseline, or impute missing observations. Compose `PointSeries` for endpoints.
39
+ *
40
+ * @param props - Wide records, endpoint accessors and coordinates, scales, and shared paint.
41
+ * @returns One batched ordinary Pibbl path containing source-ordered pair connectors.
42
+ * @see {@link PairedSeriesProps}
43
+ */
44
+ export declare function PairedSeries<D>({ data: input, before: beforeInput, after: afterInput, beforeX, afterX, xScale: xId, yScale: yId, defined, style: styleInput, ...events }: PairedSeriesProps<D>): import("../../../jsx-runtime.js").JSX.Element;
@@ -0,0 +1,93 @@
1
+ import { jsx } from "@pibbl/core/jsx-runtime";
2
+ import { Path, resolveSignalValue } from "@pibbl/core";
3
+ import { withHooksForbidden } from "@pibbl/core/internal";
4
+ import { pointAccessor, pointData } from "./point-data.js";
5
+ import { opacity, width } from "./paint.js";
6
+ import {
7
+ mapSeriesPosition,
8
+ useNumericPosition,
9
+ useSeriesPosition
10
+ } from "./series-position.js";
11
+ function style(input) {
12
+ if (input === null || typeof input !== "object" || Array.isArray(input))
13
+ throw new TypeError("PairedSeries: style must be an object.");
14
+ const value = input;
15
+ for (const field of Object.keys(value))
16
+ if (![
17
+ "stroke",
18
+ "strokeWidth",
19
+ "lineInteractionWidth",
20
+ "opacity",
21
+ "cursor"
22
+ ].includes(field))
23
+ throw new TypeError(`PairedSeries: unsupported style field ${field}.`);
24
+ const stroke = resolveSignalValue(value.stroke) ?? "#2563eb";
25
+ const strokeWidth = width(
26
+ resolveSignalValue(value.strokeWidth) ?? 2,
27
+ "PairedSeries strokeWidth"
28
+ );
29
+ const lineInteractionWidth = width(
30
+ resolveSignalValue(value.lineInteractionWidth) ?? strokeWidth,
31
+ "PairedSeries lineInteractionWidth"
32
+ );
33
+ const cursor = resolveSignalValue(value.cursor);
34
+ if (cursor !== void 0 && typeof cursor !== "string")
35
+ throw new TypeError("PairedSeries: cursor must be a string.");
36
+ return {
37
+ stroke,
38
+ strokeWidth,
39
+ lineInteractionWidth,
40
+ opacity: opacity(
41
+ resolveSignalValue(value.opacity) ?? 1,
42
+ "PairedSeries opacity"
43
+ ),
44
+ cursor
45
+ };
46
+ }
47
+ function PairedSeries({
48
+ data: input,
49
+ before: beforeInput,
50
+ after: afterInput,
51
+ beforeX,
52
+ afterX,
53
+ xScale: xId,
54
+ yScale: yId,
55
+ defined,
56
+ style: styleInput,
57
+ ...events
58
+ }) {
59
+ const xs = useSeriesPosition(xId);
60
+ const ys = useNumericPosition(yId);
61
+ const data = pointData(resolveSignalValue(input), "PairedSeries");
62
+ const before = pointAccessor(beforeInput);
63
+ const after = pointAccessor(afterInput);
64
+ const startX = mapSeriesPosition(xs, beforeX);
65
+ const endX = mapSeriesPosition(xs, afterX);
66
+ const resolved = style(resolveSignalValue(styleInput) ?? {});
67
+ const path = new Path2D();
68
+ if (startX !== void 0 && endX !== void 0)
69
+ for (let i = 0; i < data.length; i++) {
70
+ const datum = data[i];
71
+ const row = withHooksForbidden(
72
+ "PairedSeries: accessors cannot call hooks.",
73
+ () => {
74
+ if (defined && !defined(datum, i, data)) return void 0;
75
+ return {
76
+ before: before(datum, i, data),
77
+ after: after(datum, i, data)
78
+ };
79
+ }
80
+ );
81
+ if (!row) continue;
82
+ const startY = mapSeriesPosition(ys, row.before);
83
+ const endY = mapSeriesPosition(ys, row.after);
84
+ if (startY === void 0 || endY === void 0) continue;
85
+ path.moveTo(startX, startY);
86
+ path.lineTo(endX, endY);
87
+ }
88
+ return /* @__PURE__ */ jsx(Path, { ...events, style: { d: path, ...resolved } });
89
+ }
90
+ export {
91
+ PairedSeries
92
+ };
93
+ //# sourceMappingURL=paired-series.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/features/viz/lib/paired-series.tsx"],
4
+ "sourcesContent": ["import { Path, resolveSignalValue } from \"@pibbl/core\";\nimport type {\n PibblEventHandlers,\n PibblEventParticipationOptions,\n SignalValue,\n StrokeStyle,\n} from \"@pibbl/core\";\nimport { withHooksForbidden } from \"@pibbl/core/internal\";\nimport type { SignalStyle } from \"@pibbl/core/internal\";\nimport type { LineAccessor, ScaleId, SeriesCoordinate } from \"./types.js\";\nimport type { TrajectorySeriesStyle } from \"./trajectory-series.js\";\nimport { pointAccessor, pointData } from \"./point-data.js\";\nimport { opacity, width } from \"./paint.js\";\nimport {\n mapSeriesPosition,\n useNumericPosition,\n useSeriesPosition,\n} from \"./series-position.js\";\n\n/** Shared connector appearance for {@link PairedSeries}. */\nexport type PairedSeriesStyle = TrajectorySeriesStyle;\n\n/** Authored wide-record inputs for {@link PairedSeries}. */\nexport interface PairedSeriesProps<D>\n extends PibblEventHandlers, PibblEventParticipationOptions {\n /** Source records or a signal containing them. */\n readonly data: SignalValue<readonly D[]>;\n /** Numeric baseline or first-observation value. */\n readonly before: LineAccessor<D>;\n /** Numeric follow-up or second-observation value. */\n readonly after: LineAccessor<D>;\n /** Fixed x coordinate used for every `before` endpoint. */\n readonly beforeX: SeriesCoordinate;\n /** Fixed x coordinate used for every `after` endpoint. */\n readonly afterX: SeriesCoordinate;\n /** Scale mapping the two endpoint coordinates. */\n readonly xScale: ScaleId;\n /** Numeric scale mapping both endpoint values. */\n readonly yScale: ScaleId;\n /**\n * Excludes a record before before/after accessors run.\n * @param datum - Candidate source datum.\n * @param index - Zero-based source index.\n * @param data - Complete source data array.\n * @returns Whether this record contributes a connector.\n */\n readonly defined?: (datum: D, index: number, data: readonly D[]) => boolean;\n /** Shared connector style, including whole-object and shallow field signals. */\n readonly style?: SignalValue<SignalStyle<PairedSeriesStyle>>;\n}\n\ninterface ResolvedPairedStyle {\n readonly stroke: StrokeStyle;\n readonly strokeWidth: number;\n readonly lineInteractionWidth: number;\n readonly opacity: number;\n readonly cursor?: string;\n}\n\nfunction style(input: unknown): ResolvedPairedStyle {\n if (input === null || typeof input !== \"object\" || Array.isArray(input))\n throw new TypeError(\"PairedSeries: style must be an object.\");\n const value = input as Record<string, unknown>;\n for (const field of Object.keys(value))\n if (\n ![\n \"stroke\",\n \"strokeWidth\",\n \"lineInteractionWidth\",\n \"opacity\",\n \"cursor\",\n ].includes(field)\n )\n throw new TypeError(`PairedSeries: unsupported style field ${field}.`);\n const stroke = resolveSignalValue(value.stroke) ?? \"#2563eb\";\n const strokeWidth = width(\n (resolveSignalValue(value.strokeWidth) ?? 2) as number,\n \"PairedSeries strokeWidth\",\n );\n const lineInteractionWidth = width(\n (resolveSignalValue(value.lineInteractionWidth) ?? strokeWidth) as number,\n \"PairedSeries lineInteractionWidth\",\n );\n const cursor = resolveSignalValue(value.cursor);\n if (cursor !== undefined && typeof cursor !== \"string\")\n throw new TypeError(\"PairedSeries: cursor must be a string.\");\n return {\n stroke: stroke as StrokeStyle,\n strokeWidth,\n lineInteractionWidth,\n opacity: opacity(\n (resolveSignalValue(value.opacity) ?? 1) as number,\n \"PairedSeries opacity\",\n ),\n cursor,\n };\n}\n\n/**\n * Draws a connector for each complete wide-record before/after pair.\n *\n * The component does not manufacture point marks, calculate change, select a\n * baseline, or impute missing observations. Compose `PointSeries` for endpoints.\n *\n * @param props - Wide records, endpoint accessors and coordinates, scales, and shared paint.\n * @returns One batched ordinary Pibbl path containing source-ordered pair connectors.\n * @see {@link PairedSeriesProps}\n */\nexport function PairedSeries<D>({\n data: input,\n before: beforeInput,\n after: afterInput,\n beforeX,\n afterX,\n xScale: xId,\n yScale: yId,\n defined,\n style: styleInput,\n ...events\n}: PairedSeriesProps<D>) {\n const xs = useSeriesPosition(xId);\n const ys = useNumericPosition(yId);\n const data = pointData(resolveSignalValue(input), \"PairedSeries\");\n const before = pointAccessor(beforeInput);\n const after = pointAccessor(afterInput);\n const startX = mapSeriesPosition(xs, beforeX);\n const endX = mapSeriesPosition(xs, afterX);\n const resolved = style(resolveSignalValue(styleInput) ?? {});\n const path = new Path2D();\n if (startX !== undefined && endX !== undefined)\n for (let i = 0; i < data.length; i++) {\n const datum = data[i];\n const row = withHooksForbidden(\n \"PairedSeries: accessors cannot call hooks.\",\n () => {\n if (defined && !defined(datum, i, data)) return undefined;\n return {\n before: before(datum, i, data),\n after: after(datum, i, data),\n };\n },\n );\n if (!row) continue;\n const startY = mapSeriesPosition(ys, row.before);\n const endY = mapSeriesPosition(ys, row.after);\n if (startY === undefined || endY === undefined) continue;\n path.moveTo(startX, startY);\n path.lineTo(endX, endY);\n }\n return <Path {...events} style={{ d: path, ...resolved }} />;\n}\n"],
5
+ "mappings": "AAqJS;AArJT,SAAS,MAAM,0BAA0B;AAOzC,SAAS,0BAA0B;AAInC,SAAS,eAAe,iBAAiB;AACzC,SAAS,SAAS,aAAa;AAC/B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA0CP,SA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M,WAAW,MAAM,mBAAmB,UAAU,KAAK,CAAC,CAAC;AAC3D,QAAM,OAAO,IAAI,OAAO;AACxB,MAAI,WAAW,UAAa,SAAS;AACnC,aAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,YAAM,QAAQ,KAAK,CAAC;AACpB,YAAM,MAAM;AAAA,QACV;AAAA,QACA,MAAM;AACJ,cAAI,WAAW,CAAC,QAAQ,OAAO,GAAG,IAAI,EAAG,QAAO;AAChD,iBAAO;AAAA,YACL,QAAQ,OAAO,OAAO,GAAG,IAAI;AAAA,YAC7B,OAAO,MAAM,OAAO,GAAG,IAAI;AAAA,UAC7B;AAAA,QACF;AAAA,MACF;AACA,UAAI,CAAC,IAAK;AACV,YAAM,SAAS,kBAAkB,IAAI,IAAI,MAAM;AAC/C,YAAM,OAAO,kBAAkB,IAAI,IAAI,KAAK;AAC5C,UAAI,WAAW,UAAa,SAAS,OAAW;AAChD,WAAK,OAAO,QAAQ,MAAM;AAC1B,WAAK,OAAO,MAAM,IAAI;AAAA,IACxB;AACF,SAAO,oBAAC,QAAM,GAAG,QAAQ,OAAO,EAAE,GAAG,MAAM,GAAG,SAAS,GAAG;AAC5D;",
6
+ "names": []
7
+ }
@@ -1,7 +1,11 @@
1
1
  import { jsx } from "@pibbl/core/jsx-runtime";
2
2
  import { Group, resolveSignalValue } from "@pibbl/core";
3
- import { pointAccessor, pointData, finiteCoordinate } from "./point-data.js";
4
- import { useContinuousScale } from "./use-continuous-scale.js";
3
+ import { pointData } from "./point-data.js";
4
+ import {
5
+ useSeriesPosition,
6
+ seriesAccessor,
7
+ mapSeriesPosition
8
+ } from "./series-position.js";
5
9
  function PlotRow({
6
10
  datum,
7
11
  index,
@@ -21,19 +25,20 @@ function PlotSeries({
21
25
  render,
22
26
  ...events
23
27
  }) {
24
- const xs = useContinuousScale(xId).get(), ys = useContinuousScale(yId).get();
28
+ const xs = useSeriesPosition(xId), ys = useSeriesPosition(yId);
25
29
  const data = pointData(resolveSignalValue(input), "PlotSeries");
26
30
  if (typeof render !== "function")
27
31
  throw new TypeError("PlotSeries: render must be a synchronous function.");
28
- const x = pointAccessor(xInput), y = pointAccessor(yInput);
32
+ const x = seriesAccessor(xInput), y = seriesAccessor(yInput);
29
33
  const keys = /* @__PURE__ */ new Set();
30
34
  const nodes = [];
31
35
  for (let i = 0; i < data.length; i++) {
32
36
  const datum = data[i];
33
37
  if (defined && !defined(datum, i, data)) continue;
34
38
  const xv = x(datum, i, data), yv = y(datum, i, data);
35
- if (!finiteCoordinate(xv) || !finiteCoordinate(yv)) continue;
36
- const px = xs.map(xv), py = ys.map(yv);
39
+ const mappedX = mapSeriesPosition(xs, xv), mappedY = mapSeriesPosition(ys, yv);
40
+ if (mappedX === void 0 || mappedY === void 0) continue;
41
+ const px = mappedX, py = mappedY;
37
42
  const key = keyBy === void 0 ? i : typeof keyBy === "function" ? keyBy(datum, i, data) : datum[keyBy];
38
43
  if (typeof key !== "string" && typeof key !== "number")
39
44
  throw new TypeError("PlotSeries: keyBy must return a string or number.");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/features/viz/lib/plot-series.tsx"],
4
- "sourcesContent": ["import { Group, resolveSignalValue } from \"@pibbl/core\";\nimport type { PibblNode } from \"@pibbl/core\";\nimport type { PlotSeriesProps } from \"./plot-types.js\";\nimport { pointAccessor, pointData, finiteCoordinate } from \"./point-data.js\";\nimport { useContinuousScale } from \"./use-continuous-scale.js\";\nfunction PlotRow<D>({\n datum,\n index,\n data,\n render,\n}: {\n datum: D;\n index: number;\n data: readonly D[];\n render: PlotSeriesProps<D>[\"render\"];\n}): PibblNode {\n return render(datum, index, data);\n}\n/**\n * Places keyed custom Pibbl subtrees at local data coordinates.\n *\n * @param props - Data, coordinate accessors, scales, keys, and per-datum renderer. See\n * {@link PlotSeriesProps} .\n * @returns Pibbl nodes placing each rendered datum at its mapped coordinates. See {@link PibblNode}.\n *\n * @see {@link PlotSeriesProps}\n * @see {@link PibblNode}\n */\nexport function PlotSeries<D>({\n data: input,\n x: xInput,\n y: yInput,\n xScale: xId,\n yScale: yId,\n defined,\n keyBy,\n render,\n ...events\n}: PlotSeriesProps<D>): PibblNode {\n const xs = useContinuousScale(xId).get(),\n ys = useContinuousScale(yId).get();\n const data = pointData(resolveSignalValue(input), \"PlotSeries\");\n if (typeof render !== \"function\")\n throw new TypeError(\"PlotSeries: render must be a synchronous function.\");\n const x = pointAccessor(xInput),\n y = pointAccessor(yInput);\n const keys = new Set<string>();\n const nodes: PibblNode[] = [];\n for (let i = 0; i < data.length; i++) {\n const datum = data[i];\n if (defined && !defined(datum, i, data)) continue;\n const xv = x(datum, i, data),\n yv = y(datum, i, data);\n if (!finiteCoordinate(xv) || !finiteCoordinate(yv)) continue;\n const px = xs.map(xv),\n py = ys.map(yv);\n const key =\n keyBy === undefined\n ? i\n : typeof keyBy === \"function\"\n ? keyBy(datum, i, data)\n : datum[keyBy];\n if (typeof key !== \"string\" && typeof key !== \"number\")\n throw new TypeError(\"PlotSeries: keyBy must return a string or number.\");\n const normalized = String(key);\n if (keys.has(normalized))\n throw new Error(`PlotSeries: duplicate key \"${normalized}\".`);\n keys.add(normalized);\n nodes.push(\n <Group key={normalized} style={{ translateX: px, translateY: py }}>\n <PlotRow datum={datum} index={i} data={data} render={render} />\n </Group>,\n );\n }\n return <Group {...events}>{nodes}</Group>;\n}\n"],
5
- "mappings": "AAsEQ;AAtER,SAAS,OAAO,0BAA0B;AAG1C,SAAS,eAAe,WAAW,wBAAwB;AAC3D,SAAS,0BAA0B;AACnC,SAAS,QAAW;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAKc;AACZ,SAAO,OAAO,OAAO,OAAO,IAAI;AAClC;AAWO,SAAS,WAAc;AAAA,EAC5B,MAAM;AAAA,EACN,GAAG;AAAA,EACH,GAAG;AAAA,EACH,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAA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@pibbl/core\";\nimport type { PibblNode } from \"@pibbl/core\";\nimport type { PlotSeriesProps } from \"./plot-types.js\";\nimport { pointData } from \"./point-data.js\";\nimport {\n useSeriesPosition,\n seriesAccessor,\n mapSeriesPosition,\n} from \"./series-position.js\";\nfunction PlotRow<D>({\n datum,\n index,\n data,\n render,\n}: {\n datum: D;\n index: number;\n data: readonly D[];\n render: PlotSeriesProps<D>[\"render\"];\n}): PibblNode {\n return render(datum, index, data);\n}\n/**\n * Places keyed custom Pibbl subtrees at local data coordinates.\n *\n * @param props - Data, coordinate accessors, scales, keys, and per-datum renderer. See\n * {@link PlotSeriesProps} .\n * @returns Pibbl nodes placing each rendered datum at its mapped coordinates. See {@link PibblNode}.\n *\n * @see {@link PlotSeriesProps}\n * @see {@link PibblNode}\n */\nexport function PlotSeries<D>({\n data: input,\n x: xInput,\n y: yInput,\n xScale: xId,\n yScale: yId,\n defined,\n keyBy,\n render,\n ...events\n}: PlotSeriesProps<D>): PibblNode {\n const xs = useSeriesPosition(xId),\n ys = useSeriesPosition(yId);\n const data = pointData(resolveSignalValue(input), \"PlotSeries\");\n if (typeof render !== \"function\")\n throw new TypeError(\"PlotSeries: render must be a synchronous function.\");\n const x = seriesAccessor(xInput),\n y = seriesAccessor(yInput);\n const keys = new Set<string>();\n const nodes: PibblNode[] = [];\n for (let i = 0; i < data.length; i++) {\n const datum = data[i];\n if (defined && !defined(datum, i, data)) continue;\n const xv = x(datum, i, data),\n yv = y(datum, i, data);\n const mappedX = mapSeriesPosition(xs, xv),\n mappedY = mapSeriesPosition(ys, yv);\n if (mappedX === undefined || mappedY === undefined) continue;\n const px = mappedX,\n py = mappedY;\n const key =\n keyBy === undefined\n ? i\n : typeof keyBy === \"function\"\n ? keyBy(datum, i, data)\n : datum[keyBy];\n if (typeof key !== \"string\" && typeof key !== \"number\")\n throw new TypeError(\"PlotSeries: keyBy must return a string or number.\");\n const normalized = String(key);\n if (keys.has(normalized))\n throw new Error(`PlotSeries: duplicate key \"${normalized}\".`);\n keys.add(normalized);\n nodes.push(\n <Group key={normalized} style={{ translateX: px, translateY: py }}>\n <PlotRow datum={datum} index={i} data={data} render={render} />\n </Group>,\n );\n }\n return <Group {...events}>{nodes}</Group>;\n}\n"],
5
+ "mappings": "AA4EQ;AA5ER,SAAS,OAAO,0BAA0B;AAG1C,SAAS,iBAAiB;AAC1B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,QAAW;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAKc;AACZ,SAAO,OAAO,OAAO,OAAO,IAAI;AAClC;AAWO,SAAS,WAAc;AAAA,EAC5B,MAAM;AAAA,EACN,GAAG;AAAA,EACH,GAAG;AAAA,EACH,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAkC;AAChC,QAAM,KAAK,kBAAkB,GAAG,GAC9B,KAAK,kBAAkB,GAAG;AAC5B,QAAM,OAAO,UAAU,mBAAmB,KAAK,GAAG,YAAY;AAC9D,MAAI,OAAO,WAAW;AACpB,UAAM,IAAI,UAAU,oDAAoD;AAC1E,QAAM,IAAI,eAAe,MAAM,GAC7B,IAAI,eAAe,MAAM;AAC3B,QAAM,OAAO,oBAAI,IAAY;AAC7B,QAAM,QAAqB,CAAC;AAC5B,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAM,QAAQ,KAAK,CAAC;AACpB,QAAI,WAAW,CAAC,QAAQ,OAAO,GAAG,IAAI,EAAG;AACzC,UAAM,KAAK,EAAE,OAAO,GAAG,IAAI,GACzB,KAAK,EAAE,OAAO,GAAG,IAAI;AACvB,UAAM,UAAU,kBAAkB,IAAI,EAAE,GACtC,UAAU,kBAAkB,IAAI,EAAE;AACpC,QAAI,YAAY,UAAa,YAAY,OAAW;AACpD,UAAM,KAAK,SACT,KAAK;AACP,UAAM,MACJ,UAAU,SACN,IACA,OAAO,UAAU,aACf,MAAM,OAAO,GAAG,IAAI,IACpB,MAAM,KAAK;AACnB,QAAI,OAAO,QAAQ,YAAY,OAAO,QAAQ;AAC5C,YAAM,IAAI,UAAU,mDAAmD;AACzE,UAAM,aAAa,OAAO,GAAG;AAC7B,QAAI,KAAK,IAAI,UAAU;AACrB,YAAM,IAAI,MAAM,8BAA8B,UAAU,IAAI;AAC9D,SAAK,IAAI,UAAU;AACnB,UAAM;AAAA,MACJ,oBAAC,SAAuB,OAAO,EAAE,YAAY,IAAI,YAAY,GAAG,GAC9D,8BAAC,WAAQ,OAAc,OAAO,GAAG,MAAY,QAAgB,KADnD,UAEZ;AAAA,IACF;AAAA,EACF;AACA,SAAO,oBAAC,SAAO,GAAG,QAAS,iBAAM;AACnC;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,8 @@
1
1
  import type { PlotSeries } from "./plot-series.js";
2
2
  import type { PieOptions } from "./pie-slices.js";
3
- import type { PibblEventHandlers, PibblNode, SignalValue } from "@pibbl/core";
4
3
  import type { PointAccessor } from "./point-types.js";
4
+ import type { SeriesAccessor } from "./types.js";
5
+ import type { PibblEventHandlers, PibblNode, SignalValue } from "@pibbl/core";
5
6
  import type { ScaleId } from "./types.js";
6
7
  /**
7
8
  * A property or callback that provides stable identity for a plotted datum.
@@ -34,9 +35,9 @@ export interface PlotSeriesProps<D> extends PibblEventHandlers {
34
35
  */
35
36
  readonly data: SignalValue<readonly D[]>;
36
37
  /** Property key or callback extracting the horizontal domain coordinate. See {@link PointAccessor}. */
37
- readonly x: PointAccessor<D>;
38
+ readonly x: SeriesAccessor<D>;
38
39
  /** Property key or callback extracting the vertical domain coordinate. See {@link PointAccessor}. */
39
- readonly y: PointAccessor<D>;
40
+ readonly y: SeriesAccessor<D>;
40
41
  /** The scale used to map horizontal data coordinates. See {@link ScaleId}. */
41
42
  readonly xScale: ScaleId;
42
43
  /** The scale used to map vertical data coordinates. See {@link ScaleId}. */
@@ -8,4 +8,4 @@ import type { PointSeriesProps } from "./point-types.js";
8
8
  *
9
9
  * @see {@link PointSeriesProps}
10
10
  */
11
- export declare function PointSeries<D>({ data: input, x: xInput, y: yInput, xScale: xId, yScale: yId, defined, style: styleInput, ...events }: PointSeriesProps<D>): import("../../../jsx-runtime.js").JSX.Element;
11
+ export declare function PointSeries<D>({ data: input, x: xInput, y: yInput, xScale: xId, yScale: yId, defined, inspection, style: styleInput, ...events }: PointSeriesProps<D>): import("../../../jsx-runtime.js").JSX.Element;
@@ -6,8 +6,12 @@ import {
6
6
  resolveSignalValue,
7
7
  useCanvasContext
8
8
  } from "@pibbl/core";
9
- import { useContinuousScale } from "./use-continuous-scale.js";
10
- import { finiteCoordinate, pointAccessor, pointData } from "./point-data.js";
9
+ import {
10
+ useSeriesPosition,
11
+ seriesAccessor,
12
+ mapSeriesPosition
13
+ } from "./series-position.js";
14
+ import { pointData } from "./point-data.js";
11
15
  import { appendPointTarget, pointPath } from "./point-geometry.js";
12
16
  import { opacity, width } from "./paint.js";
13
17
  const fields = ["radius", "fill", "stroke", "strokeWidth", "opacity", "cursor"];
@@ -52,22 +56,33 @@ function PointSeries({
52
56
  xScale: xId,
53
57
  yScale: yId,
54
58
  defined,
59
+ inspection,
55
60
  style: styleInput,
56
61
  ...events
57
62
  }) {
58
- const xs = useContinuousScale(xId).get(), ys = useContinuousScale(yId).get();
63
+ const xs = useSeriesPosition(xId), ys = useSeriesPosition(yId);
59
64
  const data = pointData(resolveSignalValue(input), "PointSeries");
60
- const x = pointAccessor(xInput), y = pointAccessor(yInput);
65
+ const x = seriesAccessor(xInput), y = seriesAccessor(yInput);
61
66
  const specified = resolveSignalValue(styleInput);
62
67
  const shared = typeof specified === "function" ? void 0 : normalized(styleObject(specified ?? {}, false));
63
68
  const ctx = useCanvasContext();
64
69
  const target = new Path2D();
70
+ const captured = inspection ? [] : void 0;
71
+ let run = 0;
72
+ if (inspection && (xs.type === "point" || ys.type === "point")) throw new TypeError("Numeric point inspection requires numeric continuous scales.");
65
73
  for (let i = 0; i < data.length; i++) {
66
74
  const datum = data[i];
67
- if (defined && !defined(datum, i, data)) continue;
75
+ if (defined && !defined(datum, i, data)) {
76
+ run++;
77
+ continue;
78
+ }
68
79
  const xv = x(datum, i, data), yv = y(datum, i, data);
69
- if (!finiteCoordinate(xv) || !finiteCoordinate(yv)) continue;
70
- const px = xs.map(xv), py = ys.map(yv);
80
+ const mappedX = mapSeriesPosition(xs, xv), mappedY = mapSeriesPosition(ys, yv);
81
+ if (mappedX === void 0 || mappedY === void 0) {
82
+ run++;
83
+ continue;
84
+ }
85
+ const px = mappedX, py = mappedY;
71
86
  const style = shared ?? normalized(
72
87
  styleObject(
73
88
  specified(
@@ -78,6 +93,7 @@ function PointSeries({
78
93
  true
79
94
  )
80
95
  );
96
+ captured?.push(Object.freeze({ datum, sourceIndex: i, domainX: xv, domainY: yv, anchorLocal: Object.freeze({ x: px, y: py }), run, radiusLocal: style.radius, fill: !!style.fill, strokeWidthLocal: style.stroke ? style.strokeWidth : 0 }));
81
97
  if (style.radius === 0) continue;
82
98
  appendPointTarget(
83
99
  target,
@@ -92,11 +108,21 @@ function PointSeries({
92
108
  try {
93
109
  ctx.globalAlpha *= style.opacity;
94
110
  if (style.fill) {
95
- ctx.fillStyle = resolveTexturePaint(style.fill, ctx, { x: px - style.radius, y: py - style.radius, width: style.radius * 2, height: style.radius * 2 });
111
+ ctx.fillStyle = resolveTexturePaint(style.fill, ctx, {
112
+ x: px - style.radius,
113
+ y: py - style.radius,
114
+ width: style.radius * 2,
115
+ height: style.radius * 2
116
+ });
96
117
  ctx.fill(path);
97
118
  }
98
119
  if (style.stroke && style.strokeWidth > 0) {
99
- ctx.strokeStyle = resolveTexturePaint(style.stroke, ctx, { x: px - style.radius, y: py - style.radius, width: style.radius * 2, height: style.radius * 2 });
120
+ ctx.strokeStyle = resolveTexturePaint(style.stroke, ctx, {
121
+ x: px - style.radius,
122
+ y: py - style.radius,
123
+ width: style.radius * 2,
124
+ height: style.radius * 2
125
+ });
100
126
  ctx.lineWidth = style.strokeWidth;
101
127
  ctx.stroke(path);
102
128
  }
@@ -104,6 +130,7 @@ function PointSeries({
104
130
  ctx.restore();
105
131
  }
106
132
  }
133
+ if (inspection && xs.type !== "point" && ys.type !== "point") inspection.capture({ observations: captured, xScale: xs, yScale: ys });
107
134
  return /* @__PURE__ */ jsx(
108
135
  Path,
109
136
  {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/features/viz/lib/point-series.tsx"],
4
- "sourcesContent": ["import { resolveTexturePaint } from '@pibbl/core/internal';\nimport {\n Path,\n isSignal,\n resolveSignalValue,\n useCanvasContext,\n} from \"@pibbl/core\";\nimport type { FillStyle, StrokeStyle } from \"@pibbl/core\";\nimport type {\n PointMarkStyle,\n PointSeriesProps,\n PointSeriesStyle,\n} from \"./point-types.js\";\nimport { useContinuousScale } from \"./use-continuous-scale.js\";\nimport { finiteCoordinate, pointAccessor, pointData } from \"./point-data.js\";\nimport { appendPointTarget, pointPath } from \"./point-geometry.js\";\nimport { opacity, width } from \"./paint.js\";\nconst fields = [\"radius\", \"fill\", \"stroke\", \"strokeWidth\", \"opacity\", \"cursor\"];\nfunction paint(\n value: unknown,\n name: string,\n): FillStyle | StrokeStyle | undefined {\n if (\n value === undefined ||\n typeof value === \"string\" ||\n value instanceof CanvasGradient ||\n value instanceof CanvasPattern\n )\n return value;\n throw new TypeError(`PointSeries: invalid ${name}.`);\n}\nfunction styleObject(input: unknown, callback: boolean): PointSeriesStyle {\n if (input === null || typeof input !== \"object\" || Array.isArray(input))\n throw new TypeError(\"PointSeries: style must be an object.\");\n const result: Record<string, unknown> = {};\n for (const key of Object.keys(input)) {\n if (!fields.includes(key) || (callback && key === \"cursor\"))\n throw new TypeError(`PointSeries: unsupported style field ${key}.`);\n const value = (input as Record<string, unknown>)[key];\n if (callback && isSignal(value))\n throw new TypeError(\n \"PointSeries: datum styles must contain plain values; read signals explicitly.\",\n );\n result[key] = callback ? value : resolveSignalValue(value);\n }\n return result as PointSeriesStyle;\n}\nfunction normalized(style: PointSeriesStyle) {\n const radius = width(style.radius ?? 3, \"PointSeries radius\");\n if (style.cursor !== undefined && typeof style.cursor !== \"string\")\n throw new TypeError(\"PointSeries: cursor must be a string.\");\n return {\n radius,\n fill: paint(style.fill ?? \"#2563eb\", \"fill\"),\n stroke: paint(style.stroke, \"stroke\"),\n strokeWidth: width(style.strokeWidth ?? 1, \"PointSeries\"),\n opacity: opacity(style.opacity ?? 1, \"PointSeries\"),\n cursor: style.cursor,\n };\n}\n/**\n * Batched circles in source paint order with one ordinary Pibbl target.\n *\n * @param props - Data, coordinate accessors, scales, and point styling. See\n * {@link PointSeriesProps} .\n * @returns Pibbl nodes drawing the point marks.\n *\n * @see {@link PointSeriesProps}\n */\nexport function PointSeries<D>({\n data: input,\n x: xInput,\n y: yInput,\n xScale: xId,\n yScale: yId,\n defined,\n style: styleInput,\n ...events\n}: PointSeriesProps<D>) {\n const xs = useContinuousScale(xId).get(),\n ys = useContinuousScale(yId).get();\n const data = pointData(resolveSignalValue(input), \"PointSeries\");\n const x = pointAccessor(xInput),\n y = pointAccessor(yInput);\n const specified = resolveSignalValue(styleInput);\n const shared =\n typeof specified === \"function\"\n ? undefined\n : normalized(styleObject(specified ?? {}, false));\n const ctx = useCanvasContext();\n const target = new Path2D();\n for (let i = 0; i < data.length; i++) {\n const datum = data[i];\n if (defined && !defined(datum, i, data)) continue;\n const xv = x(datum, i, data),\n yv = y(datum, i, data);\n if (!finiteCoordinate(xv) || !finiteCoordinate(yv)) continue;\n const px = xs.map(xv),\n py = ys.map(yv);\n const style =\n shared ??\n normalized(\n styleObject(\n (specified as (d: D, i: number, a: readonly D[]) => PointMarkStyle)(\n datum,\n i,\n data,\n ),\n true,\n ),\n );\n if (style.radius === 0) continue;\n appendPointTarget(\n target,\n px,\n py,\n style.radius,\n !!style.fill,\n style.stroke ? style.strokeWidth : 0,\n );\n const path = pointPath(px, py, style.radius);\n ctx.save();\n try {\n ctx.globalAlpha *= style.opacity;\n if (style.fill) {\n ctx.fillStyle = resolveTexturePaint(style.fill, ctx, { x: px - style.radius, y: py - style.radius, width: style.radius * 2, height: style.radius * 2 });\n ctx.fill(path);\n }\n if (style.stroke && style.strokeWidth > 0) {\n ctx.strokeStyle = resolveTexturePaint(style.stroke, ctx, { x: px - style.radius, y: py - style.radius, width: style.radius * 2, height: style.radius * 2 });\n ctx.lineWidth = style.strokeWidth;\n ctx.stroke(path);\n }\n } finally {\n ctx.restore();\n }\n }\n return (\n <Path\n {...events}\n style={{ d: target, fill: \"transparent\", cursor: shared?.cursor }}\n />\n );\n}\n"],
5
- "mappings": "AA0II;AA1IJ,SAAS,2BAA2B;AACpC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAOP,SAAS,0BAA0B;AACnC,SAAS,kBAAkB,eAAe,iBAAiB;AAC3D,SAAS,mBAAmB,iBAAiB;AAC7C,SAAS,SAAS,aAAa;AAC/B,MAAM,SAAS,CAAC,UAAU,QAAQ,UAAU,eAAe,WAAW,QAAQ;AAC9E,SAAS,MACP,OACA,MACqC;AACrC,MACE,UAAU,UACV,OAAO,UAAU,YACjB,iBAAiB,kBACjB,iBAAiB;AAEjB,WAAO;AACT,QAAM,IAAI,UAAU,wBAAwB,IAAI,GAAG;AACrD;AACA,SAAS,YAAY,OAAgB,UAAqC;AACxE,MAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK;AACpE,UAAM,IAAI,UAAU,uCAAuC;AAC7D,QAAM,SAAkC,CAAC;AACzC,aAAW,OAAO,OAAO,KAAK,KAAK,GAAG;AACpC,QAAI,CAAC,OAAO,SAAS,GAAG,KAAM,YAAY,QAAQ;AAChD,YAAM,IAAI,UAAU,wCAAwC,GAAG,GAAG;AACpE,UAAM,QAAS,MAAkC,GAAG;AACpD,QAAI,YAAY,SAAS,KAAK;AAC5B,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AACF,WAAO,GAAG,IAA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path,\n isSignal,\n resolveSignalValue,\n useCanvasContext,\n} from \"@pibbl/core\";\nimport type { FillStyle, StrokeStyle } from \"@pibbl/core\";\nimport type {\n PointMarkStyle,\n PointSeriesProps,\n PointSeriesStyle,\n} from \"./point-types.js\";\nimport {\n useSeriesPosition,\n seriesAccessor,\n mapSeriesPosition,\n} from \"./series-position.js\";\nimport { pointData } from \"./point-data.js\";\nimport { appendPointTarget, pointPath } from \"./point-geometry.js\";\nimport { opacity, width } from \"./paint.js\";\nconst fields = [\"radius\", \"fill\", \"stroke\", \"strokeWidth\", \"opacity\", \"cursor\"];\nfunction paint(\n value: unknown,\n name: string,\n): FillStyle | StrokeStyle | undefined {\n if (\n value === undefined ||\n typeof value === \"string\" ||\n value instanceof CanvasGradient ||\n value instanceof CanvasPattern\n )\n return value;\n throw new TypeError(`PointSeries: invalid ${name}.`);\n}\nfunction styleObject(input: unknown, callback: boolean): PointSeriesStyle {\n if (input === null || typeof input !== \"object\" || Array.isArray(input))\n throw new TypeError(\"PointSeries: style must be an object.\");\n const result: Record<string, unknown> = {};\n for (const key of Object.keys(input)) {\n if (!fields.includes(key) || (callback && key === \"cursor\"))\n throw new TypeError(`PointSeries: unsupported style field ${key}.`);\n const value = (input as Record<string, unknown>)[key];\n if (callback && isSignal(value))\n throw new TypeError(\n \"PointSeries: datum styles must contain plain values; read signals explicitly.\",\n );\n result[key] = callback ? value : resolveSignalValue(value);\n }\n return result as PointSeriesStyle;\n}\nfunction normalized(style: PointSeriesStyle) {\n const radius = width(style.radius ?? 3, \"PointSeries radius\");\n if (style.cursor !== undefined && typeof style.cursor !== \"string\")\n throw new TypeError(\"PointSeries: cursor must be a string.\");\n return {\n radius,\n fill: paint(style.fill ?? \"#2563eb\", \"fill\"),\n stroke: paint(style.stroke, \"stroke\"),\n strokeWidth: width(style.strokeWidth ?? 1, \"PointSeries\"),\n opacity: opacity(style.opacity ?? 1, \"PointSeries\"),\n cursor: style.cursor,\n };\n}\n/**\n * Batched circles in source paint order with one ordinary Pibbl target.\n *\n * @param props - Data, coordinate accessors, scales, and point styling. See\n * {@link PointSeriesProps} .\n * @returns Pibbl nodes drawing the point marks.\n *\n * @see {@link PointSeriesProps}\n */\nexport function PointSeries<D>({\n data: input,\n x: xInput,\n y: yInput,\n xScale: xId,\n yScale: yId,\n defined,\n inspection,\n style: styleInput,\n ...events\n}: PointSeriesProps<D>) {\n const xs = useSeriesPosition(xId),\n ys = useSeriesPosition(yId);\n const data = pointData(resolveSignalValue(input), \"PointSeries\");\n const x = seriesAccessor(xInput),\n y = seriesAccessor(yInput);\n const specified = resolveSignalValue(styleInput);\n const shared =\n typeof specified === \"function\"\n ? undefined\n : normalized(styleObject(specified ?? {}, false));\n const ctx = useCanvasContext();\n const target = new Path2D();\n const captured: import(\"../inspection/capture-types.js\").CapturedNumericObservation<D>[] | undefined = inspection ? [] : undefined;\n let run = 0;\n if (inspection && (xs.type === \"point\" || ys.type === \"point\")) throw new TypeError(\"Numeric point inspection requires numeric continuous scales.\");\n for (let i = 0; i < data.length; i++) {\n const datum = data[i];\n if (defined && !defined(datum, i, data)) { run++; continue; }\n const xv = x(datum, i, data),\n yv = y(datum, i, data);\n const mappedX = mapSeriesPosition(xs, xv),\n mappedY = mapSeriesPosition(ys, yv);\n if (mappedX === undefined || mappedY === undefined) { run++; continue; }\n const px = mappedX,\n py = mappedY;\n const style =\n shared ??\n normalized(\n styleObject(\n (specified as (d: D, i: number, a: readonly D[]) => PointMarkStyle)(\n datum,\n i,\n data,\n ),\n true,\n ),\n );\n captured?.push(Object.freeze({datum,sourceIndex:i,domainX:xv as number,domainY:yv as number,anchorLocal:Object.freeze({x:px,y:py}),run,radiusLocal:style.radius,fill:!!style.fill,strokeWidthLocal:style.stroke ? style.strokeWidth : 0}));\n if (style.radius === 0) continue;\n appendPointTarget(\n target,\n px,\n py,\n style.radius,\n !!style.fill,\n style.stroke ? style.strokeWidth : 0,\n );\n const path = pointPath(px, py, style.radius);\n ctx.save();\n try {\n ctx.globalAlpha *= style.opacity;\n if (style.fill) {\n ctx.fillStyle = resolveTexturePaint(style.fill, ctx, {\n x: px - style.radius,\n y: py - style.radius,\n width: style.radius * 2,\n height: style.radius * 2,\n });\n ctx.fill(path);\n }\n if (style.stroke && style.strokeWidth > 0) {\n ctx.strokeStyle = resolveTexturePaint(style.stroke, ctx, {\n x: px - style.radius,\n y: py - style.radius,\n width: style.radius * 2,\n height: style.radius * 2,\n });\n ctx.lineWidth = style.strokeWidth;\n ctx.stroke(path);\n }\n } finally {\n ctx.restore();\n }\n }\n if (inspection && xs.type !== \"point\" && ys.type !== \"point\") inspection.capture({observations:captured!,xScale:xs,yScale:ys});\n return (\n <Path\n {...events}\n style={{ d: target, fill: \"transparent\", cursor: shared?.cursor }}\n />\n );\n}\n"],
5
+ "mappings": "AAgKI;AAhKJ,SAAS,2BAA2B;AACpC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAOP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB,iBAAiB;AAC7C,SAAS,SAAS,aAAa;AAC/B,MAAM,SAAS,CAAC,UAAU,QAAQ,UAAU,eAAe,WAAW,QAAQ;AAC9E,SAAS,MACP,OACA,MACqC;AACrC,MACE,UAAU,UACV,OAAO,UAAU,YACjB,iBAAiB,kBACjB,iBAAiB;AAEjB,WAAO;AACT,QAAM,IAAI,UAAU,wBAAwB,IAAI,GAAG;AACrD;AACA,SAAS,YAAY,OAAgB,UAAqC;AACxE,MAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK;AACpE,UAAM,IAAI,UAAU,uCAAuC;AAC7D,QAAM,SAAkC,CAAC;AACzC,aAAW,OAAO,OAAO,KAAK,KAAK,GAAG;AACpC,QAAI,CAAC,OAAO,SAAS,GAAG,KAAM,YAAY,QAAQ;AAChD,YAAM,IAAI,UAAU,wCAAwC,GAAG,GAAG;AACpE,UAAM,Q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AAC;AACD,YAAI,KAAK,IAAI;AAAA,MACf;AACA,UAAI,MAAM,UAAU,MAAM,cAAc,GAAG;AACzC,YAAI,cAAc,oBAAoB,MAAM,QAAQ,KAAK;AAAA,UACvD,GAAG,KAAK,MAAM;AAAA,UACd,GAAG,KAAK,MAAM;AAAA,UACd,OAAO,MAAM,SAAS;AAAA,UACtB,QAAQ,MAAM,SAAS;AAAA,QACzB,CAAC;AACD,YAAI,YAAY,MAAM;AACtB,YAAI,OAAO,IAAI;AAAA,MACjB;AAAA,IACF,UAAE;AACA,UAAI,QAAQ;AAAA,IACd;AAAA,EACF;AACA,MAAI,cAAc,GAAG,SAAS,WAAW,GAAG,SAAS,QAAS,YAAW,QAAQ,EAAC,cAAa,UAAU,QAAO,IAAG,QAAO,GAAE,CAAC;AAC7H,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,OAAO,EAAE,GAAG,QAAQ,MAAM,eAAe,QAAQ,QAAQ,OAAO;AAAA;AAAA,EAClE;AAEJ;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,5 @@
1
1
  import type { PlotSeriesProps } from "./plot-types.js";
2
+ import type { SeriesAccessor } from "./types.js";
2
3
  import type { PibblEventHandlers, PibblEventParticipationOptions, FillStyle, SignalValue, StrokeStyle } from "@pibbl/core";
3
4
  import type { SignalStyle } from "@pibbl/core/internal";
4
5
  import type { LineAccessor, ScaleId } from "./types.js";
@@ -69,10 +70,12 @@ export interface PointSeriesProps<D> extends PibblEventHandlers, PibblEventParti
69
70
  * Application data supplied to the component or reported by the event. See {@link SignalValue}.
70
71
  */
71
72
  readonly data: SignalValue<readonly D[]>;
73
+ /** Optional committed numeric inspection capture; rendering alone performs no queries. */
74
+ readonly inspection?: import("../inspection/capture-types.js").NumericInspectionRef<D>;
72
75
  /** Property key or callback extracting the horizontal domain coordinate. See {@link PointAccessor}. */
73
- readonly x: PointAccessor<D>;
76
+ readonly x: SeriesAccessor<D>;
74
77
  /** Property key or callback extracting the vertical domain coordinate. See {@link PointAccessor}. */
75
- readonly y: PointAccessor<D>;
78
+ readonly y: SeriesAccessor<D>;
76
79
  /** The scale used to map horizontal data coordinates. See {@link ScaleId}. */
77
80
  readonly xScale: ScaleId;
78
81
  /** The scale used to map vertical data coordinates. See {@link ScaleId}. */
@@ -1,6 +1,6 @@
1
1
  import type { Signal } from "@pibbl/core";
2
2
  import type { ResolvedScale, ScaleId } from "./types.js";
3
- export declare function scaleKind(value: Signal<ResolvedScale>): "band" | "linear" | "log" | "point" | "symlog" | "utc" | undefined;
3
+ export declare function scaleKind(value: Signal<ResolvedScale>): "band" | "linear" | "log" | "point" | "symlog" | "trading-time" | "utc" | undefined;
4
4
  export declare function provideScale(id: ScaleId, value: Signal<ResolvedScale>, kind: ResolvedScale["type"]): void;
5
5
  export declare function lookupScale(id: ScaleId | undefined, receiver: string): Signal<ResolvedScale> | undefined;
6
6
  /** Invocation-scoped lookup for official viz receivers; does not allocate a hook. */
@@ -1,21 +1,35 @@
1
1
  import { resolveSignalValue } from "@pibbl/core";
2
2
  function ticks(scale, props) {
3
3
  if (props.tickValues !== void 0 && props.tickCount !== void 0)
4
- throw new TypeError("Axis tickValues and tickCount are mutually exclusive.");
4
+ throw new TypeError(
5
+ "Axis tickValues and tickCount are mutually exclusive."
6
+ );
5
7
  const explicit = props.tickValues === void 0 ? void 0 : resolveSignalValue(props.tickValues);
6
8
  if (explicit !== void 0) {
7
9
  if (!Array.isArray(explicit) || explicit.length > 100)
8
- throw new RangeError("Axis tickValues must be an array with at most 100 values.");
10
+ throw new RangeError(
11
+ "Axis tickValues must be an array with at most 100 values."
12
+ );
9
13
  const seen = /* @__PURE__ */ new Set();
10
14
  for (const value of explicit) {
11
- if (seen.has(value)) throw new RangeError("Axis tickValues must not contain duplicates.");
15
+ if (seen.has(value))
16
+ throw new RangeError("Axis tickValues must not contain duplicates.");
12
17
  seen.add(value);
13
- if (scale.type !== "band" && scale.type !== "point") {
18
+ if (scale.type === "trading-time") {
19
+ if (typeof value !== "number" || scale.slotAtTime(value) === void 0)
20
+ throw new RangeError(
21
+ "Axis trading-time ticks must be supplied timestamps."
22
+ );
23
+ } else if (scale.type !== "band" && scale.type !== "point") {
14
24
  if (typeof value !== "number" || !Number.isFinite(value))
15
- throw new TypeError("Axis tickValues for a continuous scale must be finite numbers.");
25
+ throw new TypeError(
26
+ "Axis tickValues for a continuous scale must be finite numbers."
27
+ );
16
28
  const [a, b] = scale.domain;
17
29
  if (value < Math.min(a, b) || value > Math.max(a, b))
18
- throw new RangeError("Axis tickValues must be within the scale domain.");
30
+ throw new RangeError(
31
+ "Axis tickValues must be within the scale domain."
32
+ );
19
33
  } else if (typeof value !== "string" && (typeof value !== "number" || !Number.isFinite(value)) || scale.map(value) === void 0) {
20
34
  throw new RangeError("Axis tickValues must be known band categories.");
21
35
  }
@@ -26,6 +40,7 @@ function ticks(scale, props) {
26
40
  if (!Number.isInteger(count) || count < 0 || count > 100)
27
41
  throw new RangeError("Axis tickCount must be an integer from 0 to 100.");
28
42
  if (count === 0) return [];
43
+ if (scale.type === "trading-time") return scale.ticks(count);
29
44
  if (scale.type !== "band" && scale.type !== "point")
30
45
  return count === 1 ? [scale.domain[0]] : scale.ticks(count);
31
46
  const n = scale.domain.length;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/features/viz/lib/scale-ticks.ts"],
4
- "sourcesContent": ["import { resolveSignalValue } from \"@pibbl/core\";\nimport type { AxisProps, BandCategory, ResolvedScale } from \"./types.js\";\ntype Tick = number | string;\n\nexport function ticks(scale: ResolvedScale, props: Pick<AxisProps, \"tickValues\" | \"tickCount\">): readonly Tick[] {\n if (props.tickValues !== undefined && props.tickCount !== undefined)\n throw new TypeError(\"Axis tickValues and tickCount are mutually exclusive.\");\n const explicit = props.tickValues === undefined\n ? undefined\n : resolveSignalValue(props.tickValues);\n if (explicit !== undefined) {\n if (!Array.isArray(explicit) || explicit.length > 100)\n throw new RangeError(\"Axis tickValues must be an array with at most 100 values.\");\n const seen = new Set<Tick>();\n for (const value of explicit) {\n if (seen.has(value)) throw new RangeError(\"Axis tickValues must not contain duplicates.\");\n seen.add(value);\n if (scale.type !== \"band\" && scale.type !== \"point\") {\n if (typeof value !== \"number\" || !Number.isFinite(value))\n throw new TypeError(\"Axis tickValues for a continuous scale must be finite numbers.\");\n const [a, b] = scale.domain;\n if (value < Math.min(a, b) || value > Math.max(a, b))\n throw new RangeError(\"Axis tickValues must be within the scale domain.\");\n } else if (\n (typeof value !== \"string\" &&\n (typeof value !== \"number\" || !Number.isFinite(value))) ||\n scale.map(value as BandCategory) === undefined\n ) {\n throw new RangeError(\"Axis tickValues must be known band categories.\");\n }\n }\n return explicit;\n }\n const count = resolveSignalValue(props.tickCount ?? 5);\n if (!Number.isInteger(count) || count < 0 || count > 100)\n throw new RangeError(\"Axis tickCount must be an integer from 0 to 100.\");\n if (count === 0) return [];\n if (scale.type !== \"band\" && scale.type !== \"point\")\n return count === 1 ? [scale.domain[0]] : scale.ticks(count);\n const n = scale.domain.length;\n if (n === 0) return [];\n if (count === 1) return [scale.domain[0]];\n const m = Math.min(count, n);\n if (m === 1) return [scale.domain[0]];\n return Array.from(\n { length: m },\n (_, index) => scale.domain[Math.round((index * (n - 1)) / (m - 1))]!,\n );\n}\n\nexport function position(scale: ResolvedScale, value: Tick): number {\n if (scale.type === \"point\") return scale.map(value as BandCategory)!;\n return scale.type === \"band\"\n ? scale.map(value as BandCategory)! + scale.bandwidth / 2\n : scale.map(value as number);\n}\n\n"],
5
- "mappings": "AAAA,SAAS,0BAA0B;AAI5B,SAAS,MAAM,OAAsB,OAAqE;AAC/G,MAAI,MAAM,eAAe,UAAa,MAAM,cAAc;AACxD,UAAM,IAAI,UAAU,uDAAuD;AAC7E,QAAM,WAAW,MAAM,eAAe,SAClC,SACA,mBAAmB,MAAM,UAAU;AACvC,MAAI,aAAa,QAAW;AAC1B,QAAI,CAAC,MAAM,QAAQ,QAAQ,KAAK,SAAS,S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,EAAE;AAAA,IACZ,CAAC,GAAG,UAAU,MAAM,OAAO,KAAK,MAAO,SAAS,IAAI,MAAO,IAAI,EAAE,CAAC;AAAA,EACpE;AACF;AAEO,SAAS,SAAS,OAAsB,OAAqB;AAClE,MAAI,MAAM,SAAS,QAAS,QAAO,MAAM,IAAI,KAAqB;AAClE,SAAO,MAAM,SAAS,SAClB,MAAM,IAAI,KAAqB,IAAK,MAAM,YAAY,IACtD,MAAM,IAAI,KAAe;AAC/B;",
4
+ "sourcesContent": ["import { resolveSignalValue } from \"@pibbl/core\";\nimport type { AxisProps, BandCategory, ResolvedScale } from \"./types.js\";\ntype Tick = number | string;\n\nexport function ticks(\n scale: ResolvedScale,\n props: Pick<AxisProps, \"tickValues\" | \"tickCount\">,\n): readonly Tick[] {\n if (props.tickValues !== undefined && props.tickCount !== undefined)\n throw new TypeError(\n \"Axis tickValues and tickCount are mutually exclusive.\",\n );\n const explicit =\n props.tickValues === undefined\n ? undefined\n : resolveSignalValue(props.tickValues);\n if (explicit !== undefined) {\n if (!Array.isArray(explicit) || explicit.length > 100)\n throw new RangeError(\n \"Axis tickValues must be an array with at most 100 values.\",\n );\n const seen = new Set<Tick>();\n for (const value of explicit) {\n if (seen.has(value))\n throw new RangeError(\"Axis tickValues must not contain duplicates.\");\n seen.add(value);\n if (scale.type === \"trading-time\") {\n if (typeof value !== \"number\" || scale.slotAtTime(value) === undefined)\n throw new RangeError(\n \"Axis trading-time ticks must be supplied timestamps.\",\n );\n } else if (scale.type !== \"band\" && scale.type !== \"point\") {\n if (typeof value !== \"number\" || !Number.isFinite(value))\n throw new TypeError(\n \"Axis tickValues for a continuous scale must be finite numbers.\",\n );\n const [a, b] = scale.domain;\n if (value < Math.min(a, b) || value > Math.max(a, b))\n throw new RangeError(\n \"Axis tickValues must be within the scale domain.\",\n );\n } else if (\n (typeof value !== \"string\" &&\n (typeof value !== \"number\" || !Number.isFinite(value))) ||\n scale.map(value as BandCategory) === undefined\n ) {\n throw new RangeError(\"Axis tickValues must be known band categories.\");\n }\n }\n return explicit;\n }\n const count = resolveSignalValue(props.tickCount ?? 5);\n if (!Number.isInteger(count) || count < 0 || count > 100)\n throw new RangeError(\"Axis tickCount must be an integer from 0 to 100.\");\n if (count === 0) return [];\n if (scale.type === \"trading-time\") return scale.ticks(count);\n if (scale.type !== \"band\" && scale.type !== \"point\")\n return count === 1 ? [scale.domain[0]] : scale.ticks(count);\n const n = scale.domain.length;\n if (n === 0) return [];\n if (count === 1) return [scale.domain[0]];\n const m = Math.min(count, n);\n if (m === 1) return [scale.domain[0]];\n return Array.from(\n { length: m },\n (_, index) => scale.domain[Math.round((index * (n - 1)) / (m - 1))]!,\n );\n}\n\nexport function position(scale: ResolvedScale, value: Tick): number {\n if (scale.type === \"point\") return scale.map(value as BandCategory)!;\n return scale.type === \"band\"\n ? scale.map(value as BandCategory)! + scale.bandwidth / 2\n : scale.map(value as number);\n}\n"],
5
+ "mappings": "AAAA,SAAS,0BAA0B;AAI5B,SAAS,MACd,OACA,OACiB;AACjB,MAAI,MAAM,eAAe,UAAa,MAAM,cAAc;AACxD,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AACF,QAAM,WACJ,MAAM,eAAe,SACjB,SACA,mBAAmB,MAAM,UAAU;AACzC,MAAI,aAAa,QAAW;AAC1B,QAAI,CAAC,MAAM,QAAQ,QAAQ,KAAK,SAAS,SAAS;AAChD,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AACF,UAAM,OAAO,oBAAI,IAAU;AAC3B,eAAW,SAAS,UAAU;AAC5B,UAAI,KAAK,IAAI,KAAK;AAChB,cAAM,IAAI,WAAW,8CAA8C;AACrE,WAAK,IAAI,KAAK;AACd,UAAI,MAAM,SAAS,gBAAgB;AACjC,YAAI,OAAO,UAAU,YAAY,MAAM,WAAW,KAAK,MAAM;AAC3D,gBAAM,IAAI;AAAA,YACR;AAAA,UACF;AAAA,MACJ,WAAW,MAAM,SAAS,UAAU,MAAM,SAAS,SAAS;AAC1D,YAAI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QAAS,QAAO,MAAM,IAAI,KAAqB;AAClE,SAAO,MAAM,SAAS,SAClB,MAAM,IAAI,KAAqB,IAAK,MAAM,YAAY,IACtD,MAAM,IAAI,KAAe;AAC/B;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,11 @@
1
+ import { type Signal } from "@pibbl/core";
2
+ import type { SequentialColorScaleProps, ResolvedSequentialColorScale } from "./color-types.js";
3
+ import type { ScaleId } from "./types.js";
4
+ /** Provides an allocation-independent sequential color mapping.
5
+ * @param props - Explicit domain, colors, identity, and children. See {@link SequentialColorScaleProps}.
6
+ * @returns Descendant content. */
7
+ export declare function SequentialColorScale(props: SequentialColorScaleProps): import("@pibbl/core").PibblNode;
8
+ /** Reads the dedicated ancestor sequential mapping.
9
+ * @param id - Color-scale identity. See {@link ScaleId}.
10
+ * @returns Shared readonly mapping signal. See {@link ResolvedSequentialColorScale}. */
11
+ export declare function useSequentialColorScale(id: ScaleId): Signal<ResolvedSequentialColorScale>;
@@ -0,0 +1,49 @@
1
+ import { resolveSignalValue } from "@pibbl/core";
2
+ import { provideColor, useColor } from "./color-context.js";
3
+ import {
4
+ colorMix,
5
+ colorPosition,
6
+ finiteColorValue,
7
+ hexColor
8
+ } from "./color-math.js";
9
+ function resolve(props) {
10
+ const input = resolveSignalValue(props.domain), paint = resolveSignalValue(props.colors);
11
+ if (!Array.isArray(input) || input.length !== 2 || !Array.isArray(paint) || paint.length !== 2)
12
+ throw new RangeError(
13
+ "Sequential color scales require two domain endpoints and two colors."
14
+ );
15
+ const domain = Object.freeze(
16
+ Array.from(input, finiteColorValue)
17
+ ), colors = Object.freeze(Array.from(paint, hexColor));
18
+ const stops = Object.freeze(
19
+ domain.map((value, i) => Object.freeze({ value, color: colors[i] }))
20
+ );
21
+ return Object.freeze({
22
+ domain,
23
+ colors,
24
+ stops,
25
+ map(value) {
26
+ finiteColorValue(value);
27
+ return colorMix(
28
+ colors[0],
29
+ colors[1],
30
+ colorPosition(value, domain[0], domain[1])
31
+ );
32
+ }
33
+ });
34
+ }
35
+ function SequentialColorScale(props) {
36
+ provideColor(props.id, "sequential", () => resolve(props), [
37
+ props.domain,
38
+ props.colors
39
+ ]);
40
+ return props.children;
41
+ }
42
+ function useSequentialColorScale(id) {
43
+ return useColor(id, "sequential");
44
+ }
45
+ export {
46
+ SequentialColorScale,
47
+ useSequentialColorScale
48
+ };
49
+ //# sourceMappingURL=sequential-color-scale.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/features/viz/lib/sequential-color-scale.ts"],
4
+ "sourcesContent": ["import { resolveSignalValue, type Signal } from \"@pibbl/core\";\nimport type {\n SequentialColorScaleProps,\n ResolvedSequentialColorScale,\n} from \"./color-types.js\";\nimport type { ScaleId } from \"./types.js\";\nimport { provideColor, useColor } from \"./color-context.js\";\nimport {\n colorMix,\n colorPosition,\n finiteColorValue,\n hexColor,\n} from \"./color-math.js\";\nfunction resolve(\n props: SequentialColorScaleProps,\n): ResolvedSequentialColorScale {\n const input = resolveSignalValue(props.domain),\n paint = resolveSignalValue(props.colors);\n if (\n !Array.isArray(input) ||\n input.length !== 2 ||\n !Array.isArray(paint) ||\n paint.length !== 2\n )\n throw new RangeError(\n \"Sequential color scales require two domain endpoints and two colors.\",\n );\n const domain = Object.freeze(\n Array.from(input, finiteColorValue),\n ) as readonly [number, number],\n colors = Object.freeze(Array.from(paint, hexColor)) as readonly [\n string,\n string,\n ];\n const stops = Object.freeze(\n domain.map((value, i) => Object.freeze({ value, color: colors[i] })),\n );\n return Object.freeze({\n domain,\n colors,\n stops,\n map(value: number) {\n finiteColorValue(value);\n return colorMix(\n colors[0],\n colors[1],\n colorPosition(value, domain[0], domain[1]),\n );\n },\n });\n}\n/** Provides an allocation-independent sequential color mapping.\n * @param props - Explicit domain, colors, identity, and children. See {@link SequentialColorScaleProps}.\n * @returns Descendant content. */\nexport function SequentialColorScale(props: SequentialColorScaleProps) {\n provideColor(props.id, \"sequential\", () => resolve(props), [\n props.domain,\n props.colors,\n ]);\n return props.children;\n}\n/** Reads the dedicated ancestor sequential mapping.\n * @param id - Color-scale identity. See {@link ScaleId}.\n * @returns Shared readonly mapping signal. See {@link ResolvedSequentialColorScale}. */\nexport function useSequentialColorScale(\n id: ScaleId,\n): Signal<ResolvedSequentialColorScale> {\n return useColor(id, \"sequential\");\n}\n"],
5
+ "mappings": "AAAA,SAAS,0BAAuC;AAMhD,SAAS,cAAc,gBAAgB;AACvC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,QACP,OAC8B;AAC9B,QAAM,QAAQ,mBAAmB,MAAM,MAAM,GAC3C,QAAQ,mBAAmB,MAAM,MAAM;AACzC,MACE,CAAC,MAAM,QAAQ,KAAK,KACpB,MAAM,WAAW,KACjB,CAAC,MAAM,QAAQ,KAAK,KACpB,MAAM,WAAW;AAEjB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AACF,QAAM,SAAS,OAAO;AAAA,IAClB,MAAM,KAAK,OAAO,gBAAgB;AAAA,EACpC,GACA,SAAS,OAAO,OAAO,MAAM,KAAK,OAAO,QAAQ,CAAC;AAIpD,QAAM,QAAQ,OAAO;AAAA,IACnB,OAAO,IAAI,CAAC,OAAO,MAAM,OAAO,OAAO,EAAE,OAAO,OAAO,OAAO,CAAC,EAAE,CAAC,CAAC;AAAA,EACrE;AACA,SAAO,OAAO,OAAO;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,IACA,IAAI,OAAe;AACjB,uBAAiB,KAAK;AACtB,aAAO;AAAA,QACL,OAAO,CAAC;AAAA,QACR,OAAO,CAAC;AAAA,QACR,cAAc,OAAO,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC;AAAA,MAC3C;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAIO,SAAS,qBAAqB,OAAkC;AACrE,eAAa,MAAM,IAAI,cAAc,MAAM,QAAQ,KAAK,GAAG;AAAA,IACzD,MAAM;AAAA,IACN,MAAM;AAAA,EACR,CAAC;AACD,SAAO,MAAM;AACf;AAIO,SAAS,wBACd,IACsC;AACtC,SAAO,SAAS,IAAI,YAAY;AAClC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,12 @@
1
+ import type { ResolvedContinuousScale, ResolvedPointScale, ScaleId, SeriesAccessor, SeriesCoordinate } from "./types.js";
2
+ export type NumericPositionScale = ResolvedContinuousScale | import("./trading-time-scale.js").ResolvedTradingTimeScale;
3
+ type PositionScale = NumericPositionScale | ResolvedPointScale;
4
+ /** Private position receiver; public scale hooks retain their dedicated contracts. */
5
+ export declare function useSeriesPosition(id: ScaleId): PositionScale;
6
+ export declare function seriesAccessor<D>(input: SeriesAccessor<D>): (datum: D, index: number, data: readonly D[]) => SeriesCoordinate;
7
+ export declare function mapSeriesPosition(scale: PositionScale, value: SeriesCoordinate): number | undefined;
8
+ /** Private numeric/trading receiver; public continuous hook stays unchanged. */
9
+ export declare function useNumericPosition(id: ScaleId): NumericPositionScale;
10
+ /** Returns explicit supplied time for trading positions, continuous inverse otherwise. */
11
+ export declare function invertNumericPosition(scale: NumericPositionScale, position: number): number | undefined;
12
+ export {};