@pibbl/core 0.0.2 → 0.0.3-alpha.90.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 (285) 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 +68 -6
  30. package/dist/features/viz/index.js +164 -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/graph/bipartite.d.ts +14 -0
  120. package/dist/features/viz/lib/graph/bipartite.js +250 -0
  121. package/dist/features/viz/lib/graph/bipartite.js.map +7 -0
  122. package/dist/features/viz/lib/graph/chord.d.ts +44 -0
  123. package/dist/features/viz/lib/graph/chord.js +348 -0
  124. package/dist/features/viz/lib/graph/chord.js.map +7 -0
  125. package/dist/features/viz/lib/graph/dependency.d.ts +26 -0
  126. package/dist/features/viz/lib/graph/dependency.js +141 -0
  127. package/dist/features/viz/lib/graph/dependency.js.map +7 -0
  128. package/dist/features/viz/lib/graph/force.d.ts +28 -0
  129. package/dist/features/viz/lib/graph/force.js +580 -0
  130. package/dist/features/viz/lib/graph/force.js.map +7 -0
  131. package/dist/features/viz/lib/graph/hierarchy.d.ts +21 -0
  132. package/dist/features/viz/lib/graph/hierarchy.js +112 -0
  133. package/dist/features/viz/lib/graph/hierarchy.js.map +7 -0
  134. package/dist/features/viz/lib/graph/icicle.d.ts +16 -0
  135. package/dist/features/viz/lib/graph/icicle.js +153 -0
  136. package/dist/features/viz/lib/graph/icicle.js.map +7 -0
  137. package/dist/features/viz/lib/graph/matrix.d.ts +30 -0
  138. package/dist/features/viz/lib/graph/matrix.js +243 -0
  139. package/dist/features/viz/lib/graph/matrix.js.map +7 -0
  140. package/dist/features/viz/lib/graph/neighborhood.d.ts +11 -0
  141. package/dist/features/viz/lib/graph/neighborhood.js +281 -0
  142. package/dist/features/viz/lib/graph/neighborhood.js.map +7 -0
  143. package/dist/features/viz/lib/graph/routes.d.ts +35 -0
  144. package/dist/features/viz/lib/graph/routes.js +102 -0
  145. package/dist/features/viz/lib/graph/routes.js.map +7 -0
  146. package/dist/features/viz/lib/graph/sankey.d.ts +44 -0
  147. package/dist/features/viz/lib/graph/sankey.js +341 -0
  148. package/dist/features/viz/lib/graph/sankey.js.map +7 -0
  149. package/dist/features/viz/lib/graph/shared.d.ts +59 -0
  150. package/dist/features/viz/lib/graph/shared.js +296 -0
  151. package/dist/features/viz/lib/graph/shared.js.map +7 -0
  152. package/dist/features/viz/lib/graph/tree.d.ts +11 -0
  153. package/dist/features/viz/lib/graph/tree.js +232 -0
  154. package/dist/features/viz/lib/graph/tree.js.map +7 -0
  155. package/dist/features/viz/lib/graph/treemap.d.ts +20 -0
  156. package/dist/features/viz/lib/graph/treemap.js +227 -0
  157. package/dist/features/viz/lib/graph/treemap.js.map +7 -0
  158. package/dist/features/viz/lib/graph/types.d.ts +1097 -0
  159. package/dist/features/viz/lib/hover-data.d.ts +1 -1
  160. package/dist/features/viz/lib/hover-data.js +5 -2
  161. package/dist/features/viz/lib/hover-data.js.map +2 -2
  162. package/dist/features/viz/lib/interval-band-series.d.ts +49 -0
  163. package/dist/features/viz/lib/interval-band-series.js +136 -0
  164. package/dist/features/viz/lib/interval-band-series.js.map +7 -0
  165. package/dist/features/viz/lib/interval-diamond-series.d.ts +43 -0
  166. package/dist/features/viz/lib/interval-diamond-series.js +124 -0
  167. package/dist/features/viz/lib/interval-diamond-series.js.map +7 -0
  168. package/dist/features/viz/lib/interval-series.d.ts +79 -0
  169. package/dist/features/viz/lib/interval-series.js +158 -0
  170. package/dist/features/viz/lib/interval-series.js.map +7 -0
  171. package/dist/features/viz/lib/line-series.d.ts +1 -1
  172. package/dist/features/viz/lib/line-series.js +47 -28
  173. package/dist/features/viz/lib/line-series.js.map +2 -2
  174. package/dist/features/viz/lib/linear-scale.js +1 -1
  175. package/dist/features/viz/lib/linear-scale.js.map +2 -2
  176. package/dist/features/viz/lib/monotone-curve.d.ts +11 -0
  177. package/dist/features/viz/lib/monotone-curve.js +63 -0
  178. package/dist/features/viz/lib/monotone-curve.js.map +7 -0
  179. package/dist/features/viz/lib/numeric-range-interpolation.d.ts +15 -0
  180. package/dist/features/viz/lib/numeric-range-interpolation.js +36 -0
  181. package/dist/features/viz/lib/numeric-range-interpolation.js.map +7 -0
  182. package/dist/features/viz/lib/ohlc-bar-series.d.ts +55 -0
  183. package/dist/features/viz/lib/ohlc-bar-series.js +168 -0
  184. package/dist/features/viz/lib/ohlc-bar-series.js.map +7 -0
  185. package/dist/features/viz/lib/paired-series.d.ts +44 -0
  186. package/dist/features/viz/lib/paired-series.js +93 -0
  187. package/dist/features/viz/lib/paired-series.js.map +7 -0
  188. package/dist/features/viz/lib/plot-series.js +11 -6
  189. package/dist/features/viz/lib/plot-series.js.map +2 -2
  190. package/dist/features/viz/lib/plot-types.d.ts +4 -3
  191. package/dist/features/viz/lib/point-series.d.ts +1 -1
  192. package/dist/features/viz/lib/point-series.js +36 -9
  193. package/dist/features/viz/lib/point-series.js.map +2 -2
  194. package/dist/features/viz/lib/point-types.d.ts +5 -2
  195. package/dist/features/viz/lib/scale-context.d.ts +1 -1
  196. package/dist/features/viz/lib/scale-ticks.js +21 -6
  197. package/dist/features/viz/lib/scale-ticks.js.map +2 -2
  198. package/dist/features/viz/lib/sequential-color-scale.d.ts +11 -0
  199. package/dist/features/viz/lib/sequential-color-scale.js +49 -0
  200. package/dist/features/viz/lib/sequential-color-scale.js.map +7 -0
  201. package/dist/features/viz/lib/series-position.d.ts +12 -0
  202. package/dist/features/viz/lib/series-position.js +44 -0
  203. package/dist/features/viz/lib/series-position.js.map +7 -0
  204. package/dist/features/viz/lib/step-curves.d.ts +19 -0
  205. package/dist/features/viz/lib/step-curves.js +53 -0
  206. package/dist/features/viz/lib/step-curves.js.map +7 -0
  207. package/dist/features/viz/lib/threshold-color-scale.d.ts +43 -0
  208. package/dist/features/viz/lib/threshold-color-scale.js +59 -0
  209. package/dist/features/viz/lib/threshold-color-scale.js.map +7 -0
  210. package/dist/features/viz/lib/trading-time-mapping.d.ts +32 -0
  211. package/dist/features/viz/lib/trading-time-mapping.js +89 -0
  212. package/dist/features/viz/lib/trading-time-mapping.js.map +7 -0
  213. package/dist/features/viz/lib/trading-time-scale.d.ts +83 -0
  214. package/dist/features/viz/lib/trading-time-scale.js +96 -0
  215. package/dist/features/viz/lib/trading-time-scale.js.map +7 -0
  216. package/dist/features/viz/lib/trajectory-series.d.ts +71 -0
  217. package/dist/features/viz/lib/trajectory-series.js +111 -0
  218. package/dist/features/viz/lib/trajectory-series.js.map +7 -0
  219. package/dist/features/viz/lib/types.d.ts +20 -4
  220. package/dist/features/viz/lib/use-continuous-scale.js +6 -1
  221. package/dist/features/viz/lib/use-continuous-scale.js.map +2 -2
  222. package/dist/features/viz/lib/volume-series.d.ts +59 -0
  223. package/dist/features/viz/lib/volume-series.js +117 -0
  224. package/dist/features/viz/lib/volume-series.js.map +7 -0
  225. package/dist/features/viz/lib/weighted-point-series.d.ts +71 -0
  226. package/dist/features/viz/lib/weighted-point-series.js +169 -0
  227. package/dist/features/viz/lib/weighted-point-series.js.map +7 -0
  228. package/dist/filters/backdrop-contrast-gpu.d.ts +5 -0
  229. package/dist/filters/backdrop-contrast-gpu.js +33 -0
  230. package/dist/filters/backdrop-contrast-gpu.js.map +7 -0
  231. package/dist/filters/backdrop-contrast.d.ts +21 -0
  232. package/dist/filters/backdrop-contrast.js +61 -0
  233. package/dist/filters/backdrop-contrast.js.map +7 -0
  234. package/dist/filters/emboss-gpu.d.ts +4 -0
  235. package/dist/filters/emboss-gpu.js +39 -0
  236. package/dist/filters/emboss-gpu.js.map +7 -0
  237. package/dist/filters/emboss.d.ts +32 -0
  238. package/dist/filters/emboss.js +106 -0
  239. package/dist/filters/emboss.js.map +7 -0
  240. package/dist/filters/filter-executor.d.ts +11 -4
  241. package/dist/filters/filter-executor.js +104 -49
  242. package/dist/filters/filter-executor.js.map +2 -2
  243. package/dist/filters/reflection-gpu.d.ts +3 -1
  244. package/dist/filters/reflection-gpu.js +5 -2
  245. package/dist/filters/reflection-gpu.js.map +2 -2
  246. package/dist/filters/render-backdrop-contrast-boundary.d.ts +31 -0
  247. package/dist/filters/render-backdrop-contrast-boundary.js +116 -0
  248. package/dist/filters/render-backdrop-contrast-boundary.js.map +7 -0
  249. package/dist/filters/render-emboss-boundary.d.ts +13 -0
  250. package/dist/filters/render-emboss-boundary.js +131 -0
  251. package/dist/filters/render-emboss-boundary.js.map +7 -0
  252. package/dist/filters.d.ts +9 -5
  253. package/dist/filters.js +4 -0
  254. package/dist/filters.js.map +2 -2
  255. package/dist/index.d.ts +2 -0
  256. package/dist/index.js +3 -0
  257. package/dist/index.js.map +2 -2
  258. package/dist/internal.d.ts +2 -0
  259. package/dist/internal.js +4 -0
  260. package/dist/internal.js.map +2 -2
  261. package/dist/lib/events/event-facade.d.ts +13 -0
  262. package/dist/lib/events/event-facade.js +23 -0
  263. package/dist/lib/events/event-facade.js.map +2 -2
  264. package/dist/lib/events/propagation.js +19 -14
  265. package/dist/lib/events/propagation.js.map +2 -2
  266. package/dist/lib/execute-render.js +13 -0
  267. package/dist/lib/execute-render.js.map +2 -2
  268. package/dist/lib/recording/recording.d.ts +43 -0
  269. package/dist/lib/recording/recording.js +555 -0
  270. package/dist/lib/recording/recording.js.map +7 -0
  271. package/dist/lib/recording/types.d.ts +118 -0
  272. package/dist/lib/recording/wasm-bytes.d.ts +1 -0
  273. package/dist/lib/recording/wasm-bytes.js +5 -0
  274. package/dist/lib/recording/wasm-bytes.js.map +7 -0
  275. package/dist/lib/recording/worker-source.d.ts +1 -0
  276. package/dist/lib/recording/worker-source.js +5 -0
  277. package/dist/lib/recording/worker-source.js.map +7 -0
  278. package/dist/lib/render-transaction.d.ts +5 -2
  279. package/dist/lib/render-transaction.js +23 -1
  280. package/dist/lib/render-transaction.js.map +2 -2
  281. package/dist/lib/series-inspection-frame.d.ts +18 -0
  282. package/dist/lib/series-inspection-frame.js +70 -0
  283. package/dist/lib/series-inspection-frame.js.map +7 -0
  284. package/dist/lib/types.d.ts +6 -0
  285. package/package.json +10 -2
