@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,150 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@pibbl/core/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
Group,
|
|
4
|
+
Path,
|
|
5
|
+
resolveSignalValue
|
|
6
|
+
} from "@pibbl/core";
|
|
7
|
+
import { withHooksForbidden } from "@pibbl/core/internal";
|
|
8
|
+
import { useNumericPosition } from "./series-position.js";
|
|
9
|
+
import { useContinuousScale } from "./use-continuous-scale.js";
|
|
10
|
+
import { pointAccessor, pointData, finiteCoordinate } from "./point-data.js";
|
|
11
|
+
import { financialMarkWidth, candleGeometry } from "./financial-geometry.js";
|
|
12
|
+
import { opacity, width } from "./paint.js";
|
|
13
|
+
function CandlestickSeries({
|
|
14
|
+
data: input,
|
|
15
|
+
time: timeInput,
|
|
16
|
+
open: openInput,
|
|
17
|
+
high: highInput,
|
|
18
|
+
low: lowInput,
|
|
19
|
+
close: closeInput,
|
|
20
|
+
xScale,
|
|
21
|
+
yScale,
|
|
22
|
+
defined,
|
|
23
|
+
style: styleInput,
|
|
24
|
+
inspection,
|
|
25
|
+
pointerEvents,
|
|
26
|
+
...events
|
|
27
|
+
}) {
|
|
28
|
+
const xs = useNumericPosition(xScale), ys = useContinuousScale(yScale).get();
|
|
29
|
+
const data = pointData(resolveSignalValue(input), "CandlestickSeries");
|
|
30
|
+
const time = pointAccessor(timeInput), open = pointAccessor(openInput), high = pointAccessor(highInput), low = pointAccessor(lowInput), close = pointAccessor(closeInput);
|
|
31
|
+
const rows = [];
|
|
32
|
+
for (let i = 0; i < data.length; i++) {
|
|
33
|
+
const datum = data[i];
|
|
34
|
+
if (defined && !defined(datum, i, data)) continue;
|
|
35
|
+
const t = time(datum, i, data), o = open(datum, i, data), h = high(datum, i, data), l = low(datum, i, data), c = close(datum, i, data);
|
|
36
|
+
if (!finiteCoordinate(t) || !finiteCoordinate(o) || !finiteCoordinate(h) || !finiteCoordinate(l) || !finiteCoordinate(c))
|
|
37
|
+
continue;
|
|
38
|
+
if (l > Math.min(o, c) || h < Math.max(o, c))
|
|
39
|
+
throw new RangeError(
|
|
40
|
+
`CandlestickSeries: malformed OHLC at source index ${i}; require low <= open/close <= high.`
|
|
41
|
+
);
|
|
42
|
+
rows.push({
|
|
43
|
+
datum,
|
|
44
|
+
sourceIndex: i,
|
|
45
|
+
time: t,
|
|
46
|
+
open: o,
|
|
47
|
+
high: h,
|
|
48
|
+
low: l,
|
|
49
|
+
close: c,
|
|
50
|
+
x: xs.map(t)
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
const defaultWidth = financialMarkWidth(rows.map((row) => row.x));
|
|
54
|
+
const specified = typeof styleInput === "function" ? styleInput : resolveSignalValue(styleInput);
|
|
55
|
+
const marks = inspection ? [] : void 0;
|
|
56
|
+
const batches = [];
|
|
57
|
+
for (const row of rows) {
|
|
58
|
+
const style = typeof specified === "function" ? withHooksForbidden(
|
|
59
|
+
"CandlestickSeries style callback",
|
|
60
|
+
() => specified(row.datum, row.sourceIndex, data)
|
|
61
|
+
) : specified ?? {};
|
|
62
|
+
const markWidth = style.bandwidth === void 0 || style.bandwidth === "auto" ? defaultWidth : financialMarkWidth([], { width: style.bandwidth });
|
|
63
|
+
const g = candleGeometry({
|
|
64
|
+
centerX: row.x,
|
|
65
|
+
openY: ys.map(row.open),
|
|
66
|
+
closeY: ys.map(row.close),
|
|
67
|
+
highY: ys.map(row.high),
|
|
68
|
+
lowY: ys.map(row.low),
|
|
69
|
+
width: markWidth,
|
|
70
|
+
dojiHeight: 1
|
|
71
|
+
});
|
|
72
|
+
const fill = style.body?.fill ?? (row.close >= row.open ? "#087f8c" : "#d9674c"), bodyStroke = style.body?.stroke, bodyWidth = width(style.body?.strokeWidth ?? 1, "CandlestickSeries body"), wickStroke = style.wick?.stroke ?? "#173a35", wickWidth = width(style.wick?.strokeWidth ?? 1, "CandlestickSeries wick"), alpha = opacity(style.opacity ?? 1, "CandlestickSeries");
|
|
73
|
+
marks?.push(
|
|
74
|
+
Object.freeze({
|
|
75
|
+
datum: row.datum,
|
|
76
|
+
sourceIndex: row.sourceIndex,
|
|
77
|
+
time: row.time,
|
|
78
|
+
open: row.open,
|
|
79
|
+
high: row.high,
|
|
80
|
+
low: row.low,
|
|
81
|
+
close: row.close,
|
|
82
|
+
anchorLocal: Object.freeze({ x: row.x, y: ys.map(row.close) }),
|
|
83
|
+
bodyBoundsLocal: g.bodyBoundsLocal,
|
|
84
|
+
wickLocal: g.wickLocal,
|
|
85
|
+
bodyFill: !!fill && alpha > 0,
|
|
86
|
+
bodyStrokeWidthLocal: bodyStroke && alpha > 0 ? bodyWidth : 0,
|
|
87
|
+
wickStrokeWidthLocal: wickStroke && alpha > 0 ? wickWidth : 0
|
|
88
|
+
})
|
|
89
|
+
);
|
|
90
|
+
if (alpha === 0) continue;
|
|
91
|
+
const half = Math.max(bodyStroke ? bodyWidth : 0, wickStroke ? wickWidth : 0) / 2, minX = g.bodyBoundsLocal.x - half, maxX = g.bodyBoundsLocal.x + markWidth + half;
|
|
92
|
+
let batch = batches.at(-1);
|
|
93
|
+
if (!batch || minX < batch.maxX && maxX > batch.minX || batch.fill !== fill || batch.bodyStroke !== bodyStroke || batch.bodyWidth !== bodyWidth || batch.wickStroke !== wickStroke || batch.wickWidth !== wickWidth || batch.opacity !== alpha || batch.cursor !== style.cursor) {
|
|
94
|
+
batch = {
|
|
95
|
+
body: new Path2D(),
|
|
96
|
+
wick: new Path2D(),
|
|
97
|
+
fill,
|
|
98
|
+
bodyStroke,
|
|
99
|
+
bodyWidth,
|
|
100
|
+
wickStroke,
|
|
101
|
+
wickWidth,
|
|
102
|
+
opacity: alpha,
|
|
103
|
+
cursor: style.cursor,
|
|
104
|
+
minX,
|
|
105
|
+
maxX
|
|
106
|
+
};
|
|
107
|
+
batches.push(batch);
|
|
108
|
+
}
|
|
109
|
+
batch.minX = Math.min(batch.minX, minX);
|
|
110
|
+
batch.maxX = Math.max(batch.maxX, maxX);
|
|
111
|
+
const b = g.bodyBoundsLocal;
|
|
112
|
+
batch.body.rect(b.x, b.y, b.width, b.height);
|
|
113
|
+
batch.wick.moveTo(g.wickLocal.x, g.wickLocal.highY);
|
|
114
|
+
batch.wick.lineTo(g.wickLocal.x, g.wickLocal.lowY);
|
|
115
|
+
}
|
|
116
|
+
inspection?.capture({ marks, xScale: xs, yScale: ys });
|
|
117
|
+
return /* @__PURE__ */ jsx(Group, { ...events, children: batches.map((batch, index) => /* @__PURE__ */ jsxs(Group, { children: [
|
|
118
|
+
/* @__PURE__ */ jsx(
|
|
119
|
+
Path,
|
|
120
|
+
{
|
|
121
|
+
pointerEvents,
|
|
122
|
+
style: {
|
|
123
|
+
d: batch.wick,
|
|
124
|
+
stroke: batch.wickStroke,
|
|
125
|
+
strokeWidth: batch.wickWidth,
|
|
126
|
+
opacity: batch.opacity,
|
|
127
|
+
cursor: batch.cursor
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
),
|
|
131
|
+
/* @__PURE__ */ jsx(
|
|
132
|
+
Path,
|
|
133
|
+
{
|
|
134
|
+
pointerEvents,
|
|
135
|
+
style: {
|
|
136
|
+
d: batch.body,
|
|
137
|
+
fill: batch.fill,
|
|
138
|
+
stroke: batch.bodyStroke,
|
|
139
|
+
strokeWidth: batch.bodyWidth,
|
|
140
|
+
opacity: batch.opacity,
|
|
141
|
+
cursor: batch.cursor
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
)
|
|
145
|
+
] }, index)) });
|
|
146
|
+
}
|
|
147
|
+
export {
|
|
148
|
+
CandlestickSeries
|
|
149
|
+
};
|
|
150
|
+
//# sourceMappingURL=candlestick-series.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/features/viz/lib/candlestick-series.tsx"],
|
|
4
|
+
"sourcesContent": ["import {\n Group,\n Path,\n resolveSignalValue,\n type FillStyle,\n type StrokeStyle,\n type SignalValue,\n type PibblEventHandlers,\n type PibblEventParticipationOptions,\n type PibblNode,\n} from \"@pibbl/core\";\nimport { withHooksForbidden } from \"@pibbl/core/internal\";\nimport type { LineAccessor, ScaleId } from \"./types.js\";\nimport type {\n CandleInspectionRef,\n CapturedCandleMark,\n} from \"../inspection/candle.js\";\nimport { useNumericPosition } from \"./series-position.js\";\nimport { useContinuousScale } from \"./use-continuous-scale.js\";\nimport { pointAccessor, pointData, finiteCoordinate } from \"./point-data.js\";\nimport { financialMarkWidth, candleGeometry } from \"./financial-geometry.js\";\nimport { opacity, width } from \"./paint.js\";\n/** Open/close body paint, independent from wick paint.\n * @see {@link CandlestickSeries}\n */\nexport interface CandleBodyStyle {\n /** Interior; default teal for close >= open, coral otherwise. Empty string disables fill. */ readonly fill?: FillStyle;\n /** Optional body outline. */ readonly stroke?: StrokeStyle;\n /** Nonnegative local outline width; default 1. */ readonly strokeWidth?: number;\n}\n/** High/low wick paint.\n * @see {@link CandlestickSeries}\n */\nexport interface CandleWickStyle {\n /** Wick paint; default dark teal. Empty string disables wick paint. */ readonly stroke?: StrokeStyle;\n /** Nonnegative local width; default 1. */ readonly strokeWidth?: number;\n}\n/** Accepted named body/wick presentation for OHLC marks.\n * @see {@link CandlestickSeries}\n */\nexport interface CandlestickSeriesStyle {\n /** Positive local body width, or automatic 70% spacing capped at 12; singleton fallback 8. */ readonly bandwidth?:\n number | \"auto\";\n /** Independent open/close body appearance. */ readonly body?: CandleBodyStyle;\n /** Independent high/low wick appearance. */ readonly wick?: CandleWickStyle;\n /** Opacity zero through one; default 1. */ readonly opacity?: number;\n /** Cursor while the series owns targeting. */ readonly cursor?: string;\n}\n/** Source-ordered OHLC records with named accessors and optional shared inspection.\n * @see {@link CandlestickSeries}\n */\nexport interface CandlestickSeriesProps<D>\n extends PibblEventHandlers, PibblEventParticipationOptions {\n /** Original records/signal; never sorted or mutated. */ readonly data: SignalValue<\n readonly D[]\n >;\n /** UTC-millisecond property or callback. */ readonly time: LineAccessor<D>;\n /** Open price property or callback. */ readonly open: LineAccessor<D>;\n /** High price property or callback. */ readonly high: LineAccessor<D>;\n /** Low price property or callback. */ readonly low: LineAccessor<D>;\n /** Close price property or callback. */ readonly close: LineAccessor<D>;\n /** Numeric/UTC/trading horizontal mapping identity. */ readonly xScale: ScaleId;\n /** Independent numeric price mapping identity. */ readonly yScale: ScaleId;\n /** Tests original rows before accessor evaluation.\n * @param datum - Original row.\n * @param index - Source index including skipped rows.\n * @param data - Original complete array.\n * @returns Whether the candle participates.\n */ readonly defined?: (\n datum: D,\n index: number,\n data: readonly D[],\n ) => boolean;\n /** Named body/wick appearance or a hook-free datum resolver.\n * @param datum - Original row.\n * @param index - Original source index.\n * @param data - Complete source array.\n * @returns Plain named candle styles.\n */ readonly style?:\n | SignalValue<CandlestickSeriesStyle>\n | ((datum: D, index: number, data: readonly D[]) => CandlestickSeriesStyle);\n /** Optional capture on the ordinary inspection foundation; no queries while painting. */ readonly inspection?: CandleInspectionRef<D>;\n}\n/**\n * Paints OHLC bodies and wicks, preserving source order and skipping complete missing candles.\n * Finite malformed OHLC rejects; equal open/close paints a one-local-unit doji.\n * @param props - Named OHLC accessors, scales, styles and optional inspection.\n * @returns Ordinary Pibbl composition; disjoint equal styles share paint paths.\n * @see {@link CandlestickSeriesProps}\n */\nexport function CandlestickSeries<D>({\n data: input,\n time: timeInput,\n open: openInput,\n high: highInput,\n low: lowInput,\n close: closeInput,\n xScale,\n yScale,\n defined,\n style: styleInput,\n inspection,\n pointerEvents,\n ...events\n}: CandlestickSeriesProps<D>): PibblNode {\n const xs = useNumericPosition(xScale),\n ys = useContinuousScale(yScale).get();\n const data = pointData(resolveSignalValue(input), \"CandlestickSeries\");\n const time = pointAccessor(timeInput),\n open = pointAccessor(openInput),\n high = pointAccessor(highInput),\n low = pointAccessor(lowInput),\n close = pointAccessor(closeInput);\n const rows: {\n datum: D;\n sourceIndex: number;\n time: number;\n open: number;\n high: number;\n low: number;\n close: number;\n x: number;\n }[] = [];\n for (let i = 0; i < data.length; i++) {\n const datum = data[i];\n if (defined && !defined(datum, i, data)) continue;\n const t = time(datum, i, data),\n o = open(datum, i, data),\n h = high(datum, i, data),\n l = low(datum, i, data),\n c = close(datum, i, data);\n if (\n !finiteCoordinate(t) ||\n !finiteCoordinate(o) ||\n !finiteCoordinate(h) ||\n !finiteCoordinate(l) ||\n !finiteCoordinate(c)\n )\n continue;\n if (l > Math.min(o, c) || h < Math.max(o, c))\n throw new RangeError(\n `CandlestickSeries: malformed OHLC at source index ${i}; require low <= open/close <= high.`,\n );\n rows.push({\n datum,\n sourceIndex: i,\n time: t,\n open: o,\n high: h,\n low: l,\n close: c,\n x: xs.map(t),\n });\n }\n const defaultWidth = financialMarkWidth(rows.map((row) => row.x));\n const specified =\n typeof styleInput === \"function\"\n ? styleInput\n : resolveSignalValue(styleInput);\n const marks: CapturedCandleMark<D>[] | undefined = inspection\n ? []\n : undefined;\n const batches: {\n body: Path2D;\n wick: Path2D;\n fill: FillStyle;\n bodyStroke: StrokeStyle | undefined;\n bodyWidth: number;\n wickStroke: StrokeStyle;\n wickWidth: number;\n opacity: number;\n cursor: string | undefined;\n minX: number;\n maxX: number;\n }[] = [];\n for (const row of rows) {\n const style =\n typeof specified === \"function\"\n ? withHooksForbidden(\"CandlestickSeries style callback\", () =>\n specified(row.datum, row.sourceIndex, data),\n )\n : (specified ?? {});\n const markWidth =\n style.bandwidth === undefined || style.bandwidth === \"auto\"\n ? defaultWidth\n : financialMarkWidth([], { width: style.bandwidth });\n const g = candleGeometry({\n centerX: row.x,\n openY: ys.map(row.open),\n closeY: ys.map(row.close),\n highY: ys.map(row.high),\n lowY: ys.map(row.low),\n width: markWidth,\n dojiHeight: 1,\n });\n const fill =\n style.body?.fill ?? (row.close >= row.open ? \"#087f8c\" : \"#d9674c\"),\n bodyStroke = style.body?.stroke,\n bodyWidth = width(style.body?.strokeWidth ?? 1, \"CandlestickSeries body\"),\n wickStroke = style.wick?.stroke ?? \"#173a35\",\n wickWidth = width(style.wick?.strokeWidth ?? 1, \"CandlestickSeries wick\"),\n alpha = opacity(style.opacity ?? 1, \"CandlestickSeries\");\n marks?.push(\n Object.freeze({\n datum: row.datum,\n sourceIndex: row.sourceIndex,\n time: row.time,\n open: row.open,\n high: row.high,\n low: row.low,\n close: row.close,\n anchorLocal: Object.freeze({ x: row.x, y: ys.map(row.close) }),\n bodyBoundsLocal: g.bodyBoundsLocal,\n wickLocal: g.wickLocal,\n bodyFill: !!fill && alpha > 0,\n bodyStrokeWidthLocal: bodyStroke && alpha > 0 ? bodyWidth : 0,\n wickStrokeWidthLocal: wickStroke && alpha > 0 ? wickWidth : 0,\n }),\n );\n if (alpha === 0) continue;\n const half =\n Math.max(bodyStroke ? bodyWidth : 0, wickStroke ? wickWidth : 0) / 2,\n minX = g.bodyBoundsLocal.x - half,\n maxX = g.bodyBoundsLocal.x + markWidth + half;\n let batch = batches.at(-1);\n if (\n !batch ||\n (minX < batch.maxX && maxX > batch.minX) ||\n batch.fill !== fill ||\n batch.bodyStroke !== bodyStroke ||\n batch.bodyWidth !== bodyWidth ||\n batch.wickStroke !== wickStroke ||\n batch.wickWidth !== wickWidth ||\n batch.opacity !== alpha ||\n batch.cursor !== style.cursor\n ) {\n batch = {\n body: new Path2D(),\n wick: new Path2D(),\n fill,\n bodyStroke,\n bodyWidth,\n wickStroke,\n wickWidth,\n opacity: alpha,\n cursor: style.cursor,\n minX,\n maxX,\n };\n batches.push(batch);\n }\n batch.minX = Math.min(batch.minX, minX);\n batch.maxX = Math.max(batch.maxX, maxX);\n const b = g.bodyBoundsLocal;\n batch.body.rect(b.x, b.y, b.width, b.height);\n batch.wick.moveTo(g.wickLocal.x, g.wickLocal.highY);\n batch.wick.lineTo(g.wickLocal.x, g.wickLocal.lowY);\n }\n inspection?.capture({ marks: marks!, xScale: xs, yScale: ys });\n return (\n <Group {...events}>\n {batches.map((batch, index) => (\n <Group key={index}>\n <Path\n pointerEvents={pointerEvents}\n style={{\n d: batch.wick,\n stroke: batch.wickStroke,\n strokeWidth: batch.wickWidth,\n opacity: batch.opacity,\n cursor: batch.cursor,\n }}\n />\n <Path\n pointerEvents={pointerEvents}\n style={{\n d: batch.body,\n fill: batch.fill,\n stroke: batch.bodyStroke,\n strokeWidth: batch.bodyWidth,\n opacity: batch.opacity,\n cursor: batch.cursor,\n }}\n />\n </Group>\n ))}\n </Group>\n );\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { FillStyle, PibblEventHandlers, PibblEventParticipationOptions, SignalValue, StrokeStyle } from "@pibbl/core";
|
|
2
|
+
import type { SignalStyle } from "@pibbl/core/internal";
|
|
3
|
+
import type { LineAccessor, ScaleId } from "./types.js";
|
|
4
|
+
/** A supplied assay reporting status. `below` and `above` retain the supplied reporting limit.
|
|
5
|
+
* @see {@link CensoredPointSeriesProps}
|
|
6
|
+
*/
|
|
7
|
+
export type CensoringStatus = "observed" | "below" | "above";
|
|
8
|
+
/** Extracts an observation's supplied reporting status.
|
|
9
|
+
* @param datum - Original record being read.
|
|
10
|
+
* @param index - Zero-based source index.
|
|
11
|
+
* @param data - Complete supplied record array.
|
|
12
|
+
* @returns The supplied status, or a nullish sentinel that omits the record.
|
|
13
|
+
* @see {@link CensoringStatus}
|
|
14
|
+
*/
|
|
15
|
+
export type CensoringAccessor<D> = {
|
|
16
|
+
[K in keyof D]-?: D[K] extends CensoringStatus | null | undefined ? K : never;
|
|
17
|
+
}[keyof D] | ((datum: D, index: number, data: readonly D[]) => CensoringStatus | null | undefined);
|
|
18
|
+
/** Shared mark paint and local-pixel geometry for {@link CensoredPointSeries}. */
|
|
19
|
+
export interface CensoredPointSeriesStyle {
|
|
20
|
+
/** Circle and open censor marker radius in local pixels; defaults to 4. */
|
|
21
|
+
readonly radius?: number;
|
|
22
|
+
/** Fill for observed circles; defaults to #087f8c. Censor markers remain open. */
|
|
23
|
+
readonly fill?: FillStyle;
|
|
24
|
+
/** Outline for circles and open directional censor markers; defaults to #087f8c. */
|
|
25
|
+
readonly stroke?: StrokeStyle;
|
|
26
|
+
/** Outline width in local pixels; defaults to 1.5. */
|
|
27
|
+
readonly strokeWidth?: number;
|
|
28
|
+
/** Shared paint opacity from zero to one; defaults to 1. */
|
|
29
|
+
readonly opacity?: number;
|
|
30
|
+
/** Cursor for painted mark targets. */
|
|
31
|
+
readonly cursor?: string;
|
|
32
|
+
}
|
|
33
|
+
/** Authored inputs for supplied observed and censored numeric observations.
|
|
34
|
+
* @see {@link CensoredPointSeries}
|
|
35
|
+
*/
|
|
36
|
+
export interface CensoredPointSeriesProps<D> extends PibblEventHandlers, PibblEventParticipationOptions {
|
|
37
|
+
/** Original records, or a signal of records. The series performs no imputation or inference. */
|
|
38
|
+
readonly data: SignalValue<readonly D[]>;
|
|
39
|
+
/** Property or callback supplying the numeric horizontal coordinate. */
|
|
40
|
+
readonly x: LineAccessor<D>;
|
|
41
|
+
/** Property or callback supplying the numeric vertical value or reporting limit. */
|
|
42
|
+
readonly y: LineAccessor<D>;
|
|
43
|
+
/** Property or callback yielding `observed`, `below`, or `above`. */
|
|
44
|
+
readonly censoring: CensoringAccessor<D>;
|
|
45
|
+
/** Ancestor continuous numeric scale mapping x. */
|
|
46
|
+
readonly xScale: ScaleId;
|
|
47
|
+
/** Ancestor continuous numeric scale mapping y and its reporting limit. */
|
|
48
|
+
readonly yScale: ScaleId;
|
|
49
|
+
/** Optional synchronous predicate; excluded rows contribute no mark.
|
|
50
|
+
* @param datum - Original record being tested.
|
|
51
|
+
* @param index - Zero-based source index.
|
|
52
|
+
* @param data - Complete supplied record array.
|
|
53
|
+
* @returns Whether this record contributes a mark.
|
|
54
|
+
*/
|
|
55
|
+
readonly defined?: (datum: D, index: number, data: readonly D[]) => boolean;
|
|
56
|
+
/** Shared style; whole-object and shallow field signals are observed by the series. */
|
|
57
|
+
readonly style?: SignalValue<SignalStyle<CensoredPointSeriesStyle>>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Draws supplied numeric observations as circles and below/above reporting limits as open arrows.
|
|
61
|
+
*
|
|
62
|
+
* `below` points toward decreasing y-domain values and `above` toward increasing y-domain values,
|
|
63
|
+
* including when the y scale uses a reversed domain or range. The supplied `y` value remains the
|
|
64
|
+
* reporting limit; this component never substitutes a measurement, imputes a value, or fits a model.
|
|
65
|
+
*
|
|
66
|
+
* @param props - Supplied observations, coordinates, reporting statuses, scales, and paint.
|
|
67
|
+
* See {@link CensoredPointSeriesProps}.
|
|
68
|
+
* @returns Two ordinary batched paths for observed and open censored marks.
|
|
69
|
+
* @see {@link CensoredPointSeriesProps}
|
|
70
|
+
*/
|
|
71
|
+
export declare function CensoredPointSeries<D>({ data: input, x: xInput, y: yInput, censoring: censoringInput, xScale: xId, yScale: yId, defined, style: styleInput, pointerEvents, ...events }: CensoredPointSeriesProps<D>): import("../../../jsx-runtime.js").JSX.Element;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "@pibbl/core/jsx-runtime";
|
|
2
|
+
import { Path, resolveSignalValue } from "@pibbl/core";
|
|
3
|
+
import { validateTexturePaint, withHooksForbidden } from "@pibbl/core/internal";
|
|
4
|
+
import { finiteCoordinate, pointAccessor, pointData } from "./point-data.js";
|
|
5
|
+
import { opacity, width } from "./paint.js";
|
|
6
|
+
import { useContinuousScale } from "./use-continuous-scale.js";
|
|
7
|
+
const fields = ["radius", "fill", "stroke", "strokeWidth", "opacity", "cursor"];
|
|
8
|
+
function paint(value, name) {
|
|
9
|
+
if (value === void 0 || typeof value === "string" || value instanceof CanvasGradient || value instanceof CanvasPattern)
|
|
10
|
+
return value;
|
|
11
|
+
try {
|
|
12
|
+
validateTexturePaint(value);
|
|
13
|
+
return value;
|
|
14
|
+
} catch {
|
|
15
|
+
}
|
|
16
|
+
throw new TypeError(`CensoredPointSeries: invalid ${name}.`);
|
|
17
|
+
}
|
|
18
|
+
function triangle(path, x, y, radius, direction) {
|
|
19
|
+
path.moveTo(x, y + direction * radius);
|
|
20
|
+
path.lineTo(x - radius * 0.78, y - direction * radius * 0.55);
|
|
21
|
+
path.lineTo(x + radius * 0.78, y - direction * radius * 0.55);
|
|
22
|
+
path.closePath();
|
|
23
|
+
}
|
|
24
|
+
function CensoredPointSeries({
|
|
25
|
+
data: input,
|
|
26
|
+
x: xInput,
|
|
27
|
+
y: yInput,
|
|
28
|
+
censoring: censoringInput,
|
|
29
|
+
xScale: xId,
|
|
30
|
+
yScale: yId,
|
|
31
|
+
defined,
|
|
32
|
+
style: styleInput,
|
|
33
|
+
pointerEvents,
|
|
34
|
+
...events
|
|
35
|
+
}) {
|
|
36
|
+
const xScale = useContinuousScale(xId).get();
|
|
37
|
+
const yScale = useContinuousScale(yId).get();
|
|
38
|
+
const data = pointData(resolveSignalValue(input), "CensoredPointSeries");
|
|
39
|
+
const x = pointAccessor(xInput), y = pointAccessor(yInput);
|
|
40
|
+
const censoring = typeof censoringInput === "function" ? censoringInput : (datum) => datum[censoringInput];
|
|
41
|
+
const specified = resolveSignalValue(styleInput) ?? {};
|
|
42
|
+
if (specified === null || typeof specified !== "object" || Array.isArray(specified))
|
|
43
|
+
throw new TypeError("CensoredPointSeries: style must be an object.");
|
|
44
|
+
const style = {};
|
|
45
|
+
for (const key of Object.keys(specified)) {
|
|
46
|
+
if (!fields.includes(key))
|
|
47
|
+
throw new TypeError(
|
|
48
|
+
`CensoredPointSeries: unsupported style field ${key}.`
|
|
49
|
+
);
|
|
50
|
+
style[key] = resolveSignalValue(
|
|
51
|
+
specified[key]
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
const resolved = style;
|
|
55
|
+
const radius = width(resolved.radius ?? 4, "CensoredPointSeries radius");
|
|
56
|
+
const strokeWidth = width(resolved.strokeWidth ?? 1.5, "CensoredPointSeries");
|
|
57
|
+
const alpha = opacity(resolved.opacity ?? 1, "CensoredPointSeries");
|
|
58
|
+
if (resolved.cursor !== void 0 && typeof resolved.cursor !== "string")
|
|
59
|
+
throw new TypeError("CensoredPointSeries: cursor must be a string.");
|
|
60
|
+
const fill = paint(resolved.fill ?? "#087f8c", "fill");
|
|
61
|
+
const stroke = paint(resolved.stroke ?? "#087f8c", "stroke");
|
|
62
|
+
const observed = new Path2D();
|
|
63
|
+
const censored = new Path2D();
|
|
64
|
+
const increasingY = Math.sign(
|
|
65
|
+
(yScale.domain[1] - yScale.domain[0]) * (yScale.range[1] - yScale.range[0])
|
|
66
|
+
);
|
|
67
|
+
for (let i = 0; i < data.length; i++) {
|
|
68
|
+
const datum = data[i];
|
|
69
|
+
const coordinates = withHooksForbidden(
|
|
70
|
+
"CensoredPointSeries: accessors cannot call hooks.",
|
|
71
|
+
() => {
|
|
72
|
+
if (defined && !defined(datum, i, data)) return void 0;
|
|
73
|
+
return {
|
|
74
|
+
x: x(datum, i, data),
|
|
75
|
+
y: y(datum, i, data),
|
|
76
|
+
censoring: censoring(datum, i, data)
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
if (!coordinates || !finiteCoordinate(coordinates.x) || !finiteCoordinate(coordinates.y) || coordinates.censoring == null)
|
|
81
|
+
continue;
|
|
82
|
+
if (!["observed", "below", "above"].includes(coordinates.censoring))
|
|
83
|
+
throw new TypeError(
|
|
84
|
+
`CensoredPointSeries: unknown censoring status ${String(coordinates.censoring)} (row ${i}).`
|
|
85
|
+
);
|
|
86
|
+
const px = xScale.map(coordinates.x), py = yScale.map(coordinates.y);
|
|
87
|
+
if (!Number.isFinite(px) || !Number.isFinite(py))
|
|
88
|
+
throw new RangeError(
|
|
89
|
+
`CensoredPointSeries: mapped coordinates must be finite (row ${i}).`
|
|
90
|
+
);
|
|
91
|
+
if (radius === 0) continue;
|
|
92
|
+
if (coordinates.censoring === "observed") {
|
|
93
|
+
observed.moveTo(px + radius, py);
|
|
94
|
+
observed.arc(px, py, radius, 0, Math.PI * 2);
|
|
95
|
+
observed.closePath();
|
|
96
|
+
} else {
|
|
97
|
+
const direction = coordinates.censoring === "above" ? increasingY : -increasingY;
|
|
98
|
+
triangle(censored, px, py, radius, direction || 1);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const common = {
|
|
102
|
+
stroke,
|
|
103
|
+
strokeWidth,
|
|
104
|
+
opacity: alpha,
|
|
105
|
+
cursor: resolved.cursor
|
|
106
|
+
};
|
|
107
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
108
|
+
/* @__PURE__ */ jsx(
|
|
109
|
+
Path,
|
|
110
|
+
{
|
|
111
|
+
...events,
|
|
112
|
+
pointerEvents,
|
|
113
|
+
style: { d: observed, fill, ...common }
|
|
114
|
+
}
|
|
115
|
+
),
|
|
116
|
+
/* @__PURE__ */ jsx(
|
|
117
|
+
Path,
|
|
118
|
+
{
|
|
119
|
+
...events,
|
|
120
|
+
pointerEvents,
|
|
121
|
+
style: { d: censored, fill: "transparent", ...common }
|
|
122
|
+
}
|
|
123
|
+
)
|
|
124
|
+
] });
|
|
125
|
+
}
|
|
126
|
+
export {
|
|
127
|
+
CensoredPointSeries
|
|
128
|
+
};
|
|
129
|
+
//# sourceMappingURL=censored-point-series.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/features/viz/lib/censored-point-series.tsx"],
|
|
4
|
+
"sourcesContent": ["import { Path, resolveSignalValue } from \"@pibbl/core\";\nimport type {\n FillStyle,\n PibblEventHandlers,\n PibblEventParticipationOptions,\n SignalValue,\n StrokeStyle,\n} from \"@pibbl/core\";\nimport type { SignalStyle } from \"@pibbl/core/internal\";\nimport { validateTexturePaint, withHooksForbidden } from \"@pibbl/core/internal\";\nimport type { LineAccessor, ScaleId } from \"./types.js\";\nimport { finiteCoordinate, pointAccessor, pointData } from \"./point-data.js\";\nimport { opacity, width } from \"./paint.js\";\nimport { useContinuousScale } from \"./use-continuous-scale.js\";\n\n/** A supplied assay reporting status. `below` and `above` retain the supplied reporting limit.\n * @see {@link CensoredPointSeriesProps}\n */\nexport type CensoringStatus = \"observed\" | \"below\" | \"above\";\n\n/** Extracts an observation's supplied reporting status.\n * @param datum - Original record being read.\n * @param index - Zero-based source index.\n * @param data - Complete supplied record array.\n * @returns The supplied status, or a nullish sentinel that omits the record.\n * @see {@link CensoringStatus}\n */\nexport type CensoringAccessor<D> =\n | {\n [K in keyof D]-?: D[K] extends CensoringStatus | null | undefined\n ? K\n : never;\n }[keyof D]\n | ((\n datum: D,\n index: number,\n data: readonly D[],\n ) => CensoringStatus | null | undefined);\n\n/** Shared mark paint and local-pixel geometry for {@link CensoredPointSeries}. */\nexport interface CensoredPointSeriesStyle {\n /** Circle and open censor marker radius in local pixels; defaults to 4. */\n readonly radius?: number;\n /** Fill for observed circles; defaults to #087f8c. Censor markers remain open. */\n readonly fill?: FillStyle;\n /** Outline for circles and open directional censor markers; defaults to #087f8c. */\n readonly stroke?: StrokeStyle;\n /** Outline width in local pixels; defaults to 1.5. */\n readonly strokeWidth?: number;\n /** Shared paint opacity from zero to one; defaults to 1. */\n readonly opacity?: number;\n /** Cursor for painted mark targets. */\n readonly cursor?: string;\n}\n\n/** Authored inputs for supplied observed and censored numeric observations.\n * @see {@link CensoredPointSeries}\n */\nexport interface CensoredPointSeriesProps<D>\n extends PibblEventHandlers, PibblEventParticipationOptions {\n /** Original records, or a signal of records. The series performs no imputation or inference. */\n readonly data: SignalValue<readonly D[]>;\n /** Property or callback supplying the numeric horizontal coordinate. */\n readonly x: LineAccessor<D>;\n /** Property or callback supplying the numeric vertical value or reporting limit. */\n readonly y: LineAccessor<D>;\n /** Property or callback yielding `observed`, `below`, or `above`. */\n readonly censoring: CensoringAccessor<D>;\n /** Ancestor continuous numeric scale mapping x. */\n readonly xScale: ScaleId;\n /** Ancestor continuous numeric scale mapping y and its reporting limit. */\n readonly yScale: ScaleId;\n /** Optional synchronous predicate; excluded rows contribute no mark.\n * @param datum - Original record being tested.\n * @param index - Zero-based source index.\n * @param data - Complete supplied record array.\n * @returns Whether this record contributes a mark.\n */\n readonly defined?: (datum: D, index: number, data: readonly D[]) => boolean;\n /** Shared style; whole-object and shallow field signals are observed by the series. */\n readonly style?: SignalValue<SignalStyle<CensoredPointSeriesStyle>>;\n}\n\nconst fields = [\"radius\", \"fill\", \"stroke\", \"strokeWidth\", \"opacity\", \"cursor\"];\n\nfunction paint(\n value: unknown,\n name: string,\n): FillStyle | StrokeStyle | undefined {\n if (\n value === undefined ||\n typeof value === \"string\" ||\n value instanceof CanvasGradient ||\n value instanceof CanvasPattern\n )\n return value;\n try {\n validateTexturePaint(value as never);\n return value as FillStyle | StrokeStyle;\n } catch {\n // Fall through to the local series error rather than leaking protocol detail.\n }\n throw new TypeError(`CensoredPointSeries: invalid ${name}.`);\n}\n\nfunction triangle(\n path: Path2D,\n x: number,\n y: number,\n radius: number,\n direction: number,\n) {\n path.moveTo(x, y + direction * radius);\n path.lineTo(x - radius * 0.78, y - direction * radius * 0.55);\n path.lineTo(x + radius * 0.78, y - direction * radius * 0.55);\n path.closePath();\n}\n\n/**\n * Draws supplied numeric observations as circles and below/above reporting limits as open arrows.\n *\n * `below` points toward decreasing y-domain values and `above` toward increasing y-domain values,\n * including when the y scale uses a reversed domain or range. The supplied `y` value remains the\n * reporting limit; this component never substitutes a measurement, imputes a value, or fits a model.\n *\n * @param props - Supplied observations, coordinates, reporting statuses, scales, and paint.\n * See {@link CensoredPointSeriesProps}.\n * @returns Two ordinary batched paths for observed and open censored marks.\n * @see {@link CensoredPointSeriesProps}\n */\nexport function CensoredPointSeries<D>({\n data: input,\n x: xInput,\n y: yInput,\n censoring: censoringInput,\n xScale: xId,\n yScale: yId,\n defined,\n style: styleInput,\n pointerEvents,\n ...events\n}: CensoredPointSeriesProps<D>) {\n const xScale = useContinuousScale(xId).get();\n const yScale = useContinuousScale(yId).get();\n const data = pointData(resolveSignalValue(input), \"CensoredPointSeries\");\n const x = pointAccessor(xInput),\n y = pointAccessor(yInput);\n const censoring =\n typeof censoringInput === \"function\"\n ? censoringInput\n : (datum: D) =>\n datum[censoringInput] as CensoringStatus | null | undefined;\n const specified = resolveSignalValue(styleInput) ?? {};\n if (\n specified === null ||\n typeof specified !== \"object\" ||\n Array.isArray(specified)\n )\n throw new TypeError(\"CensoredPointSeries: style must be an object.\");\n const style: Record<string, unknown> = {};\n for (const key of Object.keys(specified)) {\n if (!fields.includes(key))\n throw new TypeError(\n `CensoredPointSeries: unsupported style field ${key}.`,\n );\n style[key] = resolveSignalValue(\n (specified as Record<string, unknown>)[key],\n );\n }\n const resolved = style as CensoredPointSeriesStyle;\n const radius = width(resolved.radius ?? 4, \"CensoredPointSeries radius\");\n const strokeWidth = width(resolved.strokeWidth ?? 1.5, \"CensoredPointSeries\");\n const alpha = opacity(resolved.opacity ?? 1, \"CensoredPointSeries\");\n if (resolved.cursor !== undefined && typeof resolved.cursor !== \"string\")\n throw new TypeError(\"CensoredPointSeries: cursor must be a string.\");\n const fill = paint(resolved.fill ?? \"#087f8c\", \"fill\");\n const stroke = paint(resolved.stroke ?? \"#087f8c\", \"stroke\");\n const observed = new Path2D();\n const censored = new Path2D();\n // The sign is a property of the domain-to-range mapping, rather than canvas orientation.\n const increasingY = Math.sign(\n (yScale.domain[1] - yScale.domain[0]) * (yScale.range[1] - yScale.range[0]),\n );\n for (let i = 0; i < data.length; i++) {\n const datum = data[i];\n const coordinates = withHooksForbidden(\n \"CensoredPointSeries: accessors cannot call hooks.\",\n () => {\n if (defined && !defined(datum, i, data)) return undefined;\n return {\n x: x(datum, i, data),\n y: y(datum, i, data),\n censoring: censoring(datum, i, data),\n };\n },\n );\n if (\n !coordinates ||\n !finiteCoordinate(coordinates.x) ||\n !finiteCoordinate(coordinates.y) ||\n coordinates.censoring == null\n )\n continue;\n if (\n !([\"observed\", \"below\", \"above\"] as const).includes(coordinates.censoring)\n )\n throw new TypeError(\n `CensoredPointSeries: unknown censoring status ${String(coordinates.censoring)} (row ${i}).`,\n );\n const px = xScale.map(coordinates.x),\n py = yScale.map(coordinates.y);\n if (!Number.isFinite(px) || !Number.isFinite(py))\n throw new RangeError(\n `CensoredPointSeries: mapped coordinates must be finite (row ${i}).`,\n );\n if (radius === 0) continue;\n if (coordinates.censoring === \"observed\") {\n observed.moveTo(px + radius, py);\n observed.arc(px, py, radius, 0, Math.PI * 2);\n observed.closePath();\n } else {\n const direction =\n coordinates.censoring === \"above\" ? increasingY : -increasingY;\n triangle(censored, px, py, radius, direction || 1);\n }\n }\n const common = {\n stroke,\n strokeWidth,\n opacity: alpha,\n cursor: resolved.cursor,\n };\n return (\n <>\n <Path\n {...events}\n pointerEvents={pointerEvents}\n style={{ d: observed, fill, ...common }}\n />\n <Path\n {...events}\n pointerEvents={pointerEvents}\n style={{ d: censored, fill: \"transparent\", ...common }}\n />\n </>\n );\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type SignalValue } from "@pibbl/core";
|
|
2
|
+
import type { AxisProps, AxisStyle, BandCategory, ScaleId } from "./types.js";
|
|
3
|
+
import type { SignalStyle } from "@pibbl/core/internal";
|
|
4
|
+
/** Shared geometry and paint for decorative chart lines; no layout is allocated. See {@link GridLines}. */
|
|
5
|
+
export interface ChartLineProps {
|
|
6
|
+
/** Ancestor scale providing the line's mapped coordinate. */
|
|
7
|
+
readonly scale: ScaleId;
|
|
8
|
+
/** Direction the painted line extends. */
|
|
9
|
+
readonly direction: "horizontal" | "vertical";
|
|
10
|
+
/** Explicit perpendicular pixel endpoints, in the caller's local coordinate space. */
|
|
11
|
+
readonly span: SignalValue<readonly [number, number]>;
|
|
12
|
+
/** Stroke defaults to #dce5e8, width to 1, opacity to 1. */
|
|
13
|
+
readonly style?: SignalValue<SignalStyle<Pick<AxisStyle, "stroke" | "strokeWidth" | "opacity">>>;
|
|
14
|
+
}
|
|
15
|
+
/** Grid positions use Axis tick rules, independent of Axis label visibility. See {@link GridLines}. */
|
|
16
|
+
export type GridLinesProps = ChartLineProps & ({
|
|
17
|
+
/** Explicit domain ticks; same validation as Axis. */
|
|
18
|
+
readonly tickValues: AxisProps["tickValues"];
|
|
19
|
+
/** Mutually exclusive with explicit values. */
|
|
20
|
+
readonly tickCount?: never;
|
|
21
|
+
} | {
|
|
22
|
+
/** Mutually exclusive with generated ticks. */
|
|
23
|
+
readonly tickValues?: never;
|
|
24
|
+
/** Requested tick count; defaults to five. */
|
|
25
|
+
readonly tickCount?: AxisProps["tickCount"];
|
|
26
|
+
});
|
|
27
|
+
/** A reference value must belong to the selected scale's domain. See {@link ReferenceLine}. */
|
|
28
|
+
export interface ReferenceLineProps extends ChartLineProps {
|
|
29
|
+
/** Numeric domain value or categorical identity; signals update the line. */
|
|
30
|
+
readonly value: SignalValue<BandCategory>;
|
|
31
|
+
}
|
|
32
|
+
/** Paint grid lines at scale ticks, without labels or allocation.
|
|
33
|
+
* @param props - Scale geometry and presentation. See {@link GridLinesProps}.
|
|
34
|
+
* @returns Decorative chart content in the caller's coordinate space.
|
|
35
|
+
*/
|
|
36
|
+
export declare function GridLines(props: GridLinesProps): import("../../../jsx-runtime.js").JSX.Element[];
|
|
37
|
+
/** Paint one decorative line at a domain value, without labels or allocation.
|
|
38
|
+
* @param props - Scale geometry and presentation. See {@link ReferenceLineProps}.
|
|
39
|
+
* @returns Decorative chart content in the caller's coordinate space.
|
|
40
|
+
*/
|
|
41
|
+
export declare function ReferenceLine(props: ReferenceLineProps): import("../../../jsx-runtime.js").JSX.Element[];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx } from "@pibbl/core/jsx-runtime";
|
|
2
|
+
import { Line, resolveSignalValue } from "@pibbl/core";
|
|
3
|
+
import { lookupScale } from "./scale-context.js";
|
|
4
|
+
import { ticks, position } from "./scale-ticks.js";
|
|
5
|
+
import { width, opacity } from "./paint.js";
|
|
6
|
+
function lines(props, selection) {
|
|
7
|
+
if (props.direction !== "horizontal" && props.direction !== "vertical") throw new TypeError("Chart line direction must be horizontal or vertical.");
|
|
8
|
+
const source = lookupScale(props.scale, "Chart line");
|
|
9
|
+
if (!source) throw new TypeError("Chart lines require a scale ID.");
|
|
10
|
+
const scale = source.get(), span = resolveSignalValue(props.span);
|
|
11
|
+
if (!Array.isArray(span) || span.length !== 2 || !span.every((v) => typeof v === "number" && Number.isFinite(v))) throw new RangeError("Chart line span must have two finite pixel endpoints.");
|
|
12
|
+
const style = resolveSignalValue(props.style) ?? {};
|
|
13
|
+
const stroke = resolveSignalValue(style.stroke) ?? "#dce5e8";
|
|
14
|
+
const strokeWidth = width(resolveSignalValue(style.strokeWidth) ?? 1, "Chart line");
|
|
15
|
+
const alpha = opacity(resolveSignalValue(style.opacity) ?? 1, "Chart line");
|
|
16
|
+
return ticks(scale, selection).map((value, index) => {
|
|
17
|
+
const p = position(scale, value);
|
|
18
|
+
const coords = props.direction === "horizontal" ? [[span[0], p], [span[1], p]] : [[p, span[0]], [p, span[1]]];
|
|
19
|
+
return /* @__PURE__ */ jsx(Line, { pointerEvents: "none", style: { coords, stroke, strokeWidth, opacity: alpha } }, index);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function GridLines(props) {
|
|
23
|
+
return lines(props, props);
|
|
24
|
+
}
|
|
25
|
+
function ReferenceLine(props) {
|
|
26
|
+
return lines(props, { tickValues: [resolveSignalValue(props.value)] });
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
GridLines,
|
|
30
|
+
ReferenceLine
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=chart-lines.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/features/viz/lib/chart-lines.tsx"],
|
|
4
|
+
"sourcesContent": ["import { Line, resolveSignalValue, type SignalValue } from \"@pibbl/core\";\nimport type { AxisProps, AxisStyle, BandCategory, ScaleId } from \"./types.js\";\nimport type { SignalStyle } from \"@pibbl/core/internal\";\nimport { lookupScale } from \"./scale-context.js\";\nimport { ticks, position } from \"./scale-ticks.js\";\nimport { width, opacity } from \"./paint.js\";\n/** Shared geometry and paint for decorative chart lines; no layout is allocated. See {@link GridLines}. */\nexport interface ChartLineProps {\n /** Ancestor scale providing the line's mapped coordinate. */\n readonly scale: ScaleId;\n /** Direction the painted line extends. */\n readonly direction: \"horizontal\" | \"vertical\";\n /** Explicit perpendicular pixel endpoints, in the caller's local coordinate space. */\n readonly span: SignalValue<readonly [number, number]>;\n /** Stroke defaults to #dce5e8, width to 1, opacity to 1. */\n readonly style?: SignalValue<SignalStyle<Pick<AxisStyle, \"stroke\" | \"strokeWidth\" | \"opacity\">>>;\n}\n/** Grid positions use Axis tick rules, independent of Axis label visibility. See {@link GridLines}. */\nexport type GridLinesProps = ChartLineProps & (\n {\n /** Explicit domain ticks; same validation as Axis. */\n readonly tickValues: AxisProps[\"tickValues\"];\n /** Mutually exclusive with explicit values. */\n readonly tickCount?: never;\n } |\n {\n /** Mutually exclusive with generated ticks. */\n readonly tickValues?: never;\n /** Requested tick count; defaults to five. */\n readonly tickCount?: AxisProps[\"tickCount\"];\n }\n);\n/** A reference value must belong to the selected scale's domain. See {@link ReferenceLine}. */\nexport interface ReferenceLineProps extends ChartLineProps {\n /** Numeric domain value or categorical identity; signals update the line. */\n readonly value: SignalValue<BandCategory>;\n}\nfunction lines(props: ChartLineProps, selection: Pick<AxisProps, \"tickCount\" | \"tickValues\">) {\n if (props.direction !== \"horizontal\" && props.direction !== \"vertical\") throw new TypeError(\"Chart line direction must be horizontal or vertical.\");\n const source = lookupScale(props.scale, \"Chart line\");\n if (!source) throw new TypeError(\"Chart lines require a scale ID.\");\n const scale = source.get(), span = resolveSignalValue(props.span);\n if (!Array.isArray(span) || span.length !== 2 || !span.every(v => typeof v === \"number\" && Number.isFinite(v))) throw new RangeError(\"Chart line span must have two finite pixel endpoints.\");\n const style = resolveSignalValue(props.style) ?? {};\n const stroke = resolveSignalValue(style.stroke) ?? \"#dce5e8\";\n const strokeWidth = width(resolveSignalValue(style.strokeWidth) ?? 1, \"Chart line\");\n const alpha = opacity(resolveSignalValue(style.opacity) ?? 1, \"Chart line\");\n return ticks(scale, selection).map((value, index) => {\n const p = position(scale, value);\n const coords: [number, number][] = props.direction === \"horizontal\" ? [[span[0], p], [span[1], p]] : [[p, span[0]], [p, span[1]]];\n return <Line key={index} pointerEvents=\"none\" style={{ coords, stroke, strokeWidth, opacity: alpha }} />;\n });\n}\n/** Paint grid lines at scale ticks, without labels or allocation.\n * @param props - Scale geometry and presentation. See {@link GridLinesProps}.\n * @returns Decorative chart content in the caller's coordinate space.\n */\nexport function GridLines(props: GridLinesProps) { return lines(props, props); }\n/** Paint one decorative line at a domain value, without labels or allocation.\n * @param props - Scale geometry and presentation. See {@link ReferenceLineProps}.\n * @returns Decorative chart content in the caller's coordinate space.\n */\nexport function ReferenceLine(props: ReferenceLineProps) { return lines(props, { tickValues: [resolveSignalValue(props.value)] }); }\n"],
|
|
5
|
+
"mappings": "AAkDW;AAlDX,SAAS,MAAM,0BAA4C;AAG3D,SAAS,mBAAmB;AAC5B,SAAS,OAAO,gBAAgB;AAChC,SAAS,OAAO,eAAe;AAgC/B,SAAS,MAAM,OAAuB,WAAwD;AAC5F,MAAI,MAAM,cAAc,gBAAgB,MAAM,cAAc,WAAY,OAAM,IAAI,UAAU,sDAAsD;AAClJ,QAAM,SAAS,YAAY,MAAM,OAAO,YAAY;AACpD,MAAI,CAAC,OAAQ,OAAM,IAAI,UAAU,iCAAiC;AAClE,QAAM,QAAQ,OAAO,IAAI,GAAG,OAAO,mBAAmB,MAAM,IAAI;AAChE,MAAI,CAAC,MAAM,QAAQ,IAAI,KAAK,KAAK,WAAW,KAAK,CAAC,KAAK,MAAM,OAAK,OAAO,MAAM,YAAY,OAAO,SAAS,CAAC,CAAC,EAAG,OAAM,IAAI,WAAW,uDAAuD;AAC5L,QAAM,QAAQ,mBAAmB,MAAM,KAAK,KAAK,CAAC;AAClD,QAAM,SAAS,mBAAmB,MAAM,MAAM,KAAK;AACnD,QAAM,cAAc,MAAM,mBAAmB,MAAM,WAAW,KAAK,GAAG,YAAY;AAClF,QAAM,QAAQ,QAAQ,mBAAmB,MAAM,OAAO,KAAK,GAAG,YAAY;AAC1E,SAAO,MAAM,OAAO,SAAS,EAAE,IAAI,CAAC,OAAO,UAAU;AACnD,UAAM,IAAI,SAAS,OAAO,KAAK;AAC/B,UAAM,SAA6B,MAAM,cAAc,eAAe,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;AAChI,WAAO,oBAAC,QAAiB,eAAc,QAAO,OAAO,EAAE,QAAQ,QAAQ,aAAa,SAAS,MAAM,KAAjF,KAAoF;AAAA,EACxG,CAAC;AACH;AAKO,SAAS,UAAU,OAAuB;AAAE,SAAO,MAAM,OAAO,KAAK;AAAG;AAKxE,SAAS,cAAc,OAA2B;AAAE,SAAO,MAAM,OAAO,EAAE,YAAY,CAAC,mBAAmB,MAAM,KAAK,CAAC,EAAE,CAAC;AAAG;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type Signal } from "@pibbl/core";
|
|
2
|
+
import type { ScaleId } from "./types.js";
|
|
3
|
+
export declare function provideColor<T>(id: ScaleId, kind: string, resolve: () => T, deps: readonly unknown[]): void;
|
|
4
|
+
export declare function useColor<T>(id: ScaleId, kind: string): Signal<T>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useComputed } from "@pibbl/core";
|
|
2
|
+
import {
|
|
3
|
+
getCurrentBackendHostCanvas,
|
|
4
|
+
setCurrentComponentAfterRender,
|
|
5
|
+
useInternalHookSlot
|
|
6
|
+
} from "@pibbl/core/internal";
|
|
7
|
+
let current;
|
|
8
|
+
function provideColor(id, kind, resolve, deps) {
|
|
9
|
+
if ((typeof id !== "string" || id.length === 0) && typeof id !== "symbol")
|
|
10
|
+
throw new TypeError("Color scale id requires a nonempty string or symbol.");
|
|
11
|
+
const value = useComputed(resolve, deps), parent = current;
|
|
12
|
+
current = { id, kind, value, canvas: getCurrentBackendHostCanvas(), parent };
|
|
13
|
+
const restore = () => {
|
|
14
|
+
current = parent;
|
|
15
|
+
};
|
|
16
|
+
try {
|
|
17
|
+
setCurrentComponentAfterRender(restore);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
restore();
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function useColor(id, kind) {
|
|
24
|
+
useInternalHookSlot("vizColorScaleLookup", () => void 0);
|
|
25
|
+
for (let scope = current; scope; scope = scope.parent) {
|
|
26
|
+
if (scope.id !== id) continue;
|
|
27
|
+
if (scope.canvas !== getCurrentBackendHostCanvas())
|
|
28
|
+
throw new Error("Color scale cannot cross a Layer boundary.");
|
|
29
|
+
if (scope.kind !== kind)
|
|
30
|
+
throw new TypeError(`Expected ${kind} color scale; found ${scope.kind}.`);
|
|
31
|
+
return scope.value;
|
|
32
|
+
}
|
|
33
|
+
throw new Error(
|
|
34
|
+
`Unknown color scale ${String(id)}; add the matching ancestor provider.`
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
provideColor,
|
|
39
|
+
useColor
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=color-context.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/features/viz/lib/color-context.ts"],
|
|
4
|
+
"sourcesContent": ["import { useComputed, type Signal } from \"@pibbl/core\";\nimport {\n getCurrentBackendHostCanvas,\n setCurrentComponentAfterRender,\n useInternalHookSlot,\n} from \"@pibbl/core/internal\";\nimport type { ScaleId } from \"./types.js\";\ninterface Scope {\n id: ScaleId;\n kind: string;\n value: Signal<unknown>;\n canvas: ReturnType<typeof getCurrentBackendHostCanvas>;\n parent: Scope | undefined;\n}\nlet current: Scope | undefined;\nexport function provideColor<T>(\n id: ScaleId,\n kind: string,\n resolve: () => T,\n deps: readonly unknown[],\n): void {\n if ((typeof id !== \"string\" || id.length === 0) && typeof id !== \"symbol\")\n throw new TypeError(\"Color scale id requires a nonempty string or symbol.\");\n const value = useComputed(resolve, deps),\n parent = current;\n current = { id, kind, value, canvas: getCurrentBackendHostCanvas(), parent };\n const restore = () => {\n current = parent;\n };\n try {\n setCurrentComponentAfterRender(restore);\n } catch (error) {\n restore();\n throw error;\n }\n}\nexport function useColor<T>(id: ScaleId, kind: string): Signal<T> {\n useInternalHookSlot(\"vizColorScaleLookup\", () => undefined);\n for (let scope = current; scope; scope = scope.parent) {\n if (scope.id !== id) continue;\n if (scope.canvas !== getCurrentBackendHostCanvas())\n throw new Error(\"Color scale cannot cross a Layer boundary.\");\n if (scope.kind !== kind)\n throw new TypeError(`Expected ${kind} color scale; found ${scope.kind}.`);\n return scope.value as Signal<T>;\n }\n throw new Error(\n `Unknown color scale ${String(id)}; add the matching ancestor provider.`,\n );\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,mBAAgC;AACzC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AASP,IAAI;AACG,SAAS,aACd,IACA,MACA,SACA,MACM;AACN,OAAK,OAAO,OAAO,YAAY,GAAG,WAAW,MAAM,OAAO,OAAO;AAC/D,UAAM,IAAI,UAAU,sDAAsD;AAC5E,QAAM,QAAQ,YAAY,SAAS,IAAI,GACrC,SAAS;AACX,YAAU,EAAE,IAAI,MAAM,OAAO,QAAQ,4BAA4B,GAAG,OAAO;AAC3E,QAAM,UAAU,MAAM;AACpB,cAAU;AAAA,EACZ;AACA,MAAI;AACF,mCAA+B,OAAO;AAAA,EACxC,SAAS,OAAO;AACd,YAAQ;AACR,UAAM;AAAA,EACR;AACF;AACO,SAAS,SAAY,IAAa,MAAyB;AAChE,sBAAoB,uBAAuB,MAAM,MAAS;AAC1D,WAAS,QAAQ,SAAS,OAAO,QAAQ,MAAM,QAAQ;AACrD,QAAI,MAAM,OAAO,GAAI;AACrB,QAAI,MAAM,WAAW,4BAA4B;AAC/C,YAAM,IAAI,MAAM,4CAA4C;AAC9D,QAAI,MAAM,SAAS;AACjB,YAAM,IAAI,UAAU,YAAY,IAAI,uBAAuB,MAAM,IAAI,GAAG;AAC1E,WAAO,MAAM;AAAA,EACf;AACA,QAAM,IAAI;AAAA,IACR,uBAAuB,OAAO,EAAE,CAAC;AAAA,EACnC;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function finiteColorValue(value: number): number;
|
|
2
|
+
export declare function hexColor(color: string): string;
|
|
3
|
+
export declare function colorMix(a: string, b: string, t: number): string;
|
|
4
|
+
export declare function colorPosition(value: number, a: number, b: number): number;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
function finiteColorValue(value) {
|
|
2
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
3
|
+
throw new RangeError("Color scale values must be finite numbers.");
|
|
4
|
+
return value;
|
|
5
|
+
}
|
|
6
|
+
function hexColor(color) {
|
|
7
|
+
if (typeof color !== "string" || !/^#[0-9a-f]{6}$/i.test(color))
|
|
8
|
+
throw new TypeError("Color scales require #RRGGBB colors.");
|
|
9
|
+
return color.toLowerCase();
|
|
10
|
+
}
|
|
11
|
+
function colorMix(a, b, t) {
|
|
12
|
+
return "#" + [1, 3, 5].map(
|
|
13
|
+
(i) => Math.round(
|
|
14
|
+
parseInt(a.slice(i, i + 2), 16) * (1 - t) + parseInt(b.slice(i, i + 2), 16) * t
|
|
15
|
+
).toString(16).padStart(2, "0")
|
|
16
|
+
).join("");
|
|
17
|
+
}
|
|
18
|
+
function colorPosition(value, a, b) {
|
|
19
|
+
if (a === b) return 0.5;
|
|
20
|
+
if (a < b && value <= a || a > b && value >= a) return 0;
|
|
21
|
+
if (a < b && value >= b || a > b && value <= b) return 1;
|
|
22
|
+
const span = b - a;
|
|
23
|
+
return Number.isFinite(span) ? (value - a) / span : (value / 2 - a / 2) / (b / 2 - a / 2);
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
colorMix,
|
|
27
|
+
colorPosition,
|
|
28
|
+
finiteColorValue,
|
|
29
|
+
hexColor
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=color-math.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/features/viz/lib/color-math.ts"],
|
|
4
|
+
"sourcesContent": ["export function finiteColorValue(value: number): number {\n if (typeof value !== \"number\" || !Number.isFinite(value))\n throw new RangeError(\"Color scale values must be finite numbers.\");\n return value;\n}\nexport function hexColor(color: string): string {\n if (typeof color !== \"string\" || !/^#[0-9a-f]{6}$/i.test(color))\n throw new TypeError(\"Color scales require #RRGGBB colors.\");\n return color.toLowerCase();\n}\nexport function colorMix(a: string, b: string, t: number): string {\n return (\n \"#\" +\n [1, 3, 5]\n .map((i) =>\n Math.round(\n parseInt(a.slice(i, i + 2), 16) * (1 - t) +\n parseInt(b.slice(i, i + 2), 16) * t,\n )\n .toString(16)\n .padStart(2, \"0\"),\n )\n .join(\"\")\n );\n}\nexport function colorPosition(value: number, a: number, b: number): number {\n if (a === b) return 0.5;\n if ((a < b && value <= a) || (a > b && value >= a)) return 0;\n if ((a < b && value >= b) || (a > b && value <= b)) return 1;\n const span = b - a;\n return Number.isFinite(span)\n ? (value - a) / span\n : (value / 2 - a / 2) / (b / 2 - a / 2);\n}\n"],
|
|
5
|
+
"mappings": "AAAO,SAAS,iBAAiB,OAAuB;AACtD,MAAI,OAAO,UAAU,YAAY,CAAC,OAAO,SAAS,KAAK;AACrD,UAAM,IAAI,WAAW,4CAA4C;AACnE,SAAO;AACT;AACO,SAAS,SAAS,OAAuB;AAC9C,MAAI,OAAO,UAAU,YAAY,CAAC,kBAAkB,KAAK,KAAK;AAC5D,UAAM,IAAI,UAAU,sCAAsC;AAC5D,SAAO,MAAM,YAAY;AAC3B;AACO,SAAS,SAAS,GAAW,GAAW,GAAmB;AAChE,SACE,MACA,CAAC,GAAG,GAAG,CAAC,EACL;AAAA,IAAI,CAAC,MACJ,KAAK;AAAA,MACH,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,KAAK,IAAI,KACrC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI;AAAA,IACtC,EACG,SAAS,EAAE,EACX,SAAS,GAAG,GAAG;AAAA,EACpB,EACC,KAAK,EAAE;AAEd;AACO,SAAS,cAAc,OAAe,GAAW,GAAmB;AACzE,MAAI,MAAM,EAAG,QAAO;AACpB,MAAK,IAAI,KAAK,SAAS,KAAO,IAAI,KAAK,SAAS,EAAI,QAAO;AAC3D,MAAK,IAAI,KAAK,SAAS,KAAO,IAAI,KAAK,SAAS,EAAI,QAAO;AAC3D,QAAM,OAAO,IAAI;AACjB,SAAO,OAAO,SAAS,IAAI,KACtB,QAAQ,KAAK,QACb,QAAQ,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI;AACzC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|