@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,158 @@
1
+ import { Fragment, jsx, jsxs } from "@pibbl/core/jsx-runtime";
2
+ import { Circle, Group, Line, resolveSignalValue } from "@pibbl/core";
3
+ import { withHooksForbidden } from "@pibbl/core/internal";
4
+ import { lookupScale } from "./scale-context.js";
5
+ import { useContinuousScale } from "./use-continuous-scale.js";
6
+ import { finiteCoordinate, pointAccessor, pointData } from "./point-data.js";
7
+ import { opacity, width } from "./paint.js";
8
+ function intervalSeries(props, horizontal) {
9
+ const receiver = horizontal ? "HorizontalIntervalSeries" : "VerticalIntervalSeries";
10
+ const {
11
+ data: input,
12
+ category: categoryInput,
13
+ estimate: estimateInput,
14
+ lower: lowerInput,
15
+ upper: upperInput,
16
+ categoryScale,
17
+ valueScale,
18
+ defined,
19
+ style: styleInput,
20
+ pointerEvents,
21
+ ...events
22
+ } = props;
23
+ const categories = lookupScale(categoryScale, receiver)?.get();
24
+ const values = useContinuousScale(valueScale).get();
25
+ if (!categories || categories.type !== "point" && categories.type !== "band")
26
+ throw new TypeError(
27
+ `${receiver}: categoryScale requires PointScale or BarScale.`
28
+ );
29
+ const data = pointData(resolveSignalValue(input), receiver);
30
+ const category = typeof categoryInput === "function" ? categoryInput : (datum) => datum[categoryInput];
31
+ const estimate = pointAccessor(estimateInput), lower = pointAccessor(lowerInput), upper = pointAccessor(upperInput);
32
+ const specified = resolveSignalValue(styleInput) ?? {};
33
+ if (typeof specified !== "object" || Array.isArray(specified))
34
+ throw new TypeError(`${receiver}: style must be an object.`);
35
+ const style = {};
36
+ for (const key of Object.keys(specified)) {
37
+ if (![
38
+ "radius",
39
+ "capSize",
40
+ "fill",
41
+ "stroke",
42
+ "strokeWidth",
43
+ "lineInteractionWidth",
44
+ "opacity",
45
+ "cursor"
46
+ ].includes(key))
47
+ throw new TypeError(`${receiver}: unsupported style field ${key}.`);
48
+ style[key] = resolveSignalValue(specified[key]);
49
+ }
50
+ const resolved = style;
51
+ const radius = width(resolved.radius ?? 4, `${receiver} radius`);
52
+ const halfCap = width(resolved.capSize ?? 8, `${receiver} capSize`) / 2;
53
+ const strokeWidth = width(resolved.strokeWidth ?? 1.5, receiver);
54
+ const lineInteractionWidth = width(
55
+ resolved.lineInteractionWidth ?? strokeWidth,
56
+ receiver
57
+ );
58
+ const alpha = opacity(resolved.opacity ?? 1, receiver);
59
+ if (resolved.cursor !== void 0 && typeof resolved.cursor !== "string")
60
+ throw new TypeError(`${receiver}: cursor must be a string.`);
61
+ const stroke = resolved.stroke ?? "#087f8c";
62
+ const lineStyle = {
63
+ stroke,
64
+ strokeWidth,
65
+ lineInteractionWidth,
66
+ opacity: alpha,
67
+ cursor: resolved.cursor
68
+ };
69
+ const nodes = [];
70
+ for (let i = 0; i < data.length; i++) {
71
+ const datum = data[i];
72
+ const coordinates = withHooksForbidden(
73
+ `${receiver}: accessors cannot call hooks.`,
74
+ () => {
75
+ if (defined && !defined(datum, i, data)) return void 0;
76
+ return {
77
+ category: category(datum, i, data),
78
+ estimate: estimate(datum, i, data),
79
+ lower: lower(datum, i, data),
80
+ upper: upper(datum, i, data)
81
+ };
82
+ }
83
+ );
84
+ if (!coordinates || coordinates.category == null || !finiteCoordinate(coordinates.estimate) || !finiteCoordinate(coordinates.lower) || !finiteCoordinate(coordinates.upper))
85
+ continue;
86
+ const start = categories.map(coordinates.category);
87
+ if (start === void 0) continue;
88
+ if (coordinates.lower > coordinates.upper)
89
+ throw new RangeError(
90
+ `${receiver}: lower must not exceed upper (row ${i}).`
91
+ );
92
+ const center = start + (categories.type === "band" ? categories.bandwidth / 2 : 0);
93
+ const lo = values.map(coordinates.lower), hi = values.map(coordinates.upper), point = values.map(coordinates.estimate);
94
+ if (![center, lo, hi, point].every(Number.isFinite))
95
+ throw new RangeError(
96
+ `${receiver}: mapped coordinates must be finite (row ${i}).`
97
+ );
98
+ const position = (value, offset = 0) => horizontal ? [value, center + offset] : [center + offset, value];
99
+ nodes.push(
100
+ /* @__PURE__ */ jsxs(Group, { children: [
101
+ /* @__PURE__ */ jsx(
102
+ Line,
103
+ {
104
+ pointerEvents,
105
+ style: { ...lineStyle, coords: [position(lo), position(hi)] }
106
+ }
107
+ ),
108
+ halfCap > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
109
+ /* @__PURE__ */ jsx(
110
+ Line,
111
+ {
112
+ pointerEvents,
113
+ style: {
114
+ ...lineStyle,
115
+ coords: [position(lo, -halfCap), position(lo, halfCap)]
116
+ }
117
+ }
118
+ ),
119
+ /* @__PURE__ */ jsx(
120
+ Line,
121
+ {
122
+ pointerEvents,
123
+ style: {
124
+ ...lineStyle,
125
+ coords: [position(hi, -halfCap), position(hi, halfCap)]
126
+ }
127
+ }
128
+ )
129
+ ] }),
130
+ radius > 0 && /* @__PURE__ */ jsx(
131
+ Circle,
132
+ {
133
+ pointerEvents,
134
+ style: {
135
+ ...lineStyle,
136
+ cx: horizontal ? point : center,
137
+ cy: horizontal ? center : point,
138
+ radius,
139
+ fill: resolved.fill ?? "#087f8c"
140
+ }
141
+ }
142
+ )
143
+ ] }, i)
144
+ );
145
+ }
146
+ return /* @__PURE__ */ jsx(Group, { ...events, children: nodes });
147
+ }
148
+ function HorizontalIntervalSeries(props) {
149
+ return intervalSeries(props, true);
150
+ }
151
+ function VerticalIntervalSeries(props) {
152
+ return intervalSeries(props, false);
153
+ }
154
+ export {
155
+ HorizontalIntervalSeries,
156
+ VerticalIntervalSeries
157
+ };
158
+ //# sourceMappingURL=interval-series.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/features/viz/lib/interval-series.tsx"],
4
+ "sourcesContent": ["import { Circle, Group, Line, resolveSignalValue } from \"@pibbl/core\";\nimport type {\n FillStyle,\n PibblEventHandlers,\n PibblEventParticipationOptions,\n PibblNode,\n SignalValue,\n StrokeStyle,\n} from \"@pibbl/core\";\nimport type { SignalStyle } from \"@pibbl/core/internal\";\nimport { withHooksForbidden } from \"@pibbl/core/internal\";\nimport type { BarCategoryAccessor } from \"./bar-series.js\";\nimport type { BandCategory, LineAccessor, ScaleId } from \"./types.js\";\nimport { lookupScale } from \"./scale-context.js\";\nimport { useContinuousScale } from \"./use-continuous-scale.js\";\nimport { finiteCoordinate, pointAccessor, pointData } from \"./point-data.js\";\nimport { opacity, width } from \"./paint.js\";\n\n/** Shared local-pixel geometry and paint for estimate-and-interval marks.\n * @see {@link IntervalSeriesProps}\n */\nexport interface IntervalSeriesStyle {\n /** Estimate circle radius in local pixels; defaults to 4. */\n readonly radius?: number;\n /** Full perpendicular length of each endpoint cap; defaults to 8 pixels. */\n readonly capSize?: number;\n /** Estimate circle fill; defaults to #087f8c. */\n readonly fill?: FillStyle;\n /** Interval, cap, and circle outline paint; defaults to #087f8c. */\n readonly stroke?: StrokeStyle;\n /** Visible stroke width in local pixels; defaults to 1.5. */\n readonly strokeWidth?: number;\n /** Stroke targeting width, independent of visible width; defaults to strokeWidth. */\n readonly lineInteractionWidth?: number;\n /** Shared paint opacity from zero to one; defaults to 1. */\n readonly opacity?: number;\n /** Cursor for painted mark targets. */\n readonly cursor?: string;\n}\n\n/** Explicit supplied estimates and numeric bounds placed at categorical centers.\n * @see {@link HorizontalIntervalSeries}\n * @see {@link VerticalIntervalSeries}\n */\nexport interface IntervalSeriesProps<D>\n extends PibblEventHandlers, PibblEventParticipationOptions {\n /** Original records, or a signal of records; no estimation is performed. */\n readonly data: SignalValue<readonly D[]>;\n /** Property or callback supplying a category; missing/unknown categories omit rows. */\n readonly category: BarCategoryAccessor<D>;\n /** Property or callback supplying the numeric point estimate. */\n readonly estimate: LineAccessor<D>;\n /** Property or callback supplying the numeric lower bound. */\n readonly lower: LineAccessor<D>;\n /** Property or callback supplying the numeric upper bound. */\n readonly upper: LineAccessor<D>;\n /** Ancestor PointScale or BarScale; band categories use their centers. */\n readonly categoryScale: ScaleId;\n /** Ancestor continuous numeric scale mapping estimate and both bounds independently. */\n readonly valueScale: ScaleId;\n /** Optional synchronous predicate; excluded rows contribute no marks.\n * @param datum - Original record being tested.\n * @param index - Source index of the record.\n * @param data - Complete supplied data array.\n * @returns Whether to include this record's estimate and interval.\n */\n readonly defined?: (datum: D, index: number, data: readonly D[]) => boolean;\n /** Shared style; whole-object and shallow field signals are observed by the series. */\n readonly style?: SignalValue<SignalStyle<IntervalSeriesStyle>>;\n}\n\n/** Horizontal estimate-and-interval authoring inputs. See {@link HorizontalIntervalSeries}. */\nexport type HorizontalIntervalSeriesProps<D> = IntervalSeriesProps<D>;\n/** Vertical estimate-and-interval authoring inputs. See {@link VerticalIntervalSeries}. */\nexport type VerticalIntervalSeriesProps<D> = IntervalSeriesProps<D>;\n\nfunction intervalSeries<D>(\n props: IntervalSeriesProps<D>,\n horizontal: boolean,\n): PibblNode {\n const receiver = horizontal\n ? \"HorizontalIntervalSeries\"\n : \"VerticalIntervalSeries\";\n const {\n data: input,\n category: categoryInput,\n estimate: estimateInput,\n lower: lowerInput,\n upper: upperInput,\n categoryScale,\n valueScale,\n defined,\n style: styleInput,\n pointerEvents,\n ...events\n } = props;\n const categories = lookupScale(categoryScale, receiver)?.get();\n const values = useContinuousScale(valueScale).get();\n if (\n !categories ||\n (categories.type !== \"point\" && categories.type !== \"band\")\n )\n throw new TypeError(\n `${receiver}: categoryScale requires PointScale or BarScale.`,\n );\n const data = pointData(resolveSignalValue(input), receiver);\n const category =\n typeof categoryInput === \"function\"\n ? categoryInput\n : (datum: D) => datum[categoryInput] as BandCategory | null | undefined;\n const estimate = pointAccessor(estimateInput),\n lower = pointAccessor(lowerInput),\n upper = pointAccessor(upperInput);\n const specified = resolveSignalValue(styleInput) ?? {};\n if (typeof specified !== \"object\" || Array.isArray(specified))\n throw new TypeError(`${receiver}: style must be an object.`);\n const style: Record<string, unknown> = {};\n for (const key of Object.keys(specified)) {\n if (\n ![\n \"radius\",\n \"capSize\",\n \"fill\",\n \"stroke\",\n \"strokeWidth\",\n \"lineInteractionWidth\",\n \"opacity\",\n \"cursor\",\n ].includes(key)\n )\n throw new TypeError(`${receiver}: unsupported style field ${key}.`);\n style[key] = resolveSignalValue(specified[key as keyof typeof specified]);\n }\n const resolved = style as IntervalSeriesStyle;\n const radius = width(resolved.radius ?? 4, `${receiver} radius`);\n const halfCap = width(resolved.capSize ?? 8, `${receiver} capSize`) / 2;\n const strokeWidth = width(resolved.strokeWidth ?? 1.5, receiver);\n const lineInteractionWidth = width(\n resolved.lineInteractionWidth ?? strokeWidth,\n receiver,\n );\n const alpha = opacity(resolved.opacity ?? 1, receiver);\n if (resolved.cursor !== undefined && typeof resolved.cursor !== \"string\")\n throw new TypeError(`${receiver}: cursor must be a string.`);\n const stroke = resolved.stroke ?? \"#087f8c\";\n const lineStyle = {\n stroke,\n strokeWidth,\n lineInteractionWidth,\n opacity: alpha,\n cursor: resolved.cursor,\n };\n const nodes: PibblNode[] = [];\n for (let i = 0; i < data.length; i++) {\n const datum = data[i];\n const coordinates = withHooksForbidden(\n `${receiver}: accessors cannot call hooks.`,\n () => {\n if (defined && !defined(datum, i, data)) return undefined;\n return {\n category: category(datum, i, data),\n estimate: estimate(datum, i, data),\n lower: lower(datum, i, data),\n upper: upper(datum, i, data),\n };\n },\n );\n if (\n !coordinates ||\n coordinates.category == null ||\n !finiteCoordinate(coordinates.estimate) ||\n !finiteCoordinate(coordinates.lower) ||\n !finiteCoordinate(coordinates.upper)\n )\n continue;\n const start = categories.map(coordinates.category);\n if (start === undefined) continue;\n if (coordinates.lower > coordinates.upper)\n throw new RangeError(\n `${receiver}: lower must not exceed upper (row ${i}).`,\n );\n const center =\n start + (categories.type === \"band\" ? categories.bandwidth / 2 : 0);\n const lo = values.map(coordinates.lower),\n hi = values.map(coordinates.upper),\n point = values.map(coordinates.estimate);\n if (![center, lo, hi, point].every(Number.isFinite))\n throw new RangeError(\n `${receiver}: mapped coordinates must be finite (row ${i}).`,\n );\n const position = (value: number, offset = 0): [number, number] =>\n horizontal ? [value, center + offset] : [center + offset, value];\n nodes.push(\n <Group key={i}>\n <Line\n pointerEvents={pointerEvents}\n style={{ ...lineStyle, coords: [position(lo), position(hi)] }}\n />\n {halfCap > 0 && (\n <>\n <Line\n pointerEvents={pointerEvents}\n style={{\n ...lineStyle,\n coords: [position(lo, -halfCap), position(lo, halfCap)],\n }}\n />\n <Line\n pointerEvents={pointerEvents}\n style={{\n ...lineStyle,\n coords: [position(hi, -halfCap), position(hi, halfCap)],\n }}\n />\n </>\n )}\n {radius > 0 && (\n <Circle\n pointerEvents={pointerEvents}\n style={{\n ...lineStyle,\n cx: horizontal ? point : center,\n cy: horizontal ? center : point,\n radius,\n fill: resolved.fill ?? \"#087f8c\",\n }}\n />\n )}\n </Group>,\n );\n }\n return <Group {...events}>{nodes}</Group>;\n}\n\n/**\n * Draw supplied numeric intervals horizontally with an estimate circle per category.\n * Missing/non-finite coordinates omit the entire row; reversed bounds reject it.\n * Mapping does not clamp or clip; compose a Clip when required. Marks use ordinary\n * Line/Circle targets, with series handlers receiving their bubbled events.\n *\n * @param props - Supplied data, categorical/numeric scale IDs, and shared style.\n * @returns Ordinary Pibbl content in source order, interval then circle for each row.\n * @see {@link HorizontalIntervalSeriesProps}\n */\nexport function HorizontalIntervalSeries<D>(\n props: HorizontalIntervalSeriesProps<D>,\n): PibblNode {\n return intervalSeries(props, true);\n}\n\n/**\n * Draw supplied numeric intervals vertically with an estimate circle per category.\n * Shares the missing-data, bounds, paint, targeting, and clipping contract of\n * HorizontalIntervalSeries; orientation is explicit in the operation name.\n *\n * @param props - Supplied data, categorical/numeric scale IDs, and shared style.\n * @returns Ordinary Pibbl content in source order, interval then circle for each row.\n * @see {@link VerticalIntervalSeriesProps}\n */\nexport function VerticalIntervalSeries<D>(\n props: VerticalIntervalSeriesProps<D>,\n): PibblNode {\n return intervalSeries(props, false);\n}\n"],
5
+ "mappings": "AAkMQ,SAKE,UALF,KAKE,YALF;AAlMR,SAAS,QAAQ,OAAO,MAAM,0BAA0B;AAUxD,SAAS,0BAA0B;AAGnC,SAAS,mBAAmB;AAC5B,SAAS,0BAA0B;AACnC,SAAS,kBAAkB,eAAe,iBAAiB;AAC3D,SAAS,SAAS,aAAa;AA4D/B,SAAS,eACP,OACA,YACW;AACX,QAAM,WAAW,aACb,6BACA;AACJ,QAAM;AAAA,IACJ,MAAM;AAAA,IACN,UAAU;AAAA,IACV,UAAU;AAAA,IACV,OAAO;AAAA,IACP,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AACJ,QAAM,aAAa,YAAY,eAAe,QAAQ,GAAG,IAAI;AAC7D,QAAM,SAAS,mBAAmB,UAAU,EAAE,IAAI;AAClD,MACE,CAAC,cACA,WAAW,SAAS,WAAW,WAAW,SAAS;AAEpD,UAAM,IAAI;AAAA,MACR,GAAG,QAAQ;AAAA,IACb;AACF,QAAM,OAAO,UAAU,mBAAmB,KAAK,GAAG,QAAQ;AAC1D,QAAM,WACJ,OAAO,kBAAkB,aACrB,gBACA,CAAC,UAAa,MAAM,aAAa;AACvC,QAAM,WAAW,cAAc,aAAa,GAC1C,QAAQ,cAAc,UAAU,GAChC,QAAQ,cAAc,UAAU;AAClC,QAAM,YAAY,mBAAmB,UAAU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AAI,CAAC,OAAO,GAAG,SAAS,IAAI,OAAO,CAAC;AAAA,cACxD;AAAA;AAAA,UACF;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACC;AAAA,cACA,OAAO;AAAA,gBACL,GAAG;AAAA,gBACH,QAAQ,CAAC,SAAS,IAAI,CAAC,OAAO,GAAG,SAAS,IAAI,OAAO,CAAC;AAAA,cACxD;AAAA;AAAA,UACF;AAAA,WACF;AAAA,QAED,SAAS,KACR;AAAA,UAAC;AAAA;AAAA,YACC;AAAA,YACA,OAAO;AAAA,cACL,GAAG;AAAA,cACH,IAAI,aAAa,QAAQ;AAAA,cACzB,IAAI,aAAa,SAAS;AAAA,cAC1B;AAAA,cACA,MAAM,SAAS,QAAQ;AAAA,YACzB;AAAA;AAAA,QACF;AAAA,WAjCQ,CAmCZ;AAAA,IACF;AAAA,EACF;AACA,SAAO,oBAAC,SAAO,GAAG,QAAS,iBAAM;AACnC;AAYO,SAAS,yBACd,OACW;AACX,SAAO,eAAe,OAAO,IAAI;AACnC;AAWO,SAAS,uBACd,OACW;AACX,SAAO,eAAe,OAAO,KAAK;AACpC;",
6
+ "names": []
7
+ }
@@ -8,4 +8,4 @@ import type { LineSeriesProps } from "./types.js";
8
8
  *
