@pibbl/core 0.0.1 → 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/README.md +1 -1
- package/THIRD_PARTY_NOTICES.txt +81 -0
- package/dist/features/machines/animation.d.ts +64 -0
- package/dist/features/machines/animation.js +55 -0
- package/dist/features/machines/animation.js.map +7 -0
- package/dist/features/machines/animation.mjs +1 -0
- package/dist/features/machines/assign.d.ts +16 -0
- package/dist/features/machines/assign.js +15 -0
- package/dist/features/machines/assign.js.map +7 -0
- package/dist/features/machines/callback.d.ts +9 -0
- package/dist/features/machines/callback.js +7 -0
- package/dist/features/machines/callback.js.map +7 -0
- package/dist/features/machines/hook.d.ts +30 -0
- package/dist/features/machines/hook.js +37 -0
- package/dist/features/machines/hook.js.map +7 -0
- package/dist/features/machines/index.d.ts +6 -0
- package/dist/features/machines/index.js +12 -0
- package/dist/features/machines/index.js.map +7 -0
- package/dist/features/machines/index.mjs +1 -0
- package/dist/features/machines/runtime.d.ts +18 -0
- package/dist/features/machines/runtime.js +363 -0
- package/dist/features/machines/runtime.js.map +7 -0
- package/dist/features/machines/types.d.ts +164 -0
- package/dist/features/physics/2d-geometry.d.ts +3 -3
- package/dist/features/physics/2d-geometry.js.map +1 -1
- 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/2d.d.ts +115 -62
- package/dist/features/physics/2d.js +59 -28
- package/dist/features/physics/2d.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/query-types.d.ts +6 -0
- package/dist/features/physics/lib/2d/runtime/controller.d.ts +7 -6
- 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/types.d.ts +8 -30
- package/dist/features/physics/lib/2d/world/queries.d.ts +7 -6
- package/dist/features/physics/lib/2d/world/queries.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/formats/aseprite.d.ts +5 -0
- package/dist/features/sprites/formats/texture-packer.d.ts +5 -0
- package/dist/features/sprites/index.d.ts +6 -0
- package/dist/features/sprites/loader.d.ts +25 -0
- package/dist/features/sprites/loader.js +6 -3
- package/dist/features/sprites/loader.js.map +2 -2
- package/dist/features/sprites/model.d.ts +75 -0
- package/dist/features/sprites/sprite.d.ts +22 -0
- 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 +92 -5
- package/dist/features/viz/index.js +202 -4
- 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-labels.d.ts +2 -0
- package/dist/features/viz/lib/axis-labels.js +41 -0
- package/dist/features/viz/lib/axis-labels.js.map +7 -0
- package/dist/features/viz/lib/axis-title.d.ts +23 -0
- package/dist/features/viz/lib/axis-title.js +24 -0
- package/dist/features/viz/lib/axis-title.js.map +7 -0
- package/dist/features/viz/lib/axis.d.ts +1 -1
- package/dist/features/viz/lib/axis.js +50 -50
- package/dist/features/viz/lib/axis.js.map +2 -2
- package/dist/features/viz/lib/bar-scale.d.ts +7 -0
- package/dist/features/viz/lib/bar-scale.js +34 -0
- package/dist/features/viz/lib/bar-scale.js.map +7 -0
- package/dist/features/viz/lib/bar-series.d.ts +3 -1
- package/dist/features/viz/lib/bar-series.js +21 -5
- 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/chart-lines.d.ts +41 -0
- package/dist/features/viz/lib/chart-lines.js +32 -0
- package/dist/features/viz/lib/chart-lines.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 +6 -3
- package/dist/features/viz/lib/hover-data.js.map +2 -2
- package/dist/features/viz/lib/hover-types.d.ts +5 -5
- 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-component.d.ts +7 -0
- package/dist/features/viz/lib/linear-scale-component.js +18 -0
- package/dist/features/viz/lib/linear-scale-component.js.map +7 -0
- 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/log-scale-component.d.ts +7 -0
- package/dist/features/viz/lib/log-scale-component.js +19 -0
- package/dist/features/viz/lib/log-scale-component.js.map +7 -0
- package/dist/features/viz/lib/log-scale.d.ts +2 -0
- package/dist/features/viz/lib/log-scale.js +53 -0
- package/dist/features/viz/lib/log-scale.js.map +7 -0
- 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/nearest.d.ts +9 -9
- package/dist/features/viz/lib/nearest.js.map +1 -1
- 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/numeric-ticks.d.ts +38 -0
- package/dist/features/viz/lib/numeric-ticks.js +54 -0
- package/dist/features/viz/lib/numeric-ticks.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-scale-component.d.ts +7 -0
- package/dist/features/viz/lib/point-scale-component.js +19 -0
- package/dist/features/viz/lib/point-scale-component.js.map +7 -0
- package/dist/features/viz/lib/point-scale.d.ts +2 -0
- package/dist/features/viz/lib/point-scale.js +45 -0
- package/dist/features/viz/lib/point-scale.js.map +7 -0
- 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.d.ts +16 -0
- package/dist/features/viz/lib/reference-band.js +30 -0
- package/dist/features/viz/lib/reference-band.js.map +7 -0
- package/dist/features/viz/lib/scale-adjust.js +9 -4
- package/dist/features/viz/lib/scale-adjust.js.map +2 -2
- package/dist/features/viz/lib/scale-context.d.ts +5 -4
- package/dist/features/viz/lib/scale-context.js +15 -11
- package/dist/features/viz/lib/scale-context.js.map +2 -2
- package/dist/features/viz/lib/scale-provider.d.ts +2 -0
- package/dist/features/viz/lib/scale-provider.js +13 -0
- package/dist/features/viz/lib/scale-provider.js.map +7 -0
- package/dist/features/viz/lib/scale-ticks.d.ts +5 -0
- package/dist/features/viz/lib/scale-ticks.js +64 -0
- package/dist/features/viz/lib/scale-ticks.js.map +7 -0
- package/dist/features/viz/lib/scale-view.d.ts +4 -0
- package/dist/features/viz/lib/scale-view.js +21 -0
- package/dist/features/viz/lib/scale-view.js.map +7 -0
- 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/symlog-scale-component.d.ts +7 -0
- package/dist/features/viz/lib/symlog-scale-component.js +19 -0
- package/dist/features/viz/lib/symlog-scale-component.js.map +7 -0
- package/dist/features/viz/lib/symlog-scale.d.ts +2 -0
- package/dist/features/viz/lib/symlog-scale.js +38 -0
- package/dist/features/viz/lib/symlog-scale.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 +114 -21
- package/dist/features/viz/lib/use-bar-scale.d.ts +8 -0
- package/dist/features/viz/lib/use-bar-scale.js +9 -0
- package/dist/features/viz/lib/use-bar-scale.js.map +7 -0
- package/dist/features/viz/lib/use-continuous-scale.d.ts +8 -0
- package/dist/features/viz/lib/use-continuous-scale.js +14 -0
- package/dist/features/viz/lib/use-continuous-scale.js.map +7 -0
- package/dist/features/viz/lib/use-linear-scale.d.ts +8 -0
- package/dist/features/viz/lib/use-linear-scale.js +9 -0
- package/dist/features/viz/lib/use-linear-scale.js.map +7 -0
- package/dist/features/viz/lib/use-log-scale.d.ts +8 -0
- package/dist/features/viz/lib/use-log-scale.js +9 -0
- package/dist/features/viz/lib/use-log-scale.js.map +7 -0
- package/dist/features/viz/lib/use-point-scale.d.ts +8 -0
- package/dist/features/viz/lib/use-point-scale.js +9 -0
- package/dist/features/viz/lib/use-point-scale.js.map +7 -0
- package/dist/features/viz/lib/use-symlog-scale.d.ts +8 -0
- package/dist/features/viz/lib/use-symlog-scale.js +9 -0
- package/dist/features/viz/lib/use-symlog-scale.js.map +7 -0
- package/dist/features/viz/lib/use-utc-scale.d.ts +8 -0
- package/dist/features/viz/lib/use-utc-scale.js +9 -0
- package/dist/features/viz/lib/use-utc-scale.js.map +7 -0
- package/dist/features/viz/lib/utc-labels.d.ts +12 -0
- package/dist/features/viz/lib/utc-labels.js +27 -0
- package/dist/features/viz/lib/utc-labels.js.map +7 -0
- package/dist/features/viz/lib/utc-scale-component.d.ts +7 -0
- package/dist/features/viz/lib/utc-scale-component.js +18 -0
- package/dist/features/viz/lib/utc-scale-component.js.map +7 -0
- package/dist/features/viz/lib/utc-scale.d.ts +21 -0
- package/dist/features/viz/lib/utc-scale.js +124 -0
- package/dist/features/viz/lib/utc-scale.js.map +7 -0
- 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 +10 -6
- 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/animation/definition.d.ts +5 -3
- package/dist/lib/animation/definition.js +29 -4
- package/dist/lib/animation/definition.js.map +2 -2
- package/dist/lib/animation/playback.d.ts +8 -0
- package/dist/lib/animation/playback.js +33 -11
- package/dist/lib/animation/playback.js.map +2 -2
- package/dist/lib/animation/spring.d.ts +3 -1
- package/dist/lib/animation/spring.js.map +2 -2
- package/dist/lib/animation/types.d.ts +29 -73
- 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/hooks/use-animated-value.d.ts +11 -21
- package/dist/lib/hooks/use-animated-value.js +23 -70
- package/dist/lib/hooks/use-animated-value.js.map +3 -3
- package/dist/lib/hooks/use-playback.js +1 -0
- package/dist/lib/hooks/use-playback.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 +43 -6
- package/dist/features/viz/lib/scale.d.ts +0 -11
- package/dist/features/viz/lib/scale.js +0 -80
- package/dist/features/viz/lib/scale.js.map +0 -7
- package/dist/features/viz/lib/use-scale.d.ts +0 -20
- package/dist/features/viz/lib/use-scale.js +0 -10
- package/dist/features/viz/lib/use-scale.js.map +0 -7
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@pibbl/core/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
Group,
|
|
4
|
+
Path,
|
|
5
|
+
resolveSignalValue
|
|
6
|
+
} from "@pibbl/core";
|
|
7
|
+
import { withHooksForbidden } from "@pibbl/core/internal";
|
|
8
|
+
import { financialMarkWidth } from "./financial-geometry.js";
|
|
9
|
+
import { opacity, width } from "./paint.js";
|
|
10
|
+
import { finiteCoordinate, pointAccessor, pointData } from "./point-data.js";
|
|
11
|
+
import { useNumericPosition } from "./series-position.js";
|
|
12
|
+
import { useContinuousScale } from "./use-continuous-scale.js";
|
|
13
|
+
function OhlcBarSeries({
|
|
14
|
+
data: input,
|
|
15
|
+
time: timeInput,
|
|
16
|
+
open: openInput,
|
|
17
|
+
high: highInput,
|
|
18
|
+
low: lowInput,
|
|
19
|
+
close: closeInput,
|
|
20
|
+
xScale,
|
|
21
|
+
yScale,
|
|
22
|
+
defined,
|
|
23
|
+
style: styleInput,
|
|
24
|
+
inspection,
|
|
25
|
+
pointerEvents,
|
|
26
|
+
...events
|
|
27
|
+
}) {
|
|
28
|
+
const xs = useNumericPosition(xScale), ys = useContinuousScale(yScale).get();
|
|
29
|
+
const data = pointData(resolveSignalValue(input), "OhlcBarSeries");
|
|
30
|
+
const time = pointAccessor(timeInput), open = pointAccessor(openInput), high = pointAccessor(highInput), low = pointAccessor(lowInput), close = pointAccessor(closeInput);
|
|
31
|
+
const rows = [];
|
|
32
|
+
for (let i = 0; i < data.length; i++) {
|
|
33
|
+
const datum = data[i];
|
|
34
|
+
if (defined && !defined(datum, i, data)) continue;
|
|
35
|
+
const t = time(datum, i, data), o = open(datum, i, data), h = high(datum, i, data), l = low(datum, i, data), c = close(datum, i, data);
|
|
36
|
+
if (!finiteCoordinate(t) || !finiteCoordinate(o) || !finiteCoordinate(h) || !finiteCoordinate(l) || !finiteCoordinate(c))
|
|
37
|
+
continue;
|
|
38
|
+
if (l > Math.min(o, c) || h < Math.max(o, c))
|
|
39
|
+
throw new RangeError(
|
|
40
|
+
`OhlcBarSeries: malformed OHLC at source index ${i}; require low <= open/close <= high.`
|
|
41
|
+
);
|
|
42
|
+
rows.push({
|
|
43
|
+
datum,
|
|
44
|
+
sourceIndex: i,
|
|
45
|
+
time: t,
|
|
46
|
+
open: o,
|
|
47
|
+
high: h,
|
|
48
|
+
low: l,
|
|
49
|
+
close: c,
|
|
50
|
+
x: xs.map(t)
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
const defaultWidth = financialMarkWidth(rows.map((row) => row.x));
|
|
54
|
+
const specified = typeof styleInput === "function" ? styleInput : resolveSignalValue(styleInput);
|
|
55
|
+
const marks = inspection ? [] : void 0;
|
|
56
|
+
const batches = [];
|
|
57
|
+
for (const row of rows) {
|
|
58
|
+
const style = typeof specified === "function" ? withHooksForbidden(
|
|
59
|
+
"OhlcBarSeries style callback",
|
|
60
|
+
() => specified(row.datum, row.sourceIndex, data)
|
|
61
|
+
) : specified ?? {};
|
|
62
|
+
const markWidth = style.bandwidth === void 0 || style.bandwidth === "auto" ? defaultWidth : financialMarkWidth([], { width: style.bandwidth });
|
|
63
|
+
const halfWidth = markWidth / 2;
|
|
64
|
+
const stemLocal = Object.freeze({
|
|
65
|
+
x: row.x,
|
|
66
|
+
highY: ys.map(row.high),
|
|
67
|
+
lowY: ys.map(row.low)
|
|
68
|
+
});
|
|
69
|
+
const openTickLocal = Object.freeze({
|
|
70
|
+
x1: row.x - halfWidth,
|
|
71
|
+
x2: row.x,
|
|
72
|
+
y: ys.map(row.open)
|
|
73
|
+
});
|
|
74
|
+
const closeTickLocal = Object.freeze({
|
|
75
|
+
x1: row.x,
|
|
76
|
+
x2: row.x + halfWidth,
|
|
77
|
+
y: ys.map(row.close)
|
|
78
|
+
});
|
|
79
|
+
const stroke = style.stroke ?? "#173a35", strokeWidth = width(style.strokeWidth ?? 1, "OhlcBarSeries"), alpha = opacity(style.opacity ?? 1, "OhlcBarSeries");
|
|
80
|
+
marks?.push(
|
|
81
|
+
Object.freeze({
|
|
82
|
+
datum: row.datum,
|
|
83
|
+
sourceIndex: row.sourceIndex,
|
|
84
|
+
time: row.time,
|
|
85
|
+
open: row.open,
|
|
86
|
+
high: row.high,
|
|
87
|
+
low: row.low,
|
|
88
|
+
close: row.close,
|
|
89
|
+
anchorLocal: Object.freeze({ x: row.x, y: closeTickLocal.y }),
|
|
90
|
+
stemLocal,
|
|
91
|
+
openTickLocal,
|
|
92
|
+
closeTickLocal,
|
|
93
|
+
strokeWidthLocal: stroke && alpha > 0 ? strokeWidth : 0
|
|
94
|
+
})
|
|
95
|
+
);
|
|
96
|
+
if (alpha === 0 || !stroke) continue;
|
|
97
|
+
const xPad = strokeWidth / 2, minX = row.x - halfWidth - xPad, maxX = row.x + halfWidth + xPad;
|
|
98
|
+
let batch = batches.at(-1);
|
|
99
|
+
if (!batch || minX < batch.maxX && maxX > batch.minX || batch.stroke !== stroke || batch.strokeWidth !== strokeWidth || batch.opacity !== alpha || batch.cursor !== style.cursor) {
|
|
100
|
+
batch = {
|
|
101
|
+
stem: new Path2D(),
|
|
102
|
+
openTick: new Path2D(),
|
|
103
|
+
closeTick: new Path2D(),
|
|
104
|
+
stroke,
|
|
105
|
+
strokeWidth,
|
|
106
|
+
opacity: alpha,
|
|
107
|
+
cursor: style.cursor,
|
|
108
|
+
minX,
|
|
109
|
+
maxX
|
|
110
|
+
};
|
|
111
|
+
batches.push(batch);
|
|
112
|
+
}
|
|
113
|
+
batch.minX = Math.min(batch.minX, minX);
|
|
114
|
+
batch.maxX = Math.max(batch.maxX, maxX);
|
|
115
|
+
batch.stem.moveTo(stemLocal.x, stemLocal.highY);
|
|
116
|
+
batch.stem.lineTo(stemLocal.x, stemLocal.lowY);
|
|
117
|
+
batch.openTick.moveTo(openTickLocal.x1, openTickLocal.y);
|
|
118
|
+
batch.openTick.lineTo(openTickLocal.x2, openTickLocal.y);
|
|
119
|
+
batch.closeTick.moveTo(closeTickLocal.x1, closeTickLocal.y);
|
|
120
|
+
batch.closeTick.lineTo(closeTickLocal.x2, closeTickLocal.y);
|
|
121
|
+
}
|
|
122
|
+
inspection?.capture({ marks, xScale: xs, yScale: ys });
|
|
123
|
+
return /* @__PURE__ */ jsx(Group, { ...events, children: batches.map((batch, index) => /* @__PURE__ */ jsxs(Group, { children: [
|
|
124
|
+
/* @__PURE__ */ jsx(
|
|
125
|
+
Path,
|
|
126
|
+
{
|
|
127
|
+
pointerEvents,
|
|
128
|
+
style: {
|
|
129
|
+
d: batch.stem,
|
|
130
|
+
stroke: batch.stroke,
|
|
131
|
+
strokeWidth: batch.strokeWidth,
|
|
132
|
+
opacity: batch.opacity,
|
|
133
|
+
cursor: batch.cursor
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
),
|
|
137
|
+
/* @__PURE__ */ jsx(
|
|
138
|
+
Path,
|
|
139
|
+
{
|
|
140
|
+
pointerEvents,
|
|
141
|
+
style: {
|
|
142
|
+
d: batch.openTick,
|
|
143
|
+
stroke: batch.stroke,
|
|
144
|
+
strokeWidth: batch.strokeWidth,
|
|
145
|
+
opacity: batch.opacity,
|
|
146
|
+
cursor: batch.cursor
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
),
|
|
150
|
+
/* @__PURE__ */ jsx(
|
|
151
|
+
Path,
|
|
152
|
+
{
|
|
153
|
+
pointerEvents,
|
|
154
|
+
style: {
|
|
155
|
+
d: batch.closeTick,
|
|
156
|
+
stroke: batch.stroke,
|
|
157
|
+
strokeWidth: batch.strokeWidth,
|
|
158
|
+
opacity: batch.opacity,
|
|
159
|
+
cursor: batch.cursor
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
)
|
|
163
|
+
] }, index)) });
|
|
164
|
+
}
|
|
165
|
+
export {
|
|
166
|
+
OhlcBarSeries
|
|
167
|
+
};
|
|
168
|
+
//# sourceMappingURL=ohlc-bar-series.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/features/viz/lib/ohlc-bar-series.tsx"],
|
|
4
|
+
"sourcesContent": ["import {\n Group,\n Path,\n resolveSignalValue,\n type PibblEventHandlers,\n type PibblEventParticipationOptions,\n type PibblNode,\n type SignalValue,\n type StrokeStyle,\n} from \"@pibbl/core\";\nimport { withHooksForbidden } from \"@pibbl/core/internal\";\nimport type {\n OhlcBarInspectionRef,\n CapturedOhlcBarMark,\n} from \"../inspection/ohlc-bar.js\";\nimport { financialMarkWidth } from \"./financial-geometry.js\";\nimport { opacity, width } from \"./paint.js\";\nimport { finiteCoordinate, pointAccessor, pointData } from \"./point-data.js\";\nimport { useNumericPosition } from \"./series-position.js\";\nimport type { LineAccessor, ScaleId } from \"./types.js\";\nimport { useContinuousScale } from \"./use-continuous-scale.js\";\n\n/** Shared stroke presentation for an OHLC bar.\n * @see {@link OhlcBarSeries}\n */\nexport interface OhlcBarSeriesStyle {\n /** Positive total width, or automatic 70% spacing capped at 12; singleton fallback 8. */ readonly bandwidth?:\n number | \"auto\";\n /** Stem and tick stroke; defaults to dark teal. Empty string disables painting. */ readonly stroke?: StrokeStyle;\n /** Nonnegative local stroke width; default 1. */ readonly strokeWidth?: number;\n /** Paint opacity from zero through one; default 1. */ readonly opacity?: number;\n /** Cursor while the series owns targeting. */ readonly cursor?: string;\n}\n\n/** Source-ordered OHLC records rendered as a high/low stem with open/close ticks.\n * @see {@link OhlcBarSeries}\n */\nexport interface OhlcBarSeriesProps<D>\n extends PibblEventHandlers, PibblEventParticipationOptions {\n /** Original records or signal; never sorted or mutated. */\n readonly data: SignalValue<readonly D[]>;\n /** UTC-millisecond property or callback. */\n readonly time: LineAccessor<D>;\n /** Opening price property or callback. */\n readonly open: LineAccessor<D>;\n /** High price property or callback. */\n readonly high: LineAccessor<D>;\n /** Low price property or callback. */\n readonly low: LineAccessor<D>;\n /** Closing price property or callback. */\n readonly close: LineAccessor<D>;\n /** Numeric, UTC, or trading-time horizontal mapping identity. */\n readonly xScale: ScaleId;\n /** Continuous price mapping identity. */\n readonly yScale: ScaleId;\n /** Tests original rows before accessor evaluation.\n * @param datum - Original row.\n * @param index - Source index including skipped rows.\n * @param data - Complete source array.\n * @returns Whether the bar participates.\n */\n readonly defined?: (datum: D, index: number, data: readonly D[]) => boolean;\n /** Shared presentation or a hook-free original-row resolver.\n * @param datum - Original row.\n * @param index - Source index.\n * @param data - Complete source array.\n * @returns Plain OHLC-bar style.\n */\n readonly style?:\n | SignalValue<OhlcBarSeriesStyle>\n | ((datum: D, index: number, data: readonly D[]) => OhlcBarSeriesStyle);\n /** Optional committed capture; the renderer does not execute inspection queries. */ readonly inspection?: OhlcBarInspectionRef<D>;\n}\n\n/** Paints source-ordered OHLC bars with a high/low stem, left open tick, and right close tick.\n * @param props - Original OHLC accessors, scales, styles, events, and optional capture.\n * @returns Ordinary Pibbl composition; equal disjoint styles share paths.\n * @see {@link OhlcBarSeriesProps}\n */\nexport function OhlcBarSeries<D>({\n data: input,\n time: timeInput,\n open: openInput,\n high: highInput,\n low: lowInput,\n close: closeInput,\n xScale,\n yScale,\n defined,\n style: styleInput,\n inspection,\n pointerEvents,\n ...events\n}: OhlcBarSeriesProps<D>): PibblNode {\n const xs = useNumericPosition(xScale),\n ys = useContinuousScale(yScale).get();\n const data = pointData(resolveSignalValue(input), \"OhlcBarSeries\");\n const time = pointAccessor(timeInput),\n open = pointAccessor(openInput),\n high = pointAccessor(highInput),\n low = pointAccessor(lowInput),\n close = pointAccessor(closeInput);\n const rows: {\n datum: D;\n sourceIndex: number;\n time: number;\n open: number;\n high: number;\n low: number;\n close: number;\n x: number;\n }[] = [];\n for (let i = 0; i < data.length; i++) {\n const datum = data[i];\n if (defined && !defined(datum, i, data)) continue;\n const t = time(datum, i, data),\n o = open(datum, i, data),\n h = high(datum, i, data),\n l = low(datum, i, data),\n c = close(datum, i, data);\n if (\n !finiteCoordinate(t) ||\n !finiteCoordinate(o) ||\n !finiteCoordinate(h) ||\n !finiteCoordinate(l) ||\n !finiteCoordinate(c)\n )\n continue;\n if (l > Math.min(o, c) || h < Math.max(o, c))\n throw new RangeError(\n `OhlcBarSeries: malformed OHLC at source index ${i}; require low <= open/close <= high.`,\n );\n rows.push({\n datum,\n sourceIndex: i,\n time: t,\n open: o,\n high: h,\n low: l,\n close: c,\n x: xs.map(t),\n });\n }\n const defaultWidth = financialMarkWidth(rows.map((row) => row.x));\n const specified =\n typeof styleInput === \"function\"\n ? styleInput\n : resolveSignalValue(styleInput);\n const marks: CapturedOhlcBarMark<D>[] | undefined = inspection\n ? []\n : undefined;\n const batches: {\n stem: Path2D;\n openTick: Path2D;\n closeTick: Path2D;\n stroke: StrokeStyle;\n strokeWidth: number;\n opacity: number;\n cursor: string | undefined;\n minX: number;\n maxX: number;\n }[] = [];\n for (const row of rows) {\n const style =\n typeof specified === \"function\"\n ? withHooksForbidden(\"OhlcBarSeries style callback\", () =>\n specified(row.datum, row.sourceIndex, data),\n )\n : (specified ?? {});\n const markWidth =\n style.bandwidth === undefined || style.bandwidth === \"auto\"\n ? defaultWidth\n : financialMarkWidth([], { width: style.bandwidth });\n const halfWidth = markWidth / 2;\n const stemLocal = Object.freeze({\n x: row.x,\n highY: ys.map(row.high),\n lowY: ys.map(row.low),\n });\n const openTickLocal = Object.freeze({\n x1: row.x - halfWidth,\n x2: row.x,\n y: ys.map(row.open),\n });\n const closeTickLocal = Object.freeze({\n x1: row.x,\n x2: row.x + halfWidth,\n y: ys.map(row.close),\n });\n const stroke = style.stroke ?? \"#173a35\",\n strokeWidth = width(style.strokeWidth ?? 1, \"OhlcBarSeries\"),\n alpha = opacity(style.opacity ?? 1, \"OhlcBarSeries\");\n marks?.push(\n Object.freeze({\n datum: row.datum,\n sourceIndex: row.sourceIndex,\n time: row.time,\n open: row.open,\n high: row.high,\n low: row.low,\n close: row.close,\n anchorLocal: Object.freeze({ x: row.x, y: closeTickLocal.y }),\n stemLocal,\n openTickLocal,\n closeTickLocal,\n strokeWidthLocal: stroke && alpha > 0 ? strokeWidth : 0,\n }),\n );\n if (alpha === 0 || !stroke) continue;\n const xPad = strokeWidth / 2,\n minX = row.x - halfWidth - xPad,\n maxX = row.x + halfWidth + xPad;\n let batch = batches.at(-1);\n if (\n !batch ||\n (minX < batch.maxX && maxX > batch.minX) ||\n batch.stroke !== stroke ||\n batch.strokeWidth !== strokeWidth ||\n batch.opacity !== alpha ||\n batch.cursor !== style.cursor\n ) {\n batch = {\n stem: new Path2D(),\n openTick: new Path2D(),\n closeTick: new Path2D(),\n stroke,\n strokeWidth,\n opacity: alpha,\n cursor: style.cursor,\n minX,\n maxX,\n };\n batches.push(batch);\n }\n batch.minX = Math.min(batch.minX, minX);\n batch.maxX = Math.max(batch.maxX, maxX);\n batch.stem.moveTo(stemLocal.x, stemLocal.highY);\n batch.stem.lineTo(stemLocal.x, stemLocal.lowY);\n batch.openTick.moveTo(openTickLocal.x1, openTickLocal.y);\n batch.openTick.lineTo(openTickLocal.x2, openTickLocal.y);\n batch.closeTick.moveTo(closeTickLocal.x1, closeTickLocal.y);\n batch.closeTick.lineTo(closeTickLocal.x2, closeTickLocal.y);\n }\n inspection?.capture({ marks: marks!, xScale: xs, yScale: ys });\n return (\n <Group {...events}>\n {batches.map((batch, index) => (\n <Group key={index}>\n <Path\n pointerEvents={pointerEvents}\n style={{\n d: batch.stem,\n stroke: batch.stroke,\n strokeWidth: batch.strokeWidth,\n opacity: batch.opacity,\n cursor: batch.cursor,\n }}\n />\n <Path\n pointerEvents={pointerEvents}\n style={{\n d: batch.openTick,\n stroke: batch.stroke,\n strokeWidth: batch.strokeWidth,\n opacity: batch.opacity,\n cursor: batch.cursor,\n }}\n />\n <Path\n pointerEvents={pointerEvents}\n style={{\n d: batch.closeTick,\n stroke: batch.stroke,\n strokeWidth: batch.strokeWidth,\n opacity: batch.opacity,\n cursor: batch.cursor,\n }}\n />\n </Group>\n ))}\n </Group>\n );\n}\n"],
|
|
5
|
+
"mappings": "AAuPQ,SACE,KADF;AAvPR;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAMK;AACP,SAAS,0BAA0B;AAKnC,SAAS,0BAA0B;AACnC,SAAS,SAAS,aAAa;AAC/B,SAAS,kBAAkB,eAAe,iBAAiB;AAC3D,SAAS,0BAA0B;AAEnC,SAAS,0BAA0B;AA2D5B,SAAS,cAAiB;AAAA,EAC/B,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAqC;AACnC,QAAM,KAAK,mBAAmB,MAAM,GAClC,KAAK,mBAAmB,MAAM,EAAE,IAAI;AACtC,QAAM,OAAO,UAAU,mBAAmB,KAAK,GAAG,eAAe;AACjE,QAAM,OAAO,cAAc,SAAS,GAClC,OAAO,cAAc,SAAS,GAC9B,OAAO,cAAc,SAAS,GAC9B,MAAM,cAAc,QAAQ,GAC5B,QAAQ,cAAc,UAAU;AAClC,QAAM,OASA,CAAC;AACP,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAM,QAAQ,KAAK,CAAC;AACpB,QAAI,WAAW,CAAC,QAAQ,OAAO,GAAG,IAAI,EAAG;AACzC,UAAM,IAAI,KAAK,OAAO,GAAG,IAAI,GAC3B,IAAI,KAAK,OAAO,GAAG,IAAI,GACvB,IAAI,KAAK,OAAO,GAAG,IAAI,GACvB,IAAI,IAAI,OAAO,GAAG,IAAI,GACtB,IAAI,MAAM,OAAO,GAAG,IAAI;AAC1B,QACE,CAAC,i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ptions, SignalValue } from "@pibbl/core";
|
|
2
|
+
import type { SignalStyle } from "@pibbl/core/internal";
|
|
3
|
+
import type { LineAccessor, ScaleId, SeriesCoordinate } from "./types.js";
|
|
4
|
+
import type { TrajectorySeriesStyle } from "./trajectory-series.js";
|
|
5
|
+
/** Shared connector appearance for {@link PairedSeries}. */
|
|
6
|
+
export type PairedSeriesStyle = TrajectorySeriesStyle;
|
|
7
|
+
/** Authored wide-record inputs for {@link PairedSeries}. */
|
|
8
|
+
export interface PairedSeriesProps<D> extends PibblEventHandlers, PibblEventParticipationOptions {
|
|
9
|
+
/** Source records or a signal containing them. */
|
|
10
|
+
readonly data: SignalValue<readonly D[]>;
|
|
11
|
+
/** Numeric baseline or first-observation value. */
|
|
12
|
+
readonly before: LineAccessor<D>;
|
|
13
|
+
/** Numeric follow-up or second-observation value. */
|
|
14
|
+
readonly after: LineAccessor<D>;
|
|
15
|
+
/** Fixed x coordinate used for every `before` endpoint. */
|
|
16
|
+
readonly beforeX: SeriesCoordinate;
|
|
17
|
+
/** Fixed x coordinate used for every `after` endpoint. */
|
|
18
|
+
readonly afterX: SeriesCoordinate;
|
|
19
|
+
/** Scale mapping the two endpoint coordinates. */
|
|
20
|
+
readonly xScale: ScaleId;
|
|
21
|
+
/** Numeric scale mapping both endpoint values. */
|
|
22
|
+
readonly yScale: ScaleId;
|
|
23
|
+
/**
|
|
24
|
+
* Excludes a record before before/after accessors run.
|
|
25
|
+
* @param datum - Candidate source datum.
|
|
26
|
+
* @param index - Zero-based source index.
|
|
27
|
+
* @param data - Complete source data array.
|
|
28
|
+
* @returns Whether this record contributes a connector.
|
|
29
|
+
*/
|
|
30
|
+
readonly defined?: (datum: D, index: number, data: readonly D[]) => boolean;
|
|
31
|
+
/** Shared connector style, including whole-object and shallow field signals. */
|
|
32
|
+
readonly style?: SignalValue<SignalStyle<PairedSeriesStyle>>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Draws a connector for each complete wide-record before/after pair.
|
|
36
|
+
*
|
|
37
|
+
* The component does not manufacture point marks, calculate change, select a
|
|
38
|
+
* baseline, or impute missing observations. Compose `PointSeries` for endpoints.
|
|
39
|
+
*
|
|
40
|
+
* @param props - Wide records, endpoint accessors and coordinates, scales, and shared paint.
|
|
41
|
+
* @returns One batched ordinary Pibbl path containing source-ordered pair connectors.
|
|
42
|
+
* @see {@link PairedSeriesProps}
|
|
43
|
+
*/
|
|
44
|
+
export declare function PairedSeries<D>({ data: input, before: beforeInput, after: afterInput, beforeX, afterX, xScale: xId, yScale: yId, defined, style: styleInput, ...events }: PairedSeriesProps<D>): import("../../../jsx-runtime.js").JSX.Element;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { jsx } from "@pibbl/core/jsx-runtime";
|
|
2
|
+
import { Path, resolveSignalValue } from "@pibbl/core";
|
|
3
|
+
import { withHooksForbidden } from "@pibbl/core/internal";
|
|
4
|
+
import { pointAccessor, pointData } from "./point-data.js";
|
|
5
|
+
import { opacity, width } from "./paint.js";
|
|
6
|
+
import {
|
|
7
|
+
mapSeriesPosition,
|
|
8
|
+
useNumericPosition,
|
|
9
|
+
useSeriesPosition
|
|
10
|
+
} from "./series-position.js";
|
|
11
|
+
function style(input) {
|
|
12
|
+
if (input === null || typeof input !== "object" || Array.isArray(input))
|
|
13
|
+
throw new TypeError("PairedSeries: style must be an object.");
|
|
14
|
+
const value = input;
|
|
15
|
+
for (const field of Object.keys(value))
|
|
16
|
+
if (![
|
|
17
|
+
"stroke",
|
|
18
|
+
"strokeWidth",
|
|
19
|
+
"lineInteractionWidth",
|
|
20
|
+
"opacity",
|
|
21
|
+
"cursor"
|
|
22
|
+
].includes(field))
|
|
23
|
+
throw new TypeError(`PairedSeries: unsupported style field ${field}.`);
|
|
24
|
+
const stroke = resolveSignalValue(value.stroke) ?? "#2563eb";
|
|
25
|
+
const strokeWidth = width(
|
|
26
|
+
resolveSignalValue(value.strokeWidth) ?? 2,
|
|
27
|
+
"PairedSeries strokeWidth"
|
|
28
|
+
);
|
|
29
|
+
const lineInteractionWidth = width(
|
|
30
|
+
resolveSignalValue(value.lineInteractionWidth) ?? strokeWidth,
|
|
31
|
+
"PairedSeries lineInteractionWidth"
|
|
32
|
+
);
|
|
33
|
+
const cursor = resolveSignalValue(value.cursor);
|
|
34
|
+
if (cursor !== void 0 && typeof cursor !== "string")
|
|
35
|
+
throw new TypeError("PairedSeries: cursor must be a string.");
|
|
36
|
+
return {
|
|
37
|
+
stroke,
|
|
38
|
+
strokeWidth,
|
|
39
|
+
lineInteractionWidth,
|
|
40
|
+
opacity: opacity(
|
|
41
|
+
resolveSignalValue(value.opacity) ?? 1,
|
|
42
|
+
"PairedSeries opacity"
|
|
43
|
+
),
|
|
44
|
+
cursor
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function PairedSeries({
|
|
48
|
+
data: input,
|
|
49
|
+
before: beforeInput,
|
|
50
|
+
after: afterInput,
|
|
51
|
+
beforeX,
|
|
52
|
+
afterX,
|
|
53
|
+
xScale: xId,
|
|
54
|
+
yScale: yId,
|
|
55
|
+
defined,
|
|
56
|
+
style: styleInput,
|
|
57
|
+
...events
|
|
58
|
+
}) {
|
|
59
|
+
const xs = useSeriesPosition(xId);
|
|
60
|
+
const ys = useNumericPosition(yId);
|
|
61
|
+
const data = pointData(resolveSignalValue(input), "PairedSeries");
|
|
62
|
+
const before = pointAccessor(beforeInput);
|
|
63
|
+
const after = pointAccessor(afterInput);
|
|
64
|
+
const startX = mapSeriesPosition(xs, beforeX);
|
|
65
|
+
const endX = mapSeriesPosition(xs, afterX);
|
|
66
|
+
const resolved = style(resolveSignalValue(styleInput) ?? {});
|
|
67
|
+
const path = new Path2D();
|
|
68
|
+
if (startX !== void 0 && endX !== void 0)
|
|
69
|
+
for (let i = 0; i < data.length; i++) {
|
|
70
|
+
const datum = data[i];
|
|
71
|
+
const row = withHooksForbidden(
|
|
72
|
+
"PairedSeries: accessors cannot call hooks.",
|
|
73
|
+
() => {
|
|
74
|
+
if (defined && !defined(datum, i, data)) return void 0;
|
|
75
|
+
return {
|
|
76
|
+
before: before(datum, i, data),
|
|
77
|
+
after: after(datum, i, data)
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
if (!row) continue;
|
|
82
|
+
const startY = mapSeriesPosition(ys, row.before);
|
|
83
|
+
const endY = mapSeriesPosition(ys, row.after);
|
|
84
|
+
if (startY === void 0 || endY === void 0) continue;
|
|
85
|
+
path.moveTo(startX, startY);
|
|
86
|
+
path.lineTo(endX, endY);
|
|
87
|
+
}
|
|
88
|
+
return /* @__PURE__ */ jsx(Path, { ...events, style: { d: path, ...resolved } });
|
|
89
|
+
}
|
|
90
|
+
export {
|
|
91
|
+
PairedSeries
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=paired-series.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/features/viz/lib/paired-series.tsx"],
|
|
4
|
+
"sourcesContent": ["import { Path, resolveSignalValue } from \"@pibbl/core\";\nimport type {\n PibblEventHandlers,\n PibblEventParticipationOptions,\n SignalValue,\n StrokeStyle,\n} from \"@pibbl/core\";\nimport { withHooksForbidden } from \"@pibbl/core/internal\";\nimport type { SignalStyle } from \"@pibbl/core/internal\";\nimport type { LineAccessor, ScaleId, SeriesCoordinate } from \"./types.js\";\nimport type { TrajectorySeriesStyle } from \"./trajectory-series.js\";\nimport { pointAccessor, pointData } from \"./point-data.js\";\nimport { opacity, width } from \"./paint.js\";\nimport {\n mapSeriesPosition,\n useNumericPosition,\n useSeriesPosition,\n} from \"./series-position.js\";\n\n/** Shared connector appearance for {@link PairedSeries}. */\nexport type PairedSeriesStyle = TrajectorySeriesStyle;\n\n/** Authored wide-record inputs for {@link PairedSeries}. */\nexport interface PairedSeriesProps<D>\n extends PibblEventHandlers, PibblEventParticipationOptions {\n /** Source records or a signal containing them. */\n readonly data: SignalValue<readonly D[]>;\n /** Numeric baseline or first-observation value. */\n readonly before: LineAccessor<D>;\n /** Numeric follow-up or second-observation value. */\n readonly after: LineAccessor<D>;\n /** Fixed x coordinate used for every `before` endpoint. */\n readonly beforeX: SeriesCoordinate;\n /** Fixed x coordinate used for every `after` endpoint. */\n readonly afterX: SeriesCoordinate;\n /** Scale mapping the two endpoint coordinates. */\n readonly xScale: ScaleId;\n /** Numeric scale mapping both endpoint values. */\n readonly yScale: ScaleId;\n /**\n * Excludes a record before before/after accessors run.\n * @param datum - Candidate source datum.\n * @param index - Zero-based source index.\n * @param data - Complete source data array.\n * @returns Whether this record contributes a connector.\n */\n readonly defined?: (datum: D, index: number, data: readonly D[]) => boolean;\n /** Shared connector style, including whole-object and shallow field signals. */\n readonly style?: SignalValue<SignalStyle<PairedSeriesStyle>>;\n}\n\ninterface ResolvedPairedStyle {\n readonly stroke: StrokeStyle;\n readonly strokeWidth: number;\n readonly lineInteractionWidth: number;\n readonly opacity: number;\n readonly cursor?: string;\n}\n\nfunction style(input: unknown): ResolvedPairedStyle {\n if (input === null || typeof input !== \"object\" || Array.isArray(input))\n throw new TypeError(\"PairedSeries: style must be an object.\");\n const value = input as Record<string, unknown>;\n for (const field of Object.keys(value))\n if (\n ![\n \"stroke\",\n \"strokeWidth\",\n \"lineInteractionWidth\",\n \"opacity\",\n \"cursor\",\n ].includes(field)\n )\n throw new TypeError(`PairedSeries: unsupported style field ${field}.`);\n const stroke = resolveSignalValue(value.stroke) ?? \"#2563eb\";\n const strokeWidth = width(\n (resolveSignalValue(value.strokeWidth) ?? 2) as number,\n \"PairedSeries strokeWidth\",\n );\n const lineInteractionWidth = width(\n (resolveSignalValue(value.lineInteractionWidth) ?? strokeWidth) as number,\n \"PairedSeries lineInteractionWidth\",\n );\n const cursor = resolveSignalValue(value.cursor);\n if (cursor !== undefined && typeof cursor !== \"string\")\n throw new TypeError(\"PairedSeries: cursor must be a string.\");\n return {\n stroke: stroke as StrokeStyle,\n strokeWidth,\n lineInteractionWidth,\n opacity: opacity(\n (resolveSignalValue(value.opacity) ?? 1) as number,\n \"PairedSeries opacity\",\n ),\n cursor,\n };\n}\n\n/**\n * Draws a connector for each complete wide-record before/after pair.\n *\n * The component does not manufacture point marks, calculate change, select a\n * baseline, or impute missing observations. Compose `PointSeries` for endpoints.\n *\n * @param props - Wide records, endpoint accessors and coordinates, scales, and shared paint.\n * @returns One batched ordinary Pibbl path containing source-ordered pair connectors.\n * @see {@link PairedSeriesProps}\n */\nexport function PairedSeries<D>({\n data: input,\n before: beforeInput,\n after: afterInput,\n beforeX,\n afterX,\n xScale: xId,\n yScale: yId,\n defined,\n style: styleInput,\n ...events\n}: PairedSeriesProps<D>) {\n const xs = useSeriesPosition(xId);\n const ys = useNumericPosition(yId);\n const data = pointData(resolveSignalValue(input), \"PairedSeries\");\n const before = pointAccessor(beforeInput);\n const after = pointAccessor(afterInput);\n const startX = mapSeriesPosition(xs, beforeX);\n const endX = mapSeriesPosition(xs, afterX);\n const resolved = style(resolveSignalValue(styleInput) ?? {});\n const path = new Path2D();\n if (startX !== undefined && endX !== undefined)\n for (let i = 0; i < data.length; i++) {\n const datum = data[i];\n const row = withHooksForbidden(\n \"PairedSeries: accessors cannot call hooks.\",\n () => {\n if (defined && !defined(datum, i, data)) return undefined;\n return {\n before: before(datum, i, data),\n after: after(datum, i, data),\n };\n },\n );\n if (!row) continue;\n const startY = mapSeriesPosition(ys, row.before);\n const endY = mapSeriesPosition(ys, row.after);\n if (startY === undefined || endY === undefined) continue;\n path.moveTo(startX, startY);\n path.lineTo(endX, endY);\n }\n return <Path {...events} style={{ d: path, ...resolved }} />;\n}\n"],
|
|
5
|
+
"mappings": "AAqJS;AArJT,SAAS,MAAM,0BAA0B;AAOzC,SAAS,0BAA0B;AAInC,SAAS,eAAe,iBAAiB;AACzC,SAAS,SAAS,aAAa;AAC/B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA0CP,SAAS,MAAM,OAAqC;AAClD,MAAI,UAAU,QAAQ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CAAC;AAC3D,QAAM,OAAO,IAAI,OAAO;AACxB,MAAI,WAAW,UAAa,SAAS;AACnC,aAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,YAAM,QAAQ,KAAK,CAAC;AACpB,YAAM,MAAM;AAAA,QACV;AAAA,QACA,MAAM;AACJ,cAAI,WAAW,CAAC,QAAQ,OAAO,GAAG,IAAI,EAAG,QAAO;AAChD,iBAAO;AAAA,YACL,QAAQ,OAAO,OAAO,GAAG,IAAI;AAAA,YAC7B,OAAO,MAAM,OAAO,GAAG,IAAI;AAAA,UAC7B;AAAA,QACF;AAAA,MACF;AACA,UAAI,CAAC,IAAK;AACV,YAAM,SAAS,kBAAkB,IAAI,IAAI,MAAM;AAC/C,YAAM,OAAO,kBAAkB,IAAI,IAAI,KAAK;AAC5C,UAAI,WAAW,UAAa,SAAS,OAAW;AAChD,WAAK,OAAO,QAAQ,MAAM;AAC1B,WAAK,OAAO,MAAM,IAAI;AAAA,IACxB;AACF,SAAO,oBAAC,QAAM,GAAG,QAAQ,OAAO,EAAE,GAAG,MAAM,GAAG,SAAS,GAAG;AAC5D;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -214,7 +214,8 @@ function annularSliceBounds(slice, sweep) {
|
|
|
214
214
|
height: slice.radius * 2
|
|
215
215
|
};
|
|
216
216
|
const angles = [sweep.startAngle, sweep.endAngle];
|
|
217
|
-
for (
|
|
217
|
+
for (let cardinalIndex = 0; cardinalIndex < 4; cardinalIndex++) {
|
|
218
|
+
const cardinal = cardinalIndex * (Math.PI / 2);
|
|
218
219
|
const angle = cardinal < sweep.startAngle ? cardinal + fullTurn : cardinal;
|
|
219
220
|
if (angle <= sweep.endAngle) angles.push(angle);
|
|
220
221
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/features/viz/lib/pie-layout.tsx"],
|
|
4
|
-
"sourcesContent": ["import {\n Group,\n Path,\n Wedge,\n definePrimitive,\n Line,\n Rectangle,\n resolveSignalValue,\n useComputed,\n useCanvasContext,\n useLayoutBox,\n} from \"@pibbl/core\";\nimport { resolveTexturePaint, withHooksForbidden } from \"@pibbl/core/internal\";\nimport type {\n PieLayoutProps,\n PieLayoutSlice,\n PieSliceProps,\n PieLabelProps,\n PieLabelLayout,\n} from \"./pie-types.js\";\nimport { pieSlices } from \"./pie-slices.js\";\nimport { layoutPie } from \"./layout-pie.js\";\nfunction finite(value: number, name: string, nonnegative = false) {\n if (!Number.isFinite(value) || (nonnegative && value < 0))\n throw new RangeError(\n `PieLayout: ${name} must be finite${nonnegative ? \" and nonnegative\" : \"\"}.`,\n );\n return value;\n}\n/**\n * Computes pie geometry and label placement, then renders children for each resolved slice.\n *\n * @param props - Data, pie geometry, label policy, and child renderer. See {@link PieLayoutProps}.\n * @returns Pibbl content arranged as pie slices.\n *\n * @see {@link PieLayoutProps}\n */\nexport function PieLayout<D>(props: PieLayoutProps<D>) {\n const allocation = useLayoutBox();\n const context = useCanvasContext();\n const style = resolveSignalValue(props.style) ?? {};\n const bounds = resolveSignalValue(props.bounds) ?? {\n x: 0,\n y: 0,\n width: allocation.width,\n height: allocation.height,\n };\n const bx = finite(bounds.x, \"bounds.x\"),\n by = finite(bounds.y, \"bounds.y\");\n const bw = finite(bounds.width, \"bounds.width\", true),\n bh = finite(bounds.height, \"bounds.height\", true);\n finite(bx + bw, \"bounds right\");\n finite(by + bh, \"bounds bottom\");\n const cx = finite(resolveSignalValue(style.cx) ?? bx + bw / 2, \"cx\");\n const cy = finite(resolveSignalValue(style.cy) ?? by + bh / 2, \"cy\");\n const radius = finite(\n resolveSignalValue(style.radius) ?? Math.min(bw * 0.28, bh * 0.4),\n \"radius\",\n true,\n );\n const innerRadius = finite(\n resolveSignalValue(style.innerRadius) ?? 0,\n \"innerRadius\",\n true,\n );\n if (radius === 0 ? innerRadius !== 0 : innerRadius >= radius)\n throw new RangeError(\n \"PieLayout: innerRadius must be zero when radius is zero, or less than radius.\",\n );\n const gap = finite(resolveSignalValue(style.labelGap) ?? 8, \"labelGap\", true);\n finite(cx + radius + gap, \"right label edge\");\n finite(cx - radius - gap, \"left label edge\");\n finite(cy + radius, \"bottom\");\n finite(cy - radius, \"top\");\n const font = resolveSignalValue(style.labelFont) ?? \"14px sans-serif\";\n if (typeof font !== \"string\" || !font.trim())\n throw new TypeError(\"PieLayout: labelFont must be a Canvas font string.\");\n const placement = resolveSignalValue(props.placement) ?? \"outside\";\n if (![\"inside\", \"outside\", \"auto\"].includes(placement))\n throw new TypeError(\n \"PieLayout: placement must be inside, outside, or auto.\",\n );\n if (typeof props.children !== \"function\")\n throw new TypeError(\n \"PieLayout: children must be a function returning Pibbl elements.\",\n );\n const revision =\n props.revision === undefined ? undefined : resolveSignalValue(props.revision);\n if (\n revision !== undefined &&\n (!Number.isSafeInteger(revision) || revision < 0)\n )\n throw new RangeError(\n \"PieLayout: revision must be a finite nonnegative safe integer.\",\n );\n // An omitted revision deliberately replaces this token on every evaluation.\n // Stable callback identities alone are not evidence of stable results.\n const cacheKey = revision === undefined ? {} : revision;\n const slices = useComputed(\n () =>\n pieSlices(resolveSignalValue(props.data), {\n value: props.value,\n keyBy: props.keyBy,\n }),\n [cacheKey, props.data, props.value, props.keyBy],\n );\n const layout = useComputed(() => {\n context.save();\n try {\n // Canvas silently ignores malformed fonts. Two distinct sentinels detect\n // that without depending on the caller's inherited font or CSS spelling.\n context.font = \"10px serif\";\n context.font = font;\n const normalized = context.font;\n context.font = \"11px monospace\";\n context.font = font;\n if (context.font !== normalized)\n throw new TypeError(\"PieLayout: labelFont must be a valid Canvas font.\");\n context.textAlign = \"left\";\n context.textBaseline = \"alphabetic\";\n return layoutPie(\n slices.get(),\n cx,\n cy,\n radius,\n innerRadius,\n { x: bx, y: by, width: bw, height: bh },\n context.font,\n gap,\n placement,\n props.label,\n (text) => {\n const m = context.measureText(text);\n const width = Math.max(\n m.width,\n m.actualBoundingBoxLeft + m.actualBoundingBoxRight,\n );\n const ascent = Math.max(0, m.actualBoundingBoxAscent),\n descent = Math.max(0, m.actualBoundingBoxDescent);\n return {\n width: finite(width, \"label width\", true),\n height: finite(Math.max(1, ascent + descent), \"label height\", true),\n left: Math.max(0, m.actualBoundingBoxLeft),\n ascent,\n };\n },\n );\n } finally {\n context.restore();\n }\n }, [\n slices,\n cx,\n cy,\n radius,\n innerRadius,\n bx,\n by,\n bw,\n bh,\n font,\n gap,\n placement,\n props.label,\n context,\n ]);\n return layout\n .get()\n .map((slice) => (\n <Group key={slice.key}>\n {withHooksForbidden(\n \"PieLayout children cannot call hooks; return a component instead.\",\n () => props.children(slice),\n )}\n </Group>\n ));\n}\n/**\n * Draws a resolved pie slice using wedge geometry and the supplied paint style.\n *\n * @param props - Slice geometry, appearance, handlers, and children. See {@link PieSliceProps}.\n * @returns Pibbl nodes drawing one pie slice and its children.\n *\n * @see {@link PieSliceProps}\n */\nexport function PieSlice<D>({\n slice,\n style: input,\n children,\n ...events\n}: PieSliceProps<D>) {\n const style = resolveSignalValue(input) ?? {};\n if (slice.innerRadius === 0) {\n return (\n <Group>\n <Wedge\n {...events}\n style={{\n ...style,\n cx: slice.cx,\n cy: slice.cy,\n radius: slice.radius,\n startAngle: slice.startAngle,\n endAngle: slice.endAngle,\n }}\n />\n {children}\n </Group>\n );\n }\n const sweep = resolveClockwiseSweep(slice.startAngle, slice.endAngle);\n const path = new Path2D();\n path.arc(\n slice.cx,\n slice.cy,\n slice.radius,\n sweep.startAngle,\n sweep.endAngle,\n );\n if (slice.innerRadius > 0)\n path.arc(\n slice.cx,\n slice.cy,\n slice.innerRadius,\n sweep.endAngle,\n sweep.startAngle,\n true,\n );\n else path.lineTo(slice.cx, slice.cy);\n path.closePath();\n return (\n <Group>\n <Path\n {...events}\n keyboardNavigationBounds={\n events.keyboardNavigationBounds ??\n annularSliceBounds(slice, sweep)\n }\n style={{\n ...style,\n d: path,\n }}\n />\n {children}\n </Group>\n );\n}\n\n/** The outer and inner arcs both contribute to an annular path's focus box. */\nfunction annularSliceBounds(\n slice: PieLayoutSlice<unknown>,\n sweep: Readonly<ClockwiseSweep>,\n) {\n if (sweep.sweep === 0) return undefined;\n if (sweep.fullCircle)\n return {\n x: slice.cx - slice.radius,\n y: slice.cy - slice.radius,\n width: slice.radius * 2,\n height: slice.radius * 2,\n };\n const angles = [sweep.startAngle, sweep.endAngle];\n for (const cardinal of [0, Math.PI / 2, Math.PI, Math.PI * 1.5]) {\n const angle = cardinal < sweep.startAngle ? cardinal + fullTurn : cardinal;\n if (angle <= sweep.endAngle) angles.push(angle);\n }\n const xs: number[] = [];\n const ys: number[] = [];\n for (const angle of angles) {\n const cosine = Math.cos(angle);\n const sine = Math.sin(angle);\n xs.push(\n slice.cx + slice.radius * cosine,\n slice.cx + slice.innerRadius * cosine,\n );\n ys.push(\n slice.cy + slice.radius * sine,\n slice.cy + slice.innerRadius * sine,\n );\n }\n const left = Math.min(...xs);\n const right = Math.max(...xs);\n const top = Math.min(...ys);\n const bottom = Math.max(...ys);\n return { x: left, y: top, width: right - left, height: bottom - top };\n}\n\nconst fullTurn = Math.PI * 2;\n\ninterface ClockwiseSweep {\n readonly startAngle: number;\n readonly endAngle: number;\n readonly sweep: number;\n readonly fullCircle: boolean;\n}\n\n/** Matches Canvas's bounded clockwise arc rule without retaining unbounded turns. */\nfunction resolveClockwiseSweep(\n startAngle: number,\n endAngle: number,\n): ClockwiseSweep {\n if (!Number.isFinite(startAngle) || !Number.isFinite(endAngle))\n throw new RangeError(\"PieSlice: slice angles must be finite.\");\n const start = positiveModulo(startAngle, fullTurn);\n if (endAngle - startAngle >= fullTurn)\n return {\n startAngle: start,\n endAngle: start + fullTurn,\n sweep: fullTurn,\n fullCircle: true,\n };\n const sweep = positiveModulo(\n positiveModulo(endAngle, fullTurn) - start,\n fullTurn,\n );\n return {\n startAngle: start,\n endAngle: start + sweep,\n sweep,\n fullCircle: false,\n };\n}\n\nfunction positiveModulo(value: number, divisor: number) {\n const result = value % divisor;\n if (result === 0) return 0;\n return result < 0 ? result + divisor : result;\n}\n\nconst LabelText = definePrimitive<\n { label: Extract<PieLabelLayout, { status: \"placed\" }> },\n { readonly custom?: never; fill: import(\"@pibbl/core\").FillStyle }\n>(({ label }, style, context) => {\n context.font = label.font;\n context.textAlign = \"left\";\n context.textBaseline = \"alphabetic\";\n context.fillStyle = resolveTexturePaint(style.fill, context, { x: label.x, y: label.y, width: label.width, height: label.height });\n context.fillText(label.text, label.textX, label.textY);\n});\n\n/**\n * Draws a resolved slice label and optional leader line; decorative labels ignore pointer\n * targeting\n * by default.\n *\n * @param props - Slice geometry, label appearance, and interaction options. See\n * {@link PieLabelProps} .\n * @returns Pibbl content drawing the slice label, or null when the label was not placed.\n *\n * @see {@link PieLabelProps}\n */\nexport function PieLabel<D>({\n slice,\n style: input,\n pointerEvents = \"none\",\n ...events\n}: PieLabelProps<D>) {\n const style = resolveSignalValue(input) ?? {};\n const label = slice.label;\n if (!label || label.status !== \"placed\") return null;\n return (\n <Group {...events}>\n {label.leader && (\n <Line\n pointerEvents=\"none\"\n style={{\n coords: label.leader.map((p) => [p[0], p[1]]),\n stroke: resolveSignalValue(style.leaderStroke) ?? \"#94a3b8\",\n strokeWidth: resolveSignalValue(style.leaderWidth) ?? 1,\n }}\n />\n )}\n <Rectangle\n pointerEvents={pointerEvents}\n style={{\n left: label.x,\n top: label.y,\n width: label.width,\n height: label.height,\n fill: \"transparent\",\n }}\n />\n <LabelText\n label={label}\n style={{ fill: resolveSignalValue(style.fill) ?? \"#182c42\" }}\n />\n </Group>\n );\n}\n"],
|
|
5
|
-
"mappings": "AAyKM,cAyBA,YAzBA;AAzKN;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,qBAAqB,0BAA0B;AAQxD,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAA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AM;AAAA,YACV,IAAI,MAAM;AAAA,YACV,QAAQ,MAAM;AAAA,YACd,YAAY,MAAM;AAAA,YAClB,UAAU,MAAM;AAAA,UAClB;AAAA;AAAA,MACF;AAAA,MACC;AAAA,OACH;AAAA,EAEJ;AACA,QAAM,QAAQ,sBAAsB,MAAM,YAAY,MAAM,QAAQ;AACpE,QAAM,OAAO,IAAI,OAAO;AACxB,OAAK;AAAA,IACH,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,EACR;AACA,MAAI,MAAM,cAAc;AACtB,SAAK;AAAA,MACH,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN;AAAA,IACF;AAAA,MACG,MAAK,OAAO,MAAM,IAAI,MAAM,EAAE;AACnC,OAAK,UAAU;AACf,SACE,qBAAC,SACC;AAAA;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACJ,0BACE,OAAO,4BACP,mBAAmB,OAAO,KAAK;AAAA,QAEjC,OAAO;AAAA,UACL,GAAG;AAAA,UACH,GAAG;AAAA,QACL;AAAA;AAAA,IACF;AAAA,IACC;AAAA,KACH;AAEJ;AAGA,SAAS,mBACP,OACA,OACA;AACA,MAAI,MAAM,UAAU,EAAG,QAAO;AAC9B,MAAI,MAAM;AACR,WAAO;AAAA,MACL,GAAG,MAAM,KAAK,MAAM;AAAA,MACpB,GAAG,MAAM,KAAK,MAAM;AAAA,MACpB,OAAO,MAAM,SAAS;AAAA,MACtB,QAAQ,MAAM,SAAS;AAAA,IACzB;AACF,QAAM,SAAS,CAAC,MAAM,YAAY,MAAM,QAAQ;AAChD,
|
|
4
|
+
"sourcesContent": ["import {\n Group,\n Path,\n Wedge,\n definePrimitive,\n Line,\n Rectangle,\n resolveSignalValue,\n useComputed,\n useCanvasContext,\n useLayoutBox,\n} from \"@pibbl/core\";\nimport { resolveTexturePaint, withHooksForbidden } from \"@pibbl/core/internal\";\nimport type {\n PieLayoutProps,\n PieLayoutSlice,\n PieSliceProps,\n PieLabelProps,\n PieLabelLayout,\n} from \"./pie-types.js\";\nimport { pieSlices } from \"./pie-slices.js\";\nimport { layoutPie } from \"./layout-pie.js\";\nfunction finite(value: number, name: string, nonnegative = false) {\n if (!Number.isFinite(value) || (nonnegative && value < 0))\n throw new RangeError(\n `PieLayout: ${name} must be finite${nonnegative ? \" and nonnegative\" : \"\"}.`,\n );\n return value;\n}\n/**\n * Computes pie geometry and label placement, then renders children for each resolved slice.\n *\n * @param props - Data, pie geometry, label policy, and child renderer. See {@link PieLayoutProps}.\n * @returns Pibbl content arranged as pie slices.\n *\n * @see {@link PieLayoutProps}\n */\nexport function PieLayout<D>(props: PieLayoutProps<D>) {\n const allocation = useLayoutBox();\n const context = useCanvasContext();\n const style = resolveSignalValue(props.style) ?? {};\n const bounds = resolveSignalValue(props.bounds) ?? {\n x: 0,\n y: 0,\n width: allocation.width,\n height: allocation.height,\n };\n const bx = finite(bounds.x, \"bounds.x\"),\n by = finite(bounds.y, \"bounds.y\");\n const bw = finite(bounds.width, \"bounds.width\", true),\n bh = finite(bounds.height, \"bounds.height\", true);\n finite(bx + bw, \"bounds right\");\n finite(by + bh, \"bounds bottom\");\n const cx = finite(resolveSignalValue(style.cx) ?? bx + bw / 2, \"cx\");\n const cy = finite(resolveSignalValue(style.cy) ?? by + bh / 2, \"cy\");\n const radius = finite(\n resolveSignalValue(style.radius) ?? Math.min(bw * 0.28, bh * 0.4),\n \"radius\",\n true,\n );\n const innerRadius = finite(\n resolveSignalValue(style.innerRadius) ?? 0,\n \"innerRadius\",\n true,\n );\n if (radius === 0 ? innerRadius !== 0 : innerRadius >= radius)\n throw new RangeError(\n \"PieLayout: innerRadius must be zero when radius is zero, or less than radius.\",\n );\n const gap = finite(resolveSignalValue(style.labelGap) ?? 8, \"labelGap\", true);\n finite(cx + radius + gap, \"right label edge\");\n finite(cx - radius - gap, \"left label edge\");\n finite(cy + radius, \"bottom\");\n finite(cy - radius, \"top\");\n const font = resolveSignalValue(style.labelFont) ?? \"14px sans-serif\";\n if (typeof font !== \"string\" || !font.trim())\n throw new TypeError(\"PieLayout: labelFont must be a Canvas font string.\");\n const placement = resolveSignalValue(props.placement) ?? \"outside\";\n if (![\"inside\", \"outside\", \"auto\"].includes(placement))\n throw new TypeError(\n \"PieLayout: placement must be inside, outside, or auto.\",\n );\n if (typeof props.children !== \"function\")\n throw new TypeError(\n \"PieLayout: children must be a function returning Pibbl elements.\",\n );\n const revision =\n props.revision === undefined ? undefined : resolveSignalValue(props.revision);\n if (\n revision !== undefined &&\n (!Number.isSafeInteger(revision) || revision < 0)\n )\n throw new RangeError(\n \"PieLayout: revision must be a finite nonnegative safe integer.\",\n );\n // An omitted revision deliberately replaces this token on every evaluation.\n // Stable callback identities alone are not evidence of stable results.\n const cacheKey = revision === undefined ? {} : revision;\n const slices = useComputed(\n () =>\n pieSlices(resolveSignalValue(props.data), {\n value: props.value,\n keyBy: props.keyBy,\n }),\n [cacheKey, props.data, props.value, props.keyBy],\n );\n const layout = useComputed(() => {\n context.save();\n try {\n // Canvas silently ignores malformed fonts. Two distinct sentinels detect\n // that without depending on the caller's inherited font or CSS spelling.\n context.font = \"10px serif\";\n context.font = font;\n const normalized = context.font;\n context.font = \"11px monospace\";\n context.font = font;\n if (context.font !== normalized)\n throw new TypeError(\"PieLayout: labelFont must be a valid Canvas font.\");\n context.textAlign = \"left\";\n context.textBaseline = \"alphabetic\";\n return layoutPie(\n slices.get(),\n cx,\n cy,\n radius,\n innerRadius,\n { x: bx, y: by, width: bw, height: bh },\n context.font,\n gap,\n placement,\n props.label,\n (text) => {\n const m = context.measureText(text);\n const width = Math.max(\n m.width,\n m.actualBoundingBoxLeft + m.actualBoundingBoxRight,\n );\n const ascent = Math.max(0, m.actualBoundingBoxAscent),\n descent = Math.max(0, m.actualBoundingBoxDescent);\n return {\n width: finite(width, \"label width\", true),\n height: finite(Math.max(1, ascent + descent), \"label height\", true),\n left: Math.max(0, m.actualBoundingBoxLeft),\n ascent,\n };\n },\n );\n } finally {\n context.restore();\n }\n }, [\n slices,\n cx,\n cy,\n radius,\n innerRadius,\n bx,\n by,\n bw,\n bh,\n font,\n gap,\n placement,\n props.label,\n context,\n ]);\n return layout\n .get()\n .map((slice) => (\n <Group key={slice.key}>\n {withHooksForbidden(\n \"PieLayout children cannot call hooks; return a component instead.\",\n () => props.children(slice),\n )}\n </Group>\n ));\n}\n/**\n * Draws a resolved pie slice using wedge geometry and the supplied paint style.\n *\n * @param props - Slice geometry, appearance, handlers, and children. See {@link PieSliceProps}.\n * @returns Pibbl nodes drawing one pie slice and its children.\n *\n * @see {@link PieSliceProps}\n */\nexport function PieSlice<D>({\n slice,\n style: input,\n children,\n ...events\n}: PieSliceProps<D>) {\n const style = resolveSignalValue(input) ?? {};\n if (slice.innerRadius === 0) {\n return (\n <Group>\n <Wedge\n {...events}\n style={{\n ...style,\n cx: slice.cx,\n cy: slice.cy,\n radius: slice.radius,\n startAngle: slice.startAngle,\n endAngle: slice.endAngle,\n }}\n />\n {children}\n </Group>\n );\n }\n const sweep = resolveClockwiseSweep(slice.startAngle, slice.endAngle);\n const path = new Path2D();\n path.arc(\n slice.cx,\n slice.cy,\n slice.radius,\n sweep.startAngle,\n sweep.endAngle,\n );\n if (slice.innerRadius > 0)\n path.arc(\n slice.cx,\n slice.cy,\n slice.innerRadius,\n sweep.endAngle,\n sweep.startAngle,\n true,\n );\n else path.lineTo(slice.cx, slice.cy);\n path.closePath();\n return (\n <Group>\n <Path\n {...events}\n keyboardNavigationBounds={\n events.keyboardNavigationBounds ??\n annularSliceBounds(slice, sweep)\n }\n style={{\n ...style,\n d: path,\n }}\n />\n {children}\n </Group>\n );\n}\n\n/** The outer and inner arcs both contribute to an annular path's focus box. */\nfunction annularSliceBounds(\n slice: PieLayoutSlice<unknown>,\n sweep: Readonly<ClockwiseSweep>,\n) {\n if (sweep.sweep === 0) return undefined;\n if (sweep.fullCircle)\n return {\n x: slice.cx - slice.radius,\n y: slice.cy - slice.radius,\n width: slice.radius * 2,\n height: slice.radius * 2,\n };\n const angles = [sweep.startAngle, sweep.endAngle];\n for (let cardinalIndex = 0; cardinalIndex < 4; cardinalIndex++) {\n const cardinal = cardinalIndex * (Math.PI / 2);\n const angle = cardinal < sweep.startAngle ? cardinal + fullTurn : cardinal;\n if (angle <= sweep.endAngle) angles.push(angle);\n }\n const xs: number[] = [];\n const ys: number[] = [];\n for (const angle of angles) {\n const cosine = Math.cos(angle);\n const sine = Math.sin(angle);\n xs.push(\n slice.cx + slice.radius * cosine,\n slice.cx + slice.innerRadius * cosine,\n );\n ys.push(\n slice.cy + slice.radius * sine,\n slice.cy + slice.innerRadius * sine,\n );\n }\n const left = Math.min(...xs);\n const right = Math.max(...xs);\n const top = Math.min(...ys);\n const bottom = Math.max(...ys);\n return { x: left, y: top, width: right - left, height: bottom - top };\n}\n\nconst fullTurn = Math.PI * 2;\n\ninterface ClockwiseSweep {\n readonly startAngle: number;\n readonly endAngle: number;\n readonly sweep: number;\n readonly fullCircle: boolean;\n}\n\n/** Matches Canvas's bounded clockwise arc rule without retaining unbounded turns. */\nfunction resolveClockwiseSweep(\n startAngle: number,\n endAngle: number,\n): ClockwiseSweep {\n if (!Number.isFinite(startAngle) || !Number.isFinite(endAngle))\n throw new RangeError(\"PieSlice: slice angles must be finite.\");\n const start = positiveModulo(startAngle, fullTurn);\n if (endAngle - startAngle >= fullTurn)\n return {\n startAngle: start,\n endAngle: start + fullTurn,\n sweep: fullTurn,\n fullCircle: true,\n };\n const sweep = positiveModulo(\n positiveModulo(endAngle, fullTurn) - start,\n fullTurn,\n );\n return {\n startAngle: start,\n endAngle: start + sweep,\n sweep,\n fullCircle: false,\n };\n}\n\nfunction positiveModulo(value: number, divisor: number) {\n const result = value % divisor;\n if (result === 0) return 0;\n return result < 0 ? result + divisor : result;\n}\n\nconst LabelText = definePrimitive<\n { label: Extract<PieLabelLayout, { status: \"placed\" }> },\n { readonly custom?: never; fill: import(\"@pibbl/core\").FillStyle }\n>(({ label }, style, context) => {\n context.font = label.font;\n context.textAlign = \"left\";\n context.textBaseline = \"alphabetic\";\n context.fillStyle = resolveTexturePaint(style.fill, context, { x: label.x, y: label.y, width: label.width, height: label.height });\n context.fillText(label.text, label.textX, label.textY);\n});\n\n/**\n * Draws a resolved slice label and optional leader line; decorative labels ignore pointer\n * targeting\n * by default.\n *\n * @param props - Slice geometry, label appearance, and interaction options. See\n * {@link PieLabelProps} .\n * @returns Pibbl content drawing the slice label, or null when the label was not placed.\n *\n * @see {@link PieLabelProps}\n */\nexport function PieLabel<D>({\n slice,\n style: input,\n pointerEvents = \"none\",\n ...events\n}: PieLabelProps<D>) {\n const style = resolveSignalValue(input) ?? {};\n const label = slice.label;\n if (!label || label.status !== \"placed\") return null;\n return (\n <Group {...events}>\n {label.leader && (\n <Line\n pointerEvents=\"none\"\n style={{\n coords: label.leader.map((p) => [p[0], p[1]]),\n stroke: resolveSignalValue(style.leaderStroke) ?? \"#94a3b8\",\n strokeWidth: resolveSignalValue(style.leaderWidth) ?? 1,\n }}\n />\n )}\n <Rectangle\n pointerEvents={pointerEvents}\n style={{\n left: label.x,\n top: label.y,\n width: label.width,\n height: label.height,\n fill: \"transparent\",\n }}\n />\n <LabelText\n label={label}\n style={{ fill: resolveSignalValue(style.fill) ?? \"#182c42\" }}\n />\n </Group>\n );\n}\n"],
|
|
5
|
+
"mappings": "AAyKM,cAyBA,YAzBA;AAzKN;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,qBAAqB,0BAA0B;AAQxD,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,OAAO,OAAe,MAAc,cAAc,OAAO;AAChE,MAAI,CAAC,OAAO,SAAS,KAAK,KAAM,eAAe,QAAQ;AACrD,UAAM,IA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-runtime";
|
|
2
2
|
import { Group, resolveSignalValue } from "@pibbl/core";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { pointData } from "./point-data.js";
|
|
4
|
+
import {
|
|
5
|
+
useSeriesPosition,
|
|
6
|
+
seriesAccessor,
|
|
7
|
+
mapSeriesPosition
|
|
8
|
+
} from "./series-position.js";
|
|
5
9
|
function PlotRow({
|
|
6
10
|
datum,
|
|
7
11
|
index,
|
|
@@ -21,19 +25,20 @@ function PlotSeries({
|
|
|
21
25
|
render,
|
|
22
26
|
...events
|
|
23
27
|
}) {
|
|
24
|
-
const xs =
|
|
28
|
+
const xs = useSeriesPosition(xId), ys = useSeriesPosition(yId);
|
|
25
29
|
const data = pointData(resolveSignalValue(input), "PlotSeries");
|
|
26
30
|
if (typeof render !== "function")
|
|
27
31
|
throw new TypeError("PlotSeries: render must be a synchronous function.");
|
|
28
|
-
const x =
|
|
32
|
+
const x = seriesAccessor(xInput), y = seriesAccessor(yInput);
|
|
29
33
|
const keys = /* @__PURE__ */ new Set();
|
|
30
34
|
const nodes = [];
|
|
31
35
|
for (let i = 0; i < data.length; i++) {
|
|
32
36
|
const datum = data[i];
|
|
33
37
|
if (defined && !defined(datum, i, data)) continue;
|
|
34
38
|
const xv = x(datum, i, data), yv = y(datum, i, data);
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
const mappedX = mapSeriesPosition(xs, xv), mappedY = mapSeriesPosition(ys, yv);
|
|
40
|
+
if (mappedX === void 0 || mappedY === void 0) continue;
|
|
41
|
+
const px = mappedX, py = mappedY;
|
|
37
42
|
const key = keyBy === void 0 ? i : typeof keyBy === "function" ? keyBy(datum, i, data) : datum[keyBy];
|
|
38
43
|
if (typeof key !== "string" && typeof key !== "number")
|
|
39
44
|
throw new TypeError("PlotSeries: keyBy must return a string or number.");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/features/viz/lib/plot-series.tsx"],
|
|
4
|
-
"sourcesContent": ["import { Group, resolveSignalValue } from \"@pibbl/core\";\nimport type { PibblNode } from \"@pibbl/core\";\nimport type { PlotSeriesProps } from \"./plot-types.js\";\nimport {
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { Group, resolveSignalValue } from \"@pibbl/core\";\nimport type { PibblNode } from \"@pibbl/core\";\nimport type { PlotSeriesProps } from \"./plot-types.js\";\nimport { pointData } from \"./point-data.js\";\nimport {\n useSeriesPosition,\n seriesAccessor,\n mapSeriesPosition,\n} from \"./series-position.js\";\nfunction PlotRow<D>({\n datum,\n index,\n data,\n render,\n}: {\n datum: D;\n index: number;\n data: readonly D[];\n render: PlotSeriesProps<D>[\"render\"];\n}): PibblNode {\n return render(datum, index, data);\n}\n/**\n * Places keyed custom Pibbl subtrees at local data coordinates.\n *\n * @param props - Data, coordinate accessors, scales, keys, and per-datum renderer. See\n * {@link PlotSeriesProps} .\n * @returns Pibbl nodes placing each rendered datum at its mapped coordinates. See {@link PibblNode}.\n *\n * @see {@link PlotSeriesProps}\n * @see {@link PibblNode}\n */\nexport function PlotSeries<D>({\n data: input,\n x: xInput,\n y: yInput,\n xScale: xId,\n yScale: yId,\n defined,\n keyBy,\n render,\n ...events\n}: PlotSeriesProps<D>): PibblNode {\n const xs = useSeriesPosition(xId),\n ys = useSeriesPosition(yId);\n const data = pointData(resolveSignalValue(input), \"PlotSeries\");\n if (typeof render !== \"function\")\n throw new TypeError(\"PlotSeries: render must be a synchronous function.\");\n const x = seriesAccessor(xInput),\n y = seriesAccessor(yInput);\n const keys = new Set<string>();\n const nodes: PibblNode[] = [];\n for (let i = 0; i < data.length; i++) {\n const datum = data[i];\n if (defined && !defined(datum, i, data)) continue;\n const xv = x(datum, i, data),\n yv = y(datum, i, data);\n const mappedX = mapSeriesPosition(xs, xv),\n mappedY = mapSeriesPosition(ys, yv);\n if (mappedX === undefined || mappedY === undefined) continue;\n const px = mappedX,\n py = mappedY;\n const key =\n keyBy === undefined\n ? i\n : typeof keyBy === \"function\"\n ? keyBy(datum, i, data)\n : datum[keyBy];\n if (typeof key !== \"string\" && typeof key !== \"number\")\n throw new TypeError(\"PlotSeries: keyBy must return a string or number.\");\n const normalized = String(key);\n if (keys.has(normalized))\n throw new Error(`PlotSeries: duplicate key \"${normalized}\".`);\n keys.add(normalized);\n nodes.push(\n <Group key={normalized} style={{ translateX: px, translateY: py }}>\n <PlotRow datum={datum} index={i} data={data} render={render} />\n </Group>,\n );\n }\n return <Group {...events}>{nodes}</Group>;\n}\n"],
|
|
5
|
+
"mappings": "AA4EQ;AA5ER,SAAS,OAAO,0BAA0B;AAG1C,SAAS,iBAAiB;AAC1B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,QAAW;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAKc;AACZ,SAAO,OAAO,OAAO,OAAO,IAAI;AAClC;AAWO,SAAS,WAAc;AAAA,EAC5B,MAAM;AAAA,EACN,GAAG;AAAA,EACH,GAAG;AAAA,EACH,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAkC;AAChC,QAAM,KAAK,kBAAkB,GAAG,GAC9B,KAAK,kBAAkB,GAAG;AAC5B,QAAM,OAAO,UAAU,mBAAmB,KAAK,GAAG,YAAY;AAC9D,MAAI,OAAO,WAAW;AACpB,UAAM,IAAI,UAAU,oDAAoD;AAC1E,QAAM,IAAI,eAAe,MAAM,GAC7B,IAAI,eAAe,MAAM;AAC3B,QAAM,OAAO,oBAAI,IAAY;AAC7B,QAAM,QAAqB,CAAC;AAC5B,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAM,QAAQ,KAAK,CAAC;AACpB,QAAI,WAAW,CAAC,QAAQ,OAAO,GAAG,IAAI,EAAG;AACzC,UAAM,KAAK,EAAE,OAAO,GAAG,IAAI,GACzB,KAAK,EAAE,OAAO,GAAG,IAAI;AACvB,UAAM,UAAU,kBAAkB,IAAI,EAAE,GACtC,UAAU,kBAAkB,IAAI,EAAE;AACpC,QAAI,YAAY,UAAa,YAAY,OAAW;AACpD,UAAM,KAAK,SACT,KAAK;AACP,UAAM,MACJ,UAAU,SACN,IACA,OAAO,UAAU,aACf,MAAM,OAAO,GAAG,IAAI,IACpB,MAAM,KAAK;AACnB,QAAI,OAAO,QAAQ,YAAY,OAAO,QAAQ;AAC5C,YAAM,IAAI,UAAU,mDAAmD;AACzE,UAAM,aAAa,OAAO,GAAG;AAC7B,QAAI,KAAK,IAAI,UAAU;AACrB,YAAM,IAAI,MAAM,8BAA8B,UAAU,IAAI;AAC9D,SAAK,IAAI,UAAU;AACnB,UAAM;AAAA,MACJ,oBAAC,SAAuB,OAAO,EAAE,YAAY,IAAI,YAAY,GAAG,GAC9D,8BAAC,WAAQ,OAAc,OAAO,GAAG,MAAY,QAAgB,KADnD,UAEZ;AAAA,IACF;AAAA,EACF;AACA,SAAO,oBAAC,SAAO,GAAG,QAAS,iBAAM;AACnC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { PlotSeries } from "./plot-series.js";
|
|
2
2
|
import type { PieOptions } from "./pie-slices.js";
|
|
3
|
-
import type { PibblEventHandlers, PibblNode, SignalValue } from "@pibbl/core";
|
|
4
3
|
import type { PointAccessor } from "./point-types.js";
|
|
4
|
+
import type { SeriesAccessor } from "./types.js";
|
|
5
|
+
import type { PibblEventHandlers, PibblNode, SignalValue } from "@pibbl/core";
|
|
5
6
|
import type { ScaleId } from "./types.js";
|
|
6
7
|
/**
|
|
7
8
|
* A property or callback that provides stable identity for a plotted datum.
|
|
@@ -34,9 +35,9 @@ export interface PlotSeriesProps<D> extends PibblEventHandlers {
|
|
|
34
35
|
*/
|
|
35
36
|
readonly data: SignalValue<readonly D[]>;
|
|
36
37
|
/** Property key or callback extracting the horizontal domain coordinate. See {@link PointAccessor}. */
|
|
37
|
-
readonly x:
|
|
38
|
+
readonly x: SeriesAccessor<D>;
|
|
38
39
|
/** Property key or callback extracting the vertical domain coordinate. See {@link PointAccessor}. */
|
|
39
|
-
readonly y:
|
|
40
|
+
readonly y: SeriesAccessor<D>;
|
|
40
41
|
/** The scale used to map horizontal data coordinates. See {@link ScaleId}. */
|
|
41
42
|
readonly xScale: ScaleId;
|
|
42
43
|
/** The scale used to map vertical data coordinates. See {@link ScaleId}. */
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PointScaleProps } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Provides a named point mapping to descendant visualization components.
|
|
4
|
+
* @param props - Identity, domain, range, and padding. See {@link PointScaleProps}.
|
|
5
|
+
* @returns Descendant content within the scale scope.
|
|
6
|
+
*/
|
|
7
|
+
export declare function PointScale(props: PointScaleProps): import("@pibbl/core").PibblNode;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { resolveSignalValue, useLayoutBox } from "@pibbl/core";
|
|
2
|
+
import { resolvePointScale } from "./point-scale.js";
|
|
3
|
+
import { useScaleProvider } from "./scale-provider.js";
|
|
4
|
+
function PointScale(props) {
|
|
5
|
+
const { width, height } = useLayoutBox();
|
|
6
|
+
useScaleProvider(props.id, "point", () => resolvePointScale(
|
|
7
|
+
resolveSignalValue(props.domain),
|
|
8
|
+
resolveSignalValue(props.range),
|
|
9
|
+
resolveSignalValue(props.reverse ?? false),
|
|
10
|
+
width,
|
|
11
|
+
height,
|
|
12
|
+
resolveSignalValue(props.padding ?? 0)
|
|
13
|
+
), [props.domain, props.range, props.reverse, props.padding, width, height]);
|
|
14
|
+
return props.children;
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
PointScale
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=point-scale-component.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/features/viz/lib/point-scale-component.ts"],
|
|
4
|
+
"sourcesContent": ["import { resolveSignalValue, useLayoutBox } from \"@pibbl/core\";\nimport type { PointScaleProps } from \"./types.js\";\nimport { resolvePointScale } from \"./point-scale.js\";\nimport { useScaleProvider } from \"./scale-provider.js\";\n/**\n * Provides a named point mapping to descendant visualization components.\n * @param props - Identity, domain, range, and padding. See {@link PointScaleProps}.\n * @returns Descendant content within the scale scope.\n */\nexport function PointScale(props: PointScaleProps) {\n const { width, height } = useLayoutBox();\n useScaleProvider(props.id, \"point\", () => resolvePointScale(\n resolveSignalValue(props.domain), resolveSignalValue(props.range),\n resolveSignalValue(props.reverse ?? false), width, height, resolveSignalValue(props.padding ?? 0),\n ), [props.domain, props.range, props.reverse, props.padding, width, height]);\n return props.children;\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAoB,oBAAoB;AAEjD,SAAS,yBAAyB;AAClC,SAAS,wBAAwB;AAM1B,SAAS,WAAW,OAAwB;AACjD,QAAM,EAAE,OAAO,OAAO,IAAI,aAAa;AACvC,mBAAiB,MAAM,IAAI,SAAS,MAAM;AAAA,IACxC,mBAAmB,MAAM,MAAM;AAAA,IAAG,mBAAmB,MAAM,KAAK;AAAA,IAChE,mBAAmB,MAAM,WAAW,KAAK;AAAA,IAAG;AAAA,IAAO;AAAA,IAAQ,mBAAmB,MAAM,WAAW,CAAC;AAAA,EAClG,GAAG,CAAC,MAAM,QAAQ,MAAM,OAAO,MAAM,SAAS,MAAM,SAAS,OAAO,MAAM,CAAC;AAC3E,SAAO,MAAM;AACf;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|