@pibbl/core 0.0.2 → 0.0.3-alpha.109.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.
- package/THIRD_PARTY_NOTICES.txt +81 -0
- package/dist/features/physics/2d-testing.d.ts +1 -1
- package/dist/features/physics/2d-testing.js +2 -2
- package/dist/features/physics/2d-testing.js.map +2 -2
- package/dist/features/physics/lib/2d/canvas/components.js +25 -21
- package/dist/features/physics/lib/2d/canvas/components.js.map +2 -2
- package/dist/features/physics/lib/2d/canvas/presentation.js +1 -2
- package/dist/features/physics/lib/2d/canvas/presentation.js.map +2 -2
- package/dist/features/physics/lib/2d/collision/casts.js +4 -2
- package/dist/features/physics/lib/2d/collision/casts.js.map +2 -2
- package/dist/features/physics/lib/2d/runtime/controller.js +1 -1
- package/dist/features/physics/lib/2d/runtime/controller.js.map +2 -2
- package/dist/features/physics/lib/2d/runtime/obstacles.js +9 -11
- package/dist/features/physics/lib/2d/runtime/obstacles.js.map +2 -2
- package/dist/features/physics/lib/2d/shapes.js +8 -9
- package/dist/features/physics/lib/2d/shapes.js.map +2 -2
- package/dist/features/physics/lib/2d/world/rapier.js +22 -26
- package/dist/features/physics/lib/2d/world/rapier.js.map +2 -2
- package/dist/features/sprites/loader.js +6 -3
- package/dist/features/sprites/loader.js.map +2 -2
- package/dist/features/textures/index.d.ts +12 -2
- package/dist/features/textures/index.js +33 -1
- package/dist/features/textures/index.js.map +2 -2
- package/dist/features/textures/lib/chemical-field.d.ts +56 -0
- package/dist/features/textures/lib/chemical-field.js +154 -0
- package/dist/features/textures/lib/chemical-field.js.map +7 -0
- package/dist/features/textures/lib/chemical-recipes.d.ts +119 -0
- package/dist/features/textures/lib/chemical-recipes.js +275 -0
- package/dist/features/textures/lib/chemical-recipes.js.map +7 -0
- package/dist/features/textures/lib/definitions.d.ts +3 -18
- package/dist/features/textures/lib/definitions.js +17 -24
- package/dist/features/textures/lib/definitions.js.map +2 -2
- package/dist/features/textures/lib/geometric-patterns.d.ts +149 -0
- package/dist/features/textures/lib/geometric-patterns.js +305 -0
- package/dist/features/textures/lib/geometric-patterns.js.map +7 -0
- package/dist/features/textures/lib/gray-scott.d.ts +55 -0
- package/dist/features/textures/lib/gray-scott.js +37 -0
- package/dist/features/textures/lib/gray-scott.js.map +7 -0
- package/dist/features/textures/lib/palette.js +1 -3
- package/dist/features/textures/lib/palette.js.map +2 -2
- package/dist/features/textures/lib/patterns.d.ts +123 -0
- package/dist/features/textures/lib/patterns.js +344 -0
- package/dist/features/textures/lib/patterns.js.map +7 -0
- package/dist/features/textures/lib/rain-drops.js +2 -1
- package/dist/features/textures/lib/rain-drops.js.map +2 -2
- package/dist/features/textures/lib/reaction-diffusion.d.ts +3 -2
- package/dist/features/textures/lib/reaction-diffusion.js +9 -20
- package/dist/features/textures/lib/reaction-diffusion.js.map +2 -2
- package/dist/features/textures/lib/simulation.d.ts +10 -4
- package/dist/features/textures/lib/simulation.js +23 -13
- package/dist/features/textures/lib/simulation.js.map +2 -2
- package/dist/features/textures/lib/wasm/electric.js +8 -1
- package/dist/features/textures/lib/wasm/electric.js.map +2 -2
- package/dist/features/textures/lib/water-surface.js +1 -3
- package/dist/features/textures/lib/water-surface.js.map +2 -2
- package/dist/features/viz/index.d.ts +68 -6
- package/dist/features/viz/index.js +164 -2
- package/dist/features/viz/index.js.map +2 -2
- package/dist/features/viz/inspection/bar.d.ts +79 -0
- package/dist/features/viz/inspection/bar.js +49 -0
- package/dist/features/viz/inspection/bar.js.map +7 -0
- package/dist/features/viz/inspection/candle.d.ts +156 -0
- package/dist/features/viz/inspection/candle.js +120 -0
- package/dist/features/viz/inspection/candle.js.map +7 -0
- package/dist/features/viz/inspection/capture-types.d.ts +65 -0
- package/dist/features/viz/inspection/capture.d.ts +16 -0
- package/dist/features/viz/inspection/capture.js +49 -0
- package/dist/features/viz/inspection/capture.js.map +7 -0
- package/dist/features/viz/inspection/handler.d.ts +36 -0
- package/dist/features/viz/inspection/handler.js +91 -0
- package/dist/features/viz/inspection/handler.js.map +7 -0
- package/dist/features/viz/inspection/ohlc-bar.d.ts +132 -0
- package/dist/features/viz/inspection/ohlc-bar.js +118 -0
- package/dist/features/viz/inspection/ohlc-bar.js.map +7 -0
- package/dist/features/viz/inspection/owned-ref.d.ts +16 -0
- package/dist/features/viz/inspection/owned-ref.js +99 -0
- package/dist/features/viz/inspection/owned-ref.js.map +7 -0
- package/dist/features/viz/inspection/painted-point.d.ts +22 -0
- package/dist/features/viz/inspection/painted-point.js +29 -0
- package/dist/features/viz/inspection/painted-point.js.map +7 -0
- package/dist/features/viz/inspection/queries.d.ts +100 -0
- package/dist/features/viz/inspection/queries.js +192 -0
- package/dist/features/viz/inspection/queries.js.map +7 -0
- package/dist/features/viz/inspection/query-types.d.ts +177 -0
- package/dist/features/viz/inspection/volume.d.ts +104 -0
- package/dist/features/viz/inspection/volume.js +95 -0
- package/dist/features/viz/inspection/volume.js.map +7 -0
- package/dist/features/viz/inspection.d.ts +19 -0
- package/dist/features/viz/inspection.js +54 -0
- package/dist/features/viz/inspection.js.map +7 -0
- package/dist/features/viz/inspection.mjs +1 -0
- package/dist/features/viz/lib/area-series.d.ts +62 -0
- package/dist/features/viz/lib/area-series.js +120 -0
- package/dist/features/viz/lib/area-series.js.map +7 -0
- package/dist/features/viz/lib/axis-title.js +2 -1
- package/dist/features/viz/lib/axis-title.js.map +2 -2
- package/dist/features/viz/lib/axis.js +1 -1
- package/dist/features/viz/lib/axis.js.map +2 -2
- package/dist/features/viz/lib/bar-series.d.ts +3 -1
- package/dist/features/viz/lib/bar-series.js +16 -1
- package/dist/features/viz/lib/bar-series.js.map +2 -2
- package/dist/features/viz/lib/baseline-series.d.ts +55 -0
- package/dist/features/viz/lib/baseline-series.js +136 -0
- package/dist/features/viz/lib/baseline-series.js.map +7 -0
- package/dist/features/viz/lib/candlestick-series.d.ts +62 -0
- package/dist/features/viz/lib/candlestick-series.js +150 -0
- package/dist/features/viz/lib/candlestick-series.js.map +7 -0
- package/dist/features/viz/lib/censored-point-series.d.ts +71 -0
- package/dist/features/viz/lib/censored-point-series.js +129 -0
- package/dist/features/viz/lib/censored-point-series.js.map +7 -0
- package/dist/features/viz/lib/color-context.d.ts +4 -0
- package/dist/features/viz/lib/color-context.js +41 -0
- package/dist/features/viz/lib/color-context.js.map +7 -0
- package/dist/features/viz/lib/color-math.d.ts +4 -0
- package/dist/features/viz/lib/color-math.js +31 -0
- package/dist/features/viz/lib/color-math.js.map +7 -0
- package/dist/features/viz/lib/color-types.d.ts +53 -0
- package/dist/features/viz/lib/curve-definition.d.ts +49 -0
- package/dist/features/viz/lib/curve-definition.js +142 -0
- package/dist/features/viz/lib/curve-definition.js.map +7 -0
- package/dist/features/viz/lib/diverging-color-scale.d.ts +11 -0
- package/dist/features/viz/lib/diverging-color-scale.js +51 -0
- package/dist/features/viz/lib/diverging-color-scale.js.map +7 -0
- package/dist/features/viz/lib/domain-navigation.d.ts +40 -0
- package/dist/features/viz/lib/domain-navigation.js +77 -0
- package/dist/features/viz/lib/domain-navigation.js.map +7 -0
- package/dist/features/viz/lib/editable-chart-elements.d.ts +178 -0
- package/dist/features/viz/lib/editable-chart-elements.js +733 -0
- package/dist/features/viz/lib/editable-chart-elements.js.map +7 -0
- package/dist/features/viz/lib/financial-aggregation.d.ts +127 -0
- package/dist/features/viz/lib/financial-aggregation.js +116 -0
- package/dist/features/viz/lib/financial-aggregation.js.map +7 -0
- package/dist/features/viz/lib/financial-autoscale.d.ts +64 -0
- package/dist/features/viz/lib/financial-autoscale.js +61 -0
- package/dist/features/viz/lib/financial-autoscale.js.map +7 -0
- package/dist/features/viz/lib/financial-comparison.d.ts +62 -0
- package/dist/features/viz/lib/financial-comparison.js +98 -0
- package/dist/features/viz/lib/financial-comparison.js.map +7 -0
- package/dist/features/viz/lib/financial-geometry.d.ts +77 -0
- package/dist/features/viz/lib/financial-geometry.js +67 -0
- package/dist/features/viz/lib/financial-geometry.js.map +7 -0
- package/dist/features/viz/lib/financial-indicators.d.ts +114 -0
- package/dist/features/viz/lib/financial-indicators.js +135 -0
- package/dist/features/viz/lib/financial-indicators.js.map +7 -0
- package/dist/features/viz/lib/financial-oscillators.d.ts +171 -0
- package/dist/features/viz/lib/financial-oscillators.js +265 -0
- package/dist/features/viz/lib/financial-oscillators.js.map +7 -0
- package/dist/features/viz/lib/graph/bipartite.d.ts +14 -0
- package/dist/features/viz/lib/graph/bipartite.js +250 -0
- package/dist/features/viz/lib/graph/bipartite.js.map +7 -0
- package/dist/features/viz/lib/graph/chord.d.ts +44 -0
- package/dist/features/viz/lib/graph/chord.js +348 -0
- package/dist/features/viz/lib/graph/chord.js.map +7 -0
- package/dist/features/viz/lib/graph/dependency.d.ts +26 -0
- package/dist/features/viz/lib/graph/dependency.js +140 -0
- package/dist/features/viz/lib/graph/dependency.js.map +7 -0
- package/dist/features/viz/lib/graph/force.d.ts +28 -0
- package/dist/features/viz/lib/graph/force.js +580 -0
- package/dist/features/viz/lib/graph/force.js.map +7 -0
- package/dist/features/viz/lib/graph/hierarchy.d.ts +21 -0
- package/dist/features/viz/lib/graph/hierarchy.js +112 -0
- package/dist/features/viz/lib/graph/hierarchy.js.map +7 -0
- package/dist/features/viz/lib/graph/icicle.d.ts +16 -0
- package/dist/features/viz/lib/graph/icicle.js +153 -0
- package/dist/features/viz/lib/graph/icicle.js.map +7 -0
- package/dist/features/viz/lib/graph/matrix.d.ts +30 -0
- package/dist/features/viz/lib/graph/matrix.js +243 -0
- package/dist/features/viz/lib/graph/matrix.js.map +7 -0
- package/dist/features/viz/lib/graph/neighborhood.d.ts +11 -0
- package/dist/features/viz/lib/graph/neighborhood.js +281 -0
- package/dist/features/viz/lib/graph/neighborhood.js.map +7 -0
- package/dist/features/viz/lib/graph/routes.d.ts +35 -0
- package/dist/features/viz/lib/graph/routes.js +101 -0
- package/dist/features/viz/lib/graph/routes.js.map +7 -0
- package/dist/features/viz/lib/graph/sankey.d.ts +44 -0
- package/dist/features/viz/lib/graph/sankey.js +341 -0
- package/dist/features/viz/lib/graph/sankey.js.map +7 -0
- package/dist/features/viz/lib/graph/shared.d.ts +59 -0
- package/dist/features/viz/lib/graph/shared.js +301 -0
- package/dist/features/viz/lib/graph/shared.js.map +7 -0
- package/dist/features/viz/lib/graph/tree.d.ts +11 -0
- package/dist/features/viz/lib/graph/tree.js +232 -0
- package/dist/features/viz/lib/graph/tree.js.map +7 -0
- package/dist/features/viz/lib/graph/treemap.d.ts +20 -0
- package/dist/features/viz/lib/graph/treemap.js +227 -0
- package/dist/features/viz/lib/graph/treemap.js.map +7 -0
- package/dist/features/viz/lib/graph/types.d.ts +1097 -0
- package/dist/features/viz/lib/hover-card.js +8 -9
- package/dist/features/viz/lib/hover-card.js.map +2 -2
- package/dist/features/viz/lib/hover-data.d.ts +1 -1
- package/dist/features/viz/lib/hover-data.js +5 -2
- package/dist/features/viz/lib/hover-data.js.map +2 -2
- package/dist/features/viz/lib/interval-band-series.d.ts +49 -0
- package/dist/features/viz/lib/interval-band-series.js +136 -0
- package/dist/features/viz/lib/interval-band-series.js.map +7 -0
- package/dist/features/viz/lib/interval-diamond-series.d.ts +43 -0
- package/dist/features/viz/lib/interval-diamond-series.js +122 -0
- package/dist/features/viz/lib/interval-diamond-series.js.map +7 -0
- package/dist/features/viz/lib/interval-series.d.ts +79 -0
- package/dist/features/viz/lib/interval-series.js +158 -0
- package/dist/features/viz/lib/interval-series.js.map +7 -0
- package/dist/features/viz/lib/layout-pie.js +9 -13
- package/dist/features/viz/lib/layout-pie.js.map +2 -2
- package/dist/features/viz/lib/line-series.d.ts +1 -1
- package/dist/features/viz/lib/line-series.js +47 -28
- package/dist/features/viz/lib/line-series.js.map +2 -2
- package/dist/features/viz/lib/linear-scale.js +1 -1
- package/dist/features/viz/lib/linear-scale.js.map +2 -2
- package/dist/features/viz/lib/monotone-curve.d.ts +11 -0
- package/dist/features/viz/lib/monotone-curve.js +63 -0
- package/dist/features/viz/lib/monotone-curve.js.map +7 -0
- package/dist/features/viz/lib/numeric-range-interpolation.d.ts +15 -0
- package/dist/features/viz/lib/numeric-range-interpolation.js +36 -0
- package/dist/features/viz/lib/numeric-range-interpolation.js.map +7 -0
- package/dist/features/viz/lib/ohlc-bar-series.d.ts +55 -0
- package/dist/features/viz/lib/ohlc-bar-series.js +168 -0
- package/dist/features/viz/lib/ohlc-bar-series.js.map +7 -0
- package/dist/features/viz/lib/paired-series.d.ts +44 -0
- package/dist/features/viz/lib/paired-series.js +93 -0
- package/dist/features/viz/lib/paired-series.js.map +7 -0
- package/dist/features/viz/lib/pie-layout.js +2 -1
- package/dist/features/viz/lib/pie-layout.js.map +2 -2
- package/dist/features/viz/lib/plot-series.js +11 -6
- package/dist/features/viz/lib/plot-series.js.map +2 -2
- package/dist/features/viz/lib/plot-types.d.ts +4 -3
- package/dist/features/viz/lib/point-series.d.ts +1 -1
- package/dist/features/viz/lib/point-series.js +36 -9
- package/dist/features/viz/lib/point-series.js.map +2 -2
- package/dist/features/viz/lib/point-types.d.ts +5 -2
- package/dist/features/viz/lib/reference-band.js +4 -1
- package/dist/features/viz/lib/reference-band.js.map +2 -2
- package/dist/features/viz/lib/scale-context.d.ts +1 -1
- package/dist/features/viz/lib/scale-ticks.js +21 -6
- package/dist/features/viz/lib/scale-ticks.js.map +2 -2
- package/dist/features/viz/lib/sequential-color-scale.d.ts +11 -0
- package/dist/features/viz/lib/sequential-color-scale.js +49 -0
- package/dist/features/viz/lib/sequential-color-scale.js.map +7 -0
- package/dist/features/viz/lib/series-position.d.ts +12 -0
- package/dist/features/viz/lib/series-position.js +44 -0
- package/dist/features/viz/lib/series-position.js.map +7 -0
- package/dist/features/viz/lib/step-curves.d.ts +19 -0
- package/dist/features/viz/lib/step-curves.js +53 -0
- package/dist/features/viz/lib/step-curves.js.map +7 -0
- package/dist/features/viz/lib/threshold-color-scale.d.ts +43 -0
- package/dist/features/viz/lib/threshold-color-scale.js +59 -0
- package/dist/features/viz/lib/threshold-color-scale.js.map +7 -0
- package/dist/features/viz/lib/trading-time-mapping.d.ts +32 -0
- package/dist/features/viz/lib/trading-time-mapping.js +89 -0
- package/dist/features/viz/lib/trading-time-mapping.js.map +7 -0
- package/dist/features/viz/lib/trading-time-scale.d.ts +83 -0
- package/dist/features/viz/lib/trading-time-scale.js +96 -0
- package/dist/features/viz/lib/trading-time-scale.js.map +7 -0
- package/dist/features/viz/lib/trajectory-series.d.ts +71 -0
- package/dist/features/viz/lib/trajectory-series.js +111 -0
- package/dist/features/viz/lib/trajectory-series.js.map +7 -0
- package/dist/features/viz/lib/types.d.ts +20 -4
- package/dist/features/viz/lib/use-continuous-scale.js +6 -1
- package/dist/features/viz/lib/use-continuous-scale.js.map +2 -2
- package/dist/features/viz/lib/utc-scale.js +11 -10
- package/dist/features/viz/lib/utc-scale.js.map +2 -2
- package/dist/features/viz/lib/volume-series.d.ts +59 -0
- package/dist/features/viz/lib/volume-series.js +117 -0
- package/dist/features/viz/lib/volume-series.js.map +7 -0
- package/dist/features/viz/lib/weighted-point-series.d.ts +71 -0
- package/dist/features/viz/lib/weighted-point-series.js +169 -0
- package/dist/features/viz/lib/weighted-point-series.js.map +7 -0
- package/dist/filters/backdrop-contrast-gpu.d.ts +5 -0
- package/dist/filters/backdrop-contrast-gpu.js +33 -0
- package/dist/filters/backdrop-contrast-gpu.js.map +7 -0
- package/dist/filters/backdrop-contrast.d.ts +21 -0
- package/dist/filters/backdrop-contrast.js +61 -0
- package/dist/filters/backdrop-contrast.js.map +7 -0
- package/dist/filters/displacement.js +1 -1
- package/dist/filters/displacement.js.map +2 -2
- package/dist/filters/emboss-gpu.d.ts +4 -0
- package/dist/filters/emboss-gpu.js +39 -0
- package/dist/filters/emboss-gpu.js.map +7 -0
- package/dist/filters/emboss.d.ts +32 -0
- package/dist/filters/emboss.js +104 -0
- package/dist/filters/emboss.js.map +7 -0
- package/dist/filters/filter-executor.d.ts +11 -4
- package/dist/filters/filter-executor.js +104 -49
- package/dist/filters/filter-executor.js.map +2 -2
- package/dist/filters/reflected-light.js +1 -1
- package/dist/filters/reflected-light.js.map +2 -2
- package/dist/filters/reflection-gpu.d.ts +3 -1
- package/dist/filters/reflection-gpu.js +5 -2
- package/dist/filters/reflection-gpu.js.map +2 -2
- package/dist/filters/render-backdrop-contrast-boundary.d.ts +31 -0
- package/dist/filters/render-backdrop-contrast-boundary.js +116 -0
- package/dist/filters/render-backdrop-contrast-boundary.js.map +7 -0
- package/dist/filters/render-emboss-boundary.d.ts +13 -0
- package/dist/filters/render-emboss-boundary.js +131 -0
- package/dist/filters/render-emboss-boundary.js.map +7 -0
- package/dist/filters.d.ts +9 -5
- package/dist/filters.js +4 -0
- package/dist/filters.js.map +2 -2
- package/dist/index.d.ts +9 -5
- package/dist/index.js +18 -2
- package/dist/index.js.map +2 -2
- package/dist/internal.d.ts +4 -0
- package/dist/internal.js +6 -0
- package/dist/internal.js.map +2 -2
- package/dist/layout-kernel.d.ts +12 -0
- package/dist/layout-kernel.js +11 -0
- package/dist/layout-kernel.js.map +7 -0
- package/dist/layout-kernel.mjs +1 -0
- package/dist/lib/backend/types.d.ts +13 -1
- package/dist/lib/backend/types.js.map +2 -2
- package/dist/lib/components/arc-geometry.js +2 -1
- package/dist/lib/components/arc-geometry.js.map +2 -2
- package/dist/lib/components/g.js +2 -0
- package/dist/lib/components/g.js.map +2 -2
- package/dist/lib/components/html-box.js +2 -1
- package/dist/lib/components/html-box.js.map +2 -2
- package/dist/lib/components/img.js +3 -3
- package/dist/lib/components/img.js.map +2 -2
- package/dist/lib/components/layer.js +98 -16
- package/dist/lib/components/layer.js.map +3 -3
- package/dist/lib/components/text.d.ts +16 -0
- package/dist/lib/components/text.js +131 -24
- package/dist/lib/components/text.js.map +2 -2
- package/dist/lib/define-primitive.d.ts +4 -2
- package/dist/lib/define-primitive.js +3 -1
- package/dist/lib/define-primitive.js.map +2 -2
- package/dist/lib/element/metadata.d.ts +9 -0
- package/dist/lib/element/metadata.js +19 -0
- package/dist/lib/element/metadata.js.map +2 -2
- package/dist/lib/element/resolve-primitive-inputs.d.ts +2 -0
- package/dist/lib/element/resolve-primitive-inputs.js +17 -4
- package/dist/lib/element/resolve-primitive-inputs.js.map +2 -2
- package/dist/lib/events/event-facade.d.ts +18 -0
- package/dist/lib/events/event-facade.js +28 -2
- package/dist/lib/events/event-facade.js.map +2 -2
- package/dist/lib/events/hit-test.js +2 -1
- package/dist/lib/events/hit-test.js.map +2 -2
- package/dist/lib/events/propagation.d.ts +2 -1
- package/dist/lib/events/propagation.js +22 -16
- package/dist/lib/events/propagation.js.map +2 -2
- package/dist/lib/events/registrations.d.ts +10 -0
- package/dist/lib/events/registrations.js +160 -5
- package/dist/lib/events/registrations.js.map +2 -2
- package/dist/lib/execute-render.js +25 -1
- package/dist/lib/execute-render.js.map +2 -2
- package/dist/lib/filter/filter-region.js +3 -10
- package/dist/lib/filter/filter-region.js.map +2 -2
- package/dist/lib/focus/focus-manager.d.ts +8 -1
- package/dist/lib/focus/focus-manager.js +87 -43
- package/dist/lib/focus/focus-manager.js.map +2 -2
- package/dist/lib/focus/geometry.d.ts +2 -0
- package/dist/lib/focus/geometry.js +6 -0
- package/dist/lib/focus/geometry.js.map +2 -2
- package/dist/lib/geometry/path-bend-guide.js +1 -1
- package/dist/lib/geometry/path-bend-guide.js.map +2 -2
- package/dist/lib/geometry/path-geometry.js +12 -11
- package/dist/lib/geometry/path-geometry.js.map +2 -2
- package/dist/lib/geometry/path-transforms.js +17 -21
- package/dist/lib/geometry/path-transforms.js.map +2 -2
- package/dist/lib/geometry/path-warp-bezier.js +3 -1
- package/dist/lib/geometry/path-warp-bezier.js.map +2 -2
- package/dist/lib/geometry/path-warp.js +1 -1
- package/dist/lib/geometry/path-warp.js.map +2 -2
- package/dist/lib/global-state.js +2 -0
- package/dist/lib/global-state.js.map +2 -2
- package/dist/lib/html/html-events.d.ts +32 -0
- package/dist/lib/html/html-events.js +179 -0
- package/dist/lib/html/html-events.js.map +7 -0
- package/dist/lib/html/html-service.d.ts +8 -2
- package/dist/lib/html/html-service.js +198 -65
- package/dist/lib/html/html-service.js.map +2 -2
- package/dist/lib/html/overlay-config.js +7 -6
- package/dist/lib/html/overlay-config.js.map +2 -2
- package/dist/lib/html/types.d.ts +29 -2
- package/dist/lib/layout/absolute.d.ts +11 -5
- package/dist/lib/layout/absolute.js +329 -55
- package/dist/lib/layout/absolute.js.map +3 -3
- package/dist/lib/layout/allocation-checkpoint-owner.d.ts +11 -0
- package/dist/lib/layout/allocation-checkpoint-owner.js +86 -0
- package/dist/lib/layout/allocation-checkpoint-owner.js.map +7 -0
- package/dist/lib/layout/allocation-checkpoint.d.ts +53 -0
- package/dist/lib/layout/allocation-checkpoint.js +463 -0
- package/dist/lib/layout/allocation-checkpoint.js.map +7 -0
- package/dist/lib/layout/allocation-dependencies.d.ts +30 -0
- package/dist/lib/layout/allocation-dependencies.js +90 -0
- package/dist/lib/layout/allocation-dependencies.js.map +7 -0
- package/dist/lib/layout/allocation-revision.d.ts +13 -0
- package/dist/lib/layout/allocation-revision.js +67 -0
- package/dist/lib/layout/allocation-revision.js.map +7 -0
- package/dist/lib/layout/box-insets.d.ts +17 -0
- package/dist/lib/layout/box-insets.js +138 -0
- package/dist/lib/layout/box-insets.js.map +7 -0
- package/dist/lib/layout/box-sizing.d.ts +16 -0
- package/dist/lib/layout/box-sizing.js +77 -0
- package/dist/lib/layout/box-sizing.js.map +7 -0
- package/dist/lib/layout/box.js +42 -12
- package/dist/lib/layout/box.js.map +2 -2
- package/dist/lib/layout/canvas-measurement.d.ts +13 -0
- package/dist/lib/layout/canvas-measurement.js +57 -0
- package/dist/lib/layout/canvas-measurement.js.map +7 -0
- package/dist/lib/layout/context.d.ts +35 -6
- package/dist/lib/layout/context.js +72 -3
- package/dist/lib/layout/context.js.map +2 -2
- package/dist/lib/layout/define-layout-component.d.ts +23 -0
- package/dist/lib/layout/define-layout-component.js +84 -0
- package/dist/lib/layout/define-layout-component.js.map +7 -0
- package/dist/lib/layout/flex-allocation-cache.d.ts +42 -0
- package/dist/lib/layout/flex-baseline-mode.d.ts +2 -0
- package/dist/lib/layout/flex-baseline-mode.js +7 -0
- package/dist/lib/layout/flex-baseline-mode.js.map +7 -0
- package/dist/lib/layout/flex.d.ts +50 -15
- package/dist/lib/layout/flex.js +2124 -195
- package/dist/lib/layout/flex.js.map +3 -3
- package/dist/lib/layout/flow.js +225 -49
- package/dist/lib/layout/flow.js.map +2 -2
- package/dist/lib/layout/geometry-publication.d.ts +53 -0
- package/dist/lib/layout/geometry-publication.js +244 -0
- package/dist/lib/layout/geometry-publication.js.map +7 -0
- package/dist/lib/layout/grid-kernel.d.ts +63 -0
- package/dist/lib/layout/grid-kernel.js +168 -0
- package/dist/lib/layout/grid-kernel.js.map +7 -0
- package/dist/lib/layout/grid.d.ts +63 -4
- package/dist/lib/layout/grid.js +767 -171
- package/dist/lib/layout/grid.js.map +3 -3
- package/dist/lib/layout/measure.d.ts +55 -3
- package/dist/lib/layout/measure.js +448 -15
- package/dist/lib/layout/measure.js.map +2 -2
- package/dist/lib/layout/overlay.js +81 -23
- package/dist/lib/layout/overlay.js.map +2 -2
- package/dist/lib/layout/participation.d.ts +27 -0
- package/dist/lib/layout/participation.js +188 -0
- package/dist/lib/layout/participation.js.map +7 -0
- package/dist/lib/layout/place-child.js +1 -1
- package/dist/lib/layout/place-child.js.map +2 -2
- package/dist/lib/layout/positioning-diagnostics.d.ts +1 -1
- package/dist/lib/layout/positioning-diagnostics.js +13 -2
- package/dist/lib/layout/positioning-diagnostics.js.map +2 -2
- package/dist/lib/layout/prepared-root.d.ts +121 -0
- package/dist/lib/layout/prepared-root.js +360 -0
- package/dist/lib/layout/prepared-root.js.map +7 -0
- package/dist/lib/layout/standalone-kernel.d.ts +60 -0
- package/dist/lib/layout/standalone-kernel.js +722 -0
- package/dist/lib/layout/standalone-kernel.js.map +7 -0
- package/dist/lib/layout/topology.d.ts +21 -0
- package/dist/lib/layout/topology.js +113 -0
- package/dist/lib/layout/topology.js.map +7 -0
- package/dist/lib/layout/types.d.ts +5 -0
- package/dist/lib/layout/wasm/artifact.d.ts +1 -0
- package/dist/lib/layout/wasm/artifact.js +5 -0
- package/dist/lib/layout/wasm/artifact.js.map +7 -0
- package/dist/lib/layout/wasm/bytes.d.ts +1 -0
- package/dist/lib/layout/wasm/bytes.js +5 -0
- package/dist/lib/layout/wasm/bytes.js.map +7 -0
- package/dist/lib/layout/wasm/embedded.d.ts +2 -0
- package/dist/lib/layout/wasm/embedded.js +12 -0
- package/dist/lib/layout/wasm/embedded.js.map +7 -0
- package/dist/lib/layout/wasm/layout.wasm +0 -0
- package/dist/lib/layout/wasm/module.d.ts +8 -0
- package/dist/lib/layout/wasm/module.js +70 -0
- package/dist/lib/layout/wasm/module.js.map +7 -0
- package/dist/lib/layout/wasm/region.d.ts +267 -0
- package/dist/lib/layout/wasm/region.js +1018 -0
- package/dist/lib/layout/wasm/region.js.map +7 -0
- package/dist/lib/manipulation/controller.js +4 -7
- package/dist/lib/manipulation/controller.js.map +2 -2
- package/dist/lib/manipulation/frame.js +1 -1
- package/dist/lib/manipulation/frame.js.map +2 -2
- package/dist/lib/manipulation/handles.js +32 -33
- package/dist/lib/manipulation/handles.js.map +2 -2
- package/dist/lib/manipulation/solve.js +12 -10
- package/dist/lib/manipulation/solve.js.map +2 -2
- package/dist/lib/mount-pibbl.js +1 -0
- package/dist/lib/mount-pibbl.js.map +2 -2
- package/dist/lib/mount-prepared-pibbl.d.ts +5 -0
- package/dist/lib/mount-prepared-pibbl.js +29 -0
- package/dist/lib/mount-prepared-pibbl.js.map +7 -0
- package/dist/lib/mount-request.d.ts +8 -0
- package/dist/lib/mount-request.js +41 -0
- package/dist/lib/mount-request.js.map +7 -0
- package/dist/lib/pibbl.d.ts +21 -13
- package/dist/lib/pibbl.js +18 -16
- package/dist/lib/pibbl.js.map +2 -2
- package/dist/lib/recording/recording.d.ts +43 -0
- package/dist/lib/recording/recording.js +555 -0
- package/dist/lib/recording/recording.js.map +7 -0
- package/dist/lib/recording/types.d.ts +118 -0
- package/dist/lib/recording/wasm-bytes.d.ts +1 -0
- package/dist/lib/recording/wasm-bytes.js +5 -0
- package/dist/lib/recording/wasm-bytes.js.map +7 -0
- package/dist/lib/recording/worker-source.d.ts +1 -0
- package/dist/lib/recording/worker-source.js +5 -0
- package/dist/lib/recording/worker-source.js.map +7 -0
- package/dist/lib/render-layer/controller.d.ts +9 -3
- package/dist/lib/render-layer/controller.js +259 -110
- package/dist/lib/render-layer/controller.js.map +2 -2
- package/dist/lib/render-transaction.d.ts +12 -2
- package/dist/lib/render-transaction.js +69 -1
- package/dist/lib/render-transaction.js.map +2 -2
- package/dist/lib/render.js +32 -8
- package/dist/lib/render.js.map +2 -2
- package/dist/lib/scheduler/realm-scheduler.d.ts +2 -0
- package/dist/lib/scheduler/realm-scheduler.js +55 -26
- package/dist/lib/scheduler/realm-scheduler.js.map +2 -2
- package/dist/lib/scheduler/renderer-participant.js +1 -0
- package/dist/lib/scheduler/renderer-participant.js.map +2 -2
- package/dist/lib/series-inspection-frame.d.ts +18 -0
- package/dist/lib/series-inspection-frame.js +70 -0
- package/dist/lib/series-inspection-frame.js.map +7 -0
- package/dist/lib/signals/edge.d.ts +7 -4
- package/dist/lib/signals/edge.js +25 -3
- package/dist/lib/signals/edge.js.map +2 -2
- package/dist/lib/signals/graph.d.ts +16 -2
- package/dist/lib/signals/graph.js +54 -12
- package/dist/lib/signals/graph.js.map +2 -2
- package/dist/lib/signals/input-provision.d.ts +15 -0
- package/dist/lib/signals/input-provision.js +53 -3
- package/dist/lib/signals/input-provision.js.map +2 -2
- package/dist/lib/signals/render-consumer.d.ts +3 -0
- package/dist/lib/signals/render-consumer.js +22 -14
- package/dist/lib/signals/render-consumer.js.map +2 -2
- package/dist/lib/style/positioning.d.ts +50 -2
- package/dist/lib/style/positioning.js +28 -4
- package/dist/lib/style/positioning.js.map +2 -2
- package/dist/lib/style/resolve-built-in.d.ts +4 -3
- package/dist/lib/style/resolve-built-in.js +17 -3
- package/dist/lib/style/resolve-built-in.js.map +2 -2
- package/dist/lib/style/resolve-dispatch.d.ts +3 -0
- package/dist/lib/style/resolve-dispatch.js +77 -4
- package/dist/lib/style/resolve-dispatch.js.map +2 -2
- package/dist/lib/style/resolve-length.d.ts +2 -0
- package/dist/lib/style/resolve-length.js +13 -9
- package/dist/lib/style/resolve-length.js.map +2 -2
- package/dist/lib/style/sizing-length.d.ts +51 -0
- package/dist/lib/style/sizing-length.js +77 -0
- package/dist/lib/style/sizing-length.js.map +7 -0
- package/dist/lib/style/types.d.ts +63 -25
- package/dist/lib/surface/root-surface.js +10 -6
- package/dist/lib/surface/root-surface.js.map +2 -2
- package/dist/lib/textures/texture.js +10 -8
- package/dist/lib/textures/texture.js.map +2 -2
- package/dist/lib/transitions/capture.js +4 -1
- package/dist/lib/transitions/capture.js.map +2 -2
- package/dist/lib/transitions/embers-physics.js +17 -10
- package/dist/lib/transitions/embers-physics.js.map +2 -2
- package/dist/lib/types.d.ts +110 -1
- package/dist/sync.d.ts +16 -0
- package/dist/sync.js +13 -0
- package/dist/sync.js.map +7 -0
- package/dist/sync.mjs +1 -0
- package/package.json +26 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/features/viz/lib/bar-series.tsx"],
|
|
4
|
-
"sourcesContent": ["import {\n Group,\n isSignal,\n Rectangle,\n resolveSignalValue,\n useCanvasContext,\n} from \"@pibbl/core\";\nimport type {\n PibblEventHandlers,\n PibblEventParticipationOptions,\n PibblNode,\n FillStyle,\n SignalValue,\n StrokeStyle,\n} from \"@pibbl/core\";\nimport { withHooksForbidden } from \"@pibbl/core/internal\";\nimport { lookupScale } from \"./scale-context.js\";\nimport type { SignalStyle } from \"@pibbl/core/internal\";\nimport type { BandCategory, LineAccessor, ScaleId } from \"./types.js\";\nimport { useContinuousScale } from \"./use-continuous-scale.js\";\nimport { useBarScale } from \"./use-bar-scale.js\";\nimport { pointAccessor, pointData, finiteCoordinate } from \"./point-data.js\";\nimport { opacity, width } from \"./paint.js\";\n/**\n * A data property or callback that extracts a category, with nullish values treated as missing.\n *\n * @param datum - Datum whose category is being read.\n * @param index - Zero-based index in the source data.\n * @param data - Complete source data array.\n * @returns The category, or null/undefined to indicate a missing category. See\n * {@link BandCategory} .\n *\n * @see {@link BandCategory}\n * @see {@link BarSeriesProps}\n */\nexport type BarCategoryAccessor<D> =\n | {\n [K in keyof D]-?: D[K] extends BandCategory | null | undefined\n ? K\n : never;\n }[keyof D]\n | ((\n datum: D,\n index: number,\n data: readonly D[],\n ) => BandCategory | null | undefined);\nimport { barFill, type BarThresholdFill } from \"./bar-fill.js\";\nexport type { BarThresholdFill } from \"./bar-fill.js\";\n/**\n * Supported geometry and presentation properties for BarSeries.\n *\n * @see {@link FillStyle}\n * @see {@link BarThresholdFill}\n * @see {@link StrokeStyle}\n * @see {@link BarStyleResolver}\n */\nexport interface BarSeriesStyle {\n /** Width allocated to one categorical band. See {@link BarSeriesStyle}. */\n readonly bandwidth?: number | \"auto\";\n /** Paint used for the interior. See {@link FillStyle}, {@link BarThresholdFill}. */\n readonly fill?: FillStyle | BarThresholdFill;\n /** Paint used for the outline. See {@link StrokeStyle}. */\n readonly stroke?: StrokeStyle;\n /** Width of the painted outline. See {@link BarSeriesStyle}. */\n readonly strokeWidth?: number;\n /** Opacity of the painted result. See {@link BarSeriesStyle}. */\n readonly opacity?: number;\n /** Cursor shown while this target owns pointer presentation. See {@link BarSeriesStyle}. */\n readonly cursor?: string;\n}\n/**\n * Computes bar styling from the datum, index, and source data.\n *\n * @param datum - Datum being styled.\n * @param index - Zero-based index in the source data.\n * @param data - Complete source data array.\n * @returns Style for this datum's bar. See {@link BarSeriesStyle}.\n *\n * @see {@link BarSeriesStyle}\n */\nexport type BarStyleResolver<D> = (\n datum: D,\n index: number,\n data: readonly D[],\n) => BarSeriesStyle;\n/**\n * Shared data, category/value scales, orientation, filtering, and styling for bar variants.\n *\n * @see {@link BarCategoryAccessor}\n * @see {@link BarSeriesStyle}\n * @see {@link BarSeriesProps}\n */\ninterface BarSeriesBaseProps<D> extends PibblEventHandlers, PibblEventParticipationOptions {\n /**\n * Application data supplied to the component or reported by the event. See {@link SignalValue}.\n */\n readonly data: SignalValue<readonly D[]>;\n /** Selects `\"vertical\"`, `\"horizontal\"` for orientation. See {@link BarSeriesBaseProps}. */\n readonly orientation?: \"vertical\" | \"horizontal\";\n /** Property or callback extracting a bar's discrete category. See {@link BarCategoryAccessor}. */\n readonly category: BarCategoryAccessor<D>;\n /** Band scale used to place categories. See {@link ScaleId}. */\n readonly categoryScale: ScaleId;\n /** Numeric scale used to map bar values. See {@link ScaleId}. */\n readonly valueScale: ScaleId;\n /**\n * Selects the records that participate in the bar series. See {@link BarSeriesProps}.\n * @param datum - Record to test.\n * @param index - Zero-based index in the source array.\n * @param data - Complete source data array.\n * @returns Whether this record should contribute a bar.\n */\n readonly defined?: (datum: D, index: number, data: readonly D[]) => boolean;\n /**\n * Declared presentation and layout properties. See {@link SignalValue}, {@link SignalStyle},\n * {@link BarSeriesStyle}, {@link BarStyleResolver}.\n */\n readonly style?: SignalValue<SignalStyle<BarSeriesStyle> | BarStyleResolver<D>>;\n}\n/**\n * Authored inputs for BarSeries, including the declared data and presentation options.\n *\n * @see {@link LineAccessor}\n * @see {@link SignalValue}\n * @see {@link BarCategoryAccessor}\n * @see {@link ScaleId}\n * @see {@link BarSeries}\n */\nexport type BarSeriesProps<D> = BarSeriesBaseProps<D> &\n (\n | {\n /** Value associated with this sample, input, or result. See {@link LineAccessor}. */\n readonly value: LineAccessor<D>;\n /** Numeric value from which each ordinary bar starts. See {@link SignalValue}. */\n readonly baseline?: SignalValue<number>;\n /**\n * Not accepted in this variant; use the alternative fields instead. See\n * {@link BarSeriesProps}.\n */\n readonly valueStart?: never;\n /**\n * Not accepted in this variant; use the alternative fields instead. See\n * {@link BarSeriesProps}.\n */\n readonly valueEnd?: never;\n }\n | {\n /**\n * Not accepted in this variant; use the alternative fields instead. See\n * {@link BarSeriesProps}.\n */\n readonly value?: never;\n /**\n * Not accepted in this variant; use the alternative fields instead. See\n * {@link BarSeriesProps}.\n */\n readonly baseline?: never;\n /** Accessor for the beginning of a range bar. See {@link LineAccessor}. */\n readonly valueStart: LineAccessor<D>;\n /** Accessor for the end of a range bar. See {@link LineAccessor}. */\n readonly valueEnd: LineAccessor<D>;\n }\n ) &\n (\n | {\n /** Accessor identifying the subgroup of each bar. See {@link BarCategoryAccessor}. */\n readonly group: BarCategoryAccessor<D>;\n /** Band scale used to place subgroups within a category. See {@link ScaleId}. */\n readonly groupScale: ScaleId;\n }\n | {\n /** Accessor identifying the subgroup of each bar. See {@link BarSeriesProps}. */\n readonly group?: never;\n /**\n * Not accepted in this variant; use the alternative fields instead. See\n * {@link BarSeriesProps}.\n */\n readonly groupScale?: never;\n }\n );\n/**\n * Value bars in source order; rectangles supply ordinary paint and event geometry.\n *\n * @param props - Data, category and value accessors, scales, grouping, and styling. See\n * {@link BarSeriesProps} .\n * @returns Pibbl nodes drawing the bars.\n *\n * @see {@link BarSeriesProps}\n */\nexport function BarSeries<D>({\n data: input,\n orientation = \"vertical\",\n category: categoryInput,\n value: valueInput,\n valueStart,\n valueEnd,\n categoryScale,\n valueScale,\n baseline,\n group,\n groupScale,\n defined,\n style: styleInput,\n pointerEvents,\n ...events\n}: BarSeriesProps<D>) {\n const categories = useBarScale(categoryScale).get();\n const values = useContinuousScale(valueScale).get();\n const groups = lookupScale(groupScale, \"BarSeries groupScale\")?.get();\n if ((group === undefined) !== (groupScale === undefined))\n throw new TypeError(\"BarSeries requires group and groupScale together.\");\n if (groups && groups.type !== \"band\")\n throw new TypeError(\"BarSeries groupScale requires a band scale.\");\n const groupValue =\n typeof group === \"function\"\n ? group\n : (datum: D) =>\n group === undefined\n ? undefined\n : (datum[group] as BandCategory | null | undefined);\n const slotWidth =\n groups?.type === \"band\" ? groups.bandwidth : categories.bandwidth;\n if (orientation !== \"vertical\" && orientation !== \"horizontal\")\n throw new TypeError(\"BarSeries orientation must be vertical or horizontal.\");\n const data = pointData(resolveSignalValue(input), \"BarSeries\");\n const category =\n typeof categoryInput === \"function\"\n ? categoryInput\n : (datum: D) =>\n datum[categoryInput] as BandCategory | null | undefined;\n const ranged = valueStart !== undefined || valueEnd !== undefined;\n if (\n ranged\n ? valueInput !== undefined ||\n baseline !== undefined ||\n valueStart === undefined ||\n valueEnd === undefined\n : valueInput === undefined\n )\n throw new TypeError(\n \"BarSeries requires either value with optional baseline, or both valueStart and valueEnd without value or baseline.\",\n );\n const value = pointAccessor((ranged ? valueEnd : valueInput)!);\n const startValue = ranged ? pointAccessor(valueStart!) : undefined;\n const baselineValue = resolveSignalValue(baseline ?? 0);\n const sharedBase = ranged ? undefined : values.map(baselineValue);\n const specified = resolveSignalValue(styleInput);\n const ctx = useCanvasContext();\n function normalize(input: unknown, callback: boolean) {\n if (!input || typeof input !== \"object\" || Array.isArray(input))\n throw new TypeError(\"BarSeries style must be an object.\");\n if (\n callback &&\n Object.getPrototypeOf(input) !== Object.prototype &&\n Object.getPrototypeOf(input) !== null\n )\n throw new TypeError(\n \"BarSeries datum style must be a plain synchronous object.\",\n );\n const style: Record<string, unknown> = {};\n for (const key of Object.keys(input)) {\n if (\n ![\n \"bandwidth\",\n \"fill\",\n \"stroke\",\n \"strokeWidth\",\n \"opacity\",\n \"cursor\",\n ].includes(key)\n )\n throw new TypeError(`BarSeries: unsupported style field ${key}.`);\n const value = (input as Record<string, unknown>)[key];\n if (callback && isSignal(value))\n throw new TypeError(\n \"BarSeries datum styles require plain values; read signals explicitly.\",\n );\n style[key] = callback ? value : resolveSignalValue(value);\n }\n const resolved = style as BarSeriesStyle;\n if (resolved.cursor !== undefined && typeof resolved.cursor !== \"string\")\n throw new TypeError(\"BarSeries cursor must be a string.\");\n return {\n bandwidth:\n resolved.bandwidth === undefined || resolved.bandwidth === \"auto\"\n ? slotWidth\n : width(resolved.bandwidth, \"BarSeries bandwidth\"),\n fill: barFill(ctx, resolved.fill ?? \"#2563eb\", (value) =>\n values.map(value),\n orientation,\n ),\n stroke: resolved.stroke,\n strokeWidth: width(resolved.strokeWidth ?? 1, \"BarSeries strokeWidth\"),\n alpha: opacity(resolved.opacity ?? 1, \"BarSeries\"),\n cursor: resolved.cursor,\n };\n }\n const shared =\n typeof specified === \"function\"\n ? undefined\n : normalize(specified ?? {}, false);\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 c = category(datum, i, data),\n v = value(datum, i, data),\n from = startValue ? startValue(datum, i, data) : baselineValue;\n if (c == null || !finiteCoordinate(v) || !finiteCoordinate(from)) continue;\n const categoryStart = categories.map(c);\n const g = groups ? groupValue(datum, i, data) : undefined;\n const offset = groups ? (g == null ? undefined : groups.map(g)) : 0;\n if (categoryStart === undefined || offset === undefined || slotWidth === 0)\n continue;\n const start = categoryStart + offset;\n const { bandwidth, fill, stroke, strokeWidth, alpha, cursor } =\n shared ??\n normalize(\n withHooksForbidden(\"BarSeries style callback\", () =>\n (specified as BarStyleResolver<D>)(datum, i, data),\n ),\n true,\n );\n if (bandwidth === 0) continue;\n const base = sharedBase ?? values.map(from);\n const end = values.map(v);\n const extent = Math.abs(end - base);\n if (!Number.isFinite(extent))\n throw new RangeError(\"BarSeries value extent must be finite.\");\n if (extent === 0) continue;\n const vertical = orientation === \"vertical\";\n nodes.push(\n <Rectangle\n key={i}\n pointerEvents={pointerEvents}\n style={{\n left: vertical ? start + (slotWidth - bandwidth) / 2 : Math.min(base, end),\n top: vertical ? Math.min(base, end) : start + (slotWidth - bandwidth) / 2,\n width: vertical ? bandwidth : extent,\n height: vertical ? extent : bandwidth,\n fill: fill(from, v),\n stroke,\n strokeWidth,\n opacity: alpha,\n cursor,\n }}\n />,\n );\n }\n return <Group {...events}>{nodes}</Group>;\n}\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import {\n Group,\n isSignal,\n Rectangle,\n resolveSignalValue,\n useCanvasContext,\n} from \"@pibbl/core\";\nimport type {\n PibblEventHandlers,\n PibblEventParticipationOptions,\n PibblNode,\n FillStyle,\n SignalValue,\n StrokeStyle,\n} from \"@pibbl/core\";\nimport { withHooksForbidden } from \"@pibbl/core/internal\";\nimport { lookupScale } from \"./scale-context.js\";\nimport type { SignalStyle } from \"@pibbl/core/internal\";\nimport type { BandCategory, LineAccessor, ScaleId } from \"./types.js\";\nimport { useContinuousScale } from \"./use-continuous-scale.js\";\nimport { useBarScale } from \"./use-bar-scale.js\";\nimport { pointAccessor, pointData, finiteCoordinate } from \"./point-data.js\";\nimport { opacity, width } from \"./paint.js\";\n/**\n * A data property or callback that extracts a category, with nullish values treated as missing.\n *\n * @param datum - Datum whose category is being read.\n * @param index - Zero-based index in the source data.\n * @param data - Complete source data array.\n * @returns The category, or null/undefined to indicate a missing category. See\n * {@link BandCategory} .\n *\n * @see {@link BandCategory}\n * @see {@link BarSeriesProps}\n */\nexport type BarCategoryAccessor<D> =\n | {\n [K in keyof D]-?: D[K] extends BandCategory | null | undefined\n ? K\n : never;\n }[keyof D]\n | ((\n datum: D,\n index: number,\n data: readonly D[],\n ) => BandCategory | null | undefined);\nimport { barFill, type BarThresholdFill } from \"./bar-fill.js\";\nexport type { BarThresholdFill } from \"./bar-fill.js\";\n/**\n * Supported geometry and presentation properties for BarSeries.\n *\n * @see {@link FillStyle}\n * @see {@link BarThresholdFill}\n * @see {@link StrokeStyle}\n * @see {@link BarStyleResolver}\n */\nexport interface BarSeriesStyle {\n /** Width allocated to one categorical band. See {@link BarSeriesStyle}. */\n readonly bandwidth?: number | \"auto\";\n /** Paint used for the interior. See {@link FillStyle}, {@link BarThresholdFill}. */\n readonly fill?: FillStyle | BarThresholdFill;\n /** Paint used for the outline. See {@link StrokeStyle}. */\n readonly stroke?: StrokeStyle;\n /** Width of the painted outline. See {@link BarSeriesStyle}. */\n readonly strokeWidth?: number;\n /** Opacity of the painted result. See {@link BarSeriesStyle}. */\n readonly opacity?: number;\n /** Cursor shown while this target owns pointer presentation. See {@link BarSeriesStyle}. */\n readonly cursor?: string;\n}\n/**\n * Computes bar styling from the datum, index, and source data.\n *\n * @param datum - Datum being styled.\n * @param index - Zero-based index in the source data.\n * @param data - Complete source data array.\n * @returns Style for this datum's bar. See {@link BarSeriesStyle}.\n *\n * @see {@link BarSeriesStyle}\n */\nexport type BarStyleResolver<D> = (\n datum: D,\n index: number,\n data: readonly D[],\n) => BarSeriesStyle;\n/**\n * Shared data, category/value scales, orientation, filtering, and styling for bar variants.\n *\n * @see {@link BarCategoryAccessor}\n * @see {@link BarSeriesStyle}\n * @see {@link BarSeriesProps}\n */\ninterface BarSeriesBaseProps<D> extends PibblEventHandlers, PibblEventParticipationOptions {\n /**\n * Application data supplied to the component or reported by the event. See {@link SignalValue}.\n */\n readonly data: SignalValue<readonly D[]>;\n /** Optional committed bar capture; rendering alone performs no inspection searches. */\n readonly inspection?: import(\"../inspection/bar.js\").BarInspectionRef<D>;\n /** Selects `\"vertical\"`, `\"horizontal\"` for orientation. See {@link BarSeriesBaseProps}. */\n readonly orientation?: \"vertical\" | \"horizontal\";\n /** Property or callback extracting a bar's discrete category. See {@link BarCategoryAccessor}. */\n readonly category: BarCategoryAccessor<D>;\n /** Band scale used to place categories. See {@link ScaleId}. */\n readonly categoryScale: ScaleId;\n /** Numeric scale used to map bar values. See {@link ScaleId}. */\n readonly valueScale: ScaleId;\n /**\n * Selects the records that participate in the bar series. See {@link BarSeriesProps}.\n * @param datum - Record to test.\n * @param index - Zero-based index in the source array.\n * @param data - Complete source data array.\n * @returns Whether this record should contribute a bar.\n */\n readonly defined?: (datum: D, index: number, data: readonly D[]) => boolean;\n /**\n * Declared presentation and layout properties. See {@link SignalValue}, {@link SignalStyle},\n * {@link BarSeriesStyle}, {@link BarStyleResolver}.\n */\n readonly style?: SignalValue<SignalStyle<BarSeriesStyle> | BarStyleResolver<D>>;\n}\n/**\n * Authored inputs for BarSeries, including the declared data and presentation options.\n *\n * @see {@link LineAccessor}\n * @see {@link SignalValue}\n * @see {@link BarCategoryAccessor}\n * @see {@link ScaleId}\n * @see {@link BarSeries}\n */\nexport type BarSeriesProps<D> = BarSeriesBaseProps<D> &\n (\n | {\n /** Value associated with this sample, input, or result. See {@link LineAccessor}. */\n readonly value: LineAccessor<D>;\n /** Numeric value from which each ordinary bar starts. See {@link SignalValue}. */\n readonly baseline?: SignalValue<number>;\n /**\n * Not accepted in this variant; use the alternative fields instead. See\n * {@link BarSeriesProps}.\n */\n readonly valueStart?: never;\n /**\n * Not accepted in this variant; use the alternative fields instead. See\n * {@link BarSeriesProps}.\n */\n readonly valueEnd?: never;\n }\n | {\n /**\n * Not accepted in this variant; use the alternative fields instead. See\n * {@link BarSeriesProps}.\n */\n readonly value?: never;\n /**\n * Not accepted in this variant; use the alternative fields instead. See\n * {@link BarSeriesProps}.\n */\n readonly baseline?: never;\n /** Accessor for the beginning of a range bar. See {@link LineAccessor}. */\n readonly valueStart: LineAccessor<D>;\n /** Accessor for the end of a range bar. See {@link LineAccessor}. */\n readonly valueEnd: LineAccessor<D>;\n }\n ) &\n (\n | {\n /** Accessor identifying the subgroup of each bar. See {@link BarCategoryAccessor}. */\n readonly group: BarCategoryAccessor<D>;\n /** Band scale used to place subgroups within a category. See {@link ScaleId}. */\n readonly groupScale: ScaleId;\n }\n | {\n /** Accessor identifying the subgroup of each bar. See {@link BarSeriesProps}. */\n readonly group?: never;\n /**\n * Not accepted in this variant; use the alternative fields instead. See\n * {@link BarSeriesProps}.\n */\n readonly groupScale?: never;\n }\n );\n/**\n * Value bars in source order; rectangles supply ordinary paint and event geometry.\n *\n * @param props - Data, category and value accessors, scales, grouping, and styling. See\n * {@link BarSeriesProps} .\n * @returns Pibbl nodes drawing the bars.\n *\n * @see {@link BarSeriesProps}\n */\nexport function BarSeries<D>({\n data: input,\n orientation = \"vertical\",\n category: categoryInput,\n value: valueInput,\n valueStart,\n valueEnd,\n categoryScale,\n valueScale,\n baseline,\n group,\n groupScale,\n defined,\n style: styleInput,\n pointerEvents,\n inspection,\n ...events\n}: BarSeriesProps<D>) {\n const categories = useBarScale(categoryScale).get();\n const values = useContinuousScale(valueScale).get();\n const groups = lookupScale(groupScale, \"BarSeries groupScale\")?.get();\n if ((group === undefined) !== (groupScale === undefined))\n throw new TypeError(\"BarSeries requires group and groupScale together.\");\n if (groups && groups.type !== \"band\")\n throw new TypeError(\"BarSeries groupScale requires a band scale.\");\n const groupValue =\n typeof group === \"function\"\n ? group\n : (datum: D) =>\n group === undefined\n ? undefined\n : (datum[group] as BandCategory | null | undefined);\n const slotWidth =\n groups?.type === \"band\" ? groups.bandwidth : categories.bandwidth;\n if (orientation !== \"vertical\" && orientation !== \"horizontal\")\n throw new TypeError(\"BarSeries orientation must be vertical or horizontal.\");\n const data = pointData(resolveSignalValue(input), \"BarSeries\");\n const category =\n typeof categoryInput === \"function\"\n ? categoryInput\n : (datum: D) =>\n datum[categoryInput] as BandCategory | null | undefined;\n const ranged = valueStart !== undefined || valueEnd !== undefined;\n if (\n ranged\n ? valueInput !== undefined ||\n baseline !== undefined ||\n valueStart === undefined ||\n valueEnd === undefined\n : valueInput === undefined\n )\n throw new TypeError(\n \"BarSeries requires either value with optional baseline, or both valueStart and valueEnd without value or baseline.\",\n );\n const value = pointAccessor((ranged ? valueEnd : valueInput)!);\n const startValue = ranged ? pointAccessor(valueStart!) : undefined;\n const baselineValue = resolveSignalValue(baseline ?? 0);\n const sharedBase = ranged ? undefined : values.map(baselineValue);\n const specified = resolveSignalValue(styleInput);\n const ctx = useCanvasContext();\n function normalize(input: unknown, callback: boolean) {\n if (!input || typeof input !== \"object\" || Array.isArray(input))\n throw new TypeError(\"BarSeries style must be an object.\");\n if (\n callback &&\n Object.getPrototypeOf(input) !== Object.prototype &&\n Object.getPrototypeOf(input) !== null\n )\n throw new TypeError(\n \"BarSeries datum style must be a plain synchronous object.\",\n );\n const style: Record<string, unknown> = {};\n for (const key of Object.keys(input)) {\n if (\n ![\n \"bandwidth\",\n \"fill\",\n \"stroke\",\n \"strokeWidth\",\n \"opacity\",\n \"cursor\",\n ].includes(key)\n )\n throw new TypeError(`BarSeries: unsupported style field ${key}.`);\n const value = (input as Record<string, unknown>)[key];\n if (callback && isSignal(value))\n throw new TypeError(\n \"BarSeries datum styles require plain values; read signals explicitly.\",\n );\n style[key] = callback ? value : resolveSignalValue(value);\n }\n const resolved = style as BarSeriesStyle;\n if (resolved.cursor !== undefined && typeof resolved.cursor !== \"string\")\n throw new TypeError(\"BarSeries cursor must be a string.\");\n return {\n bandwidth:\n resolved.bandwidth === undefined || resolved.bandwidth === \"auto\"\n ? slotWidth\n : width(resolved.bandwidth, \"BarSeries bandwidth\"),\n fill: barFill(ctx, resolved.fill ?? \"#2563eb\", (value) =>\n values.map(value),\n orientation,\n ),\n stroke: resolved.stroke,\n strokeWidth: width(resolved.strokeWidth ?? 1, \"BarSeries strokeWidth\"),\n alpha: opacity(resolved.opacity ?? 1, \"BarSeries\"),\n cursor: resolved.cursor,\n };\n }\n const shared =\n typeof specified === \"function\"\n ? undefined\n : normalize(specified ?? {}, false);\n const nodes: PibblNode[] = [];\n const captured: import(\"../inspection/bar.js\").CapturedBarMark<D>[] | undefined = inspection ? [] : undefined;\n for (let i = 0; i < data.length; i++) {\n const datum = data[i];\n if (defined && !defined(datum, i, data)) continue;\n const c = category(datum, i, data),\n v = value(datum, i, data),\n from = startValue ? startValue(datum, i, data) : baselineValue;\n if (c == null || !finiteCoordinate(v) || !finiteCoordinate(from)) continue;\n const categoryStart = categories.map(c);\n const g = groups ? groupValue(datum, i, data) : undefined;\n const offset = groups ? (g == null ? undefined : groups.map(g)) : 0;\n if (categoryStart === undefined || offset === undefined || slotWidth === 0)\n continue;\n const start = categoryStart + offset;\n const { bandwidth, fill, stroke, strokeWidth, alpha, cursor } =\n shared ??\n normalize(\n withHooksForbidden(\"BarSeries style callback\", () =>\n (specified as BarStyleResolver<D>)(datum, i, data),\n ),\n true,\n );\n if (bandwidth === 0) continue;\n const base = sharedBase ?? values.map(from);\n const end = values.map(v);\n const extent = Math.abs(end - base);\n if (!Number.isFinite(extent))\n throw new RangeError(\"BarSeries value extent must be finite.\");\n if (extent === 0) continue;\n const vertical = orientation === \"vertical\";\n const markFill = fill(from,v);\n captured?.push(Object.freeze({datum,sourceIndex:i,category:c,group:g ?? undefined,valueStart:from,valueEnd:v,\n boundsLocal:Object.freeze({x:vertical?start+(slotWidth-bandwidth)/2:Math.min(base,end),y:vertical?Math.min(base,end):start+(slotWidth-bandwidth)/2,width:vertical?bandwidth:extent,height:vertical?extent:bandwidth}),\n fill:!!markFill,strokeWidthLocal:stroke?strokeWidth:0}));\n nodes.push(\n <Rectangle\n key={i}\n pointerEvents={pointerEvents}\n style={{\n left: vertical ? start + (slotWidth - bandwidth) / 2 : Math.min(base, end),\n top: vertical ? Math.min(base, end) : start + (slotWidth - bandwidth) / 2,\n width: vertical ? bandwidth : extent,\n height: vertical ? extent : bandwidth,\n fill: markFill,\n stroke,\n strokeWidth,\n opacity: alpha,\n cursor,\n }}\n />,\n );\n }\n if (inspection) inspection.capture(captured!);\n return <Group {...events}>{nodes}</Group>;\n}\n"],
|
|
5
|
+
"mappings": "AAoVM;AApVN;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AASP,SAAS,0BAA0B;AACnC,SAAS,mBAAmB;AAG5B,SAAS,0BAA0B;AACnC,SAAS,mBAAmB;AAC5B,SAAS,eAAe,WAAW,wBAAwB;AAC3D,SAAS,SAAS,aAAa;AAwB/B,SAAS,eAAsC;AAiJxC,SAAS,UAAa;AAAA,EAC3B,MAAM;AAAA,EACN,cAAc;AAAA,EACd,UAAU;AAAA,EACV,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAsB;AACpB,QAAM,aAAa,YAAY,aAAa,EAA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AC;AACzD,UAAM;AAAA,MACJ;AAAA,QAAC;AAAA;AAAA,UAEC;AAAA,UACA,OAAO;AAAA,YACL,MAAM,WAAW,SAAS,YAAY,aAAa,IAAI,KAAK,IAAI,MAAM,GAAG;AAAA,YACzE,KAAK,WAAW,KAAK,IAAI,MAAM,GAAG,IAAI,SAAS,YAAY,aAAa;AAAA,YACxE,OAAO,WAAW,YAAY;AAAA,YAC9B,QAAQ,WAAW,SAAS;AAAA,YAC5B,MAAM;AAAA,YACN;AAAA,YACA;AAAA,YACA,SAAS;AAAA,YACT;AAAA,UACF;AAAA;AAAA,QAZK;AAAA,MAaP;AAAA,IACF;AAAA,EACF;AACA,MAAI,WAAY,YAAW,QAAQ,QAAS;AAC5C,SAAO,oBAAC,SAAO,GAAG,QAAS,iBAAM;AACnC;",
|
|
6
6
|
"names": ["input", "value"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { FillStyle, PibblEventHandlers, PibblEventParticipationOptions, SignalValue, StrokeStyle } from "@pibbl/core";
|
|
2
|
+
import type { SignalStyle } from "@pibbl/core/internal";
|
|
3
|
+
import type { LineAccessor, LineSeriesProps, ScaleId } from "./types.js";
|
|
4
|
+
/** Shared paint for one side of a baseline. See {@link BaselineSeries}. */
|
|
5
|
+
export interface BaselineSideStyle {
|
|
6
|
+
/** Area fill for this side of the baseline. */
|
|
7
|
+
readonly fill?: FillStyle;
|
|
8
|
+
/** Line stroke for this side of the baseline. */
|
|
9
|
+
readonly stroke?: StrokeStyle;
|
|
10
|
+
}
|
|
11
|
+
/** Shared presentation for a linear baseline series. See {@link BaselineSeries}. */
|
|
12
|
+
export interface BaselineSeriesStyle {
|
|
13
|
+
/** Paint for y values greater than or equal to baseline. */
|
|
14
|
+
readonly above?: BaselineSideStyle;
|
|
15
|
+
/** Paint for y values less than baseline. */
|
|
16
|
+
readonly below?: BaselineSideStyle;
|
|
17
|
+
/** Opacity for both area fills; defaults to 0.2. */
|
|
18
|
+
readonly fillOpacity?: number;
|
|
19
|
+
/** Width for both line strokes; defaults to 2. */
|
|
20
|
+
readonly strokeWidth?: number;
|
|
21
|
+
/** Cursor while a painted series path owns targeting. */
|
|
22
|
+
readonly cursor?: string;
|
|
23
|
+
}
|
|
24
|
+
/** A linear connected series split into independently painted regions at baseline crossings. See
|
|
25
|
+
* {@link BaselineSeries}.
|
|
26
|
+
*/
|
|
27
|
+
export interface BaselineSeriesProps<D> extends PibblEventHandlers, PibblEventParticipationOptions {
|
|
28
|
+
/** Application records or a signal of records; source order is retained. */
|
|
29
|
+
readonly data: SignalValue<readonly D[]>;
|
|
30
|
+
/** Property key or callback extracting horizontal coordinates. */
|
|
31
|
+
readonly x: LineAccessor<D>;
|
|
32
|
+
/** Property key or callback extracting vertical coordinates. */
|
|
33
|
+
readonly y: LineAccessor<D>;
|
|
34
|
+
/** Numeric or trading-time horizontal scale identity. */
|
|
35
|
+
readonly xScale: ScaleId;
|
|
36
|
+
/** Linear vertical scale identity. */
|
|
37
|
+
readonly yScale: ScaleId;
|
|
38
|
+
/** Finite data-space division between the above and below presentations. */
|
|
39
|
+
readonly baseline: SignalValue<number>;
|
|
40
|
+
/** Excludes a record before its accessors run. */
|
|
41
|
+
readonly defined?: LineSeriesProps<D>["defined"];
|
|
42
|
+
/** Optional committed original-record capture on the standard numeric inspection foundation. */
|
|
43
|
+
readonly inspection?: import("../inspection/capture-types.js").NumericInspectionRef<D>;
|
|
44
|
+
/** Shared above/below paint and interaction presentation. */
|
|
45
|
+
readonly style?: SignalValue<SignalStyle<BaselineSeriesStyle>>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Draws a linear connected series with independently painted regions above and below a baseline.
|
|
49
|
+
* Equal values belong to the above stroke; zero-area spans never receive a fill. Gaps split runs,
|
|
50
|
+
* and optional inspection captures only original records.
|
|
51
|
+
* @param props - Records, a numeric or trading-time x scale, linear price y scale, baseline, event props, and shared side paint.
|
|
52
|
+
* @returns Filled and stroked Pibbl paths in source paint order.
|
|
53
|
+
* @see {@link LineSeriesProps}
|
|
54
|
+
*/
|
|
55
|
+
export declare function BaselineSeries<D>({ data: dataInput, x: xInput, y: yInput, xScale: xId, yScale: yId, baseline: baselineInput, defined, inspection, style: styleInput, ...eventProps }: BaselineSeriesProps<D>): import("../../../jsx-runtime.js").JSX.Element;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { Fragment, jsx } from "@pibbl/core/jsx-runtime";
|
|
2
|
+
import { Path, resolveSignalValue } from "@pibbl/core";
|
|
3
|
+
import { useInternalValueMemoSlot, validateTexturePaint } from "@pibbl/core/internal";
|
|
4
|
+
import { useNumericPosition } from "./series-position.js";
|
|
5
|
+
import { opacity, width } from "./paint.js";
|
|
6
|
+
import { finiteCoordinate, pointAccessor, pointData } from "./point-data.js";
|
|
7
|
+
function fill(value, receiver) {
|
|
8
|
+
if (typeof value === "string" || value instanceof CanvasGradient || value instanceof CanvasPattern)
|
|
9
|
+
return value;
|
|
10
|
+
try {
|
|
11
|
+
validateTexturePaint(value);
|
|
12
|
+
return value;
|
|
13
|
+
} catch {
|
|
14
|
+
throw new TypeError(`${receiver}: invalid fill.`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function side(value, baseline) {
|
|
18
|
+
return value >= baseline ? "above" : "below";
|
|
19
|
+
}
|
|
20
|
+
function BaselineSeries({
|
|
21
|
+
data: dataInput,
|
|
22
|
+
x: xInput,
|
|
23
|
+
y: yInput,
|
|
24
|
+
xScale: xId,
|
|
25
|
+
yScale: yId,
|
|
26
|
+
baseline: baselineInput,
|
|
27
|
+
defined,
|
|
28
|
+
inspection,
|
|
29
|
+
style: styleInput,
|
|
30
|
+
...eventProps
|
|
31
|
+
}) {
|
|
32
|
+
const xScale = useNumericPosition(xId), yScale = useNumericPosition(yId);
|
|
33
|
+
if (yScale.type !== "linear")
|
|
34
|
+
throw new TypeError("BaselineSeries requires LinearScale for yScale.");
|
|
35
|
+
const x = useInternalValueMemoSlot("vizBaselineXAccessor", () => pointAccessor(xInput), [xInput]);
|
|
36
|
+
const y = useInternalValueMemoSlot("vizBaselineYAccessor", () => pointAccessor(yInput), [yInput]);
|
|
37
|
+
const data = pointData(resolveSignalValue(dataInput), "BaselineSeries");
|
|
38
|
+
const baseline = resolveSignalValue(baselineInput);
|
|
39
|
+
if (typeof baseline !== "number" || !Number.isFinite(baseline))
|
|
40
|
+
throw new RangeError("BaselineSeries baseline must be finite.");
|
|
41
|
+
const baselineY = yScale.map(baseline);
|
|
42
|
+
if (!Number.isFinite(baselineY)) throw new RangeError("BaselineSeries baseline must map to a finite coordinate.");
|
|
43
|
+
const style = resolveSignalValue(styleInput) ?? {};
|
|
44
|
+
if (style === null || typeof style !== "object" || Array.isArray(style))
|
|
45
|
+
throw new TypeError("BaselineSeries style must be an object.");
|
|
46
|
+
const above = resolveSignalValue(style.above) ?? {}, below = resolveSignalValue(style.below) ?? {};
|
|
47
|
+
const aboveFill = fill(resolveSignalValue(above.fill) ?? "#087f8c", "BaselineSeries above");
|
|
48
|
+
const belowFill = fill(resolveSignalValue(below.fill) ?? "#d9674c", "BaselineSeries below");
|
|
49
|
+
const aboveStroke = resolveSignalValue(above.stroke) ?? "#087f8c";
|
|
50
|
+
const belowStroke = resolveSignalValue(below.stroke) ?? "#d9674c";
|
|
51
|
+
const fillOpacity = opacity(resolveSignalValue(style.fillOpacity) ?? 0.2, "BaselineSeries fill");
|
|
52
|
+
const strokeWidth = width(resolveSignalValue(style.strokeWidth) ?? 2, "BaselineSeries stroke");
|
|
53
|
+
const cursor = resolveSignalValue(style.cursor);
|
|
54
|
+
if (cursor !== void 0 && typeof cursor !== "string") throw new TypeError("BaselineSeries cursor must be a string.");
|
|
55
|
+
const pieces = [];
|
|
56
|
+
const captured = inspection ? [] : void 0;
|
|
57
|
+
let previous;
|
|
58
|
+
let run = 0;
|
|
59
|
+
const breakRun = () => {
|
|
60
|
+
previous = void 0;
|
|
61
|
+
run++;
|
|
62
|
+
};
|
|
63
|
+
const segment = (first, second) => {
|
|
64
|
+
const firstSide = side(first.domainY, baseline), secondSide = side(second.domainY, baseline);
|
|
65
|
+
const points = [
|
|
66
|
+
{ point: first, side: firstSide }
|
|
67
|
+
];
|
|
68
|
+
if (firstSide !== secondSide) {
|
|
69
|
+
const firstDistance = Math.abs(first.domainY - baseline);
|
|
70
|
+
const secondDistance = Math.abs(second.domainY - baseline);
|
|
71
|
+
const amount = firstDistance > secondDistance ? 1 / (1 + secondDistance / firstDistance) : firstDistance / secondDistance / (1 + firstDistance / secondDistance);
|
|
72
|
+
points.push({
|
|
73
|
+
point: { x: first.x + (second.x - first.x) * amount, y: baselineY, domainY: baseline },
|
|
74
|
+
side: firstSide
|
|
75
|
+
});
|
|
76
|
+
points.push({
|
|
77
|
+
point: { x: first.x + (second.x - first.x) * amount, y: baselineY, domainY: baseline },
|
|
78
|
+
side: secondSide
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
points.push({ point: second, side: secondSide });
|
|
82
|
+
for (let index = 1; index < points.length; index++) {
|
|
83
|
+
const start = points[index - 1], end = points[index];
|
|
84
|
+
const kind = start.side;
|
|
85
|
+
const a = start.point, b = end.point;
|
|
86
|
+
const stroke = new Path2D();
|
|
87
|
+
stroke.moveTo(a.x, a.y);
|
|
88
|
+
stroke.lineTo(b.x, b.y);
|
|
89
|
+
if (a.y === baselineY && b.y === baselineY) {
|
|
90
|
+
pieces.push({ side: kind, fill: void 0, stroke });
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
const fill2 = new Path2D();
|
|
94
|
+
fill2.moveTo(a.x, baselineY);
|
|
95
|
+
fill2.lineTo(a.x, a.y);
|
|
96
|
+
fill2.lineTo(b.x, b.y);
|
|
97
|
+
fill2.lineTo(b.x, baselineY);
|
|
98
|
+
fill2.closePath();
|
|
99
|
+
pieces.push({ side: kind, fill: fill2, stroke });
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
for (let index = 0; index < data.length; index++) {
|
|
103
|
+
const datum = data[index];
|
|
104
|
+
if (defined && !defined(datum, index, data)) {
|
|
105
|
+
breakRun();
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const domainX = x(datum, index, data), domainY = y(datum, index, data);
|
|
109
|
+
if (!finiteCoordinate(domainX) || !finiteCoordinate(domainY)) {
|
|
110
|
+
breakRun();
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
const mappedX = xScale.map(domainX), mappedY = yScale.map(domainY);
|
|
114
|
+
if (!Number.isFinite(mappedX) || !Number.isFinite(mappedY)) {
|
|
115
|
+
breakRun();
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
const point = { datum, domainX, domainY, x: mappedX, y: mappedY };
|
|
119
|
+
captured?.push(Object.freeze({ datum, sourceIndex: index, domainX: point.domainX, domainY: point.domainY, anchorLocal: Object.freeze({ x: point.x, y: point.y }), run }));
|
|
120
|
+
if (previous) segment(previous, point);
|
|
121
|
+
previous = point;
|
|
122
|
+
}
|
|
123
|
+
if (inspection) inspection.capture({ observations: captured, xScale, yScale });
|
|
124
|
+
return /* @__PURE__ */ jsx(Fragment, { children: pieces.flatMap((piece, index) => {
|
|
125
|
+
const fill2 = piece.side === "above" ? aboveFill : belowFill;
|
|
126
|
+
const stroke = piece.side === "above" ? aboveStroke : belowStroke;
|
|
127
|
+
return [
|
|
128
|
+
...piece.fill ? [/* @__PURE__ */ jsx(Path, { ...eventProps, style: { d: piece.fill, fill: fill2, opacity: fillOpacity, cursor } }, `${index}:fill`)] : [],
|
|
129
|
+
/* @__PURE__ */ jsx(Path, { ...eventProps, style: { d: piece.stroke, stroke, strokeWidth, cursor } }, `${index}:stroke`)
|
|
130
|
+
];
|
|
131
|
+
}) });
|
|
132
|
+
}
|
|
133
|
+
export {
|
|
134
|
+
BaselineSeries
|
|
135
|
+
};
|
|
136
|
+
//# sourceMappingURL=baseline-series.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/features/viz/lib/baseline-series.tsx"],
|
|
4
|
+
"sourcesContent": ["import { Path, resolveSignalValue } from \"@pibbl/core\";\nimport type {\n FillStyle,\n PibblEventHandlers,\n PibblEventParticipationOptions,\n SignalValue,\n StrokeStyle,\n} from \"@pibbl/core\";\nimport { useInternalValueMemoSlot, validateTexturePaint } from \"@pibbl/core/internal\";\nimport type { SignalStyle } from \"@pibbl/core/internal\";\nimport type { LineAccessor, LineSeriesProps, ScaleId } from \"./types.js\";\nimport { useNumericPosition } from \"./series-position.js\";\nimport { opacity, width } from \"./paint.js\";\nimport { finiteCoordinate, pointAccessor, pointData } from \"./point-data.js\";\n\n/** Shared paint for one side of a baseline. See {@link BaselineSeries}. */\nexport interface BaselineSideStyle {\n /** Area fill for this side of the baseline. */\n readonly fill?: FillStyle;\n /** Line stroke for this side of the baseline. */\n readonly stroke?: StrokeStyle;\n}\n\n/** Shared presentation for a linear baseline series. See {@link BaselineSeries}. */\nexport interface BaselineSeriesStyle {\n /** Paint for y values greater than or equal to baseline. */\n readonly above?: BaselineSideStyle;\n /** Paint for y values less than baseline. */\n readonly below?: BaselineSideStyle;\n /** Opacity for both area fills; defaults to 0.2. */\n readonly fillOpacity?: number;\n /** Width for both line strokes; defaults to 2. */\n readonly strokeWidth?: number;\n /** Cursor while a painted series path owns targeting. */\n readonly cursor?: string;\n}\n\n/** A linear connected series split into independently painted regions at baseline crossings. See\n * {@link BaselineSeries}.\n */\nexport interface BaselineSeriesProps<D>\n extends PibblEventHandlers, PibblEventParticipationOptions {\n /** Application records or a signal of records; source order is retained. */\n readonly data: SignalValue<readonly D[]>;\n /** Property key or callback extracting horizontal coordinates. */\n readonly x: LineAccessor<D>;\n /** Property key or callback extracting vertical coordinates. */\n readonly y: LineAccessor<D>;\n /** Numeric or trading-time horizontal scale identity. */\n readonly xScale: ScaleId;\n /** Linear vertical scale identity. */\n readonly yScale: ScaleId;\n /** Finite data-space division between the above and below presentations. */\n readonly baseline: SignalValue<number>;\n /** Excludes a record before its accessors run. */\n readonly defined?: LineSeriesProps<D>[\"defined\"];\n /** Optional committed original-record capture on the standard numeric inspection foundation. */\n readonly inspection?: import(\"../inspection/capture-types.js\").NumericInspectionRef<D>;\n /** Shared above/below paint and interaction presentation. */\n readonly style?: SignalValue<SignalStyle<BaselineSeriesStyle>>;\n}\n\ninterface Point<D> {\n readonly datum: D;\n readonly domainX: number;\n readonly domainY: number;\n readonly x: number;\n readonly y: number;\n}\n\ninterface Piece {\n readonly side: \"above\" | \"below\";\n readonly fill: Path2D | undefined;\n readonly stroke: Path2D;\n}\n\nfunction fill(value: unknown, receiver: string): FillStyle {\n if (typeof value === \"string\" || value instanceof CanvasGradient || value instanceof CanvasPattern)\n return value;\n try {\n validateTexturePaint(value as never);\n return value as FillStyle;\n } catch {\n throw new TypeError(`${receiver}: invalid fill.`);\n }\n}\n\nfunction side(value: number, baseline: number): \"above\" | \"below\" {\n return value >= baseline ? \"above\" : \"below\";\n}\n\n/**\n * Draws a linear connected series with independently painted regions above and below a baseline.\n * Equal values belong to the above stroke; zero-area spans never receive a fill. Gaps split runs,\n * and optional inspection captures only original records.\n * @param props - Records, a numeric or trading-time x scale, linear price y scale, baseline, event props, and shared side paint.\n * @returns Filled and stroked Pibbl paths in source paint order.\n * @see {@link LineSeriesProps}\n */\nexport function BaselineSeries<D>({\n data: dataInput,\n x: xInput,\n y: yInput,\n xScale: xId,\n yScale: yId,\n baseline: baselineInput,\n defined,\n inspection,\n style: styleInput,\n ...eventProps\n}: BaselineSeriesProps<D>) {\n const xScale = useNumericPosition(xId), yScale = useNumericPosition(yId);\n if (yScale.type !== \"linear\")\n throw new TypeError(\"BaselineSeries requires LinearScale for yScale.\");\n const x = useInternalValueMemoSlot(\"vizBaselineXAccessor\", () => pointAccessor(xInput), [xInput]);\n const y = useInternalValueMemoSlot(\"vizBaselineYAccessor\", () => pointAccessor(yInput), [yInput]);\n const data = pointData(resolveSignalValue(dataInput), \"BaselineSeries\");\n const baseline = resolveSignalValue(baselineInput);\n if (typeof baseline !== \"number\" || !Number.isFinite(baseline))\n throw new RangeError(\"BaselineSeries baseline must be finite.\");\n const baselineY = yScale.map(baseline);\n if (!Number.isFinite(baselineY)) throw new RangeError(\"BaselineSeries baseline must map to a finite coordinate.\");\n const style = resolveSignalValue(styleInput) ?? {};\n if (style === null || typeof style !== \"object\" || Array.isArray(style))\n throw new TypeError(\"BaselineSeries style must be an object.\");\n const above = resolveSignalValue(style.above) ?? {}, below = resolveSignalValue(style.below) ?? {};\n const aboveFill = fill(resolveSignalValue(above.fill) ?? \"#087f8c\", \"BaselineSeries above\");\n const belowFill = fill(resolveSignalValue(below.fill) ?? \"#d9674c\", \"BaselineSeries below\");\n const aboveStroke = resolveSignalValue(above.stroke) ?? \"#087f8c\";\n const belowStroke = resolveSignalValue(below.stroke) ?? \"#d9674c\";\n const fillOpacity = opacity(resolveSignalValue(style.fillOpacity) ?? 0.2, \"BaselineSeries fill\");\n const strokeWidth = width(resolveSignalValue(style.strokeWidth) ?? 2, \"BaselineSeries stroke\");\n const cursor = resolveSignalValue(style.cursor);\n if (cursor !== undefined && typeof cursor !== \"string\") throw new TypeError(\"BaselineSeries cursor must be a string.\");\n\n const pieces: Piece[] = [];\n const captured: import(\"../inspection/capture-types.js\").CapturedNumericObservation<D>[] | undefined = inspection ? [] : undefined;\n let previous: Point<D> | undefined;\n let run = 0;\n const breakRun = () => { previous = undefined; run++; };\n const segment = (first: Point<D>, second: Point<D>) => {\n const firstSide = side(first.domainY, baseline), secondSide = side(second.domainY, baseline);\n const points: { point: Point<D> | { x: number; y: number; domainY: number }; side: \"above\" | \"below\" }[] = [\n { point: first, side: firstSide },\n ];\n if (firstSide !== secondSide) {\n const firstDistance = Math.abs(first.domainY - baseline);\n const secondDistance = Math.abs(second.domainY - baseline);\n const amount = firstDistance > secondDistance\n ? 1 / (1 + secondDistance / firstDistance)\n : (firstDistance / secondDistance) / (1 + firstDistance / secondDistance);\n points.push({\n point: { x: first.x + (second.x - first.x) * amount, y: baselineY, domainY: baseline },\n side: firstSide,\n });\n points.push({\n point: { x: first.x + (second.x - first.x) * amount, y: baselineY, domainY: baseline },\n side: secondSide,\n });\n }\n points.push({ point: second, side: secondSide });\n for (let index = 1; index < points.length; index++) {\n const start = points[index - 1]!, end = points[index]!;\n const kind = start.side;\n const a = start.point, b = end.point;\n const stroke = new Path2D();\n stroke.moveTo(a.x, a.y);\n stroke.lineTo(b.x, b.y);\n if (a.y === baselineY && b.y === baselineY) {\n pieces.push({ side: kind, fill: undefined, stroke });\n continue;\n }\n const fill = new Path2D();\n fill.moveTo(a.x, baselineY);\n fill.lineTo(a.x, a.y);\n fill.lineTo(b.x, b.y);\n fill.lineTo(b.x, baselineY);\n fill.closePath();\n pieces.push({ side: kind, fill, stroke });\n }\n };\n for (let index = 0; index < data.length; index++) {\n const datum = data[index]!;\n if (defined && !defined(datum, index, data)) { breakRun(); continue; }\n const domainX = x(datum, index, data), domainY = y(datum, index, data);\n if (!finiteCoordinate(domainX) || !finiteCoordinate(domainY)) { breakRun(); continue; }\n const mappedX = xScale.map(domainX), mappedY = yScale.map(domainY);\n if (!Number.isFinite(mappedX) || !Number.isFinite(mappedY)) { breakRun(); continue; }\n const point: Point<D> = { datum, domainX, domainY, x: mappedX, y: mappedY };\n captured?.push(Object.freeze({ datum, sourceIndex: index, domainX: point.domainX, domainY: point.domainY, anchorLocal: Object.freeze({ x: point.x, y: point.y }), run }));\n if (previous) segment(previous, point);\n previous = point;\n }\n if (inspection) inspection.capture({ observations: captured!, xScale, yScale });\n return (\n <>\n {pieces.flatMap((piece, index) => {\n const fill = piece.side === \"above\" ? aboveFill : belowFill;\n const stroke = piece.side === \"above\" ? aboveStroke : belowStroke;\n return [\n ...(piece.fill ? [<Path key={`${index}:fill`} {...eventProps} style={{ d: piece.fill, fill, opacity: fillOpacity, cursor }} />] : []),\n <Path key={`${index}:stroke`} {...eventProps} style={{ d: piece.stroke, stroke, strokeWidth, cursor }} />,\n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SAAoF;AAAA,IACzG;AAAA,EACF,CAAC,GACH;AAEJ;",
|
|
6
|
+
"names": ["fill"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type FillStyle, type StrokeStyle, type SignalValue, type PibblEventHandlers, type PibblEventParticipationOptions, type PibblNode } from "@pibbl/core";
|
|
2
|
+
import type { LineAccessor, ScaleId } from "./types.js";
|
|
3
|
+
import type { CandleInspectionRef } from "../inspection/candle.js";
|
|
4
|
+
/** Open/close body paint, independent from wick paint.
|
|
5
|
+
* @see {@link CandlestickSeries}
|
|
6
|
+
*/
|
|
7
|
+
export interface CandleBodyStyle {
|
|
8
|
+
/** Interior; default teal for close >= open, coral otherwise. Empty string disables fill. */ readonly fill?: FillStyle;
|
|
9
|
+
/** Optional body outline. */ readonly stroke?: StrokeStyle;
|
|
10
|
+
/** Nonnegative local outline width; default 1. */ readonly strokeWidth?: number;
|
|
11
|
+
}
|
|
12
|
+
/** High/low wick paint.
|
|
13
|
+
* @see {@link CandlestickSeries}
|
|
14
|
+
*/
|
|
15
|
+
export interface CandleWickStyle {
|
|
16
|
+
/** Wick paint; default dark teal. Empty string disables wick paint. */ readonly stroke?: StrokeStyle;
|
|
17
|
+
/** Nonnegative local width; default 1. */ readonly strokeWidth?: number;
|
|
18
|
+
}
|
|
19
|
+
/** Accepted named body/wick presentation for OHLC marks.
|
|
20
|
+
* @see {@link CandlestickSeries}
|
|
21
|
+
*/
|
|
22
|
+
export interface CandlestickSeriesStyle {
|
|
23
|
+
/** Positive local body width, or automatic 70% spacing capped at 12; singleton fallback 8. */ readonly bandwidth?: number | "auto";
|
|
24
|
+
/** Independent open/close body appearance. */ readonly body?: CandleBodyStyle;
|
|
25
|
+
/** Independent high/low wick appearance. */ readonly wick?: CandleWickStyle;
|
|
26
|
+
/** Opacity zero through one; default 1. */ readonly opacity?: number;
|
|
27
|
+
/** Cursor while the series owns targeting. */ readonly cursor?: string;
|
|
28
|
+
}
|
|
29
|
+
/** Source-ordered OHLC records with named accessors and optional shared inspection.
|
|
30
|
+
* @see {@link CandlestickSeries}
|
|
31
|
+
*/
|
|
32
|
+
export interface CandlestickSeriesProps<D> extends PibblEventHandlers, PibblEventParticipationOptions {
|
|
33
|
+
/** Original records/signal; never sorted or mutated. */ readonly data: SignalValue<readonly D[]>;
|
|
34
|
+
/** UTC-millisecond property or callback. */ readonly time: LineAccessor<D>;
|
|
35
|
+
/** Open price property or callback. */ readonly open: LineAccessor<D>;
|
|
36
|
+
/** High price property or callback. */ readonly high: LineAccessor<D>;
|
|
37
|
+
/** Low price property or callback. */ readonly low: LineAccessor<D>;
|
|
38
|
+
/** Close price property or callback. */ readonly close: LineAccessor<D>;
|
|
39
|
+
/** Numeric/UTC/trading horizontal mapping identity. */ readonly xScale: ScaleId;
|
|
40
|
+
/** Independent numeric price mapping identity. */ readonly yScale: ScaleId;
|
|
41
|
+
/** Tests original rows before accessor evaluation.
|
|
42
|
+
* @param datum - Original row.
|
|
43
|
+
* @param index - Source index including skipped rows.
|
|
44
|
+
* @param data - Original complete array.
|
|
45
|
+
* @returns Whether the candle participates.
|
|
46
|
+
*/ readonly defined?: (datum: D, index: number, data: readonly D[]) => boolean;
|
|
47
|
+
/** Named body/wick appearance or a hook-free datum resolver.
|
|
48
|
+
* @param datum - Original row.
|
|
49
|
+
* @param index - Original source index.
|
|
50
|
+
* @param data - Complete source array.
|
|
51
|
+
* @returns Plain named candle styles.
|
|
52
|
+
*/ readonly style?: SignalValue<CandlestickSeriesStyle> | ((datum: D, index: number, data: readonly D[]) => CandlestickSeriesStyle);
|
|
53
|
+
/** Optional capture on the ordinary inspection foundation; no queries while painting. */ readonly inspection?: CandleInspectionRef<D>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Paints OHLC bodies and wicks, preserving source order and skipping complete missing candles.
|
|
57
|
+
* Finite malformed OHLC rejects; equal open/close paints a one-local-unit doji.
|
|
58
|
+
* @param props - Named OHLC accessors, scales, styles and optional inspection.
|
|
59
|
+
* @returns Ordinary Pibbl composition; disjoint equal styles share paint paths.
|
|
60
|
+
* @see {@link CandlestickSeriesProps}
|
|
61
|
+
*/
|
|
62
|
+
export declare function CandlestickSeries<D>({ data: input, time: timeInput, open: openInput, high: highInput, low: lowInput, close: closeInput, xScale, yScale, defined, style: styleInput, inspection, pointerEvents, ...events }: CandlestickSeriesProps<D>): PibblNode;
|
|
@@ -0,0 +1,150 @@
|
|
|
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 { useNumericPosition } from "./series-position.js";
|
|
9
|
+
import { useContinuousScale } from "./use-continuous-scale.js";
|
|
10
|
+
import { pointAccessor, pointData, finiteCoordinate } from "./point-data.js";
|
|
11
|
+
import { financialMarkWidth, candleGeometry } from "./financial-geometry.js";
|
|
12
|
+
import { opacity, width } from "./paint.js";
|
|
13
|
+
function CandlestickSeries({
|
|
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), "CandlestickSeries");
|
|
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
|
+
`CandlestickSeries: 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
|
+
"CandlestickSeries 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 g = candleGeometry({
|
|
64
|
+
centerX: row.x,
|
|
65
|
+
openY: ys.map(row.open),
|
|
66
|
+
closeY: ys.map(row.close),
|
|
67
|
+
highY: ys.map(row.high),
|
|
68
|
+
lowY: ys.map(row.low),
|
|
69
|
+
width: markWidth,
|
|
70
|
+
dojiHeight: 1
|
|
71
|
+
});
|
|
72
|
+
const fill = style.body?.fill ?? (row.close >= row.open ? "#087f8c" : "#d9674c"), bodyStroke = style.body?.stroke, bodyWidth = width(style.body?.strokeWidth ?? 1, "CandlestickSeries body"), wickStroke = style.wick?.stroke ?? "#173a35", wickWidth = width(style.wick?.strokeWidth ?? 1, "CandlestickSeries wick"), alpha = opacity(style.opacity ?? 1, "CandlestickSeries");
|
|
73
|
+
marks?.push(
|
|
74
|
+
Object.freeze({
|
|
75
|
+
datum: row.datum,
|
|
76
|
+
sourceIndex: row.sourceIndex,
|
|
77
|
+
time: row.time,
|
|
78
|
+
open: row.open,
|
|
79
|
+
high: row.high,
|
|
80
|
+
low: row.low,
|
|
81
|
+
close: row.close,
|
|
82
|
+
anchorLocal: Object.freeze({ x: row.x, y: ys.map(row.close) }),
|
|
83
|
+
bodyBoundsLocal: g.bodyBoundsLocal,
|
|
84
|
+
wickLocal: g.wickLocal,
|
|
85
|
+
bodyFill: !!fill && alpha > 0,
|
|
86
|
+
bodyStrokeWidthLocal: bodyStroke && alpha > 0 ? bodyWidth : 0,
|
|
87
|
+
wickStrokeWidthLocal: wickStroke && alpha > 0 ? wickWidth : 0
|
|
88
|
+
})
|
|
89
|
+
);
|
|
90
|
+
if (alpha === 0) continue;
|
|
91
|
+
const half = Math.max(bodyStroke ? bodyWidth : 0, wickStroke ? wickWidth : 0) / 2, minX = g.bodyBoundsLocal.x - half, maxX = g.bodyBoundsLocal.x + markWidth + half;
|
|
92
|
+
let batch = batches.at(-1);
|
|
93
|
+
if (!batch || minX < batch.maxX && maxX > batch.minX || batch.fill !== fill || batch.bodyStroke !== bodyStroke || batch.bodyWidth !== bodyWidth || batch.wickStroke !== wickStroke || batch.wickWidth !== wickWidth || batch.opacity !== alpha || batch.cursor !== style.cursor) {
|
|
94
|
+
batch = {
|
|
95
|
+
body: new Path2D(),
|
|
96
|
+
wick: new Path2D(),
|
|
97
|
+
fill,
|
|
98
|
+
bodyStroke,
|
|
99
|
+
bodyWidth,
|
|
100
|
+
wickStroke,
|
|
101
|
+
wickWidth,
|
|
102
|
+
opacity: alpha,
|
|
103
|
+
cursor: style.cursor,
|
|
104
|
+
minX,
|
|
105
|
+
maxX
|
|
106
|
+
};
|
|
107
|
+
batches.push(batch);
|
|
108
|
+
}
|
|
109
|
+
batch.minX = Math.min(batch.minX, minX);
|
|
110
|
+
batch.maxX = Math.max(batch.maxX, maxX);
|
|
111
|
+
const b = g.bodyBoundsLocal;
|
|
112
|
+
batch.body.rect(b.x, b.y, b.width, b.height);
|
|
113
|
+
batch.wick.moveTo(g.wickLocal.x, g.wickLocal.highY);
|
|
114
|
+
batch.wick.lineTo(g.wickLocal.x, g.wickLocal.lowY);
|
|
115
|
+
}
|
|
116
|
+
inspection?.capture({ marks, xScale: xs, yScale: ys });
|
|
117
|
+
return /* @__PURE__ */ jsx(Group, { ...events, children: batches.map((batch, index) => /* @__PURE__ */ jsxs(Group, { children: [
|
|
118
|
+
/* @__PURE__ */ jsx(
|
|
119
|
+
Path,
|
|
120
|
+
{
|
|
121
|
+
pointerEvents,
|
|
122
|
+
style: {
|
|
123
|
+
d: batch.wick,
|
|
124
|
+
stroke: batch.wickStroke,
|
|
125
|
+
strokeWidth: batch.wickWidth,
|
|
126
|
+
opacity: batch.opacity,
|
|
127
|
+
cursor: batch.cursor
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
),
|
|
131
|
+
/* @__PURE__ */ jsx(
|
|
132
|
+
Path,
|
|
133
|
+
{
|
|
134
|
+
pointerEvents,
|
|
135
|
+
style: {
|
|
136
|
+
d: batch.body,
|
|
137
|
+
fill: batch.fill,
|
|
138
|
+
stroke: batch.bodyStroke,
|
|
139
|
+
strokeWidth: batch.bodyWidth,
|
|
140
|
+
opacity: batch.opacity,
|
|
141
|
+
cursor: batch.cursor
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
)
|
|
145
|
+
] }, index)) });
|
|
146
|
+
}
|
|
147
|
+
export {
|
|
148
|
+
CandlestickSeries
|
|
149
|
+
};
|
|
150
|
+
//# sourceMappingURL=candlestick-series.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/features/viz/lib/candlestick-series.tsx"],
|
|
4
|
+
"sourcesContent": ["import {\n Group,\n Path,\n resolveSignalValue,\n type FillStyle,\n type StrokeStyle,\n type SignalValue,\n type PibblEventHandlers,\n type PibblEventParticipationOptions,\n type PibblNode,\n} from \"@pibbl/core\";\nimport { withHooksForbidden } from \"@pibbl/core/internal\";\nimport type { LineAccessor, ScaleId } from \"./types.js\";\nimport type {\n CandleInspectionRef,\n CapturedCandleMark,\n} from \"../inspection/candle.js\";\nimport { useNumericPosition } from \"./series-position.js\";\nimport { useContinuousScale } from \"./use-continuous-scale.js\";\nimport { pointAccessor, pointData, finiteCoordinate } from \"./point-data.js\";\nimport { financialMarkWidth, candleGeometry } from \"./financial-geometry.js\";\nimport { opacity, width } from \"./paint.js\";\n/** Open/close body paint, independent from wick paint.\n * @see {@link CandlestickSeries}\n */\nexport interface CandleBodyStyle {\n /** Interior; default teal for close >= open, coral otherwise. Empty string disables fill. */ readonly fill?: FillStyle;\n /** Optional body outline. */ readonly stroke?: StrokeStyle;\n /** Nonnegative local outline width; default 1. */ readonly strokeWidth?: number;\n}\n/** High/low wick paint.\n * @see {@link CandlestickSeries}\n */\nexport interface CandleWickStyle {\n /** Wick paint; default dark teal. Empty string disables wick paint. */ readonly stroke?: StrokeStyle;\n /** Nonnegative local width; default 1. */ readonly strokeWidth?: number;\n}\n/** Accepted named body/wick presentation for OHLC marks.\n * @see {@link CandlestickSeries}\n */\nexport interface CandlestickSeriesStyle {\n /** Positive local body width, or automatic 70% spacing capped at 12; singleton fallback 8. */ readonly bandwidth?:\n number | \"auto\";\n /** Independent open/close body appearance. */ readonly body?: CandleBodyStyle;\n /** Independent high/low wick appearance. */ readonly wick?: CandleWickStyle;\n /** Opacity zero through one; default 1. */ readonly opacity?: number;\n /** Cursor while the series owns targeting. */ readonly cursor?: string;\n}\n/** Source-ordered OHLC records with named accessors and optional shared inspection.\n * @see {@link CandlestickSeries}\n */\nexport interface CandlestickSeriesProps<D>\n extends PibblEventHandlers, PibblEventParticipationOptions {\n /** Original records/signal; never sorted or mutated. */ readonly data: SignalValue<\n readonly D[]\n >;\n /** UTC-millisecond property or callback. */ readonly time: LineAccessor<D>;\n /** Open price property or callback. */ readonly open: LineAccessor<D>;\n /** High price property or callback. */ readonly high: LineAccessor<D>;\n /** Low price property or callback. */ readonly low: LineAccessor<D>;\n /** Close price property or callback. */ readonly close: LineAccessor<D>;\n /** Numeric/UTC/trading horizontal mapping identity. */ readonly xScale: ScaleId;\n /** Independent numeric price mapping identity. */ 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 - Original complete array.\n * @returns Whether the candle participates.\n */ readonly defined?: (\n datum: D,\n index: number,\n data: readonly D[],\n ) => boolean;\n /** Named body/wick appearance or a hook-free datum resolver.\n * @param datum - Original row.\n * @param index - Original source index.\n * @param data - Complete source array.\n * @returns Plain named candle styles.\n */ readonly style?:\n | SignalValue<CandlestickSeriesStyle>\n | ((datum: D, index: number, data: readonly D[]) => CandlestickSeriesStyle);\n /** Optional capture on the ordinary inspection foundation; no queries while painting. */ readonly inspection?: CandleInspectionRef<D>;\n}\n/**\n * Paints OHLC bodies and wicks, preserving source order and skipping complete missing candles.\n * Finite malformed OHLC rejects; equal open/close paints a one-local-unit doji.\n * @param props - Named OHLC accessors, scales, styles and optional inspection.\n * @returns Ordinary Pibbl composition; disjoint equal styles share paint paths.\n * @see {@link CandlestickSeriesProps}\n */\nexport function CandlestickSeries<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}: CandlestickSeriesProps<D>): PibblNode {\n const xs = useNumericPosition(xScale),\n ys = useContinuousScale(yScale).get();\n const data = pointData(resolveSignalValue(input), \"CandlestickSeries\");\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 `CandlestickSeries: 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: CapturedCandleMark<D>[] | undefined = inspection\n ? []\n : undefined;\n const batches: {\n body: Path2D;\n wick: Path2D;\n fill: FillStyle;\n bodyStroke: StrokeStyle | undefined;\n bodyWidth: number;\n wickStroke: StrokeStyle;\n wickWidth: 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(\"CandlestickSeries 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 g = candleGeometry({\n centerX: row.x,\n openY: ys.map(row.open),\n closeY: ys.map(row.close),\n highY: ys.map(row.high),\n lowY: ys.map(row.low),\n width: markWidth,\n dojiHeight: 1,\n });\n const fill =\n style.body?.fill ?? (row.close >= row.open ? \"#087f8c\" : \"#d9674c\"),\n bodyStroke = style.body?.stroke,\n bodyWidth = width(style.body?.strokeWidth ?? 1, \"CandlestickSeries body\"),\n wickStroke = style.wick?.stroke ?? \"#173a35\",\n wickWidth = width(style.wick?.strokeWidth ?? 1, \"CandlestickSeries wick\"),\n alpha = opacity(style.opacity ?? 1, \"CandlestickSeries\");\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: ys.map(row.close) }),\n bodyBoundsLocal: g.bodyBoundsLocal,\n wickLocal: g.wickLocal,\n bodyFill: !!fill && alpha > 0,\n bodyStrokeWidthLocal: bodyStroke && alpha > 0 ? bodyWidth : 0,\n wickStrokeWidthLocal: wickStroke && alpha > 0 ? wickWidth : 0,\n }),\n );\n if (alpha === 0) continue;\n const half =\n Math.max(bodyStroke ? bodyWidth : 0, wickStroke ? wickWidth : 0) / 2,\n minX = g.bodyBoundsLocal.x - half,\n maxX = g.bodyBoundsLocal.x + markWidth + half;\n let batch = batches.at(-1);\n if (\n !batch ||\n (minX < batch.maxX && maxX > batch.minX) ||\n batch.fill !== fill ||\n batch.bodyStroke !== bodyStroke ||\n batch.bodyWidth !== bodyWidth ||\n batch.wickStroke !== wickStroke ||\n batch.wickWidth !== wickWidth ||\n batch.opacity !== alpha ||\n batch.cursor !== style.cursor\n ) {\n batch = {\n body: new Path2D(),\n wick: new Path2D(),\n fill,\n bodyStroke,\n bodyWidth,\n wickStroke,\n wickWidth,\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 const b = g.bodyBoundsLocal;\n batch.body.rect(b.x, b.y, b.width, b.height);\n batch.wick.moveTo(g.wickLocal.x, g.wickLocal.highY);\n batch.wick.lineTo(g.wickLocal.x, g.wickLocal.lowY);\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.wick,\n stroke: batch.wickStroke,\n strokeWidth: batch.wickWidth,\n opacity: batch.opacity,\n cursor: batch.cursor,\n }}\n />\n <Path\n pointerEvents={pointerEvents}\n style={{\n d: batch.body,\n fill: batch.fill,\n stroke: batch.bodyStroke,\n strokeWidth: batch.bodyWidth,\n opacity: batch.opacity,\n cursor: batch.cursor,\n }}\n />\n </Group>\n ))}\n </Group>\n );\n}\n"],
|
|
5
|
+
"mappings": "AAsQQ,SACE,KADF;AAtQR;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAOK;AACP,SAAS,0BAA0B;AAMnC,SAAS,0BAA0B;AACnC,SAAS,0BAA0B;AACnC,SAAS,eAAe,WAAW,wBAAwB;AAC3D,SAAS,oBAAoB,sBAAsB;AACnD,SAAS,SAAS,aAAa;AAqExB,SAAS,kBAAqB;AAAA,EACnC,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,GAAyC;AACvC,QAAM,KAAK,mBAAmB,MAAM,GAClC,KAAK,mBAAmB,MAAM,EAAE,IAAI;AACtC,QAAM,OAAO,UAAU,mBAAmB,KAAK,GAAG,mBAAmB;AACrE,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,Q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