@@ -0,0 +1,168 @@
1
+ import { jsx, jsxs } from "@pibbl/core/jsx-runtime";
2
+ import {
3
+ Group,
4
+ Path,
5
+ resolveSignalValue
6
+ } from "@pibbl/core";
7
+ import { withHooksForbidden } from "@pibbl/core/internal";
8
+ import { financialMarkWidth } from "./financial-geometry.js";
9
+ import { opacity, width } from "./paint.js";
10
+ import { finiteCoordinate, pointAccessor, pointData } from "./point-data.js";
11
+ import { useNumericPosition } from "./series-position.js";
12
+ import { useContinuousScale } from "./use-continuous-scale.js";
13
+ function OhlcBarSeries({
14
+ data: input,
15
+ time: timeInput,
16
+ open: openInput,
17
+ high: highInput,
18
+ low: lowInput,
19
+ close: closeInput,
20
+ xScale,
21
+ yScale,
22
+ defined,
23
+ style: styleInput,
24
+ inspection,
25
+ pointerEvents,
26
+ ...events
27
+ }) {
28
+ const xs = useNumericPosition(xScale), ys = useContinuousScale(yScale).get();
29
+ const data = pointData(resolveSignalValue(input), "OhlcBarSeries");
30
+ const time = pointAccessor(timeInput), open = pointAccessor(openInput), high = pointAccessor(highInput), low = pointAccessor(lowInput), close = pointAccessor(closeInput);
31
+ const rows = [];
32
+ for (let i = 0; i < data.length; i++) {
33
+ const datum = data[i];
34
+ if (defined && !defined(datum, i, data)) continue;
35
+ const t = time(datum, i, data), o = open(datum, i, data), h = high(datum, i, data), l = low(datum, i, data), c = close(datum, i, data);
36
+ if (!finiteCoordinate(t) || !finiteCoordinate(o) || !finiteCoordinate(h) || !finiteCoordinate(l) || !finiteCoordinate(c))
37
+ continue;
38
+ if (l > Math.min(o, c) || h < Math.max(o, c))
39
+ throw new RangeError(
40
+ `OhlcBarSeries: malformed OHLC at source index ${i}; require low <= open/close <= high.`
41
+ );
42
+ rows.push({
43
+ datum,
44
+ sourceIndex: i,
45
+ time: t,
46
+ open: o,
47
+ high: h,
48
+ low: l,
49
+ close: c,
50
+ x: xs.map(t)
51
+ });
52
+ }
53
+ const defaultWidth = financialMarkWidth(rows.map((row) => row.x));
54
+ const specified = typeof styleInput === "function" ? styleInput : resolveSignalValue(styleInput);
55
+ const marks = inspection ? [] : void 0;
56
+ const batches = [];
57
+ for (const row of rows) {
58
+ const style = typeof specified === "function" ? withHooksForbidden(
59
+ "OhlcBarSeries style callback",
60
+ () => specified(row.datum, row.sourceIndex, data)
61
+ ) : specified ?? {};
62
+ const markWidth = style.bandwidth === void 0 || style.bandwidth === "auto" ? defaultWidth : financialMarkWidth([], { width: style.bandwidth });
63
+ const halfWidth = markWidth / 2;
64
+ const stemLocal = Object.freeze({
65
+ x: row.x,
66
+ highY: ys.map(row.high),
67
+ lowY: ys.map(row.low)
68
+ });
69
+ const openTickLocal = Object.freeze({
70
+ x1: row.x - halfWidth,
71
+ x2: row.x,
72
+ y: ys.map(row.open)
73
+ });
74
+ const closeTickLocal = Object.freeze({
75
+ x1: row.x,
76
+ x2: row.x + halfWidth,
77
+ y: ys.map(row.close)
78
+ });
79
+ const stroke = style.stroke ?? "#173a35", strokeWidth = width(style.strokeWidth ?? 1, "OhlcBarSeries"), alpha = opacity(style.opacity ?? 1, "OhlcBarSeries");
80
+ marks?.push(
81
+ Object.freeze({
82
+ datum: row.datum,
83
+ sourceIndex: row.sourceIndex,
84
+ time: row.time,
85
+ open: row.open,
86
+ high: row.high,
87
+ low: row.low,
88
+ close: row.close,
89
+ anchorLocal: Object.freeze({ x: row.x, y: closeTickLocal.y }),
90
+ stemLocal,
91
+ openTickLocal,
92
+ closeTickLocal,
93
+ strokeWidthLocal: stroke && alpha > 0 ? strokeWidth : 0
94
+ })
95
+ );
96
+ if (alpha === 0 || !stroke) continue;
97
+ const xPad = strokeWidth / 2, minX = row.x - halfWidth - xPad, maxX = row.x + halfWidth + xPad;
98
+ let batch = batches.at(-1);
99
+ if (!batch || minX < batch.maxX && maxX > batch.minX || batch.stroke !== stroke || batch.strokeWidth !== strokeWidth || batch.opacity !== alpha || batch.cursor !== style.cursor) {
100
+ batch = {
101
+ stem: new Path2D(),
102
+ openTick: new Path2D(),
103
+ closeTick: new Path2D(),
104
+ stroke,
105
+ strokeWidth,
106
+ opacity: alpha,
107
+ cursor: style.cursor,
108
+ minX,
109
+ maxX
110
+ };
111
+ batches.push(batch);
112
+ }
113
+ batch.minX = Math.min(batch.minX, minX);
114
+ batch.maxX = Math.max(batch.maxX, maxX);
115
+ batch.stem.moveTo(stemLocal.x, stemLocal.highY);
116
+ batch.stem.lineTo(stemLocal.x, stemLocal.lowY);
117
+ batch.openTick.moveTo(openTickLocal.x1, openTickLocal.y);
118
+ batch.openTick.lineTo(openTickLocal.x2, openTickLocal.y);
119
+ batch.closeTick.moveTo(closeTickLocal.x1, closeTickLocal.y);
120
+ batch.closeTick.lineTo(closeTickLocal.x2, closeTickLocal.y);
121
+ }
122
+ inspection?.capture({ marks, xScale: xs, yScale: ys });
123
+ return /* @__PURE__ */ jsx(Group, { ...events, children: batches.map((batch, index) => /* @__PURE__ */ jsxs(Group, { children: [
124
+ /* @__PURE__ */ jsx(
125
+ Path,
126
+ {
127
+ pointerEvents,
128
+ style: {
129
+ d: batch.stem,
130
+ stroke: batch.stroke,
131
+ strokeWidth: batch.strokeWidth,
132
+ opacity: batch.opacity,
133
+ cursor: batch.cursor
134
+ }
135
+ }
136
+ ),
137
+ /* @__PURE__ */ jsx(
138
+ Path,
139
+ {
140
+ pointerEvents,
141
+ style: {
142
+ d: batch.openTick,
143
+ stroke: batch.stroke,
144
+ strokeWidth: batch.strokeWidth,
145
+ opacity: batch.opacity,
146
+ cursor: batch.cursor
147
+ }
148
+ }
149
+ ),
150
+ /* @__PURE__ */ jsx(
151
+ Path,
152
+ {
153
+ pointerEvents,
154
+ style: {
155
+ d: batch.closeTick,
156
+ stroke: batch.stroke,
157
+ strokeWidth: batch.strokeWidth,
158
+ opacity: batch.opacity,
159
+ cursor: batch.cursor
160
+ }
161
+ }
162
+ )
163
+ ] }, index)) });
164
+ }
165
+ export {
166
+ OhlcBarSeries
167
+ };
168
+ //# sourceMappingURL=ohlc-bar-series.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/features/viz/lib/ohlc-bar-series.tsx"],
4
+ "sourcesContent": ["import {\n Group,\n Path,\n resolveSignalValue,\n type PibblEventHandlers,\n type PibblEventParticipationOptions,\n type PibblNode,\n type SignalValue,\n type StrokeStyle,\n} from \"@pibbl/core\";\nimport { withHooksForbidden } from \"@pibbl/core/internal\";\nimport type {\n OhlcBarInspectionRef,\n CapturedOhlcBarMark,\n} from \"../inspection/ohlc-bar.js\";\nimport { financialMarkWidth } from \"./financial-geometry.js\";\nimport { opacity, width } from \"./paint.js\";\nimport { finiteCoordinate, pointAccessor, pointData } from \"./point-data.js\";\nimport { useNumericPosition } from \"./series-position.js\";\nimport type { LineAccessor, ScaleId } from \"./types.js\";\nimport { useContinuousScale } from \"./use-continuous-scale.js\";\n\n/** Shared stroke presentation for an OHLC bar.\n * @see {@link OhlcBarSeries}\n */\nexport interface OhlcBarSeriesStyle {\n /** Positive total width, or automatic 70% spacing capped at 12; singleton fallback 8. */ readonly bandwidth?:\n number | \"auto\";\n /** Stem and tick stroke; defaults to dark teal. Empty string disables painting. */ readonly stroke?: StrokeStyle;\n /** Nonnegative local stroke width; default 1. */ readonly strokeWidth?: number;\n /** Paint opacity from zero through one; default 1. */ readonly opacity?: number;\n /** Cursor while the series owns targeting. */ readonly cursor?: string;\n}\n\n/** Source-ordered OHLC records rendered as a high/low stem with open/close ticks.\n * @see {@link OhlcBarSeries}\n */\nexport interface OhlcBarSeriesProps<D>\n extends PibblEventHandlers, PibblEventParticipationOptions {\n /** Original records or signal; never sorted or mutated. */\n readonly data: SignalValue<readonly D[]>;\n /** UTC-millisecond property or callback. */\n readonly time: LineAccessor<D>;\n /** Opening price property or callback. */\n readonly open: LineAccessor<D>;\n /** High price property or callback. */\n readonly high: LineAccessor<D>;\n /** Low price property or callback. */\n readonly low: LineAccessor<D>;\n /** Closing price property or callback. */\n readonly close: LineAccessor<D>;\n /** Numeric, UTC, or trading-time horizontal mapping identity. */\n readonly xScale: ScaleId;\n /** Continuous price mapping identity. */\n readonly yScale: ScaleId;\n /** Tests original rows before accessor evaluation.\n * @param datum - Original row.\n * @param index - Source index including skipped rows.\n * @param data - Complete source array.\n * @returns Whether the bar participates.\n */\n readonly defined?: (datum: D, index: number, data: readonly D[]) => boolean;\n /** Shared presentation or a hook-free original-row resolver.\n * @param datum - Original row.\n * @param index - Source index.\n * @param data - Complete source array.\n * @returns Plain OHLC-bar style.\n */\n readonly style?:\n | SignalValue<OhlcBarSeriesStyle>\n | ((datum: D, index: number, data: readonly D[]) => OhlcBarSeriesStyle);\n /** Optional committed capture; the renderer does not execute inspection queries. */ readonly inspection?: OhlcBarInspectionRef<D>;\n}\n\n/** Paints source-ordered OHLC bars with a high/low stem, left open tick, and right close tick.\n * @param props - Original OHLC accessors, scales, styles, events, and optional capture.\n * @returns Ordinary Pibbl composition; equal disjoint styles share paths.\n * @see {@link OhlcBarSeriesProps}\n */\nexport function OhlcBarSeries<D>({\n data: input,\n time: timeInput,\n open: openInput,\n high: highInput,\n low: lowInput,\n close: closeInput,\n xScale,\n yScale,\n defined,\n style: styleInput,\n inspection,\n pointerEvents,\n ...events\n}: OhlcBarSeriesProps<D>): PibblNode {\n const xs = useNumericPosition(xScale),\n ys = useContinuousScale(yScale).get();\n const data = pointData(resolveSignalValue(input), \"OhlcBarSeries\");\n const time = pointAccessor(timeInput),\n open = pointAccessor(openInput),\n high = pointAccessor(highInput),\n low = pointAccessor(lowInput),\n close = pointAccessor(closeInput);\n const rows: {\n datum: D;\n sourceIndex: number;\n time: number;\n open: number;\n high: number;\n low: number;\n close: number;\n x: number;\n }[] = [];\n for (let i = 0; i < data.length; i++) {\n const datum = data[i];\n if (defined && !defined(datum, i, data)) continue;\n const t = time(datum, i, data),\n o = open(datum, i, data),\n h = high(datum, i, data),\n l = low(datum, i, data),\n c = close(datum, i, data);\n if (\n !finiteCoordinate(t) ||\n !finiteCoordinate(o) ||\n !finiteCoordinate(h) ||\n !finiteCoordinate(l) ||\n !finiteCoordinate(c)\n )\n continue;\n if (l > Math.min(o, c) || h < Math.max(o, c))\n throw new RangeError(\n `OhlcBarSeries: malformed OHLC at source index ${i}; require low <= open/close <= high.`,\n );\n rows.push({\n datum,\n sourceIndex: i,\n time: t,\n open: o,\n high: h,\n low: l,\n close: c,\n x: xs.map(t),\n });\n }\n const defaultWidth = financialMarkWidth(rows.map((row) => row.x));\n const specified =\n typeof styleInput === \"function\"\n ? styleInput\n : resolveSignalValue(styleInput);\n const marks: CapturedOhlcBarMark<D>[] | undefined = inspection\n ? []\n : undefined;\n const batches: {\n stem: Path2D;\n openTick: Path2D;\n closeTick: Path2D;\n stroke: StrokeStyle;\n strokeWidth: number;\n opacity: number;\n cursor: string | undefined;\n minX: number;\n maxX: number;\n }[] = [];\n for (const row of rows) {\n const style =\n typeof specified === \"function\"\n ? withHooksForbidden(\"OhlcBarSeries style callback\", () =>\n specified(row.datum, row.sourceIndex, data),\n )\n : (specified ?? {});\n const markWidth =\n style.bandwidth === undefined || style.bandwidth === \"auto\"\n ? defaultWidth\n : financialMarkWidth([], { width: style.bandwidth });\n const halfWidth = markWidth / 2;\n const stemLocal = Object.freeze({\n x: row.x,\n highY: ys.map(row.high),\n lowY: ys.map(row.low),\n });\n const openTickLocal = Object.freeze({\n x1: row.x - halfWidth,\n x2: row.x,\n y: ys.map(row.open),\n });\n const closeTickLocal = Object.freeze({\n x1: row.x,\n x2: row.x + halfWidth,\n y: ys.map(row.close),\n });\n const stroke = style.stroke ?? \"#173a35\",\n strokeWidth = width(style.strokeWidth ?? 1, \"OhlcBarSeries\"),\n alpha = opacity(style.opacity ?? 1, \"OhlcBarSeries\");\n marks?.push(\n Object.freeze({\n datum: row.datum,\n sourceIndex: row.sourceIndex,\n time: row.time,\n open: row.open,\n high: row.high,\n low: row.low,\n close: row.close,\n anchorLocal: Object.freeze({ x: row.x, y: closeTickLocal.y }),\n stemLocal,\n openTickLocal,\n closeTickLocal,\n strokeWidthLocal: stroke && alpha > 0 ? strokeWidth : 0,\n }),\n );\n if (alpha === 0 || !stroke) continue;\n const xPad = strokeWidth / 2,\n minX = row.x - halfWidth - xPad,\n maxX = row.x + halfWidth + xPad;\n let batch = batches.at(-1);\n if (\n !batch ||\n (minX < batch.maxX && maxX > batch.minX) ||\n batch.stroke !== stroke ||\n batch.strokeWidth !== strokeWidth ||\n batch.opacity !== alpha ||\n batch.cursor !== style.cursor\n ) {\n batch = {\n stem: new Path2D(),\n openTick: new Path2D(),\n closeTick: new Path2D(),\n stroke,\n strokeWidth,\n opacity: alpha,\n cursor: style.cursor,\n minX,\n maxX,\n };\n batches.push(batch);\n }\n batch.minX = Math.min(batch.minX, minX);\n batch.maxX = Math.max(batch.maxX, maxX);\n batch.stem.moveTo(stemLocal.x, stemLocal.highY);\n batch.stem.lineTo(stemLocal.x, stemLocal.lowY);\n batch.openTick.moveTo(openTickLocal.x1, openTickLocal.y);\n batch.openTick.lineTo(openTickLocal.x2, openTickLocal.y);\n batch.closeTick.moveTo(closeTickLocal.x1, closeTickLocal.y);\n batch.closeTick.lineTo(closeTickLocal.x2, closeTickLocal.y);\n }\n inspection?.capture({ marks: marks!, xScale: xs, yScale: ys });\n return (\n <Group {...events}>\n {batches.map((batch, index) => (\n <Group key={index}>\n <Path\n pointerEvents={pointerEvents}\n style={{\n d: batch.stem,\n stroke: batch.stroke,\n strokeWidth: batch.strokeWidth,\n opacity: batch.opacity,\n cursor: batch.cursor,\n }}\n />\n <Path\n pointerEvents={pointerEvents}\n style={{\n d: batch.openTick,\n stroke: batch.stroke,\n strokeWidth: batch.strokeWidth,\n opacity: batch.opacity,\n cursor: batch.cursor,\n }}\n />\n <Path\n pointerEvents={pointerEvents}\n style={{\n d: batch.closeTick,\n stroke: batch.stroke,\n strokeWidth: batch.strokeWidth,\n opacity: batch.opacity,\n cursor: batch.cursor,\n }}\n />\n </Group>\n ))}\n </Group>\n );\n}\n"],
5
+ "mappings": "AAuPQ,SACE,KADF;AAvPR;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAMK;AACP,SAAS,0BAA0B;AAKnC,SAAS,0BAA0B;AACnC,SAAS,SAAS,aAAa;AAC/B,SAAS,kBAAkB,eAAe,iBAAiB;AAC3D,SAAS,0BAA0B;AAEnC,SAAS,0BAA0B;AA2D5B,SAAS,cAAiB;AAAA,EAC/B,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAqC;AACnC,QAAM,KAAK,mBAAmB,MAAM,GAClC,KAAK,mBAAmB,MAAM,EAAE,IAAI;AACtC,QAAM,OAAO,UAAU,mBAAmB,KAAK,GAAG,eAAe;AACjE,QAAM,OAAO,cAAc,SAAS,GAClC,OAAO,cAAc,SAAS,GAC9B,OAAO,cAAc,SAAS,GAC9B,MAAM,cAAc,QAAQ,GAC5B,QAAQ,cAAc,UAAU;AAClC,QAAM,OASA,CAAC;AACP,WAAS,IAAI,GAAG,IAAI,KAAK,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ACC;AAAA,QACA,OAAO;AAAA,UACL,GAAG,MAAM;AAAA,UACT,QAAQ,MAAM;AAAA,UACd,aAAa,MAAM;AAAA,UACnB,SAAS,MAAM;AAAA,UACf,QAAQ,MAAM;AAAA,QAChB;AAAA;AAAA,IACF;AAAA,OA9BU,KA+BZ,CACD,GACH;AAEJ;",
6
+ "names": []
7
+ }
@@ -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,SAAS,MAAM,OAAqC;AAClD,MAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK;AACpE,UAAM,IAAI,UAAU,wCAAwC;AAC9D,QAAM,QAAQ;AACd,aAAW,SAAS,OAAO,KAAK,KAAK;AACnC,QACE,CAAC;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,EAAE,SAAS,KAAK;AAEhB,YAAM,IAAI,UAAU,yCAAyC,KAAK,GAAG;AACzE,QAAM,SAAS,mBAAmB,MAAM,MAAM,KAAK;AACnD,QAAM,cAAc;AAAA,IACjB,mBAAmB,MAAM,WAAW,KAAK;AAAA,IAC1C;AAAA,EACF;AACA,QAAM,uBAAuB;AAAA,IAC1B,mBAAmB,MAAM,oBAAoB,KAAK;AAAA,IACnD;AAAA,EACF;AACA,QAAM,SAAS,mBAAmB,MAAM,MAAM;AAC9C,MAAI,WAAW,UAAa,OAAO,WAAW;AAC5C,UAAM,IAAI,UAAU,wCAAwC;AAC9D,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,MACN,mBAAmB,MAAM,OAAO,KAAK;AAAA,MACtC;AAAA,IACF;AAAA,IACA;AAAA,EACF;AACF;AAYO,SAAS,aA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"@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;AAAA,EACA,GAAG;AACL,GAAkC;AAChC,QAAM,KAAK,mBAAmB,GAAG,EAAE,IAAI,GACrC,KAAK,mBAAmB,GAAG,EAAE,IAAI;AACnC,QAAM,OAAO,UAAU,mBAAmB,KAAK,GAAG,YAAY;AAC9D,MAAI,OAAO,WAAW;AACpB,UAAM,IAAI,UAAU,oDAAoD;AAC1E,QAAM,IAAI,cAAc,MAAM,GAC5B,IAAI,cAAc,MAAM;AAC1B,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,QAAI,CAAC,iBAAiB,EAAE,KAAK,CAAC,iBAAiB,EAAE,EAAG;AACpD,UAAM,KAAK,GAAG,IAAI,EAAE,GAClB,KAAK,GAAG,IAAI,EAAE;AAChB,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;",
4
+ "sourcesContent": ["import { Group, resolveSignalValue } from \"@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,wBAAw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,KAAK,EAAE,GAAG,KAAK,MAAM,QAAQ,GAAG,KAAK,MAAM,QAAQ,OAAO,MAAM,SAAS,GAAG,QAAQ,MAAM,SAAS,EAAE,CAAC;AAC1J,YAAI,YAAY,MAAM;AACtB,YAAI,OAAO,IAAI;AAAA,MACjB;AAAA,IACF,UAAE;AACA,UAAI,QAAQ;AAAA,IACd;AAAA,EACF;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,OAAO,EAAE,GAAG,QAAQ,MAAM,eAAe,QAAQ,QAAQ,OAAO;AAAA;AAAA,EAClE;AAEJ;",
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 {\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,MAC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,EAAG;AACxB;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAM;AAAA,MACN,CAAC,CAAC,MAAM;AAAA,MACR,MAAM,SAAS,MAAM,cAAc;AAAA,IACrC;AACA,UAAM,OAAO,UAAU,IAAI,IAAI,MAAM,MAAM;AAC3C,QAAI,KAAK;AACT,QAAI;AACF,UAAI,eAAe,MAAM;AACzB,UAAI,MAAM,MAAM;AACd,YAAI,YAAY,oBAAoB,MAAM,MAAM,KAAK;AAAA,UACnD,GAAG,KAAK,MAAM;AAAA,UACd,GAAG,KAAK,MAAM;AAAA,UACd,OAAO,MAAM,SAAS;AAAA,UACtB,QAAQ,MAAM,SAAS;AAAA,QACzB,CAAC;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. */