9
9
  * @see {@link LineSeriesProps}
10
10
  */
11
- export declare function LineSeries<D>({ data: dataInput, x: xInput, y: yInput, xScale: xId, yScale: yId, defined, curve, style: styleInput, ...eventProps }: LineSeriesProps<D>): import("../../../jsx-runtime.js").JSX.Element;
11
+ export declare function LineSeries<D>({ data: dataInput, x: xInput, y: yInput, xScale: xId, yScale: yId, defined, inspection, curve, style: styleInput, ...eventProps }: LineSeriesProps<D>): import("../../../jsx-runtime.js").JSX.Element;
@@ -1,11 +1,17 @@
1
1
  import { jsx } from "@pibbl/core/jsx-runtime";
2
2
  import { Path, resolveSignalValue } from "@pibbl/core";
3
3
  import { useInternalValueMemoSlot } from "@pibbl/core/internal";
4
- import { useContinuousScale } from "./use-continuous-scale.js";
4
+ import {
5
+ appendCurveForward,
6
+ curveGeometry,
7
+ resolveSeriesCurve
8
+ } from "./curve-definition.js";
9
+ import {
10
+ useSeriesPosition,
11
+ seriesAccessor,
12
+ mapSeriesPosition
13
+ } from "./series-position.js";
5
14
  import { width, opacity } from "./paint.js";
