@pibbl/core 0.0.1 → 0.0.3-alpha.85.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.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/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.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/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/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 +15 -20
- 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 +39 -0
- package/dist/features/textures/lib/gray-scott.js.map +7 -0
- 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/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/viz/index.d.ts +79 -5
- package/dist/features/viz/index.js +145 -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 +23 -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 +148 -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/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 +124 -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/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/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 +27 -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 +123 -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/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 +106 -0
- package/dist/filters/emboss.js.map +7 -0
- 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-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 +2 -0
- package/dist/filters.js +2 -0
- package/dist/filters.js.map +2 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +2 -2
- package/dist/internal.d.ts +2 -0
- package/dist/internal.js +4 -0
- package/dist/internal.js.map +2 -2
- 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/events/event-facade.d.ts +13 -0
- package/dist/lib/events/event-facade.js +23 -0
- package/dist/lib/events/event-facade.js.map +2 -2
- package/dist/lib/events/propagation.js +19 -14
- package/dist/lib/events/propagation.js.map +2 -2
- package/dist/lib/execute-render.js +13 -0
- package/dist/lib/execute-render.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/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-transaction.d.ts +5 -2
- package/dist/lib/render-transaction.js +23 -1
- package/dist/lib/render-transaction.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/types.d.ts +6 -0
- package/package.json +27 -5
- 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,136 @@
|
|
|
1
|
+
import { Fragment, jsx } from "@pibbl/core/jsx-runtime";
|
|
2
|
+
import { Path, resolveSignalValue } from "@pibbl/core";
|
|
3
|
+
import { useInternalValueMemoSlot, validateTexturePaint } from "@pibbl/core/internal";
|
|
4
|
+
import { useNumericPosition } from "./series-position.js";
|
|
5
|
+
import { opacity, width } from "./paint.js";
|
|
6
|
+
import { finiteCoordinate, pointAccessor, pointData } from "./point-data.js";
|
|
7
|
+
function fill(value, receiver) {
|
|
8
|
+
if (typeof value === "string" || value instanceof CanvasGradient || value instanceof CanvasPattern)
|
|
9
|
+
return value;
|
|
10
|
+
try {
|
|
11
|
+
validateTexturePaint(value);
|
|
12
|
+
return value;
|
|
13
|
+
} catch {
|
|
14
|
+
throw new TypeError(`${receiver}: invalid fill.`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function side(value, baseline) {
|
|
18
|
+
return value >= baseline ? "above" : "below";
|
|
19
|
+
}
|
|
20
|
+
function BaselineSeries({
|
|
21
|
+
data: dataInput,
|
|
22
|
+
x: xInput,
|
|
23
|
+
y: yInput,
|
|
24
|
+
xScale: xId,
|
|
25
|
+
yScale: yId,
|
|
26
|
+
baseline: baselineInput,
|
|
27
|
+
defined,
|
|
28
|
+
inspection,
|
|
29
|
+
style: styleInput,
|
|
30
|
+
...eventProps
|
|
31
|
+
}) {
|
|
32
|
+
const xScale = useNumericPosition(xId), yScale = useNumericPosition(yId);
|
|
33
|
+
if (yScale.type !== "linear")
|
|
34
|
+
throw new TypeError("BaselineSeries requires LinearScale for yScale.");
|
|
35
|
+
const x = useInternalValueMemoSlot("vizBaselineXAccessor", () => pointAccessor(xInput), [xInput]);
|
|
36
|
+
const y = useInternalValueMemoSlot("vizBaselineYAccessor", () => pointAccessor(yInput), [yInput]);
|
|
37
|
+
const data = pointData(resolveSignalValue(dataInput), "BaselineSeries");
|
|
38
|
+
const baseline = resolveSignalValue(baselineInput);
|
|
39
|
+
if (typeof baseline !== "number" || !Number.isFinite(baseline))
|
|
40
|
+
throw new RangeError("BaselineSeries baseline must be finite.");
|
|
41
|
+
const baselineY = yScale.map(baseline);
|
|
42
|
+
if (!Number.isFinite(baselineY)) throw new RangeError("BaselineSeries baseline must map to a finite coordinate.");
|
|
43
|
+
const style = resolveSignalValue(styleInput) ?? {};
|
|
44
|
+
if (style === null || typeof style !== "object" || Array.isArray(style))
|
|
45
|
+
throw new TypeError("BaselineSeries style must be an object.");
|
|
46
|
+
const above = resolveSignalValue(style.above) ?? {}, below = resolveSignalValue(style.below) ?? {};
|
|
47
|
+
const aboveFill = fill(resolveSignalValue(above.fill) ?? "#087f8c", "BaselineSeries above");
|
|
48
|
+
const belowFill = fill(resolveSignalValue(below.fill) ?? "#d9674c", "BaselineSeries below");
|
|
49
|
+
const aboveStroke = resolveSignalValue(above.stroke) ?? "#087f8c";
|
|
50
|
+
const belowStroke = resolveSignalValue(below.stroke) ?? "#d9674c";
|
|
51
|
+
const fillOpacity = opacity(resolveSignalValue(style.fillOpacity) ?? 0.2, "BaselineSeries fill");
|
|
52
|
+
const strokeWidth = width(resolveSignalValue(style.strokeWidth) ?? 2, "BaselineSeries stroke");
|
|
53
|
+
const cursor = resolveSignalValue(style.cursor);
|
|
54
|
+
if (cursor !== void 0 && typeof cursor !== "string") throw new TypeError("BaselineSeries cursor must be a string.");
|
|
55
|
+
const pieces = [];
|
|
56
|
+
const captured = inspection ? [] : void 0;
|
|
57
|
+
let previous;
|
|
58
|
+
let run = 0;
|
|
59
|
+
const breakRun = () => {
|
|
60
|
+
previous = void 0;
|
|
61
|
+
run++;
|
|
62
|
+
};
|
|
63
|
+
const segment = (first, second) => {
|
|
64
|
+
const firstSide = side(first.domainY, baseline), secondSide = side(second.domainY, baseline);
|
|
65
|
+
const points = [
|
|
66
|
+
{ point: first, side: firstSide }
|
|
67
|
+
];
|
|
68
|
+
if (firstSide !== secondSide) {
|
|
69
|
+
const firstDistance = Math.abs(first.domainY - baseline);
|
|
70
|
+
const secondDistance = Math.abs(second.domainY - baseline);
|
|
71
|
+
const amount = firstDistance > secondDistance ? 1 / (1 + secondDistance / firstDistance) : firstDistance / secondDistance / (1 + firstDistance / secondDistance);
|
|
72
|
+
points.push({
|
|
73
|
+
point: { x: first.x + (second.x - first.x) * amount, y: baselineY, domainY: baseline },
|
|
74
|
+
side: firstSide
|
|
75
|
+
});
|
|
76
|
+
points.push({
|
|
77
|
+
point: { x: first.x + (second.x - first.x) * amount, y: baselineY, domainY: baseline },
|
|
78
|
+
side: secondSide
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
points.push({ point: second, side: secondSide });
|
|
82
|
+
for (let index = 1; index < points.length; index++) {
|
|
83
|
+
const start = points[index - 1], end = points[index];
|
|
84
|
+
const kind = start.side;
|
|
85
|
+
const a = start.point, b = end.point;
|
|
86
|
+
const stroke = new Path2D();
|
|
87
|
+
stroke.moveTo(a.x, a.y);
|
|
88
|
+
stroke.lineTo(b.x, b.y);
|
|
89
|
+
if (a.y === baselineY && b.y === baselineY) {
|
|
90
|
+
pieces.push({ side: kind, fill: void 0, stroke });
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
const fill2 = new Path2D();
|
|
94
|
+
fill2.moveTo(a.x, baselineY);
|
|
95
|
+
fill2.lineTo(a.x, a.y);
|
|
96
|
+
fill2.lineTo(b.x, b.y);
|
|
97
|
+
fill2.lineTo(b.x, baselineY);
|
|
98
|
+
fill2.closePath();
|
|
99
|
+
pieces.push({ side: kind, fill: fill2, stroke });
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
for (let index = 0; index < data.length; index++) {
|
|
103
|
+
const datum = data[index];
|
|
104
|
+
if (defined && !defined(datum, index, data)) {
|
|
105
|
+
breakRun();
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const domainX = x(datum, index, data), domainY = y(datum, index, data);
|
|
109
|
+
if (!finiteCoordinate(domainX) || !finiteCoordinate(domainY)) {
|
|
110
|
+
breakRun();
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
const mappedX = xScale.map(domainX), mappedY = yScale.map(domainY);
|
|
114
|
+
if (!Number.isFinite(mappedX) || !Number.isFinite(mappedY)) {
|
|
115
|
+
breakRun();
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
const point = { datum, domainX, domainY, x: mappedX, y: mappedY };
|
|
119
|
+
captured?.push(Object.freeze({ datum, sourceIndex: index, domainX: point.domainX, domainY: point.domainY, anchorLocal: Object.freeze({ x: point.x, y: point.y }), run }));
|
|
120
|
+
if (previous) segment(previous, point);
|
|
121
|
+
previous = point;
|
|
122
|
+
}
|
|
123
|
+
if (inspection) inspection.capture({ observations: captured, xScale, yScale });
|
|
124
|
+
return /* @__PURE__ */ jsx(Fragment, { children: pieces.flatMap((piece, index) => {
|
|
125
|
+
const fill2 = piece.side === "above" ? aboveFill : belowFill;
|
|
126
|
+
const stroke = piece.side === "above" ? aboveStroke : belowStroke;
|
|
127
|
+
return [
|
|
128
|
+
...piece.fill ? [/* @__PURE__ */ jsx(Path, { ...eventProps, style: { d: piece.fill, fill: fill2, opacity: fillOpacity, cursor } }, `${index}:fill`)] : [],
|
|
129
|
+
/* @__PURE__ */ jsx(Path, { ...eventProps, style: { d: piece.stroke, stroke, strokeWidth, cursor } }, `${index}:stroke`)
|
|
130
|
+
];
|
|
131
|
+
}) });
|
|
132
|
+
}
|
|
133
|
+
export {
|
|
134
|
+
BaselineSeries
|
|
135
|
+
};
|
|
136
|
+
//# sourceMappingURL=baseline-series.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/features/viz/lib/baseline-series.tsx"],
|
|
4
|
+
"sourcesContent": ["import { Path, resolveSignalValue } from \"@pibbl/core\";\nimport type {\n FillStyle,\n PibblEventHandlers,\n PibblEventParticipationOptions,\n SignalValue,\n StrokeStyle,\n} from \"@pibbl/core\";\nimport { useInternalValueMemoSlot, validateTexturePaint } from \"@pibbl/core/internal\";\nimport type { SignalStyle } from \"@pibbl/core/internal\";\nimport type { LineAccessor, LineSeriesProps, ScaleId } from \"./types.js\";\nimport { useNumericPosition } from \"./series-position.js\";\nimport { opacity, width } from \"./paint.js\";\nimport { finiteCoordinate, pointAccessor, pointData } from \"./point-data.js\";\n\n/** Shared paint for one side of a baseline. See {@link BaselineSeries}. */\nexport interface BaselineSideStyle {\n /** Area fill for this side of the baseline. */\n readonly fill?: FillStyle;\n /** Line stroke for this side of the baseline. */\n readonly stroke?: StrokeStyle;\n}\n\n/** Shared presentation for a linear baseline series. See {@link BaselineSeries}. */\nexport interface BaselineSeriesStyle {\n /** Paint for y values greater than or equal to baseline. */\n readonly above?: BaselineSideStyle;\n /** Paint for y values less than baseline. */\n readonly below?: BaselineSideStyle;\n /** Opacity for both area fills; defaults to 0.2. */\n readonly fillOpacity?: number;\n /** Width for both line strokes; defaults to 2. */\n readonly strokeWidth?: number;\n /** Cursor while a painted series path owns targeting. */\n readonly cursor?: string;\n}\n\n/** A linear connected series split into independently painted regions at baseline crossings. See\n * {@link BaselineSeries}.\n */\nexport interface BaselineSeriesProps<D>\n extends PibblEventHandlers, PibblEventParticipationOptions {\n /** Application records or a signal of records; source order is retained. */\n readonly data: SignalValue<readonly D[]>;\n /** Property key or callback extracting horizontal coordinates. */\n readonly x: LineAccessor<D>;\n /** Property key or callback extracting vertical coordinates. */\n readonly y: LineAccessor<D>;\n /** Numeric or trading-time horizontal scale identity. */\n readonly xScale: ScaleId;\n /** Linear vertical scale identity. */\n readonly yScale: ScaleId;\n /** Finite data-space division between the above and below presentations. */\n readonly baseline: SignalValue<number>;\n /** Excludes a record before its accessors run. */\n readonly defined?: LineSeriesProps<D>[\"defined\"];\n /** Optional committed original-record capture on the standard numeric inspection foundation. */\n readonly inspection?: import(\"../inspection/capture-types.js\").NumericInspectionRef<D>;\n /** Shared above/below paint and interaction presentation. */\n readonly style?: SignalValue<SignalStyle<BaselineSeriesStyle>>;\n}\n\ninterface Point<D> {\n readonly datum: D;\n readonly domainX: number;\n readonly domainY: number;\n readonly x: number;\n readonly y: number;\n}\n\ninterface Piece {\n readonly side: \"above\" | \"below\";\n readonly fill: Path2D | undefined;\n readonly stroke: Path2D;\n}\n\nfunction fill(value: unknown, receiver: string): FillStyle {\n if (typeof value === \"string\" || value instanceof CanvasGradient || value instanceof CanvasPattern)\n return value;\n try {\n validateTexturePaint(value as never);\n return value as FillStyle;\n } catch {\n throw new TypeError(`${receiver}: invalid fill.`);\n }\n}\n\nfunction side(value: number, baseline: number): \"above\" | \"below\" {\n return value >= baseline ? \"above\" : \"below\";\n}\n\n/**\n * Draws a linear connected series with independently painted regions above and below a baseline.\n * Equal values belong to the above stroke; zero-area spans never receive a fill. Gaps split runs,\n * and optional inspection captures only original records.\n * @param props - Records, a numeric or trading-time x scale, linear price y scale, baseline, event props, and shared side paint.\n * @returns Filled and stroked Pibbl paths in source paint order.\n * @see {@link LineSeriesProps}\n */\nexport function BaselineSeries<D>({\n data: dataInput,\n x: xInput,\n y: yInput,\n xScale: xId,\n yScale: yId,\n baseline: baselineInput,\n defined,\n inspection,\n style: styleInput,\n ...eventProps\n}: BaselineSeriesProps<D>) {\n const xScale = useNumericPosition(xId), yScale = useNumericPosition(yId);\n if (yScale.type !== \"linear\")\n throw new TypeError(\"BaselineSeries requires LinearScale for yScale.\");\n const x = useInternalValueMemoSlot(\"vizBaselineXAccessor\", () => pointAccessor(xInput), [xInput]);\n const y = useInternalValueMemoSlot(\"vizBaselineYAccessor\", () => pointAccessor(yInput), [yInput]);\n const data = pointData(resolveSignalValue(dataInput), \"BaselineSeries\");\n const baseline = resolveSignalValue(baselineInput);\n if (typeof baseline !== \"number\" || !Number.isFinite(baseline))\n throw new RangeError(\"BaselineSeries baseline must be finite.\");\n const baselineY = yScale.map(baseline);\n if (!Number.isFinite(baselineY)) throw new RangeError(\"BaselineSeries baseline must map to a finite coordinate.\");\n const style = resolveSignalValue(styleInput) ?? {};\n if (style === null || typeof style !== \"object\" || Array.isArray(style))\n throw new TypeError(\"BaselineSeries style must be an object.\");\n const above = resolveSignalValue(style.above) ?? {}, below = resolveSignalValue(style.below) ?? {};\n const aboveFill = fill(resolveSignalValue(above.fill) ?? \"#087f8c\", \"BaselineSeries above\");\n const belowFill = fill(resolveSignalValue(below.fill) ?? \"#d9674c\", \"BaselineSeries below\");\n const aboveStroke = resolveSignalValue(above.stroke) ?? \"#087f8c\";\n const belowStroke = resolveSignalValue(below.stroke) ?? \"#d9674c\";\n const fillOpacity = opacity(resolveSignalValue(style.fillOpacity) ?? 0.2, \"BaselineSeries fill\");\n const strokeWidth = width(resolveSignalValue(style.strokeWidth) ?? 2, \"BaselineSeries stroke\");\n const cursor = resolveSignalValue(style.cursor);\n if (cursor !== undefined && typeof cursor !== \"string\") throw new TypeError(\"BaselineSeries cursor must be a string.\");\n\n const pieces: Piece[] = [];\n const captured: import(\"../inspection/capture-types.js\").CapturedNumericObservation<D>[] | undefined = inspection ? [] : undefined;\n let previous: Point<D> | undefined;\n let run = 0;\n const breakRun = () => { previous = undefined; run++; };\n const segment = (first: Point<D>, second: Point<D>) => {\n const firstSide = side(first.domainY, baseline), secondSide = side(second.domainY, baseline);\n const points: { point: Point<D> | { x: number; y: number; domainY: number }; side: \"above\" | \"below\" }[] = [\n { point: first, side: firstSide },\n ];\n if (firstSide !== secondSide) {\n const firstDistance = Math.abs(first.domainY - baseline);\n const secondDistance = Math.abs(second.domainY - baseline);\n const amount = firstDistance > secondDistance\n ? 1 / (1 + secondDistance / firstDistance)\n : (firstDistance / secondDistance) / (1 + firstDistance / secondDistance);\n points.push({\n point: { x: first.x + (second.x - first.x) * amount, y: baselineY, domainY: baseline },\n side: firstSide,\n });\n points.push({\n point: { x: first.x + (second.x - first.x) * amount, y: baselineY, domainY: baseline },\n side: secondSide,\n });\n }\n points.push({ point: second, side: secondSide });\n for (let index = 1; index < points.length; index++) {\n const start = points[index - 1]!, end = points[index]!;\n const kind = start.side;\n const a = start.point, b = end.point;\n const stroke = new Path2D();\n stroke.moveTo(a.x, a.y);\n stroke.lineTo(b.x, b.y);\n if (a.y === baselineY && b.y === baselineY) {\n pieces.push({ side: kind, fill: undefined, stroke });\n continue;\n }\n const fill = new Path2D();\n fill.moveTo(a.x, baselineY);\n fill.lineTo(a.x, a.y);\n fill.lineTo(b.x, b.y);\n fill.lineTo(b.x, baselineY);\n fill.closePath();\n pieces.push({ side: kind, fill, stroke });\n }\n };\n for (let index = 0; index < data.length; index++) {\n const datum = data[index]!;\n if (defined && !defined(datum, index, data)) { breakRun(); continue; }\n const domainX = x(datum, index, data), domainY = y(datum, index, data);\n if (!finiteCoordinate(domainX) || !finiteCoordinate(domainY)) { breakRun(); continue; }\n const mappedX = xScale.map(domainX), mappedY = yScale.map(domainY);\n if (!Number.isFinite(mappedX) || !Number.isFinite(mappedY)) { breakRun(); continue; }\n const point: Point<D> = { datum, domainX, domainY, x: mappedX, y: mappedY };\n captured?.push(Object.freeze({ datum, sourceIndex: index, domainX: point.domainX, domainY: point.domainY, anchorLocal: Object.freeze({ x: point.x, y: point.y }), run }));\n if (previous) segment(previous, point);\n previous = point;\n }\n if (inspection) inspection.capture({ observations: captured!, xScale, yScale });\n return (\n <>\n {pieces.flatMap((piece, index) => {\n const fill = piece.side === \"above\" ? aboveFill : belowFill;\n const stroke = piece.side === \"above\" ? aboveStroke : belowStroke;\n return [\n ...(piece.fill ? [<Path key={`${index}:fill`} {...eventProps} style={{ d: piece.fill, fill, opacity: fillOpacity, cursor }} />] : []),\n <Path key={`${index}:stroke`} {...eventProps} style={{ d: piece.stroke, stroke, strokeWidth, cursor }} />,\n ];\n })}\n </>\n );\n}\n"],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,EACF,CAAC,GACH;AAEJ;",
|
|
6
|
+
"names": ["fill"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type FillStyle, type StrokeStyle, type SignalValue, type PibblEventHandlers, type PibblEventParticipationOptions, type PibblNode } from "@pibbl/core";
|
|
2
|
+
import type { LineAccessor, ScaleId } from "./types.js";
|
|
3
|
+
import type { CandleInspectionRef } from "../inspection/candle.js";
|
|
4
|
+
/** Open/close body paint, independent from wick paint.
|
|
5
|
+
* @see {@link CandlestickSeries}
|
|
6
|
+
*/
|
|
7
|
+
export interface CandleBodyStyle {
|
|
8
|
+
/** Interior; default teal for close >= open, coral otherwise. Empty string disables fill. */ readonly fill?: FillStyle;
|
|
9
|
+
/** Optional body outline. */ readonly stroke?: StrokeStyle;
|
|
10
|
+
/** Nonnegative local outline width; default 1. */ readonly strokeWidth?: number;
|
|
11
|
+
}
|
|
12
|
+
/** High/low wick paint.
|
|
13
|
+
* @see {@link CandlestickSeries}
|
|
14
|
+
*/
|
|
15
|
+
export interface CandleWickStyle {
|
|
16
|
+
/** Wick paint; default dark teal. Empty string disables wick paint. */ readonly stroke?: StrokeStyle;
|
|
17
|
+
/** Nonnegative local width; default 1. */ readonly strokeWidth?: number;
|
|
18
|
+
}
|
|
19
|
+
/** Accepted named body/wick presentation for OHLC marks.
|
|
20
|
+
* @see {@link CandlestickSeries}
|
|
21
|
+
*/
|
|
22
|
+
export interface CandlestickSeriesStyle {
|
|
23
|
+
/** Positive local body width, or automatic 70% spacing capped at 12; singleton fallback 8. */ readonly bandwidth?: number | "auto";
|
|
24
|
+
/** Independent open/close body appearance. */ readonly body?: CandleBodyStyle;
|
|
25
|
+
/** Independent high/low wick appearance. */ readonly wick?: CandleWickStyle;
|
|
26
|
+
/** Opacity zero through one; default 1. */ readonly opacity?: number;
|
|
27
|
+
/** Cursor while the series owns targeting. */ readonly cursor?: string;
|
|
28
|
+
}
|
|
29
|
+
/** Source-ordered OHLC records with named accessors and optional shared inspection.
|
|
30
|
+
* @see {@link CandlestickSeries}
|
|
31
|
+
*/
|
|
32
|
+
export interface CandlestickSeriesProps<D> extends PibblEventHandlers, PibblEventParticipationOptions {
|
|
33
|
+
/** Original records/signal; never sorted or mutated. */ readonly data: SignalValue<readonly D[]>;
|
|
34
|
+
/** UTC-millisecond property or callback. */ readonly time: LineAccessor<D>;
|
|
35
|
+
/** Open price property or callback. */ readonly open: LineAccessor<D>;
|
|
36
|
+
/** High price property or callback. */ readonly high: LineAccessor<D>;
|
|
37
|
+
/** Low price property or callback. */ readonly low: LineAccessor<D>;
|
|
38
|
+
/** Close price property or callback. */ readonly close: LineAccessor<D>;
|
|
39
|
+
/** Numeric/UTC/trading horizontal mapping identity. */ readonly xScale: ScaleId;
|
|
40
|
+
/** Independent numeric price mapping identity. */ readonly yScale: ScaleId;
|
|
41
|
+
/** Tests original rows before accessor evaluation.
|
|
42
|
+
* @param datum - Original row.
|
|
43
|
+
* @param index - Source index including skipped rows.
|
|
44
|
+
* @param data - Original complete array.
|
|
45
|
+
* @returns Whether the candle participates.
|
|
46
|
+
*/ readonly defined?: (datum: D, index: number, data: readonly D[]) => boolean;
|
|
47
|
+
/** Named body/wick appearance or a hook-free datum resolver.
|
|
48
|
+
* @param datum - Original row.
|
|
49
|
+
* @param index - Original source index.
|
|
50
|
+
* @param data - Complete source array.
|
|
51
|
+
* @returns Plain named candle styles.
|
|
52
|
+
*/ readonly style?: SignalValue<CandlestickSeriesStyle> | ((datum: D, index: number, data: readonly D[]) => CandlestickSeriesStyle);
|
|
53
|
+
/** Optional capture on the ordinary inspection foundation; no queries while painting. */ readonly inspection?: CandleInspectionRef<D>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Paints OHLC bodies and wicks, preserving source order and skipping complete missing candles.
|
|
57
|
+
* Finite malformed OHLC rejects; equal open/close paints a one-local-unit doji.
|
|
58
|
+
* @param props - Named OHLC accessors, scales, styles and optional inspection.
|
|
59
|
+
* @returns Ordinary Pibbl composition; disjoint equal styles share paint paths.
|
|
60
|
+
* @see {@link CandlestickSeriesProps}
|
|
61
|
+
*/
|
|
62
|
+
export declare function CandlestickSeries<D>({ data: input, time: timeInput, open: openInput, high: highInput, low: lowInput, close: closeInput, xScale, yScale, defined, style: styleInput, inspection, pointerEvents, ...events }: CandlestickSeriesProps<D>): PibblNode;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@pibbl/core/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
Group,
|
|
4
|
+
Path,
|
|
5
|
+
resolveSignalValue
|
|
6
|
+
} from "@pibbl/core";
|
|
7
|
+
import { withHooksForbidden } from "@pibbl/core/internal";
|
|
8
|
+
import { useNumericPosition } from "./series-position.js";
|
|
9
|
+
import { useContinuousScale } from "./use-continuous-scale.js";
|
|
10
|
+
import { pointAccessor, pointData, finiteCoordinate } from "./point-data.js";
|
|
11
|
+
import { financialMarkWidth, candleGeometry } from "./financial-geometry.js";
|
|
12
|
+
import { opacity, width } from "./paint.js";
|
|
13
|
+
function CandlestickSeries({
|
|
14
|
+
data: input,
|
|
15
|
+
time: timeInput,
|
|
16
|
+
open: openInput,
|
|
17
|
+
high: highInput,
|
|
18
|
+
low: lowInput,
|
|
19
|
+
close: closeInput,
|
|
20
|
+
xScale,
|
|
21
|
+
yScale,
|
|
22
|
+
defined,
|
|
23
|
+
style: styleInput,
|
|
24
|
+
inspection,
|
|
25
|
+
pointerEvents,
|
|
26
|
+
...events
|
|
27
|
+
}) {
|
|
28
|
+
const xs = useNumericPosition(xScale), ys = useContinuousScale(yScale).get();
|
|
29
|
+
const data = pointData(resolveSignalValue(input), "CandlestickSeries");
|
|
30
|
+
const time = pointAccessor(timeInput), open = pointAccessor(openInput), high = pointAccessor(highInput), low = pointAccessor(lowInput), close = pointAccessor(closeInput);
|
|
31
|
+
const rows = [];
|
|
32
|
+
for (let i = 0; i < data.length; i++) {
|
|
33
|
+
const datum = data[i];
|
|
34
|
+
if (defined && !defined(datum, i, data)) continue;
|
|
35
|
+
const t = time(datum, i, data), o = open(datum, i, data), h = high(datum, i, data), l = low(datum, i, data), c = close(datum, i, data);
|
|
36
|
+
if (!finiteCoordinate(t) || !finiteCoordinate(o) || !finiteCoordinate(h) || !finiteCoordinate(l) || !finiteCoordinate(c))
|
|
37
|
+
continue;
|
|
38
|
+
if (l > Math.min(o, c) || h < Math.max(o, c))
|
|
39
|
+
throw new RangeError(
|
|
40
|
+
`CandlestickSeries: malformed OHLC at source index ${i}; require low <= open/close <= high.`
|
|
41
|
+
);
|
|
42
|
+
rows.push({
|
|
43
|
+
datum,
|
|
44
|
+
sourceIndex: i,
|
|
45
|
+
time: t,
|
|
46
|
+
open: o,
|
|
47
|
+
high: h,
|
|
48
|
+
low: l,
|
|
49
|
+
close: c,
|
|
50
|
+
x: xs.map(t)
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
const defaultWidth = financialMarkWidth(rows.map((row) => row.x));
|
|
54
|
+
const specified = typeof styleInput === "function" ? styleInput : resolveSignalValue(styleInput);
|
|
55
|
+
const marks = inspection ? [] : void 0;
|
|
56
|
+
const batches = [];
|
|
57
|
+
for (const row of rows) {
|
|
58
|
+
const style = typeof specified === "function" ? withHooksForbidden(
|
|
59
|
+
"CandlestickSeries style callback",
|
|
60
|
+
() => specified(row.datum, row.sourceIndex, data)
|
|
61
|
+
) : specified ?? {};
|
|
62
|
+
const markWidth = style.bandwidth === void 0 || style.bandwidth === "auto" ? defaultWidth : financialMarkWidth([], { width: style.bandwidth });
|
|
63
|
+
const g = candleGeometry({
|
|
64
|
+
centerX: row.x,
|
|
65
|
+
openY: ys.map(row.open),
|
|
66
|
+
closeY: ys.map(row.close),
|
|
67
|
+
highY: ys.map(row.high),
|
|
68
|
+
lowY: ys.map(row.low),
|
|
69
|
+
width: markWidth,
|
|
70
|
+
dojiHeight: 1
|
|
71
|
+
});
|
|
72
|
+
const fill = style.body?.fill ?? (row.close >= row.open ? "#087f8c" : "#d9674c"), bodyStroke = style.body?.stroke, bodyWidth = width(style.body?.strokeWidth ?? 1, "CandlestickSeries body"), wickStroke = style.wick?.stroke ?? "#173a35", wickWidth = width(style.wick?.strokeWidth ?? 1, "CandlestickSeries wick"), alpha = opacity(style.opacity ?? 1, "CandlestickSeries");
|
|
73
|
+
marks?.push(
|
|
74
|
+
Object.freeze({
|
|
75
|
+
datum: row.datum,
|
|
76
|
+
sourceIndex: row.sourceIndex,
|
|
77
|
+
time: row.time,
|
|
78
|
+
open: row.open,
|
|
79
|
+
high: row.high,
|
|
80
|
+
low: row.low,
|
|
81
|
+
close: row.close,
|
|
82
|
+
anchorLocal: Object.freeze({ x: row.x, y: ys.map(row.close) }),
|
|
83
|
+
bodyBoundsLocal: g.bodyBoundsLocal,
|
|
84
|
+
wickLocal: g.wickLocal,
|
|
85
|
+
bodyFill: !!fill && alpha > 0,
|
|
86
|
+
bodyStrokeWidthLocal: bodyStroke && alpha > 0 ? bodyWidth : 0,
|
|
87
|
+
wickStrokeWidthLocal: wickStroke && alpha > 0 ? wickWidth : 0
|
|
88
|
+
})
|
|
89
|
+
);
|
|
90
|
+
if (alpha === 0) continue;
|
|
91
|
+
const half = Math.max(bodyStroke ? bodyWidth : 0, wickStroke ? wickWidth : 0) / 2, minX = g.bodyBoundsLocal.x - half, maxX = g.bodyBoundsLocal.x + markWidth + half;
|
|
92
|
+
let batch = batches.at(-1);
|
|
93
|
+
if (!batch || minX < batch.maxX && maxX > batch.minX || batch.fill !== fill || batch.bodyStroke !== bodyStroke || batch.bodyWidth !== bodyWidth || batch.wickStroke !== wickStroke || batch.wickWidth !== wickWidth || batch.opacity !== alpha || batch.cursor !== style.cursor) {
|
|
94
|
+
batch = {
|
|
95
|
+
body: new Path2D(),
|
|
96
|
+
wick: new Path2D(),
|
|
97
|
+
fill,
|
|
98
|
+
bodyStroke,
|
|
99
|
+
bodyWidth,
|
|
100
|
+
wickStroke,
|
|
101
|
+
wickWidth,
|
|
102
|
+
opacity: alpha,
|
|
103
|
+
cursor: style.cursor,
|
|
104
|
+
minX,
|
|
105
|
+
maxX
|
|
106
|
+
};
|
|
107
|
+
batches.push(batch);
|
|
108
|
+
}
|
|
109
|
+
batch.minX = Math.min(batch.minX, minX);
|
|
110
|
+
batch.maxX = Math.max(batch.maxX, maxX);
|
|
111
|
+
const b = g.bodyBoundsLocal;
|
|
112
|
+
batch.body.rect(b.x, b.y, b.width, b.height);
|
|
113
|
+
batch.wick.moveTo(g.wickLocal.x, g.wickLocal.highY);
|
|
114
|
+
batch.wick.lineTo(g.wickLocal.x, g.wickLocal.lowY);
|
|
115
|
+
}
|
|
116
|
+
inspection?.capture({ marks, xScale: xs, yScale: ys });
|
|
117
|
+
return /* @__PURE__ */ jsx(Group, { ...events, children: batches.map((batch, index) => /* @__PURE__ */ jsxs(Group, { children: [
|
|
118
|
+
/* @__PURE__ */ jsx(
|
|
119
|
+
Path,
|
|
120
|
+
{
|
|
121
|
+
pointerEvents,
|
|
122
|
+
style: {
|
|
123
|
+
d: batch.wick,
|
|
124
|
+
stroke: batch.wickStroke,
|
|
125
|
+
strokeWidth: batch.wickWidth,
|
|
126
|
+
opacity: batch.opacity,
|
|
127
|
+
cursor: batch.cursor
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
),
|
|
131
|
+
/* @__PURE__ */ jsx(
|
|
132
|
+
Path,
|
|
133
|
+
{
|
|
134
|
+
pointerEvents,
|
|
135
|
+
style: {
|
|
136
|
+
d: batch.body,
|
|
137
|
+
fill: batch.fill,
|
|
138
|
+
stroke: batch.bodyStroke,
|
|
139
|
+
strokeWidth: batch.bodyWidth,
|
|
140
|
+
opacity: batch.opacity,
|
|
141
|
+
cursor: batch.cursor
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
)
|
|
145
|
+
] }, index)) });
|
|
146
|
+
}
|
|
147
|
+
export {
|
|
148
|
+
CandlestickSeries
|
|
149
|
+
};
|
|
150
|
+
//# sourceMappingURL=candlestick-series.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/features/viz/lib/candlestick-series.tsx"],
|
|
4
|
+
"sourcesContent": ["import {\n Group,\n Path,\n resolveSignalValue,\n type FillStyle,\n type StrokeStyle,\n type SignalValue,\n type PibblEventHandlers,\n type PibblEventParticipationOptions,\n type PibblNode,\n} from \"@pibbl/core\";\nimport { withHooksForbidden } from \"@pibbl/core/internal\";\nimport type { LineAccessor, ScaleId } from \"./types.js\";\nimport type {\n CandleInspectionRef,\n CapturedCandleMark,\n} from \"../inspection/candle.js\";\nimport { useNumericPosition } from \"./series-position.js\";\nimport { useContinuousScale } from \"./use-continuous-scale.js\";\nimport { pointAccessor, pointData, finiteCoordinate } from \"./point-data.js\";\nimport { financialMarkWidth, candleGeometry } from \"./financial-geometry.js\";\nimport { opacity, width } from \"./paint.js\";\n/** Open/close body paint, independent from wick paint.\n * @see {@link CandlestickSeries}\n */\nexport interface CandleBodyStyle {\n /** Interior; default teal for close >= open, coral otherwise. Empty string disables fill. */ readonly fill?: FillStyle;\n /** Optional body outline. */ readonly stroke?: StrokeStyle;\n /** Nonnegative local outline width; default 1. */ readonly strokeWidth?: number;\n}\n/** High/low wick paint.\n * @see {@link CandlestickSeries}\n */\nexport interface CandleWickStyle {\n /** Wick paint; default dark teal. Empty string disables wick paint. */ readonly stroke?: StrokeStyle;\n /** Nonnegative local width; default 1. */ readonly strokeWidth?: number;\n}\n/** Accepted named body/wick presentation for OHLC marks.\n * @see {@link CandlestickSeries}\n */\nexport interface CandlestickSeriesStyle {\n /** Positive local body width, or automatic 70% spacing capped at 12; singleton fallback 8. */ readonly bandwidth?:\n number | \"auto\";\n /** Independent open/close body appearance. */ readonly body?: CandleBodyStyle;\n /** Independent high/low wick appearance. */ readonly wick?: CandleWickStyle;\n /** Opacity zero through one; default 1. */ readonly opacity?: number;\n /** Cursor while the series owns targeting. */ readonly cursor?: string;\n}\n/** Source-ordered OHLC records with named accessors and optional shared inspection.\n * @see {@link CandlestickSeries}\n */\nexport interface CandlestickSeriesProps<D>\n extends PibblEventHandlers, PibblEventParticipationOptions {\n /** Original records/signal; never sorted or mutated. */ readonly data: SignalValue<\n readonly D[]\n >;\n /** UTC-millisecond property or callback. */ readonly time: LineAccessor<D>;\n /** Open price property or callback. */ readonly open: LineAccessor<D>;\n /** High price property or callback. */ readonly high: LineAccessor<D>;\n /** Low price property or callback. */ readonly low: LineAccessor<D>;\n /** Close price property or callback. */ readonly close: LineAccessor<D>;\n /** Numeric/UTC/trading horizontal mapping identity. */ readonly xScale: ScaleId;\n /** Independent numeric price mapping identity. */ readonly yScale: ScaleId;\n /** Tests original rows before accessor evaluation.\n * @param datum - Original row.\n * @param index - Source index including skipped rows.\n * @param data - Original complete array.\n * @returns Whether the candle participates.\n */ readonly defined?: (\n datum: D,\n index: number,\n data: readonly D[],\n ) => boolean;\n /** Named body/wick appearance or a hook-free datum resolver.\n * @param datum - Original row.\n * @param index - Original source index.\n * @param data - Complete source array.\n * @returns Plain named candle styles.\n */ readonly style?:\n | SignalValue<CandlestickSeriesStyle>\n | ((datum: D, index: number, data: readonly D[]) => CandlestickSeriesStyle);\n /** Optional capture on the ordinary inspection foundation; no queries while painting. */ readonly inspection?: CandleInspectionRef<D>;\n}\n/**\n * Paints OHLC bodies and wicks, preserving source order and skipping complete missing candles.\n * Finite malformed OHLC rejects; equal open/close paints a one-local-unit doji.\n * @param props - Named OHLC accessors, scales, styles and optional inspection.\n * @returns Ordinary Pibbl composition; disjoint equal styles share paint paths.\n * @see {@link CandlestickSeriesProps}\n */\nexport function CandlestickSeries<D>({\n data: input,\n time: timeInput,\n open: openInput,\n high: highInput,\n low: lowInput,\n close: closeInput,\n xScale,\n yScale,\n defined,\n style: styleInput,\n inspection,\n pointerEvents,\n ...events\n}: CandlestickSeriesProps<D>): PibblNode {\n const xs = useNumericPosition(xScale),\n ys = useContinuousScale(yScale).get();\n const data = pointData(resolveSignalValue(input), \"CandlestickSeries\");\n const time = pointAccessor(timeInput),\n open = pointAccessor(openInput),\n high = pointAccessor(highInput),\n low = pointAccessor(lowInput),\n close = pointAccessor(closeInput);\n const rows: {\n datum: D;\n sourceIndex: number;\n time: number;\n open: number;\n high: number;\n low: number;\n close: number;\n x: number;\n }[] = [];\n for (let i = 0; i < data.length; i++) {\n const datum = data[i];\n if (defined && !defined(datum, i, data)) continue;\n const t = time(datum, i, data),\n o = open(datum, i, data),\n h = high(datum, i, data),\n l = low(datum, i, data),\n c = close(datum, i, data);\n if (\n !finiteCoordinate(t) ||\n !finiteCoordinate(o) ||\n !finiteCoordinate(h) ||\n !finiteCoordinate(l) ||\n !finiteCoordinate(c)\n )\n continue;\n if (l > Math.min(o, c) || h < Math.max(o, c))\n throw new RangeError(\n `CandlestickSeries: malformed OHLC at source index ${i}; require low <= open/close <= high.`,\n );\n rows.push({\n datum,\n sourceIndex: i,\n time: t,\n open: o,\n high: h,\n low: l,\n close: c,\n x: xs.map(t),\n });\n }\n const defaultWidth = financialMarkWidth(rows.map((row) => row.x));\n const specified =\n typeof styleInput === \"function\"\n ? styleInput\n : resolveSignalValue(styleInput);\n const marks: CapturedCandleMark<D>[] | undefined = inspection\n ? []\n : undefined;\n const batches: {\n body: Path2D;\n wick: Path2D;\n fill: FillStyle;\n bodyStroke: StrokeStyle | undefined;\n bodyWidth: number;\n wickStroke: StrokeStyle;\n wickWidth: number;\n opacity: number;\n cursor: string | undefined;\n minX: number;\n maxX: number;\n }[] = [];\n for (const row of rows) {\n const style =\n typeof specified === \"function\"\n ? withHooksForbidden(\"CandlestickSeries style callback\", () =>\n specified(row.datum, row.sourceIndex, data),\n )\n : (specified ?? {});\n const markWidth =\n style.bandwidth === undefined || style.bandwidth === \"auto\"\n ? defaultWidth\n : financialMarkWidth([], { width: style.bandwidth });\n const g = candleGeometry({\n centerX: row.x,\n openY: ys.map(row.open),\n closeY: ys.map(row.close),\n highY: ys.map(row.high),\n lowY: ys.map(row.low),\n width: markWidth,\n dojiHeight: 1,\n });\n const fill =\n style.body?.fill ?? (row.close >= row.open ? \"#087f8c\" : \"#d9674c\"),\n bodyStroke = style.body?.stroke,\n bodyWidth = width(style.body?.strokeWidth ?? 1, \"CandlestickSeries body\"),\n wickStroke = style.wick?.stroke ?? \"#173a35\",\n wickWidth = width(style.wick?.strokeWidth ?? 1, \"CandlestickSeries wick\"),\n alpha = opacity(style.opacity ?? 1, \"CandlestickSeries\");\n marks?.push(\n Object.freeze({\n datum: row.datum,\n sourceIndex: row.sourceIndex,\n time: row.time,\n open: row.open,\n high: row.high,\n low: row.low,\n close: row.close,\n anchorLocal: Object.freeze({ x: row.x, y: ys.map(row.close) }),\n bodyBoundsLocal: g.bodyBoundsLocal,\n wickLocal: g.wickLocal,\n bodyFill: !!fill && alpha > 0,\n bodyStrokeWidthLocal: bodyStroke && alpha > 0 ? bodyWidth : 0,\n wickStrokeWidthLocal: wickStroke && alpha > 0 ? wickWidth : 0,\n }),\n );\n if (alpha === 0) continue;\n const half =\n Math.max(bodyStroke ? bodyWidth : 0, wickStroke ? wickWidth : 0) / 2,\n minX = g.bodyBoundsLocal.x - half,\n maxX = g.bodyBoundsLocal.x + markWidth + half;\n let batch = batches.at(-1);\n if (\n !batch ||\n (minX < batch.maxX && maxX > batch.minX) ||\n batch.fill !== fill ||\n batch.bodyStroke !== bodyStroke ||\n batch.bodyWidth !== bodyWidth ||\n batch.wickStroke !== wickStroke ||\n batch.wickWidth !== wickWidth ||\n batch.opacity !== alpha ||\n batch.cursor !== style.cursor\n ) {\n batch = {\n body: new Path2D(),\n wick: new Path2D(),\n fill,\n bodyStroke,\n bodyWidth,\n wickStroke,\n wickWidth,\n opacity: alpha,\n cursor: style.cursor,\n minX,\n maxX,\n };\n batches.push(batch);\n }\n batch.minX = Math.min(batch.minX, minX);\n batch.maxX = Math.max(batch.maxX, maxX);\n const b = g.bodyBoundsLocal;\n batch.body.rect(b.x, b.y, b.width, b.height);\n batch.wick.moveTo(g.wickLocal.x, g.wickLocal.highY);\n batch.wick.lineTo(g.wickLocal.x, g.wickLocal.lowY);\n }\n inspection?.capture({ marks: marks!, xScale: xs, yScale: ys });\n return (\n <Group {...events}>\n {batches.map((batch, index) => (\n <Group key={index}>\n <Path\n pointerEvents={pointerEvents}\n style={{\n d: batch.wick,\n stroke: batch.wickStroke,\n strokeWidth: batch.wickWidth,\n opacity: batch.opacity,\n cursor: batch.cursor,\n }}\n />\n <Path\n pointerEvents={pointerEvents}\n style={{\n d: batch.body,\n fill: batch.fill,\n stroke: batch.bodyStroke,\n strokeWidth: batch.bodyWidth,\n opacity: batch.opacity,\n cursor: batch.cursor,\n }}\n />\n </Group>\n ))}\n </Group>\n );\n}\n"],
|
|
5
|
+
"mappings": "AAsQQ,SACE,KADF;AAtQR;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAOK;AACP,SAAS,0BAA0B;AAMnC,SAAS,0BAA0B;AACnC,SAAS,0BAA0B;AACnC,SAAS,eAAe,WAAW,wBAAwB;AAC3D,SAAS,oBAAoB,sBAAsB;AACnD,SAAS,SAAS,aAAa;AAqExB,SAAS,kBAAqB;AAAA,EACnC,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAyC;AACvC,QAAM,KAAK,mBAAmB,MAAM,GAClC,KAAK,mBAAmB,MAAM,EAAE,IAAI;AACtC,QAAM,OAAO,UAAU,mBAAmB,KAAK,GAAG,mBAAmB;AACrE,QAAM,OAAO,cAAc,SAAS,GAClC,OAAO,cAAc,SAAS,GAC9B,OAAO,cAAc,SAAS,GAC9B,MAAM,cAAc,QAAQ,GAC5B,QAAQ,cAAc,UAAU;AAClC,QAAM,OASA,CAAC;AACP,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAM,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,MAAM;AAAA,UACf,QAAQ,MAAM;AAAA,QAChB;AAAA;AAAA,IACF;AAAA,OArBU,KAsBZ,CACD,GACH;AAEJ;",
|
|
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
|