6
- function accessor(input) {
7
- return typeof input === "function" ? input : (datum) => datum[input];
8
- }
9
15
  function LineSeries({
10
16
  data: dataInput,
11
17
  x: xInput,
@@ -13,20 +19,24 @@ function LineSeries({
13
19
  xScale: xId,
14
20
  yScale: yId,
15
21
  defined,
22
+ inspection,
16
23
  curve,
17
24
  style: styleInput,
18
25
  ...eventProps
19
26
  }) {
20
- const xScale = useContinuousScale(xId).get();
21
- const yScale = useContinuousScale(yId).get();
22
- const x = useInternalValueMemoSlot("vizXAccessor", () => accessor(xInput), [
23
- xInput
24
- ]);
25
- const y = useInternalValueMemoSlot("vizYAccessor", () => accessor(yInput), [
26
- yInput
27
- ]);
28
- if (curve !== void 0 && curve !== "linear")
29
- throw new TypeError('LineSeries supports curve="linear" only.');
27
+ const xScale = useSeriesPosition(xId);
28
+ const yScale = useSeriesPosition(yId);
29
+ const x = useInternalValueMemoSlot(
30
+ "vizXAccessor",
31
+ () => seriesAccessor(xInput),
32
+ [xInput]
33
+ );
34
+ const y = useInternalValueMemoSlot(
35
+ "vizYAccessor",
36
+ () => seriesAccessor(yInput),
37
+ [yInput]
38
+ );
39
+ const curveDefinition = resolveSeriesCurve(curve);
30
40
  const data = resolveSignalValue(dataInput);
31
41
  if (!Array.isArray(data))
32
42
  throw new TypeError(
@@ -45,29 +55,38 @@ function LineSeries({
45
55
  "LineSeries"
46
56
  );
47
57
  const path = new Path2D();
48
- let previous;
49
- let inRun = false;
58
+ const captured = inspection ? [] : void 0;
59
+ let runId = 0;
60
+ if (inspection && (xScale.type === "point" || yScale.type === "point")) throw new TypeError("Numeric line inspection requires numeric continuous scales.");
61
+ let run = [];
62
+ const flushRun = () => {
63
+ if (run.length >= 2) {
64
+ const geometry = curveGeometry(curveDefinition, run);
65
+ path.moveTo(geometry.start[0], geometry.start[1]);
66
+ appendCurveForward(path, geometry);
67
+ }
68
+ run = [];
69
+ };
50
70
  for (let i = 0; i < data.length; i++) {
51
71
  const datum = data[i];
52
72
  if (defined && !defined(datum, i, data)) {
53
- previous = void 0;
54
- inRun = false;
73
+ flushRun();
74
+ runId++;
55
75
  continue;
56
76
  }
57
77
  const xv = x(datum, i, data), yv = y(datum, i, data);
58
- if (typeof xv !== "number" || typeof yv !== "number" || !Number.isFinite(xv) || !Number.isFinite(yv)) {
59
- previous = void 0;
60
- inRun = false;
78
+ const px = mapSeriesPosition(xScale, xv), py = mapSeriesPosition(yScale, yv);
79
+ if (px === void 0 || py === void 0) {
80
+ flushRun();
81
+ runId++;
61
82
  continue;
62
83
  }
63
- const point = [xScale.map(xv), yScale.map(yv)];
64
- if (previous) {
65
- if (!inRun) path.moveTo(previous[0], previous[1]);
66
- path.lineTo(point[0], point[1]);
67
- inRun = true;
68
- }
69
- previous = point;
84
+ captured?.push(Object.freeze({ datum, sourceIndex: i, domainX: xv, domainY: yv, anchorLocal: Object.freeze({ x: px, y: py }), run: runId }));
85
+ const point = [px, py];
86
+ run.push(point);
70
87
  }
88
+ flushRun();
89
+ if (inspection && xScale.type !== "point" && yScale.type !== "point") inspection.capture({ observations: captured, xScale, yScale });
71
90
  return /* @__PURE__ */ jsx(
72
91
  Path,
73
92
  {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/features/viz/lib/line-series.tsx"],
4
- "sourcesContent": ["import { Path, resolveSignalValue } from \"@pibbl/core\";\nimport { useInternalValueMemoSlot } from \"@pibbl/core/internal\";\nimport type { LineAccessor, LineCoordinate, LineSeriesProps } from \"./types.js\";\nimport { useContinuousScale } from \"./use-continuous-scale.js\";\nimport { width, opacity } from \"./paint.js\";\nfunction accessor<D>(\n input: LineAccessor<D>,\n): (datum: D, index: number, data: readonly D[]) => LineCoordinate {\n return typeof input === \"function\"\n ? input\n : (datum) => datum[input] as LineCoordinate;\n}\n/**\n * Draws a scaled line through defined data values, leaving gaps for undefined values.\n *\n * @param props - Data, coordinate accessors, scales, and line styling. See {@link LineSeriesProps}\n * .\n * @returns Pibbl nodes drawing the data as a line series.\n *\n * @see {@link LineSeriesProps}\n */\nexport function LineSeries<D>({\n data: dataInput,\n x: xInput,\n y: yInput,\n xScale: xId,\n yScale: yId,\n defined,\n curve,\n style: styleInput,\n ...eventProps\n}: LineSeriesProps<D>) {\n const xScale = useContinuousScale(xId).get();\n const yScale = useContinuousScale(yId).get();\n const x = useInternalValueMemoSlot(\"vizXAccessor\", () => accessor(xInput), [\n xInput,\n ]);\n const y = useInternalValueMemoSlot(\"vizYAccessor\", () => accessor(yInput), [\n yInput,\n ]);\n if (curve !== undefined && curve !== \"linear\")\n throw new TypeError('LineSeries supports curve=\"linear\" only.');\n const data = resolveSignalValue(dataInput);\n if (!Array.isArray(data))\n throw new TypeError(\n \"LineSeries data must be an array or a signal containing an array.\",\n );\n const style = resolveSignalValue(styleInput) ?? {};\n const stroke = resolveSignalValue(style.stroke) ?? \"#2563eb\";\n const strokeWidth = width(\n resolveSignalValue(style.strokeWidth) ?? 2,\n \"LineSeries\",\n );\n const alpha = opacity(resolveSignalValue(style.opacity) ?? 1, \"LineSeries\");\n const cursor = resolveSignalValue(style.cursor);\n const lineInteractionWidth = width(\n resolveSignalValue(style.lineInteractionWidth) ?? strokeWidth,\n \"LineSeries\",\n );\n const path = new Path2D();\n let previous: readonly [number, number] | undefined;\n let inRun = false;\n for (let i = 0; i < data.length; i++) {\n const datum = data[i];\n if (defined && !defined(datum, i, data)) {\n previous = undefined;\n inRun = false;\n continue;\n }\n const xv = x(datum, i, data),\n yv = y(datum, i, data);\n if (\n typeof xv !== \"number\" ||\n typeof yv !== \"number\" ||\n !Number.isFinite(xv) ||\n !Number.isFinite(yv)\n ) {\n previous = undefined;\n inRun = false;\n continue;\n }\n const point = [xScale.map(xv), yScale.map(yv)] as const;\n if (previous) {\n if (!inRun) path.moveTo(previous[0], previous[1]);\n path.lineTo(point[0], point[1]);\n inRun = true;\n }\n previous = point;\n }\n return (\n <Path\n {...eventProps}\n style={{\n d: path,\n stroke,\n strokeWidth,\n opacity: alpha,\n cursor,\n lineInteractionWidth,\n }}\n />\n );\n}\n"],
5
- "mappings": "AA0FI;AA1FJ,SAAS,MAAM,0BAA0B;AACzC,SAAS,gCAAgC;AAEzC,SAAS,0BAA0B;AACnC,SAAS,OAAO,eAAe;AAC/B,SAAS,SACP,OACiE;AACjE,SAAO,OAAO,UAAU,aACpB,QACA,CAAC,UAAU,MAAM,KAAK;AAC5B;AAUO,SAAS,WAAc;AAAA,EAC5B,MAAM;AAAA,EACN,GAAG;AAAA,EACH,GAAG;AAAA,EACH,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP,GAAG;AACL,GAAuB;AACrB,QAAM,SAAS,mBAAmB,GAAG,EAAE,IAAI;AAC3C,QAAM,SAAS,mBAAmB,GAAG,EAAE,IAAI;AAC3C,QAAM,IAAI,yBAAyB,gBAAgB,MAAM,SAAS,MAAM,GAAG;AAAA,IACzE;AAAA,EACF,CAAC;AACD,QAAM,IAAI,yBAAyB,gBAAgB,MAAM,SAAS,MAAM,GAAG;AAAA,IACzE;AAAA,EACF,CAAC;AACD,MAAI,UAAU,UAAa,UAAU;AACnC,UAAM,IAAI,UAAU,0CAA0C;AAChE,QAAM,OAAO,mBAAmB,SAAS;AACzC,MAAI,CAAC,MAAM,QAAQ,IAAI;AACrB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AACF,QAAM,QAAQ,mBAAmB,UAAU,KAAK,CAAC;AACjD,QAAM,SAAS,mBAAmB,MAAM,MAAM,KAAK;AACnD,QAAM,cAAc;AAAA,IAClB,mBAAmB,MAAM,WAAW,KAAK;AAAA,IACzC;AAAA,EACF;AACA,QAAM,QAAQ,QAAQ,mBAAmB,MAAM,OAAO,KAAK,GAAG,YAAY;AAC1E,QAAM,SAAS,mBAAmB,MAAM,MAAM;AAC9C,QAAM,uBAAuB;AAAA,IAC3B,mBAAmB,MAAM,oBAAoB,KAAK;AAAA,IAClD;AAAA,EACF;AACA,QAAM,OAAO,IAAI,OAAO;AACxB,MAAI;AACJ,MAAI,QAAQ;AACZ,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAM,QAAQ,KAAK,CAAC;AACpB,QAAI,WAAW,CAAC,QAAQ,OAAO,GAAG,IAAI,GAAG;AACvC,iBAAW;AACX,cAAQ;AACR;AAAA,IACF;AACA,UAAM,KAAK,EAAE,OAAO,GAAG,IAAI,GACzB,KAAK,EAAE,OAAO,GAAG,IAAI;AACvB,QACE,OAAO,OAAO,YACd,OAAO,OAAO,YACd,CAAC,OAAO,SAAS,EAAE,KACnB,CAAC,OAAO,SAAS,EAAE,GACnB;AACA,iBAAW;AACX,cAAQ;AACR;AAAA,IACF;AACA,UAAM,QAAQ,CAAC,OAAO,IAAI,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;AAC7C,QAAI,UAAU;AACZ,UAAI,CAAC,MAAO,MAAK,OAAO,SAAS,CAAC,GAAG,SAAS,CAAC,CAAC;AAChD,WAAK,OAAO,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC;AAC9B,cAAQ;AAAA,IACV;AACA,eAAW;AAAA,EACb;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,OAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,QACA;AAAA,QACA,SAAS;AAAA,QACT;AAAA,QACA;AAAA,MACF;AAAA;AAAA,EACF;AAEJ;",
4
+ "sourcesContent": ["import { Path, resolveSignalValue } from \"@pibbl/core\";\nimport { useInternalValueMemoSlot } from \"@pibbl/core/internal\";\nimport type { LineSeriesProps } from \"./types.js\";\nimport {\n appendCurveForward,\n curveGeometry,\n resolveSeriesCurve,\n} from \"./curve-definition.js\";\nimport {\n useSeriesPosition,\n seriesAccessor,\n mapSeriesPosition,\n} from \"./series-position.js\";\nimport { width, opacity } from \"./paint.js\";\n/**\n * Draws a scaled line through defined data values, leaving gaps for undefined values.\n *\n * @param props - Data, coordinate accessors, scales, and line styling. See {@link LineSeriesProps}\n * .\n * @returns Pibbl nodes drawing the data as a line series.\n *\n * @see {@link LineSeriesProps}\n */\nexport function LineSeries<D>({\n data: dataInput,\n x: xInput,\n y: yInput,\n xScale: xId,\n yScale: yId,\n defined,\n inspection,\n curve,\n style: styleInput,\n ...eventProps\n}: LineSeriesProps<D>) {\n const xScale = useSeriesPosition(xId);\n const yScale = useSeriesPosition(yId);\n const x = useInternalValueMemoSlot(\n \"vizXAccessor\",\n () => seriesAccessor(xInput),\n [xInput],\n );\n const y = useInternalValueMemoSlot(\n \"vizYAccessor\",\n () => seriesAccessor(yInput),\n [yInput],\n );\n const curveDefinition = resolveSeriesCurve(curve);\n const data = resolveSignalValue(dataInput);\n if (!Array.isArray(data))\n throw new TypeError(\n \"LineSeries data must be an array or a signal containing an array.\",\n );\n const style = resolveSignalValue(styleInput) ?? {};\n const stroke = resolveSignalValue(style.stroke) ?? \"#2563eb\";\n const strokeWidth = width(\n resolveSignalValue(style.strokeWidth) ?? 2,\n \"LineSeries\",\n );\n const alpha = opacity(resolveSignalValue(style.opacity) ?? 1, \"LineSeries\");\n const cursor = resolveSignalValue(style.cursor);\n const lineInteractionWidth = width(\n resolveSignalValue(style.lineInteractionWidth) ?? strokeWidth,\n \"LineSeries\",\n );\n const path = new Path2D();\n const captured: import(\"../inspection/capture-types.js\").CapturedNumericObservation<D>[] | undefined = inspection ? [] : undefined;\n let runId = 0;\n if (inspection && (xScale.type === \"point\" || yScale.type === \"point\")) throw new TypeError(\"Numeric line inspection requires numeric continuous scales.\");\n let run: (readonly [number, number])[] = [];\n const flushRun = () => {\n if (run.length >= 2) {\n const geometry = curveGeometry(curveDefinition, run);\n path.moveTo(geometry.start[0], geometry.start[1]);\n appendCurveForward(path, geometry);\n }\n run = [];\n };\n for (let i = 0; i < data.length; i++) {\n const datum = data[i];\n if (defined && !defined(datum, i, data)) {\n flushRun();\n runId++;\n continue;\n }\n const xv = x(datum, i, data),\n yv = y(datum, i, data);\n const px = mapSeriesPosition(xScale, xv),\n py = mapSeriesPosition(yScale, yv);\n if (px === undefined || py === undefined) {\n flushRun();\n runId++;\n continue;\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:runId}));\n const point = [px, py] as const;\n run.push(point);\n }\n flushRun();\n if (inspection && xScale.type !== \"point\" && yScale.type !== \"point\") inspection.capture({observations:captured!,xScale,yScale});\n return (\n <Path\n {...eventProps}\n style={{\n d: path,\n stroke,\n strokeWidth,\n opacity: alpha,\n cursor,\n lineInteractionWidth,\n }}\n />\n );\n}\n"],
5
+ "mappings": "AAqGI;AArGJ,SAAS,MAAM,0BAA0B;AACzC,SAAS,gCAAgC;AAEzC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,OAAO,eAAe;AAUxB,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,OAAO;AAAA,EACP,GAAG;AACL,GAAuB;AACrB,QAAM,SAAS,kBAAkB,GAAG;AACpC,QAAM,SAAS,kBAAkB,GAAG;AACpC,QAAM,IAAI;AAAA,IACR;AAAA,IACA,MAAM,eAAe,MAAM;AAAA,IAC3B,CAAC,MAAM;AAAA,EACT;AACA,QAAM,IAAI;AAAA,IACR;AAAA,IACA,MAAM,eAAe,MAAM;AAAA,IAC3B,CAAC,MAAM;AAAA,EACT;AACA,QAAM,kBAAkB,mBAAmB,KAAK;AAChD,QAAM,OAAO,mBAAmB,SAA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;AAAA,IACF;AACA,cAAU,KAAK,OAAO,OAAO,EAAC,OAAM,aAAY,GAAE,SAAQ,IAAa,SAAQ,IAAa,aAAY,OAAO,OAAO,EAAC,GAAE,IAAG,GAAE,GAAE,CAAC,GAAE,KAAI,MAAK,CAAC,CAAC;AAC9I,UAAM,QAAQ,CAAC,IAAI,EAAE;AACrB,QAAI,KAAK,KAAK;AAAA,EAChB;AACA,WAAS;AACT,MAAI,cAAc,OAAO,SAAS,WAAW,OAAO,SAAS,QAAS,YAAW,QAAQ,EAAC,cAAa,UAAU,QAAO,OAAM,CAAC;AAC/H,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,OAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,QACA;AAAA,QACA,SAAS;AAAA,QACT;AAAA,QACA;AAAA,MACF;AAAA;AAAA,EACF;AAEJ;",
6
6
  "names": []
7
7
  }
@@ -61,7 +61,7 @@ function resolveLinearScale(domainInput, rangeInput, reverse, width, height) {
61
61
  });
62
62
  }
63
63
  function equalScale(a, b) {
64
- return a.type === b.type && (a.type !== "symlog" || b.type === "symlog" && a.constant === b.constant) && (a.type !== "point" || b.type === "point" && a.padding === b.padding) && (a.type !== "log" || b.type === "log" && a.base === b.base) && a.domain.length === b.domain.length && a.domain.every((value, index) => Object.is(value, b.domain[index])) && (a.type !== "band" || b.type === "band" && a.bandwidth === b.bandwidth && a.step === b.step) && Object.is(a.range[0], b.range[0]) && Object.is(a.range[1], b.range[1]) && Object.is(a.frame.width, b.frame.width) && Object.is(a.frame.height, b.frame.height);
64
+ return a.type === b.type && (a.type !== "trading-time" || b.type === "trading-time" && a.logicalRange.every((v, i) => v === b.logicalRange[i])) && (a.type !== "symlog" || b.type === "symlog" && a.constant === b.constant) && (a.type !== "point" || b.type === "point" && a.padding === b.padding) && (a.type !== "log" || b.type === "log" && a.base === b.base) && a.domain.length === b.domain.length && a.domain.every((value, index) => Object.is(value, b.domain[index])) && (a.type !== "band" || b.type === "band" && a.bandwidth === b.bandwidth && a.step === b.step) && Object.is(a.range[0], b.range[0]) && Object.is(a.range[1], b.range[1]) && Object.is(a.frame.width, b.frame.width) && Object.is(a.frame.height, b.frame.height);
65
65
  }
66
66
  export {
67
67
  equalScale,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/features/viz/lib/linear-scale.ts"],
4
- "sourcesContent": ["import type {\n LinearDomain,\n ResolvedLinearScale,\n ResolvedScale,\n ScaleRange,\n} from \"./types.js\";\nfunction finite(value: number, field: string): number {\n if (typeof value !== \"number\" || !Number.isFinite(value))\n throw new RangeError(`Scale ${field} must be finite.`);\n return value;\n}\nfunction pair(\n value: readonly number[],\n field: string,\n): readonly [number, number] {\n if (!Array.isArray(value) || value.length !== 2)\n throw new RangeError(`Scale ${field} requires two finite endpoints.`);\n return Object.freeze([finite(value[0], field), finite(value[1], field)]);\n}\nexport function resolveLinearScale(\n domainInput: LinearDomain,\n rangeInput: ScaleRange,\n reverse: boolean,\n width: number,\n height: number,\n): ResolvedLinearScale {\n finite(width, \"frame.width\");\n finite(height, \"frame.height\");\n if (width < 0 || height < 0)\n throw new RangeError(\"Scale allocation must be nonnegative.\");\n if (typeof reverse !== \"boolean\")\n throw new TypeError(\"Scale reverse must be boolean.\");\n const domain = pair(domainInput, \"domain\");\n if (domain[0] === domain[1])\n throw new RangeError(\"Scale domain endpoints must differ.\");\n const original = pair(\n rangeInput === \"width\"\n ? [0, width]\n : rangeInput === \"height\"\n ? [0, height]\n : (rangeInput as readonly number[]),\n \"range\",\n );\n const range = reverse ? pair([original[1], original[0]], \"range\") : original;\n const domainSpan = finite(domain[1] - domain[0], \"domain span\");\n const rangeSpan = finite(range[1] - range[0], \"range span\");\n return Object.freeze({\n type: \"linear\",\n domain,\n range,\n frame: Object.freeze({ x: 0, y: 0, width, height }),\n map(value: number) {\n return finite(\n range[0] +\n ((finite(value, \"map input\") - domain[0]) / domainSpan) * rangeSpan,\n \"mapped output\",\n );\n },\n invert(pixel: number) {\n if (rangeSpan === 0)\n throw new RangeError(\n \"Scale cannot invert a collapsed range; supply a nonzero extent.\",\n );\n return finite(\n domain[0] +\n ((finite(pixel, \"invert input\") - range[0]) / rangeSpan) * domainSpan,\n \"inverted output\",\n );\n },\n ticks(count = 5) {\n if (!Number.isInteger(count) || count < 2 || count > 100)\n throw new RangeError(\n \"Scale ticks count must be an integer from 2 to 100.\",\n );\n return Object.freeze(\n Array.from({ length: count }, (_, i) =>\n i === count - 1\n ? domain[1]\n : finite(domain[0] + (domainSpan * i) / (count - 1), \"tick\"),\n ),\n );\n },\n });\n}\nexport function equalScale(a: ResolvedScale, b: ResolvedScale): boolean {\n return (\n a.type === b.type &&\n (a.type !== \"symlog\" || (b.type === \"symlog\" && a.constant === b.constant)) &&\n (a.type !== \"point\" || (b.type === \"point\" && a.padding === b.padding)) &&\n (a.type !== \"log\" || (b.type === \"log\" && a.base === b.base)) &&\n a.domain.length === b.domain.length &&\n a.domain.every((value, index) => Object.is(value, b.domain[index])) &&\n (a.type !== \"band\" ||\n (b.type === \"band\" &&\n a.bandwidth === b.bandwidth &&\n a.step === b.step)) &&\n Object.is(a.range[0], b.range[0]) &&\n Object.is(a.range[1], b.range[1]) &&\n Object.is(a.frame.width, b.frame.width) &&\n Object.is(a.frame.height, b.frame.height)\n );\n}\n"],
5
- "mappings": "AAMA,SAAS,OAAO,OAAe,OAAuB;AACpD,MAAI,OAAO,UAAU,YAAY,CAAC,OAAO,SAAS,KAAK;AACrD,UAAM,IAAI,WAAW,SAAS,KAAK,kBAAkB;AACvD,SAAO;AACT;AACA,SAAS,KACP,OACA,OAC2B;AAC3B,MAAI,CAAC,MAAM,QAAQ,KAAK,KAAK,MAAM,WAAW;AAC5C,UAAM,IAAI,WAAW,SAAS,KAAK,iCAAiC;AACtE,SAAO,OAAO,OAAO,CAAC,OAAO,MAAM,CAAC,GAAG,KAAK,GAAG,OAAO,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC;AAC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AAK,QAAQ,KAAK,QAAQ;AACnD,cAAM,IAAI;AAAA,UACR;AAAA,QACF;AACF,aAAO,OAAO;AAAA,QACZ,MAAM;AAAA,UAAK,EAAE,QAAQ,MAAM;AAAA,UAAG,CAAC,GAAG,MAChC,MAAM,QAAQ,IACV,OAAO,CAAC,IACR,OAAO,OAAO,CAAC,IAAK,aAAa,KAAM,QAAQ,IAAI,MAAM;AAAA,QAC/D;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AACH;AACO,SAAS,WAAW,GAAkB,GAA2B;AACtE,SACE,EAAE,SAAS,EAAE,SACZ,EAAE,SAAS,YAAa,EAAE,SAAS,YAAY,EAAE,aAAa,EAAE,cAChE,EAAE,SAAS,WAAY,EAAE,SAAS,WAAW,EAAE,YAAY,EAAE,aAC7D,EAAE,SAAS,SAAU,EAAE,SAAS,SAAS,EAAE,SAAS,EAAE,SACvD,EAAE,OAAO,WAAW,EAAE,OAAO,UAC7B,EAAE,OAAO,MAAM,CAAC,OAAO,UAAU,OAAO,GAAG,OAAO,EAAE,OAAO,KAAK,CAAC,CAAC,MACjE,EAAE,SAAS,UACT,EAAE,SAAS,UACV,EAAE,cAAc,EAAE,aAClB,EAAE,SAAS,EAAE,SACjB,OAAO,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,KAChC,OAAO,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,KAChC,OAAO,GAAG,EAAE,MAAM,OAAO,EAAE,MAAM,KAAK,KACtC,OAAO,GAAG,EAAE,MAAM,QAAQ,EAAE,MAAM,MAAM;AAE5C;",
4
+ "sourcesContent": ["import type {\n LinearDomain,\n ResolvedLinearScale,\n ResolvedScale,\n ScaleRange,\n} from \"./types.js\";\nfunction finite(value: number, field: string): number {\n if (typeof value !== \"number\" || !Number.isFinite(value))\n throw new RangeError(`Scale ${field} must be finite.`);\n return value;\n}\nfunction pair(\n value: readonly number[],\n field: string,\n): readonly [number, number] {\n if (!Array.isArray(value) || value.length !== 2)\n throw new RangeError(`Scale ${field} requires two finite endpoints.`);\n return Object.freeze([finite(value[0], field), finite(value[1], field)]);\n}\nexport function resolveLinearScale(\n domainInput: LinearDomain,\n rangeInput: ScaleRange,\n reverse: boolean,\n width: number,\n height: number,\n): ResolvedLinearScale {\n finite(width, \"frame.width\");\n finite(height, \"frame.height\");\n if (width < 0 || height < 0)\n throw new RangeError(\"Scale allocation must be nonnegative.\");\n if (typeof reverse !== \"boolean\")\n throw new TypeError(\"Scale reverse must be boolean.\");\n const domain = pair(domainInput, \"domain\");\n if (domain[0] === domain[1])\n throw new RangeError(\"Scale domain endpoints must differ.\");\n const original = pair(\n rangeInput === \"width\"\n ? [0, width]\n : rangeInput === \"height\"\n ? [0, height]\n : (rangeInput as readonly number[]),\n \"range\",\n );\n const range = reverse ? pair([original[1], original[0]], \"range\") : original;\n const domainSpan = finite(domain[1] - domain[0], \"domain span\");\n const rangeSpan = finite(range[1] - range[0], \"range span\");\n return Object.freeze({\n type: \"linear\",\n domain,\n range,\n frame: Object.freeze({ x: 0, y: 0, width, height }),\n map(value: number) {\n return finite(\n range[0] +\n ((finite(value, \"map input\") - domain[0]) / domainSpan) * rangeSpan,\n \"mapped output\",\n );\n },\n invert(pixel: number) {\n if (rangeSpan === 0)\n throw new RangeError(\n \"Scale cannot invert a collapsed range; supply a nonzero extent.\",\n );\n return finite(\n domain[0] +\n ((finite(pixel, \"invert input\") - range[0]) / rangeSpan) * domainSpan,\n \"inverted output\",\n );\n },\n ticks(count = 5) {\n if (!Number.isInteger(count) || count < 2 || count > 100)\n throw new RangeError(\n \"Scale ticks count must be an integer from 2 to 100.\",\n );\n return Object.freeze(\n Array.from({ length: count }, (_, i) =>\n i === count - 1\n ? domain[1]\n : finite(domain[0] + (domainSpan * i) / (count - 1), \"tick\"),\n ),\n );\n },\n });\n}\nexport function equalScale(a: ResolvedScale, b: ResolvedScale): boolean {\n return (\n a.type === b.type &&\n (a.type !== \"trading-time\" ||\n (b.type === \"trading-time\" &&\n a.logicalRange.every((v, i) => v === b.logicalRange[i]))) &&\n (a.type !== \"symlog\" ||\n (b.type === \"symlog\" && a.constant === b.constant)) &&\n (a.type !== \"point\" || (b.type === \"point\" && a.padding === b.padding)) &&\n (a.type !== \"log\" || (b.type === \"log\" && a.base === b.base)) &&\n a.domain.length === b.domain.length &&\n a.domain.every((value, index) => Object.is(value, b.domain[index])) &&\n (a.type !== \"band\" ||\n (b.type === \"band\" &&\n a.bandwidth === b.bandwidth &&\n a.step === b.step)) &&\n Object.is(a.range[0], b.range[0]) &&\n Object.is(a.range[1], b.range[1]) &&\n Object.is(a.frame.width, b.frame.width) &&\n Object.is(a.frame.height, b.frame.height)\n );\n}\n"],
5
+ "mappings": "AAMA,SAAS,OAAO,OAAe,OAAuB;AACpD,MAAI,OAAO,UAAU,YAAY,CAAC,OAAO,SAAS,KAAK;AACrD,UAAM,IAAI,WAAW,SAAS,KAAK,kBAAkB;AACvD,SAAO;AACT;AACA,SAAS,KACP,OACA,OAC2B;AAC3B,MAAI,CAAC,MAAM,QAAQ,KAAK,KAAK,MAAM,WAAW;AAC5C,UAAM,IAAI,WAAW,SAAS,KAAK,iCAAiC;AACtE,SAAO,OAAO,OAAO,CAAC,OAAO,MAAM,CAAC,GAAG,KAAK,GAAG,OAAO,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC;AACzE;AACO,SAAS,mBACd,aACA,YACA,SACA,OACA,QACqB;AACrB,SAAO,OAAO,aAAa;AAC3B,SAAO,QAAQ,cAAc;AAC7B,MAAI,QAAQ,KAAK,SAAS;AACxB,UAAM,IAAI,WAAW,uCAAuC;AAC9D,MAAI,OAAO,YAAY;AACrB,UAAM,IAAI,UAAU,gCAAgC;AACtD,QAAM,SAAS,KAAK,aAAa,QAAQ;AACzC,MAAI,OAAO,CAAC,MAAM,OAAO,CAAC;AACxB,UAAM,IAAI,WAAW,qCAAqC;AAC5D,QAAM,WAAW;AAAA,IACf,eAAe,UACX,CAA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AAE,SAAS,kBACT,EAAE,SAAS,kBACV,EAAE,aAAa,MAAM,CAAC,GAAG,MAAM,MAAM,EAAE,aAAa,CAAC,CAAC,OACzD,EAAE,SAAS,YACT,EAAE,SAAS,YAAY,EAAE,aAAa,EAAE,cAC1C,EAAE,SAAS,WAAY,EAAE,SAAS,WAAW,EAAE,YAAY,EAAE,aAC7D,EAAE,SAAS,SAAU,EAAE,SAAS,SAAS,EAAE,SAAS,EAAE,SACvD,EAAE,OAAO,WAAW,EAAE,OAAO,UAC7B,EAAE,OAAO,MAAM,CAAC,OAAO,UAAU,OAAO,GAAG,OAAO,EAAE,OAAO,KAAK,CAAC,CAAC,MACjE,EAAE,SAAS,UACT,EAAE,SAAS,UACV,EAAE,cAAc,EAAE,aAClB,EAAE,SAAS,EAAE,SACjB,OAAO,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,KAChC,OAAO,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,KAChC,OAAO,GAAG,EAAE,MAAM,OAAO,EAAE,MAAM,KAAK,KACtC,OAAO,GAAG,EAAE,MAAM,QAAQ,EAAE,MAAM,MAAM;AAE5C;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,11 @@
1
+ import { type SeriesCurve } from "./curve-definition.js";
2
+ /**
3
+ * Returns the immutable monotone-X cubic Hermite definition.
4
+ *
5
+ * It uses weighted harmonic interior slopes and limited one-sided endpoint slopes, preserving every observation,
6
+ * flat segment, and local extremum without sorting data. Each run must have strictly ascending
7
+ * or strictly descending x coordinates.
8
+ *
9
+ * @returns The named {@link SeriesCurve} definition.
10
+ */
11
+ export declare function monotoneX(): SeriesCurve;
@@ -0,0 +1,63 @@
1
+ import {
2
+ createSeriesCurve
3
+ } from "./curve-definition.js";
4
+ function endpointSlope(h0, h1, first, second) {
5
+ let slope = ((2 * h0 + h1) * first - h0 * second) / (h0 + h1);
6
+ if (Math.sign(slope) !== Math.sign(first)) return 0;
7
+ if (Math.sign(first) !== Math.sign(second) && Math.abs(slope) > Math.abs(3 * first))
8
+ slope = 3 * first;
9
+ return slope;
10
+ }
11
+ function monotoneSegments(points) {
12
+ if (points.length < 2) return [];
13
+ const direction = points[1][0] > points[0][0] ? 1 : -1;
14
+ const x = points.map((point) => direction * point[0]);
15
+ const h = [];
16
+ const delta = [];
17
+ for (let i = 0; i < points.length - 1; i++) {
18
+ const width = x[i + 1] - x[i];
19
+ if (!Number.isFinite(width) || width <= 0)
20
+ throw new RangeError(
21
+ "monotoneX requires strictly ascending or descending finite x coordinates."
22
+ );
23
+ h.push(width);
24
+ delta.push((points[i + 1][1] - points[i][1]) / width);
25
+ }
26
+ const slopes = new Array(points.length);
27
+ if (points.length === 2) slopes[0] = slopes[1] = delta[0];
28
+ else {
29
+ slopes[0] = endpointSlope(h[0], h[1], delta[0], delta[1]);
30
+ slopes[points.length - 1] = endpointSlope(
31
+ h.at(-1),
32
+ h.at(-2),
33
+ delta.at(-1),
34
+ delta.at(-2)
35
+ );
36
+ for (let i = 1; i < points.length - 1; i++) {
37
+ const previous = delta[i - 1], next = delta[i];
38
+ slopes[i] = previous === 0 || next === 0 || Math.sign(previous) !== Math.sign(next) ? 0 : 3 * (h[i - 1] + h[i]) / ((2 * h[i] + h[i - 1]) / previous + (h[i] + 2 * h[i - 1]) / next);
39
+ }
40
+ }
41
+ return points.slice(1).map((end, index) => {
42
+ const start = points[index], width = h[index];
43
+ const control1 = [
44
+ start[0] + (end[0] - start[0]) / 3,
45
+ start[1] + slopes[index] * width / 3
46
+ ];
47
+ const control2 = [
48
+ end[0] - (end[0] - start[0]) / 3,
49
+ end[1] - slopes[index + 1] * width / 3
50
+ ];
51
+ if (![...control1, ...control2, ...end].every(Number.isFinite))
52
+ throw new RangeError("monotoneX generated non-finite cubic controls.");
53
+ return Object.freeze({ end, control1, control2 });
54
+ });
55
+ }
56
+ const monotone = /* @__PURE__ */ createSeriesCurve(monotoneSegments);
57
+ function monotoneX() {
58
+ return monotone;
59
+ }
60
+ export {
61
+ monotoneX
62
+ };
63
+ //# sourceMappingURL=monotone-curve.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/features/viz/lib/monotone-curve.ts"],
4
+ "sourcesContent": ["import {\n createSeriesCurve,\n type SeriesCurve,\n type SeriesCurvePoint,\n} from \"./curve-definition.js\";\n\nfunction endpointSlope(\n h0: number,\n h1: number,\n first: number,\n second: number,\n): number {\n let slope = ((2 * h0 + h1) * first - h0 * second) / (h0 + h1);\n if (Math.sign(slope) !== Math.sign(first)) return 0;\n if (\n Math.sign(first) !== Math.sign(second) &&\n Math.abs(slope) > Math.abs(3 * first)\n )\n slope = 3 * first;\n return slope;\n}\n\nfunction monotoneSegments(points: readonly SeriesCurvePoint[]) {\n if (points.length < 2) return [];\n const direction = points[1][0] > points[0][0] ? 1 : -1;\n const x = points.map((point) => direction * point[0]);\n const h: number[] = [];\n const delta: number[] = [];\n for (let i = 0; i < points.length - 1; i++) {\n const width = x[i + 1] - x[i];\n if (!Number.isFinite(width) || width <= 0)\n throw new RangeError(\n \"monotoneX requires strictly ascending or descending finite x coordinates.\",\n );\n h.push(width);\n delta.push((points[i + 1][1] - points[i][1]) / width);\n }\n const slopes = new Array<number>(points.length);\n if (points.length === 2) slopes[0] = slopes[1] = delta[0];\n else {\n slopes[0] = endpointSlope(h[0], h[1], delta[0], delta[1]);\n slopes[points.length - 1] = endpointSlope(\n h.at(-1)!,\n h.at(-2)!,\n delta.at(-1)!,\n delta.at(-2)!,\n );\n for (let i = 1; i < points.length - 1; i++) {\n const previous = delta[i - 1],\n next = delta[i];\n slopes[i] =\n previous === 0 || next === 0 || Math.sign(previous) !== Math.sign(next)\n ? 0\n : (3 * (h[i - 1] + h[i])) /\n ((2 * h[i] + h[i - 1]) / previous + (h[i] + 2 * h[i - 1]) / next);\n }\n }\n return points.slice(1).map((end, index) => {\n const start = points[index],\n width = h[index];\n const control1: SeriesCurvePoint = [\n start[0] + (end[0] - start[0]) / 3,\n start[1] + (slopes[index] * width) / 3,\n ];\n const control2: SeriesCurvePoint = [\n end[0] - (end[0] - start[0]) / 3,\n end[1] - (slopes[index + 1] * width) / 3,\n ];\n if (![...control1, ...control2, ...end].every(Number.isFinite))\n throw new RangeError(\"monotoneX generated non-finite cubic controls.\");\n return Object.freeze({ end, control1, control2 });\n });\n}\n\nconst monotone = /* @__PURE__ */ createSeriesCurve(monotoneSegments);\n\n/**\n * Returns the immutable monotone-X cubic Hermite definition.\n *\n * It uses weighted harmonic interior slopes and limited one-sided endpoint slopes, preserving every observation,\n * flat segment, and local extremum without sorting data. Each run must have strictly ascending\n * or strictly descending x coordinates.\n *\n * @returns The named {@link SeriesCurve} definition.\n */\nexport function monotoneX(): SeriesCurve {\n return monotone;\n}\n"],
5
+ "mappings": "AAAA;AAAA,EACE;AAAA,OAGK;AAEP,SAAS,cACP,IACA,IACA,OACA,QACQ;AACR,MAAI,UAAU,IAAI,KAAK,MAAM,QAAQ,KAAK,WAAW,KAAK;AAC1D,MAAI,KAAK,KAAK,KAAK,MAAM,KAAK,KAAK,KAAK,EAAG,QAAO;AAClD,MACE,KAAK,KAAK,KAAK,MAAM,KAAK,KAAK,MAAM,KACrC,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,IAAI,KAAK;AAEpC,YAAQ,IAAI;AACd,SAAO;AACT;AAEA,SAAS,iBAAiB,QAAqC;AAC7D,MAAI,OAAO,SAAS,EAAG,QAAO,CAAC;AAC/B,QAAM,YAAY,OAAO,CAAC,EAAE,CAAC,IAAI,OAAO,CAAC,EAAE,CAAC,IAAI,IAAI;AACpD,QAAM,IAAI,OAAO,IAAI,CAAC,UAAU,YAAY,MAAM,CAAC,CAAC;AACpD,QAAM,IAAc,CAAC;AACrB,QAAM,QAAkB,CAAC;AACzB,WAAS,IAAI,GAAG,IAAI,OAAO,SAAS,GAAG,KAAK;AAC1C,UAAM,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;AAC5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O,KAAK,IAAI,QAAS;AAAA,IACvC;AACA,UAAM,WAA6B;AAAA,MACjC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,MAAM,CAAC,KAAK;AAAA,MAC/B,IAAI,CAAC,IAAK,OAAO,QAAQ,CAAC,IAAI,QAAS;AAAA,IACzC;AACA,QAAI,CAAC,CAAC,GAAG,UAAU,GAAG,UAAU,GAAG,GAAG,EAAE,MAAM,OAAO,QAAQ;AAC3D,YAAM,IAAI,WAAW,gDAAgD;AACvE,WAAO,OAAO,OAAO,EAAE,KAAK,UAAU,SAAS,CAAC;AAAA,EAClD,CAAC;AACH;AAEA,MAAM,WAA2B,kCAAkB,gBAAgB;AAW5D,SAAS,YAAyB;AACvC,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1,15 @@
1
+ import type { NumericDomain } from "./types.js";
2
+ /**
3
+ * Linearly interpolates both endpoints of a finite numeric range.
4
+ *
5
+ * The returned pair is frozen. It preserves ascending, descending, and flat
6
+ * endpoint order for progress within zero through one. Progress outside that
7
+ * interval deliberately extrapolates, matching Pibbl's numeric tween behavior.
8
+ *
9
+ * @param from - Starting finite endpoint pair.
10
+ * @param to - Ending finite endpoint pair.
11
+ * @param progress - Finite interpolation progress supplied by an animation definition.
12
+ * @returns A frozen finite endpoint pair.
13
+ * @see {@link NumericDomain}
14
+ */
15
+ export declare function interpolateNumericRange(from: NumericDomain, to: NumericDomain, progress: number): NumericDomain;
@@ -0,0 +1,36 @@
1
+ function endpoint(value, name) {
2
+ if (typeof value !== "number" || !Number.isFinite(value))
3
+ throw new RangeError(`Numeric range ${name} must be finite.`);
4
+ return value;
5
+ }
6
+ function range(value, name) {
7
+ if (!Array.isArray(value) || value.length !== 2)
8
+ throw new TypeError(`Numeric range ${name} requires two endpoints.`);
9
+ return [endpoint(value[0], `${name}[0]`), endpoint(value[1], `${name}[1]`)];
10
+ }
11
+ function interpolateEndpoint(from, to, progress) {
12
+ if (progress === 0 || from === to) return from;
13
+ if (progress === 1) return to;
14
+ const difference = to - from;
15
+ const direct = from + difference * progress;
16
+ if (Number.isFinite(direct)) return direct;
17
+ const scale = Math.max(Math.abs(from), Math.abs(to));
18
+ const scaled = (from / scale + (to / scale - from / scale) * progress) * scale;
19
+ if (!Number.isFinite(scaled))
20
+ throw new RangeError("Numeric range interpolation must produce finite endpoints.");
21
+ return scaled;
22
+ }
23
+ function interpolateNumericRange(from, to, progress) {
24
+ const start = range(from, "from");
25
+ const end = range(to, "to");
26
+ if (typeof progress !== "number" || !Number.isFinite(progress))
27
+ throw new RangeError("Numeric range interpolation progress must be finite.");
28
+ return Object.freeze([
29
+ interpolateEndpoint(start[0], end[0], progress),
30
+ interpolateEndpoint(start[1], end[1], progress)
31
+ ]);
32
+ }
33
+ export {
34
+ interpolateNumericRange
35
+ };
36
+ //# sourceMappingURL=numeric-range-interpolation.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/features/viz/lib/numeric-range-interpolation.ts"],
4
+ "sourcesContent": ["import type { NumericDomain } from \"./types.js\";\n\nfunction endpoint(value: unknown, name: string): number {\n if (typeof value !== \"number\" || !Number.isFinite(value))\n throw new RangeError(`Numeric range ${name} must be finite.`);\n return value;\n}\n\nfunction range(value: NumericDomain, name: string): readonly [number, number] {\n if (!Array.isArray(value) || value.length !== 2)\n throw new TypeError(`Numeric range ${name} requires two endpoints.`);\n return [endpoint(value[0], `${name}[0]`), endpoint(value[1], `${name}[1]`)];\n}\n\nfunction interpolateEndpoint(from: number, to: number, progress: number): number {\n if (progress === 0 || from === to) return from;\n if (progress === 1) return to;\n const difference = to - from;\n const direct = from + difference * progress;\n if (Number.isFinite(direct)) return direct;\n\n // Scaling avoids overflow in the subtraction for opposite, very large endpoints.\n const scale = Math.max(Math.abs(from), Math.abs(to));\n const scaled =\n (from / scale + (to / scale - from / scale) * progress) * scale;\n if (!Number.isFinite(scaled))\n throw new RangeError(\"Numeric range interpolation must produce finite endpoints.\");\n return scaled;\n}\n\n/**\n * Linearly interpolates both endpoints of a finite numeric range.\n *\n * The returned pair is frozen. It preserves ascending, descending, and flat\n * endpoint order for progress within zero through one. Progress outside that\n * interval deliberately extrapolates, matching Pibbl's numeric tween behavior.\n *\n * @param from - Starting finite endpoint pair.\n * @param to - Ending finite endpoint pair.\n * @param progress - Finite interpolation progress supplied by an animation definition.\n * @returns A frozen finite endpoint pair.\n * @see {@link NumericDomain}\n */\nexport function interpolateNumericRange(\n from: NumericDomain,\n to: NumericDomain,\n progress: number,\n): NumericDomain {\n const start = range(from, \"from\");\n const end = range(to, \"to\");\n if (typeof progress !== \"number\" || !Number.isFinite(progress))\n throw new RangeError(\"Numeric range interpolation progress must be finite.\");\n return Object.freeze([\n interpolateEndpoint(start[0], end[0], progress),\n interpolateEndpoint(start[1], end[1], progress),\n ]);\n}\n"],
5
+ "mappings": "AAEA,SAAS,SAAS,OAAgB,MAAsB;AACtD,MAAI,OAAO,UAAU,YAAY,CAAC,OAAO,SAAS,KAAK;AACrD,UAAM,IAAI,WAAW,iBAAiB,IAAI,kBAAkB;AAC9D,SAAO;AACT;AAEA,SAAS,MAAM,OAAsB,MAAyC;AAC5E,MAAI,CAAC,MAAM,QAAQ,KAAK,KAAK,MAAM,WAAW;AAC5C,UAAM,IAAI,UAAU,iBAAiB,IAAI,0BAA0B;AACrE,SAAO,CAAC,SAAS,MAAM,CAAC,GAAG,GAAG,IAAI,KAAK,GAAG,SAAS,MAAM,CAAC,GAAG,GAAG,IAAI,KAAK,CAAC;AAC5E;AAEA,SAAS,oBAAoB,MAAc,IAAY,UAA0B;AAC/E,MAAI,aAAa,KAAK,SAAS,GAAI,QAAO;AAC1C,MAAI,aAAa,EAAG,QAAO;AAC3B,QAAM,aAAa,KAAK;AACxB,QAAM,SAAS,OAAO,aAAa;AACnC,MAAI,OAAO,SAAS,MAAM,EAAG,QAAO;AAGpC,QAAM,QAAQ,KAAK,IAAI,KAAK,IAAI,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;AACnD,QAAM,UACH,OAAO,SAAS,KAAK,QAAQ,OAAO,SAAS,YAAY;AAC5D,MAAI,CAAC,OAAO,SAAS,MAAM;AACzB,UAAM,IAAI,WAAW,4DAA4D;AACnF,SAAO;AACT;AAeO,SAAS,wBACd,MACA,IACA,UACe;AACf,QAAM,QAAQ,MAAM,MAAM,MAAM;AAChC,QAAM,MAAM,MAAM,IAAI,IAAI;AAC1B,MAAI,OAAO,aAAa,YAAY,CAAC,OAAO,SAAS,QAAQ;AAC3D,UAAM,IAAI,WAAW,sDAAsD;AAC7E,SAAO,OAAO,OAAO;AAAA,IACnB,oBAAoB,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,QAAQ;AAAA,IAC9C,oBAAoB,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,QAAQ;AAAA,EAChD,CAAC;AACH;",
6
+ "names": []
7
+ }
@@ -0,0 +1,55 @@
1
+ import { type PibblEventHandlers, type PibblEventParticipationOptions, type PibblNode, type SignalValue, type StrokeStyle } from "@pibbl/core";
2
+ import type { OhlcBarInspectionRef } from "../inspection/ohlc-bar.js";
3
+ import type { LineAccessor, ScaleId } from "./types.js";
4
+ /** Shared stroke presentation for an OHLC bar.
5
+ * @see {@link OhlcBarSeries}
6
+ */
7
+ export interface OhlcBarSeriesStyle {
8
+ /** Positive total width, or automatic 70% spacing capped at 12; singleton fallback 8. */ readonly bandwidth?: number | "auto";
9
+ /** Stem and tick stroke; defaults to dark teal. Empty string disables painting. */ readonly stroke?: StrokeStyle;
10
+ /** Nonnegative local stroke width; default 1. */ readonly strokeWidth?: number;
11
+ /** Paint opacity from zero through one; default 1. */ readonly opacity?: number;
12
+ /** Cursor while the series owns targeting. */ readonly cursor?: string;
13
+ }
14
+ /** Source-ordered OHLC records rendered as a high/low stem with open/close ticks.
15
+ * @see {@link OhlcBarSeries}
16
+ */
17
+ export interface OhlcBarSeriesProps<D> extends PibblEventHandlers, PibblEventParticipationOptions {
18
+ /** Original records or signal; never sorted or mutated. */
19
+ readonly data: SignalValue<readonly D[]>;
20
+ /** UTC-millisecond property or callback. */
21
+ readonly time: LineAccessor<D>;
22
+ /** Opening price property or callback. */
23
+ readonly open: LineAccessor<D>;
24
+ /** High price property or callback. */
25
+ readonly high: LineAccessor<D>;
26
+ /** Low price property or callback. */
27
+ readonly low: LineAccessor<D>;
28
+ /** Closing price property or callback. */
29
+ readonly close: LineAccessor<D>;
30
+ /** Numeric, UTC, or trading-time horizontal mapping identity. */
31
+ readonly xScale: ScaleId;
32
+ /** Continuous price mapping identity. */
33
+ readonly yScale: ScaleId;
34
+ /** Tests original rows before accessor evaluation.
35
+ * @param datum - Original row.
36
+ * @param index - Source index including skipped rows.
37
+ * @param data - Complete source array.
38
+ * @returns Whether the bar participates.
39
+ */
40
+ readonly defined?: (datum: D, index: number, data: readonly D[]) => boolean;
41
+ /** Shared presentation or a hook-free original-row resolver.
42
+ * @param datum - Original row.
43
+ * @param index - Source index.
44
+ * @param data - Complete source array.
45
+ * @returns Plain OHLC-bar style.
46
+ */
47
+ readonly style?: SignalValue<OhlcBarSeriesStyle> | ((datum: D, index: number, data: readonly D[]) => OhlcBarSeriesStyle);
48
+ /** Optional committed capture; the renderer does not execute inspection queries. */ readonly inspection?: OhlcBarInspectionRef<D>;
49
+ }
50
+ /** Paints source-ordered OHLC bars with a high/low stem, left open tick, and right close tick.
51
+ * @param props - Original OHLC accessors, scales, styles, events, and optional capture.
52
+ * @returns Ordinary Pibbl composition; equal disjoint styles share paths.
53
+ * @see {@link OhlcBarSeriesProps}
54
+ */
55
+ export declare function OhlcBarSeries<D>({ data: input, time: timeInput, open: openInput, high: highInput, low: lowInput, close: closeInput, xScale, yScale, defined, style: styleInput, inspection, pointerEvents, ...events }: OhlcBarSeriesProps<D>): PibblNode;