velo-plot 1.11.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/LICENSE +21 -0
- package/README.md +119 -0
- package/dist/EventEmitter-DAbs2K1C.js +60 -0
- package/dist/EventEmitter-DAbs2K1C.js.map +1 -0
- package/dist/core/Chart.d.ts +15 -0
- package/dist/core/ChartControls.d.ts +41 -0
- package/dist/core/ChartInitQueue.d.ts +50 -0
- package/dist/core/ChartLegend.d.ts +74 -0
- package/dist/core/ChartStatistics.d.ts +18 -0
- package/dist/core/EventEmitter.d.ts +30 -0
- package/dist/core/InteractionManager.d.ts +96 -0
- package/dist/core/OverlayRenderer.d.ts +89 -0
- package/dist/core/Series.d.ts +4 -0
- package/dist/core/animation/AnimationEngine.d.ts +156 -0
- package/dist/core/animation/index.d.ts +6 -0
- package/dist/core/annotations/AnnotationManager.d.ts +61 -0
- package/dist/core/annotations/index.d.ts +5 -0
- package/dist/core/annotations/types.d.ts +159 -0
- package/dist/core/chart/ChartAnimatedNavigation.d.ts +53 -0
- package/dist/core/chart/ChartAxisManager.d.ts +61 -0
- package/dist/core/chart/ChartCore.d.ts +336 -0
- package/dist/core/chart/ChartExporter.d.ts +18 -0
- package/dist/core/chart/ChartNavigation.d.ts +33 -0
- package/dist/core/chart/ChartPluginBridge.d.ts +34 -0
- package/dist/core/chart/ChartRenderLoop.d.ts +100 -0
- package/dist/core/chart/ChartRenderer.d.ts +52 -0
- package/dist/core/chart/ChartScaling.d.ts +31 -0
- package/dist/core/chart/ChartSeries.d.ts +4 -0
- package/dist/core/chart/ChartSetup.d.ts +67 -0
- package/dist/core/chart/ChartStateManager.d.ts +54 -0
- package/dist/core/chart/ChartUI.d.ts +40 -0
- package/dist/core/chart/exporter/SVGExporter.d.ts +6 -0
- package/dist/core/chart/exporter/index.d.ts +5 -0
- package/dist/core/chart/index.d.ts +14 -0
- package/dist/core/chart/series/SeriesActions.d.ts +7 -0
- package/dist/core/chart/series/SeriesBuffer.d.ts +4 -0
- package/dist/core/chart/series/index.d.ts +6 -0
- package/dist/core/chart/series/types.d.ts +22 -0
- package/dist/core/chart/types.d.ts +188 -0
- package/dist/core/clipboard/index.d.ts +137 -0
- package/dist/core/debug/index.d.ts +143 -0
- package/dist/core/index.d.ts +17 -0
- package/dist/core/keybindings/index.d.ts +157 -0
- package/dist/core/layout/index.d.ts +12 -0
- package/dist/core/layout/types.d.ts +165 -0
- package/dist/core/loading/index.d.ts +104 -0
- package/dist/core/locale/index.d.ts +91 -0
- package/dist/core/responsive/ResponsiveManager.d.ts +133 -0
- package/dist/core/responsive/index.d.ts +4 -0
- package/dist/core/selection/SelectionManager.d.ts +165 -0
- package/dist/core/selection/index.d.ts +4 -0
- package/dist/core/series/Series.d.ts +73 -0
- package/dist/core/series/SeriesBounds.d.ts +3 -0
- package/dist/core/series/SeriesDataUtils.d.ts +7 -0
- package/dist/core/series/index.d.ts +6 -0
- package/dist/core/sync/index.d.ts +147 -0
- package/dist/core/theme-editor/index.d.ts +122 -0
- package/dist/examples/PluginDemonstration.d.ts +20 -0
- package/dist/examples.d.ts +25 -0
- package/dist/gpu/adapter/gpuRenderer.d.ts +135 -0
- package/dist/gpu/adapter/index.d.ts +7 -0
- package/dist/gpu/adapter/seriesAdapter.d.ts +88 -0
- package/dist/gpu/backends/webgl/WebGLBackend.d.ts +42 -0
- package/dist/gpu/backends/webgl/index.d.ts +5 -0
- package/dist/gpu/backends/webgl/programFactory.d.ts +30 -0
- package/dist/gpu/backends/webgl/shaders.d.ts +14 -0
- package/dist/gpu/backends/webgpu/MassiveDataRenderer.d.ts +111 -0
- package/dist/gpu/backends/webgpu/WebGPUBackend.d.ts +58 -0
- package/dist/gpu/backends/webgpu/pipelines/bandPipeline.d.ts +24 -0
- package/dist/gpu/backends/webgpu/pipelines/heatmapPipeline.d.ts +28 -0
- package/dist/gpu/backends/webgpu/pipelines/index.d.ts +10 -0
- package/dist/gpu/backends/webgpu/pipelines/instancedLinePipeline.d.ts +23 -0
- package/dist/gpu/backends/webgpu/pipelines/instancedPointPipeline.d.ts +25 -0
- package/dist/gpu/backends/webgpu/pipelines/linePipeline.d.ts +23 -0
- package/dist/gpu/backends/webgpu/pipelines/pointPipeline.d.ts +28 -0
- package/dist/gpu/backends/webgpu/pipelines/trianglePipeline.d.ts +5 -0
- package/dist/gpu/backends/webgpu/pipelines/triangleShader.d.ts +1 -0
- package/dist/gpu/backends/webgpu/shaders/heatmap.wgsl.d.ts +8 -0
- package/dist/gpu/backends/webgpu/shaders/index.d.ts +8 -0
- package/dist/gpu/backends/webgpu/shaders/instanced.wgsl.d.ts +16 -0
- package/dist/gpu/backends/webgpu/shaders/line.wgsl.d.ts +8 -0
- package/dist/gpu/backends/webgpu/shaders/point.wgsl.d.ts +9 -0
- package/dist/gpu/benchmark/benchmark.d.ts +74 -0
- package/dist/gpu/benchmark/index.d.ts +5 -0
- package/dist/gpu/compute/gpuCompute.d.ts +72 -0
- package/dist/gpu/compute/index.d.ts +6 -0
- package/dist/gpu/compute/shaders.d.ts +9 -0
- package/dist/gpu/drawList.d.ts +77 -0
- package/dist/gpu/examples/gallery.d.ts +20 -0
- package/dist/gpu/examples/index.d.ts +3 -0
- package/dist/gpu/examples/webgpu-line-demo.d.ts +8 -0
- package/dist/gpu/examples/webgpu-triangle.d.ts +1 -0
- package/dist/gpu/frame.d.ts +25 -0
- package/dist/gpu/index.d.ts +24 -0
- package/dist/gpu/resources/bufferStore.d.ts +40 -0
- package/dist/gpu/resources/index.d.ts +9 -0
- package/dist/gpu/resources/pipelineCache.d.ts +33 -0
- package/dist/gpu/resources/textureStore.d.ts +41 -0
- package/dist/gpu/types.d.ts +47 -0
- package/dist/index-BMiZoKmm.js +536 -0
- package/dist/index-BMiZoKmm.js.map +1 -0
- package/dist/index-Ce2JgkH_.js +282 -0
- package/dist/index-Ce2JgkH_.js.map +1 -0
- package/dist/index-D8ifudJH.js +2431 -0
- package/dist/index-D8ifudJH.js.map +1 -0
- package/dist/index-Dag88bW4.js +499 -0
- package/dist/index-Dag88bW4.js.map +1 -0
- package/dist/index-qhscKTDy.js +309 -0
- package/dist/index-qhscKTDy.js.map +1 -0
- package/dist/index-x4stH3jD.js +282 -0
- package/dist/index-x4stH3jD.js.map +1 -0
- package/dist/index.core-CYu3tydL.js +7252 -0
- package/dist/index.core-CYu3tydL.js.map +1 -0
- package/dist/index.core.d.ts +20 -0
- package/dist/index.d.ts +51 -0
- package/dist/overlay/CanvasOverlay.d.ts +102 -0
- package/dist/overlay/index.d.ts +4 -0
- package/dist/plugins/3d/Area3DRenderer.d.ts +122 -0
- package/dist/plugins/3d/Axes3D.d.ts +104 -0
- package/dist/plugins/3d/Bubble3DRenderer.d.ts +198 -0
- package/dist/plugins/3d/Impulse3DRenderer.d.ts +130 -0
- package/dist/plugins/3d/Line3DRenderer.d.ts +118 -0
- package/dist/plugins/3d/PointCloud3DRenderer.d.ts +84 -0
- package/dist/plugins/3d/Raycaster3D.d.ts +137 -0
- package/dist/plugins/3d/Ribbon3DRenderer.d.ts +83 -0
- package/dist/plugins/3d/SurfaceBar3DRenderer.d.ts +92 -0
- package/dist/plugins/3d/SurfaceMesh3DRenderer.d.ts +130 -0
- package/dist/plugins/3d/Tooltip3D.d.ts +71 -0
- package/dist/plugins/3d/VectorField3DRenderer.d.ts +86 -0
- package/dist/plugins/3d/Voxel3DRenderer.d.ts +89 -0
- package/dist/plugins/3d/Waterfall3DRenderer.d.ts +94 -0
- package/dist/plugins/3d/camera/OrbitCamera.d.ts +99 -0
- package/dist/plugins/3d/camera/index.d.ts +1 -0
- package/dist/plugins/3d/colorThemes.d.ts +39 -0
- package/dist/plugins/3d/controls/OrbitController.d.ts +69 -0
- package/dist/plugins/3d/controls/index.d.ts +1 -0
- package/dist/plugins/3d/index.d.ts +50 -0
- package/dist/plugins/3d/math/Mat4.d.ts +33 -0
- package/dist/plugins/3d/math/Vec3.d.ts +37 -0
- package/dist/plugins/3d/math/index.d.ts +4 -0
- package/dist/plugins/3d/mesh/InstancedMesh.d.ts +42 -0
- package/dist/plugins/3d/mesh/geometry.d.ts +34 -0
- package/dist/plugins/3d/mesh/index.d.ts +2 -0
- package/dist/plugins/3d/series/Area3D.d.ts +17 -0
- package/dist/plugins/3d/series/Column3D.d.ts +20 -0
- package/dist/plugins/3d/series/Heatmap3D.d.ts +17 -0
- package/dist/plugins/3d/series/Impulse3D.d.ts +16 -0
- package/dist/plugins/3d/series/PointLine3D.d.ts +20 -0
- package/dist/plugins/3d/series/Ribbon3D.d.ts +17 -0
- package/dist/plugins/3d/series/Scatter3D.d.ts +21 -0
- package/dist/plugins/3d/series/SurfaceMesh3D.d.ts +35 -0
- package/dist/plugins/3d/series/Waterfall3D.d.ts +38 -0
- package/dist/plugins/3d/series/index.d.ts +13 -0
- package/dist/plugins/3d/series/types.d.ts +143 -0
- package/dist/plugins/3d/shader/index.d.ts +2 -0
- package/dist/plugins/3d/shader/programs.d.ts +24 -0
- package/dist/plugins/3d/shader/sources.d.ts +27 -0
- package/dist/plugins/3d/types.d.ts +71 -0
- package/dist/plugins/3d.d.ts +3 -0
- package/dist/plugins/3d.js +5498 -0
- package/dist/plugins/3d.js.map +1 -0
- package/dist/plugins/PluginContext.d.ts +53 -0
- package/dist/plugins/PluginManager.d.ts +129 -0
- package/dist/plugins/PluginRegistry.d.ts +38 -0
- package/dist/plugins/analysis/SeriesFit.d.ts +3 -0
- package/dist/plugins/analysis/contours.d.ts +20 -0
- package/dist/plugins/analysis/fft.d.ts +138 -0
- package/dist/plugins/analysis/filters.d.ts +76 -0
- package/dist/plugins/analysis/fitting.d.ts +24 -0
- package/dist/plugins/analysis/index.d.ts +29 -0
- package/dist/plugins/analysis/indicators.d.ts +148 -0
- package/dist/plugins/analysis/math.d.ts +32 -0
- package/dist/plugins/analysis/statistics.d.ts +78 -0
- package/dist/plugins/analysis/utils.d.ts +150 -0
- package/dist/plugins/analysis.d.ts +3 -0
- package/dist/plugins/analysis.js +1202 -0
- package/dist/plugins/analysis.js.map +1 -0
- package/dist/plugins/annotations/index.d.ts +16 -0
- package/dist/plugins/annotations.d.ts +3 -0
- package/dist/plugins/annotations.js +438 -0
- package/dist/plugins/annotations.js.map +1 -0
- package/dist/plugins/anomaly-detection/algorithms.d.ts +38 -0
- package/dist/plugins/anomaly-detection/index.d.ts +16 -0
- package/dist/plugins/anomaly-detection/types.d.ts +57 -0
- package/dist/plugins/broken-axis/BrokenAxisScale.d.ts +24 -0
- package/dist/plugins/broken-axis/exports.d.ts +6 -0
- package/dist/plugins/broken-axis/index.d.ts +6 -0
- package/dist/plugins/broken-axis/types.d.ts +50 -0
- package/dist/plugins/builtins/crosshair/CrosshairPlugin.d.ts +40 -0
- package/dist/plugins/builtins/crosshair/index.d.ts +1 -0
- package/dist/plugins/builtins/data-logger/DataLoggerPlugin.d.ts +11 -0
- package/dist/plugins/builtins/data-logger/index.d.ts +1 -0
- package/dist/plugins/builtins/direction-indicator/DirectionIndicatorPlugin.d.ts +17 -0
- package/dist/plugins/builtins/direction-indicator/index.d.ts +2 -0
- package/dist/plugins/builtins/grid-highlight/GridHighlightPlugin.d.ts +17 -0
- package/dist/plugins/builtins/grid-highlight/index.d.ts +1 -0
- package/dist/plugins/builtins/index.d.ts +25 -0
- package/dist/plugins/builtins/stats/StatsPlugin.d.ts +11 -0
- package/dist/plugins/builtins/stats/index.d.ts +1 -0
- package/dist/plugins/builtins/watermark/WatermarkPlugin.d.ts +15 -0
- package/dist/plugins/builtins/watermark/index.d.ts +1 -0
- package/dist/plugins/caching/exports.d.ts +6 -0
- package/dist/plugins/caching/index.d.ts +6 -0
- package/dist/plugins/caching/types.d.ts +120 -0
- package/dist/plugins/clipboard/index.d.ts +20 -0
- package/dist/plugins/clipboard.d.ts +3 -0
- package/dist/plugins/clipboard.js +270 -0
- package/dist/plugins/clipboard.js.map +1 -0
- package/dist/plugins/context-menu/index.d.ts +12 -0
- package/dist/plugins/context-menu/renderer.d.ts +43 -0
- package/dist/plugins/context-menu/types.d.ts +202 -0
- package/dist/plugins/context-menu.d.ts +3 -0
- package/dist/plugins/context-menu.js +621 -0
- package/dist/plugins/context-menu.js.map +1 -0
- package/dist/plugins/data-export/formatters.d.ts +34 -0
- package/dist/plugins/data-export/index.d.ts +15 -0
- package/dist/plugins/data-export/types.d.ts +166 -0
- package/dist/plugins/data-export.d.ts +3 -0
- package/dist/plugins/data-export.js +463 -0
- package/dist/plugins/data-export.js.map +1 -0
- package/dist/plugins/data-transform/index.d.ts +6 -0
- package/dist/plugins/data-transform/types.d.ts +34 -0
- package/dist/plugins/debug/index.d.ts +24 -0
- package/dist/plugins/debug.d.ts +3 -0
- package/dist/plugins/debug.js +330 -0
- package/dist/plugins/debug.js.map +1 -0
- package/dist/plugins/drag-edit/exports.d.ts +6 -0
- package/dist/plugins/drag-edit/index.d.ts +6 -0
- package/dist/plugins/drag-edit/types.d.ts +118 -0
- package/dist/plugins/forecasting/algorithms.d.ts +6 -0
- package/dist/plugins/forecasting/exports.d.ts +3 -0
- package/dist/plugins/forecasting/index.d.ts +11 -0
- package/dist/plugins/forecasting/types.d.ts +88 -0
- package/dist/plugins/gpu/index.d.ts +24 -0
- package/dist/plugins/gpu.d.ts +3 -0
- package/dist/plugins/gpu.js +2430 -0
- package/dist/plugins/gpu.js.map +1 -0
- package/dist/plugins/i18n/index.d.ts +22 -0
- package/dist/plugins/i18n.d.ts +3 -0
- package/dist/plugins/i18n.js +37 -0
- package/dist/plugins/i18n.js.map +1 -0
- package/dist/plugins/index.d.ts +110 -0
- package/dist/plugins/keyboard/index.d.ts +15 -0
- package/dist/plugins/keyboard.d.ts +3 -0
- package/dist/plugins/keyboard.js +8 -0
- package/dist/plugins/keyboard.js.map +1 -0
- package/dist/plugins/latex/exports.d.ts +6 -0
- package/dist/plugins/latex/index.d.ts +8 -0
- package/dist/plugins/latex/parser.d.ts +6 -0
- package/dist/plugins/latex/renderer.d.ts +6 -0
- package/dist/plugins/latex/symbols.d.ts +28 -0
- package/dist/plugins/latex/types.d.ts +88 -0
- package/dist/plugins/lazy-load/exports.d.ts +6 -0
- package/dist/plugins/lazy-load/index.d.ts +6 -0
- package/dist/plugins/lazy-load/types.d.ts +121 -0
- package/dist/plugins/loading/index.d.ts +15 -0
- package/dist/plugins/loading.d.ts +3 -0
- package/dist/plugins/loading.js +7 -0
- package/dist/plugins/loading.js.map +1 -0
- package/dist/plugins/ml-integration/exports.d.ts +11 -0
- package/dist/plugins/ml-integration/index.d.ts +6 -0
- package/dist/plugins/ml-integration/native-algorithms.d.ts +69 -0
- package/dist/plugins/ml-integration/types.d.ts +74 -0
- package/dist/plugins/offscreen/exports.d.ts +6 -0
- package/dist/plugins/offscreen/index.d.ts +6 -0
- package/dist/plugins/offscreen/pool.d.ts +32 -0
- package/dist/plugins/offscreen/types.d.ts +35 -0
- package/dist/plugins/pattern-recognition/index.d.ts +6 -0
- package/dist/plugins/pattern-recognition/patterns.d.ts +3 -0
- package/dist/plugins/pattern-recognition/types.d.ts +245 -0
- package/dist/plugins/radar/index.d.ts +6 -0
- package/dist/plugins/radar/types.d.ts +40 -0
- package/dist/plugins/regression/algorithms.d.ts +6 -0
- package/dist/plugins/regression/index.d.ts +6 -0
- package/dist/plugins/regression/types.d.ts +261 -0
- package/dist/plugins/roi/exports.d.ts +6 -0
- package/dist/plugins/roi/index.d.ts +49 -0
- package/dist/plugins/roi/types.d.ts +60 -0
- package/dist/plugins/snapshot/index.d.ts +11 -0
- package/dist/plugins/snapshot/types.d.ts +38 -0
- package/dist/plugins/streaming/index.d.ts +32 -0
- package/dist/plugins/streaming.d.ts +3 -0
- package/dist/plugins/streaming.js +13 -0
- package/dist/plugins/streaming.js.map +1 -0
- package/dist/plugins/sync/index.d.ts +22 -0
- package/dist/plugins/sync.d.ts +3 -0
- package/dist/plugins/sync.js +261 -0
- package/dist/plugins/sync.js.map +1 -0
- package/dist/plugins/theme-editor/index.d.ts +18 -0
- package/dist/plugins/theme-editor.d.ts +3 -0
- package/dist/plugins/theme-editor.js +7 -0
- package/dist/plugins/theme-editor.js.map +1 -0
- package/dist/plugins/tools/delta-tool/index.d.ts +159 -0
- package/dist/plugins/tools/index.d.ts +21 -0
- package/dist/plugins/tools/peak-tool/index.d.ts +159 -0
- package/dist/plugins/tools/tooltip/TooltipManager.d.ts +213 -0
- package/dist/plugins/tools/tooltip/TooltipPositioner.d.ts +83 -0
- package/dist/plugins/tools/tooltip/TooltipRenderer.d.ts +64 -0
- package/dist/plugins/tools/tooltip/index.d.ts +18 -0
- package/dist/plugins/tools/tooltip/templates/AnnotationTemplate.d.ts +18 -0
- package/dist/plugins/tools/tooltip/templates/CrosshairTemplate.d.ts +39 -0
- package/dist/plugins/tools/tooltip/templates/DefaultTemplate.d.ts +30 -0
- package/dist/plugins/tools/tooltip/templates/HeatmapTemplate.d.ts +34 -0
- package/dist/plugins/tools/tooltip/templates/MinimalTemplate.d.ts +26 -0
- package/dist/plugins/tools/tooltip/templates/RangeTemplate.d.ts +18 -0
- package/dist/plugins/tools/tooltip/templates/ScientificTemplate.d.ts +34 -0
- package/dist/plugins/tools/tooltip/templates/index.d.ts +27 -0
- package/dist/plugins/tools/tooltip/themes.d.ts +48 -0
- package/dist/plugins/tools/tooltip/types.d.ts +396 -0
- package/dist/plugins/tools.d.ts +3 -0
- package/dist/plugins/tools.js +9 -0
- package/dist/plugins/tools.js.map +1 -0
- package/dist/plugins/types.d.ts +451 -0
- package/dist/plugins/video-recorder/exports.d.ts +6 -0
- package/dist/plugins/video-recorder/index.d.ts +6 -0
- package/dist/plugins/video-recorder/types.d.ts +55 -0
- package/dist/plugins/virtualization/exports.d.ts +6 -0
- package/dist/plugins/virtualization/index.d.ts +6 -0
- package/dist/plugins/virtualization/types.d.ts +48 -0
- package/dist/react/SciPlot.d.ts +60 -0
- package/dist/react/index.d.ts +5 -0
- package/dist/react/useSciPlot.d.ts +56 -0
- package/dist/renderer/BarRenderer.d.ts +14 -0
- package/dist/renderer/CandlestickRenderer.d.ts +12 -0
- package/dist/renderer/GaugeRenderer.d.ts +3 -0
- package/dist/renderer/HeatmapRenderer.d.ts +15 -0
- package/dist/renderer/NativeWebGLRenderer.d.ts +16 -0
- package/dist/renderer/PolarRenderer.d.ts +64 -0
- package/dist/renderer/RendererInterface.d.ts +70 -0
- package/dist/renderer/SankeyRenderer.d.ts +3 -0
- package/dist/renderer/WebGPURenderer.d.ts +16 -0
- package/dist/renderer/index.d.ts +13 -0
- package/dist/renderer/native/NativeWebGLRenderer.d.ts +31 -0
- package/dist/renderer/native/bufferStore.d.ts +11 -0
- package/dist/renderer/native/draw.d.ts +47 -0
- package/dist/renderer/native/programFactory.d.ts +3 -0
- package/dist/renderer/native/renderFrame.d.ts +3 -0
- package/dist/renderer/native/shaderSources.d.ts +6 -0
- package/dist/renderer/native/textureStore.d.ts +8 -0
- package/dist/renderer/native/types.d.ts +77 -0
- package/dist/renderer/native/utils.d.ts +31 -0
- package/dist/renderer/radar/RadarRenderer.d.ts +71 -0
- package/dist/renderer/radar/index.d.ts +10 -0
- package/dist/renderer/shaders.d.ts +77 -0
- package/dist/renderer/ternary/TernaryRenderer.d.ts +39 -0
- package/dist/renderer/ternary/index.d.ts +6 -0
- package/dist/renderer/ternary/types.d.ts +56 -0
- package/dist/scales/index.d.ts +54 -0
- package/dist/serialization/index.d.ts +153 -0
- package/dist/streaming/backpressure.d.ts +179 -0
- package/dist/streaming/index.d.ts +7 -0
- package/dist/streaming/mock.d.ts +12 -0
- package/dist/streaming/types.d.ts +57 -0
- package/dist/streaming/utils.d.ts +19 -0
- package/dist/streaming/websocket.d.ts +6 -0
- package/dist/testing/index.d.ts +225 -0
- package/dist/theme/colorSchemes.d.ts +56 -0
- package/dist/theme/index.d.ts +138 -0
- package/dist/types.d.ts +753 -0
- package/dist/utils-Dbro9-qM.js +254 -0
- package/dist/utils-Dbro9-qM.js.map +1 -0
- package/dist/velo-plot.d.ts +1 -0
- package/dist/velo-plot.full.d.ts +1 -0
- package/dist/velo-plot.full.js +5804 -0
- package/dist/velo-plot.full.js.map +1 -0
- package/dist/velo-plot.js +31 -0
- package/dist/velo-plot.js.map +1 -0
- package/dist/workers/downsample.d.ts +34 -0
- package/dist/workers/downsample.worker.d.ts +46 -0
- package/package.json +185 -0
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
var u = Object.defineProperty;
|
|
2
|
+
var L = (P, e, i) => e in P ? u(P, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : P[e] = i;
|
|
3
|
+
var k = (P, e, i) => L(P, typeof e != "symbol" ? e + "" : e, i);
|
|
4
|
+
const f = {
|
|
5
|
+
line: {
|
|
6
|
+
color: "rgba(255, 255, 255, 0.7)",
|
|
7
|
+
lineWidth: 1,
|
|
8
|
+
lineDash: []
|
|
9
|
+
},
|
|
10
|
+
rectangle: {
|
|
11
|
+
fillColor: "rgba(100, 100, 255, 0.2)",
|
|
12
|
+
strokeWidth: 1
|
|
13
|
+
},
|
|
14
|
+
text: {
|
|
15
|
+
fontSize: 12,
|
|
16
|
+
fontFamily: "Inter, system-ui, sans-serif",
|
|
17
|
+
color: "#ffffff",
|
|
18
|
+
padding: 4
|
|
19
|
+
},
|
|
20
|
+
arrow: {
|
|
21
|
+
color: "rgba(255, 255, 255, 0.7)",
|
|
22
|
+
lineWidth: 2,
|
|
23
|
+
headSize: 10
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
class W {
|
|
27
|
+
constructor() {
|
|
28
|
+
k(this, "annotations", /* @__PURE__ */ new Map());
|
|
29
|
+
k(this, "idCounter", 0);
|
|
30
|
+
}
|
|
31
|
+
// ----------------------------------------
|
|
32
|
+
// CRUD Operations
|
|
33
|
+
// ----------------------------------------
|
|
34
|
+
/**
|
|
35
|
+
* Add a new annotation
|
|
36
|
+
* @returns The annotation ID
|
|
37
|
+
*/
|
|
38
|
+
add(e) {
|
|
39
|
+
const i = e.id ?? `annotation-${++this.idCounter}`, l = {
|
|
40
|
+
...e,
|
|
41
|
+
id: i,
|
|
42
|
+
visible: e.visible ?? !0,
|
|
43
|
+
interactive: e.interactive ?? !1,
|
|
44
|
+
zIndex: e.zIndex ?? 0
|
|
45
|
+
};
|
|
46
|
+
return this.annotations.set(i, l), i;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Remove an annotation by ID
|
|
50
|
+
*/
|
|
51
|
+
remove(e) {
|
|
52
|
+
return this.annotations.delete(e);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Update an annotation
|
|
56
|
+
*/
|
|
57
|
+
update(e, i) {
|
|
58
|
+
const l = this.annotations.get(e);
|
|
59
|
+
l && this.annotations.set(e, { ...l, ...i });
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get an annotation by ID
|
|
63
|
+
*/
|
|
64
|
+
get(e) {
|
|
65
|
+
return this.annotations.get(e);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Get all annotations
|
|
69
|
+
*/
|
|
70
|
+
getAll() {
|
|
71
|
+
return Array.from(this.annotations.values());
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Clear all annotations
|
|
75
|
+
*/
|
|
76
|
+
clear() {
|
|
77
|
+
this.annotations.clear();
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get count of annotations
|
|
81
|
+
*/
|
|
82
|
+
get count() {
|
|
83
|
+
return this.annotations.size;
|
|
84
|
+
}
|
|
85
|
+
// ----------------------------------------
|
|
86
|
+
// Rendering
|
|
87
|
+
// ----------------------------------------
|
|
88
|
+
/**
|
|
89
|
+
* Render all annotations
|
|
90
|
+
*/
|
|
91
|
+
render(e, i, l, t) {
|
|
92
|
+
const s = this.getAll().filter((r) => r.visible !== !1).sort((r, a) => (r.zIndex ?? 0) - (a.zIndex ?? 0));
|
|
93
|
+
e.save(), e.beginPath(), e.rect(i.x, i.y, i.width, i.height), e.clip();
|
|
94
|
+
for (const r of s)
|
|
95
|
+
this.renderAnnotation(e, r, i, l, t);
|
|
96
|
+
e.restore();
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Helper to draw text or LaTeX
|
|
100
|
+
*/
|
|
101
|
+
drawLatexOrText(e, i, l, t, s, r) {
|
|
102
|
+
if ((s.latex || i.includes("\\") || i.includes("^") || i.includes("_") || i.includes("{") && i.includes("}")) && !!r && typeof r.render == "function") {
|
|
103
|
+
e.save(), e.translate(l, t), s.rotation && e.rotate(s.rotation * Math.PI / 180);
|
|
104
|
+
const h = r.measure(i, {
|
|
105
|
+
fontSize: s.fontSize,
|
|
106
|
+
fontFamily: s.fontFamily,
|
|
107
|
+
color: s.color
|
|
108
|
+
});
|
|
109
|
+
let n = 0, d = 0;
|
|
110
|
+
const o = s.align ?? "left";
|
|
111
|
+
o === "center" ? n = -h.width / 2 : o === "right" && (n = -h.width);
|
|
112
|
+
const g = s.baseline ?? "alphabetic";
|
|
113
|
+
g === "middle" ? d = -h.height / 2 + h.baseline : g === "top" || g === "hanging" ? d = h.baseline : g === "bottom" || g === "ideographic" ? d = -(h.height - h.baseline) : d = 0, r.render(i, e, n, d, {
|
|
114
|
+
fontSize: s.fontSize,
|
|
115
|
+
fontFamily: s.fontFamily,
|
|
116
|
+
color: s.color
|
|
117
|
+
}), e.restore();
|
|
118
|
+
} else
|
|
119
|
+
e.save(), e.font = `${s.fontWeight ?? ""} ${s.fontSize}px ${s.fontFamily}`, e.fillStyle = s.color, e.textAlign = s.align ?? "left", e.textBaseline = s.baseline ?? "alphabetic", e.translate(l, t), s.rotation && e.rotate(s.rotation * Math.PI / 180), e.fillText(i, 0, 0), e.restore();
|
|
120
|
+
}
|
|
121
|
+
renderAnnotation(e, i, l, t, s) {
|
|
122
|
+
switch (i.type) {
|
|
123
|
+
case "horizontal-line":
|
|
124
|
+
this.renderHorizontalLine(e, i, l, t, s);
|
|
125
|
+
break;
|
|
126
|
+
case "vertical-line":
|
|
127
|
+
this.renderVerticalLine(e, i, l, t, s);
|
|
128
|
+
break;
|
|
129
|
+
case "rectangle":
|
|
130
|
+
this.renderRectangle(e, i, l, t, s);
|
|
131
|
+
break;
|
|
132
|
+
case "band":
|
|
133
|
+
this.renderBand(e, i, l, t, s);
|
|
134
|
+
break;
|
|
135
|
+
case "text":
|
|
136
|
+
this.renderText(e, i, l, t, s);
|
|
137
|
+
break;
|
|
138
|
+
case "arrow":
|
|
139
|
+
this.renderArrow(e, i, l, t, s);
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// ----------------------------------------
|
|
144
|
+
// Coordinate Conversion
|
|
145
|
+
// ----------------------------------------
|
|
146
|
+
dataToPixelX(e, i, l) {
|
|
147
|
+
const t = (e - i.xMin) / (i.xMax - i.xMin);
|
|
148
|
+
return l.x + t * l.width;
|
|
149
|
+
}
|
|
150
|
+
dataToPixelY(e, i, l) {
|
|
151
|
+
const t = (e - i.yMin) / (i.yMax - i.yMin);
|
|
152
|
+
return l.y + l.height * (1 - t);
|
|
153
|
+
}
|
|
154
|
+
// ----------------------------------------
|
|
155
|
+
// Render: Horizontal Line
|
|
156
|
+
// ----------------------------------------
|
|
157
|
+
renderHorizontalLine(e, i, l, t, s) {
|
|
158
|
+
const r = this.dataToPixelY(i.y, t, l);
|
|
159
|
+
if (r < l.y || r > l.y + l.height) return;
|
|
160
|
+
const a = i.xMin !== void 0 ? Math.max(this.dataToPixelX(i.xMin, t, l), l.x) : l.x, h = i.xMax !== void 0 ? Math.min(this.dataToPixelX(i.xMax, t, l), l.x + l.width) : l.x + l.width;
|
|
161
|
+
e.save(), e.strokeStyle = i.color ?? f.line.color, e.lineWidth = i.lineWidth ?? f.line.lineWidth, e.setLineDash(i.lineDash ?? f.line.lineDash), e.beginPath(), e.moveTo(a, r), e.lineTo(h, r), e.stroke(), i.label && this.renderLineLabel(
|
|
162
|
+
e,
|
|
163
|
+
i.label,
|
|
164
|
+
a,
|
|
165
|
+
h,
|
|
166
|
+
r,
|
|
167
|
+
i.labelPosition ?? "right",
|
|
168
|
+
"horizontal",
|
|
169
|
+
i.labelBackground,
|
|
170
|
+
s
|
|
171
|
+
), e.restore();
|
|
172
|
+
}
|
|
173
|
+
// ----------------------------------------
|
|
174
|
+
// Render: Vertical Line
|
|
175
|
+
// ----------------------------------------
|
|
176
|
+
renderVerticalLine(e, i, l, t, s) {
|
|
177
|
+
const r = this.dataToPixelX(i.x, t, l);
|
|
178
|
+
if (r < l.x || r > l.x + l.width) return;
|
|
179
|
+
const a = i.yMin !== void 0 ? Math.min(this.dataToPixelY(i.yMin, t, l), l.y + l.height) : l.y, h = i.yMax !== void 0 ? Math.max(this.dataToPixelY(i.yMax, t, l), l.y) : l.y + l.height;
|
|
180
|
+
e.save(), e.strokeStyle = i.color ?? f.line.color, e.lineWidth = i.lineWidth ?? f.line.lineWidth, e.setLineDash(i.lineDash ?? f.line.lineDash), e.beginPath(), e.moveTo(r, a), e.lineTo(r, h), e.stroke(), i.label && this.renderLineLabel(
|
|
181
|
+
e,
|
|
182
|
+
i.label,
|
|
183
|
+
a,
|
|
184
|
+
h,
|
|
185
|
+
r,
|
|
186
|
+
i.labelPosition ?? "top",
|
|
187
|
+
"vertical",
|
|
188
|
+
i.labelBackground,
|
|
189
|
+
s
|
|
190
|
+
), e.restore();
|
|
191
|
+
}
|
|
192
|
+
// ----------------------------------------
|
|
193
|
+
// Render: Rectangle
|
|
194
|
+
// ----------------------------------------
|
|
195
|
+
renderRectangle(e, i, l, t, s) {
|
|
196
|
+
const r = this.dataToPixelX(i.xMin, t, l), a = this.dataToPixelX(i.xMax, t, l), h = this.dataToPixelY(i.yMax, t, l), n = this.dataToPixelY(i.yMin, t, l), d = Math.min(r, a), o = Math.min(h, n), g = Math.abs(a - r), y = Math.abs(n - h);
|
|
197
|
+
e.save(), i.fillColor && (e.fillStyle = i.fillColor, e.fillRect(d, o, g, y)), i.strokeColor && (e.strokeStyle = i.strokeColor, e.lineWidth = i.strokeWidth ?? f.rectangle.strokeWidth, e.setLineDash(i.strokeDash ?? []), e.strokeRect(d, o, g, y)), i.label && this.renderCenteredLabel(e, i.label, d + g / 2, o + y / 2, s), e.restore();
|
|
198
|
+
}
|
|
199
|
+
// ----------------------------------------
|
|
200
|
+
// Render: Band
|
|
201
|
+
// ----------------------------------------
|
|
202
|
+
renderBand(e, i, l, t, s) {
|
|
203
|
+
let r, a, h, n;
|
|
204
|
+
if (i.xMin !== void 0 && i.xMax !== void 0) {
|
|
205
|
+
const d = this.dataToPixelX(i.xMin, t, l), o = this.dataToPixelX(i.xMax, t, l);
|
|
206
|
+
r = Math.min(d, o), h = Math.abs(o - d), a = l.y, n = l.height, i.yMin !== void 0 && (n = this.dataToPixelY(i.yMin, t, l) - a), i.yMax !== void 0 && (a = this.dataToPixelY(i.yMax, t, l), n = l.y + l.height - a);
|
|
207
|
+
} else if (i.yMin !== void 0 && i.yMax !== void 0) {
|
|
208
|
+
const d = this.dataToPixelY(i.yMax, t, l), o = this.dataToPixelY(i.yMin, t, l);
|
|
209
|
+
a = Math.min(d, o), n = Math.abs(o - d), r = l.x, h = l.width;
|
|
210
|
+
} else
|
|
211
|
+
return;
|
|
212
|
+
if (e.save(), e.fillStyle = i.fillColor ?? f.rectangle.fillColor, e.fillRect(r, a, h, n), i.strokeColor && (e.strokeStyle = i.strokeColor, e.lineWidth = i.strokeWidth ?? 1, e.strokeRect(r, a, h, n)), i.label) {
|
|
213
|
+
let d = r + h / 2, o = a + n / 2;
|
|
214
|
+
switch (i.labelPosition) {
|
|
215
|
+
case "top":
|
|
216
|
+
o = a + 15;
|
|
217
|
+
break;
|
|
218
|
+
case "bottom":
|
|
219
|
+
o = a + n - 5;
|
|
220
|
+
break;
|
|
221
|
+
case "left":
|
|
222
|
+
d = r + 10;
|
|
223
|
+
break;
|
|
224
|
+
case "right":
|
|
225
|
+
d = r + h - 10;
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
this.renderCenteredLabel(e, i.label, d, o, s);
|
|
229
|
+
}
|
|
230
|
+
e.restore();
|
|
231
|
+
}
|
|
232
|
+
// ----------------------------------------
|
|
233
|
+
// Render: Text
|
|
234
|
+
// ----------------------------------------
|
|
235
|
+
renderText(e, i, l, t, s) {
|
|
236
|
+
const r = this.dataToPixelX(i.x, t, l), a = this.dataToPixelY(i.y, t, l);
|
|
237
|
+
e.save(), i.rotation && (e.translate(r, a), e.rotate(i.rotation * Math.PI / 180), e.translate(-r, -a));
|
|
238
|
+
const h = i.fontSize ?? f.text.fontSize, n = i.fontFamily ?? f.text.fontFamily, d = i.fontWeight ?? "normal", o = h * 1.2;
|
|
239
|
+
e.font = `${d} ${h}px ${n}`, e.textAlign = "center", e.textBaseline = "middle";
|
|
240
|
+
const g = i.text.split(`
|
|
241
|
+
`), y = i.padding ?? f.text.padding;
|
|
242
|
+
let c = 0;
|
|
243
|
+
for (const v of g)
|
|
244
|
+
c = Math.max(c, e.measureText(v).width);
|
|
245
|
+
const M = c + y * 2, m = g.length * o - (o - h) + y * 2;
|
|
246
|
+
let b = r, T = a;
|
|
247
|
+
switch (i.anchor) {
|
|
248
|
+
case "top-left":
|
|
249
|
+
b += M / 2, T += m / 2;
|
|
250
|
+
break;
|
|
251
|
+
case "top-right":
|
|
252
|
+
b -= M / 2, T += m / 2;
|
|
253
|
+
break;
|
|
254
|
+
case "bottom-left":
|
|
255
|
+
b += M / 2, T -= m / 2;
|
|
256
|
+
break;
|
|
257
|
+
case "bottom-right":
|
|
258
|
+
b -= M / 2, T -= m / 2;
|
|
259
|
+
break;
|
|
260
|
+
case "top-center":
|
|
261
|
+
T += m / 2;
|
|
262
|
+
break;
|
|
263
|
+
case "bottom-center":
|
|
264
|
+
T -= m / 2;
|
|
265
|
+
break;
|
|
266
|
+
case "left-center":
|
|
267
|
+
b += M / 2;
|
|
268
|
+
break;
|
|
269
|
+
case "right-center":
|
|
270
|
+
b -= M / 2;
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
i.backgroundColor && (e.fillStyle = i.backgroundColor, e.beginPath(), e.roundRect(
|
|
274
|
+
b - M / 2,
|
|
275
|
+
T - m / 2,
|
|
276
|
+
M,
|
|
277
|
+
m,
|
|
278
|
+
4
|
|
279
|
+
), e.fill());
|
|
280
|
+
const S = i.color ?? f.text.color, w = T - m / 2 + y + h / 2;
|
|
281
|
+
g.forEach((v, z) => {
|
|
282
|
+
this.drawLatexOrText(e, v, b, w + z * o, {
|
|
283
|
+
fontSize: h,
|
|
284
|
+
fontFamily: n,
|
|
285
|
+
fontWeight: d,
|
|
286
|
+
color: S,
|
|
287
|
+
align: "center",
|
|
288
|
+
baseline: "middle",
|
|
289
|
+
latex: i.latex
|
|
290
|
+
}, s);
|
|
291
|
+
}), e.restore();
|
|
292
|
+
}
|
|
293
|
+
// ----------------------------------------
|
|
294
|
+
// Render: Arrow
|
|
295
|
+
// ----------------------------------------
|
|
296
|
+
renderArrow(e, i, l, t, s) {
|
|
297
|
+
const r = this.dataToPixelX(i.x1, t, l), a = this.dataToPixelY(i.y1, t, l), h = this.dataToPixelX(i.x2, t, l), n = this.dataToPixelY(i.y2, t, l);
|
|
298
|
+
e.save(), e.strokeStyle = i.color ?? f.arrow.color, e.fillStyle = i.color ?? f.arrow.color, e.lineWidth = i.lineWidth ?? f.arrow.lineWidth, e.beginPath(), e.moveTo(r, a), e.lineTo(h, n), e.stroke();
|
|
299
|
+
const d = i.headSize ?? f.arrow.headSize, o = Math.atan2(n - a, h - r), g = i.headStyle ?? "filled";
|
|
300
|
+
if (g !== "none" && (e.beginPath(), e.moveTo(h, n), e.lineTo(
|
|
301
|
+
h - d * Math.cos(o - Math.PI / 6),
|
|
302
|
+
n - d * Math.sin(o - Math.PI / 6)
|
|
303
|
+
), g === "filled" ? (e.lineTo(
|
|
304
|
+
h - d * Math.cos(o + Math.PI / 6),
|
|
305
|
+
n - d * Math.sin(o + Math.PI / 6)
|
|
306
|
+
), e.closePath(), e.fill()) : (e.moveTo(h, n), e.lineTo(
|
|
307
|
+
h - d * Math.cos(o + Math.PI / 6),
|
|
308
|
+
n - d * Math.sin(o + Math.PI / 6)
|
|
309
|
+
), e.stroke())), i.showTail) {
|
|
310
|
+
const y = o + Math.PI;
|
|
311
|
+
e.beginPath(), e.moveTo(r, a), e.lineTo(
|
|
312
|
+
r - d * Math.cos(y - Math.PI / 6),
|
|
313
|
+
a - d * Math.sin(y - Math.PI / 6)
|
|
314
|
+
), e.lineTo(
|
|
315
|
+
r - d * Math.cos(y + Math.PI / 6),
|
|
316
|
+
a - d * Math.sin(y + Math.PI / 6)
|
|
317
|
+
), e.closePath(), e.fill();
|
|
318
|
+
}
|
|
319
|
+
if (i.label) {
|
|
320
|
+
const y = (r + h) / 2, c = (a + n) / 2;
|
|
321
|
+
this.renderCenteredLabel(e, i.label, y, c - 10, s);
|
|
322
|
+
}
|
|
323
|
+
e.restore();
|
|
324
|
+
}
|
|
325
|
+
// ----------------------------------------
|
|
326
|
+
// Helper: Render Labels
|
|
327
|
+
// ----------------------------------------
|
|
328
|
+
renderLineLabel(e, i, l, t, s, r, a, h, n) {
|
|
329
|
+
e.save(), e.font = `${f.text.fontSize}px ${f.text.fontFamily}`;
|
|
330
|
+
const d = e.measureText(i), o = 4, g = d.width + o * 2, y = f.text.fontSize + o * 2;
|
|
331
|
+
let c, M;
|
|
332
|
+
if (a === "horizontal") {
|
|
333
|
+
switch (M = s, r) {
|
|
334
|
+
case "left":
|
|
335
|
+
c = l + 5, e.textAlign = "left";
|
|
336
|
+
break;
|
|
337
|
+
case "right":
|
|
338
|
+
c = t - 5, e.textAlign = "right";
|
|
339
|
+
break;
|
|
340
|
+
default:
|
|
341
|
+
c = (l + t) / 2, e.textAlign = "center";
|
|
342
|
+
}
|
|
343
|
+
e.textBaseline = "bottom", M -= 4;
|
|
344
|
+
} else {
|
|
345
|
+
switch (c = s, r) {
|
|
346
|
+
case "top":
|
|
347
|
+
M = l + y;
|
|
348
|
+
break;
|
|
349
|
+
case "bottom":
|
|
350
|
+
M = t - 5;
|
|
351
|
+
break;
|
|
352
|
+
default:
|
|
353
|
+
M = (l + t) / 2;
|
|
354
|
+
}
|
|
355
|
+
e.textAlign = "center", e.textBaseline = "middle";
|
|
356
|
+
}
|
|
357
|
+
if (h ?? !0) {
|
|
358
|
+
e.fillStyle = h ?? "rgba(0, 0, 0, 0.7)";
|
|
359
|
+
const m = e.textAlign === "left" ? c - o : e.textAlign === "right" ? c - g + o : c - g / 2;
|
|
360
|
+
e.fillRect(m, M - y + o, g, y);
|
|
361
|
+
}
|
|
362
|
+
this.drawLatexOrText(e, i, c, M, {
|
|
363
|
+
fontSize: f.text.fontSize,
|
|
364
|
+
fontFamily: f.text.fontFamily,
|
|
365
|
+
color: f.text.color,
|
|
366
|
+
align: e.textAlign,
|
|
367
|
+
baseline: e.textBaseline
|
|
368
|
+
}, n), e.restore();
|
|
369
|
+
}
|
|
370
|
+
renderCenteredLabel(e, i, l, t, s) {
|
|
371
|
+
e.save(), e.font = `${f.text.fontSize}px ${f.text.fontFamily}`;
|
|
372
|
+
const r = e.measureText(i), a = 4, h = r.width + a * 2, n = f.text.fontSize + a * 2;
|
|
373
|
+
e.fillStyle = "rgba(0, 0, 0, 0.7)", e.beginPath(), e.roundRect(l - h / 2, t - n / 2, h, n, 3), e.fill(), this.drawLatexOrText(e, i, l, t, {
|
|
374
|
+
fontSize: f.text.fontSize,
|
|
375
|
+
fontFamily: f.text.fontFamily,
|
|
376
|
+
color: f.text.color,
|
|
377
|
+
align: "center",
|
|
378
|
+
baseline: "middle"
|
|
379
|
+
}, s), e.restore();
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
const x = {
|
|
383
|
+
name: "velo-plot-annotations",
|
|
384
|
+
version: "1.0.0",
|
|
385
|
+
description: "Annotation support for velo-plot",
|
|
386
|
+
provides: ["annotation"],
|
|
387
|
+
tags: ["annotation", "overlay", "label"]
|
|
388
|
+
};
|
|
389
|
+
function C(P = {}) {
|
|
390
|
+
let e;
|
|
391
|
+
return {
|
|
392
|
+
manifest: x,
|
|
393
|
+
onInit(i) {
|
|
394
|
+
e = new W(), i.storage.set("manager", e);
|
|
395
|
+
},
|
|
396
|
+
onRenderOverlay(i) {
|
|
397
|
+
const l = i.render.plotArea, t = i.data.getViewBounds(), s = i.getPlugin("velo-plot-latex"), r = s == null ? void 0 : s.api;
|
|
398
|
+
e.render(
|
|
399
|
+
i.render.ctx2d,
|
|
400
|
+
l,
|
|
401
|
+
t,
|
|
402
|
+
r
|
|
403
|
+
);
|
|
404
|
+
},
|
|
405
|
+
onDestroy(i) {
|
|
406
|
+
e.clear();
|
|
407
|
+
},
|
|
408
|
+
api: {
|
|
409
|
+
getManager() {
|
|
410
|
+
return e;
|
|
411
|
+
},
|
|
412
|
+
add(i) {
|
|
413
|
+
return e.add(i);
|
|
414
|
+
},
|
|
415
|
+
remove(i) {
|
|
416
|
+
return e.remove(i);
|
|
417
|
+
},
|
|
418
|
+
update(i, l) {
|
|
419
|
+
return e.update(i, l);
|
|
420
|
+
},
|
|
421
|
+
get(i) {
|
|
422
|
+
return e.get(i);
|
|
423
|
+
},
|
|
424
|
+
getAll() {
|
|
425
|
+
return e.getAll();
|
|
426
|
+
},
|
|
427
|
+
clear() {
|
|
428
|
+
e.clear();
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
export {
|
|
434
|
+
W as AnnotationManager,
|
|
435
|
+
C as PluginAnnotations,
|
|
436
|
+
C as default
|
|
437
|
+
};
|
|
438
|
+
//# sourceMappingURL=annotations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotations.js","sources":["../../src/core/annotations/AnnotationManager.ts","../../src/plugins/annotations/index.ts"],"sourcesContent":["/**\n * AnnotationManager - Manages chart annotations\n * \n * Handles creation, update, removal, and rendering of all annotation types.\n */\n\nimport type { Bounds } from '../../types';\nimport type {\n Annotation,\n HorizontalLineAnnotation,\n VerticalLineAnnotation,\n RectangleAnnotation,\n BandAnnotation,\n TextAnnotation,\n ArrowAnnotation,\n} from './types';\n\n// ============================================\n// Default Styles\n// ============================================\n\nconst DEFAULT_STYLES = {\n line: {\n color: 'rgba(255, 255, 255, 0.7)',\n lineWidth: 1,\n lineDash: [] as number[],\n },\n rectangle: {\n fillColor: 'rgba(100, 100, 255, 0.2)',\n strokeColor: 'rgba(100, 100, 255, 0.5)',\n strokeWidth: 1,\n },\n text: {\n fontSize: 12,\n fontFamily: 'Inter, system-ui, sans-serif',\n color: '#ffffff',\n backgroundColor: 'rgba(0, 0, 0, 0.7)',\n padding: 4,\n },\n arrow: {\n color: 'rgba(255, 255, 255, 0.7)',\n lineWidth: 2,\n headSize: 10,\n },\n};\n\n// ============================================\n// Plot Area Type\n// ============================================\n\nexport interface PlotArea {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n// ============================================\n// AnnotationManager Class\n// ============================================\n\nexport class AnnotationManager {\n private annotations: Map<string, Annotation> = new Map();\n private idCounter = 0;\n\n // ----------------------------------------\n // CRUD Operations\n // ----------------------------------------\n\n /**\n * Add a new annotation\n * @returns The annotation ID\n */\n add(annotation: Annotation): string {\n const id = annotation.id ?? `annotation-${++this.idCounter}`;\n const resolved: Annotation = {\n ...annotation,\n id,\n visible: annotation.visible ?? true,\n interactive: annotation.interactive ?? false,\n zIndex: annotation.zIndex ?? 0,\n };\n\n this.annotations.set(id, resolved);\n return id;\n }\n\n /**\n * Remove an annotation by ID\n */\n remove(id: string): boolean {\n return this.annotations.delete(id);\n }\n\n /**\n * Update an annotation\n */\n update(id: string, updates: Partial<Annotation>): void {\n const existing = this.annotations.get(id);\n if (existing) {\n this.annotations.set(id, { ...existing, ...updates } as Annotation);\n }\n }\n\n /**\n * Get an annotation by ID\n */\n get(id: string): Annotation | undefined {\n return this.annotations.get(id);\n }\n\n /**\n * Get all annotations\n */\n getAll(): Annotation[] {\n return Array.from(this.annotations.values());\n }\n\n /**\n * Clear all annotations\n */\n clear(): void {\n this.annotations.clear();\n }\n\n /**\n * Get count of annotations\n */\n get count(): number {\n return this.annotations.size;\n }\n\n // ----------------------------------------\n // Rendering\n // ----------------------------------------\n\n /**\n * Render all annotations\n */\n render(\n ctx: CanvasRenderingContext2D,\n plotArea: PlotArea,\n bounds: Bounds,\n latexAPI?: any\n ): void {\n // Sort by zIndex\n const sorted = this.getAll()\n .filter(a => a.visible !== false)\n .sort((a, b) => (a.zIndex ?? 0) - (b.zIndex ?? 0));\n\n ctx.save();\n\n // Clip to plot area\n ctx.beginPath();\n ctx.rect(plotArea.x, plotArea.y, plotArea.width, plotArea.height);\n ctx.clip();\n\n for (const annotation of sorted) {\n this.renderAnnotation(ctx, annotation, plotArea, bounds, latexAPI);\n }\n\n ctx.restore();\n }\n\n /**\n * Helper to draw text or LaTeX\n */\n private drawLatexOrText(\n ctx: CanvasRenderingContext2D,\n text: string,\n x: number,\n y: number,\n options: {\n fontSize: number;\n fontFamily: string;\n fontWeight?: string | number;\n color: string;\n align?: CanvasTextAlign;\n baseline?: CanvasTextBaseline;\n rotation?: number;\n latex?: boolean;\n },\n latexAPI?: any\n ): void {\n const isLatex = (options.latex || text.includes('\\\\') || text.includes('^') || text.includes('_') || (text.includes('{') && text.includes('}'))) &&\n !!latexAPI && (typeof latexAPI.render === 'function');\n\n if (isLatex) {\n ctx.save();\n ctx.translate(x, y);\n if (options.rotation) ctx.rotate((options.rotation * Math.PI) / 180);\n\n const dims = latexAPI.measure(text, {\n fontSize: options.fontSize,\n fontFamily: options.fontFamily,\n color: options.color\n });\n\n let lx = 0;\n let ly = 0;\n\n // Handle Horizontal Alignment\n const align = options.align ?? \"left\";\n if (align === \"center\") lx = -dims.width / 2;\n else if (align === \"right\") lx = -dims.width;\n\n // Handle Vertical Alignment based on alphabetic baseline of the plugin\n // The plugin draws with textBaseline = 'alphabetic' at the provided y\n const baseline = options.baseline ?? \"alphabetic\";\n if (baseline === \"middle\") {\n ly = -dims.height / 2 + dims.baseline;\n } else if (baseline === \"top\" || baseline === \"hanging\") {\n ly = dims.baseline;\n } else if (baseline === \"bottom\" || baseline === \"ideographic\") {\n ly = -(dims.height - dims.baseline);\n } else {\n // 'alphabetic' or default\n ly = 0;\n }\n\n latexAPI.render(text, ctx, lx, ly, {\n fontSize: options.fontSize,\n fontFamily: options.fontFamily,\n color: options.color\n });\n ctx.restore();\n } else {\n ctx.save();\n ctx.font = `${options.fontWeight ?? ''} ${options.fontSize}px ${options.fontFamily}`;\n ctx.fillStyle = options.color;\n ctx.textAlign = options.align ?? \"left\";\n ctx.textBaseline = options.baseline ?? \"alphabetic\";\n ctx.translate(x, y);\n if (options.rotation) ctx.rotate((options.rotation * Math.PI) / 180);\n ctx.fillText(text, 0, 0);\n ctx.restore();\n }\n }\n\n private renderAnnotation(\n ctx: CanvasRenderingContext2D,\n annotation: Annotation,\n plotArea: PlotArea,\n bounds: Bounds,\n latexAPI?: any\n ): void {\n switch (annotation.type) {\n case 'horizontal-line':\n this.renderHorizontalLine(ctx, annotation, plotArea, bounds, latexAPI);\n break;\n case 'vertical-line':\n this.renderVerticalLine(ctx, annotation, plotArea, bounds, latexAPI);\n break;\n case 'rectangle':\n this.renderRectangle(ctx, annotation, plotArea, bounds, latexAPI);\n break;\n case 'band':\n this.renderBand(ctx, annotation, plotArea, bounds, latexAPI);\n break;\n case 'text':\n this.renderText(ctx, annotation, plotArea, bounds, latexAPI);\n break;\n case 'arrow':\n this.renderArrow(ctx, annotation, plotArea, bounds, latexAPI);\n break;\n }\n }\n\n // ----------------------------------------\n // Coordinate Conversion\n // ----------------------------------------\n\n private dataToPixelX(value: number, bounds: Bounds, plotArea: PlotArea): number {\n const normalized = (value - bounds.xMin) / (bounds.xMax - bounds.xMin);\n return plotArea.x + normalized * plotArea.width;\n }\n\n private dataToPixelY(value: number, bounds: Bounds, plotArea: PlotArea): number {\n const normalized = (value - bounds.yMin) / (bounds.yMax - bounds.yMin);\n return plotArea.y + plotArea.height * (1 - normalized);\n }\n\n // ----------------------------------------\n // Render: Horizontal Line\n // ----------------------------------------\n\n private renderHorizontalLine(\n ctx: CanvasRenderingContext2D,\n annotation: HorizontalLineAnnotation,\n plotArea: PlotArea,\n bounds: Bounds,\n latexAPI?: any\n ): void {\n const y = this.dataToPixelY(annotation.y, bounds, plotArea);\n\n // Skip if outside visible area\n if (y < plotArea.y || y > plotArea.y + plotArea.height) return;\n\n const xStart = annotation.xMin !== undefined\n ? Math.max(this.dataToPixelX(annotation.xMin, bounds, plotArea), plotArea.x)\n : plotArea.x;\n const xEnd = annotation.xMax !== undefined\n ? Math.min(this.dataToPixelX(annotation.xMax, bounds, plotArea), plotArea.x + plotArea.width)\n : plotArea.x + plotArea.width;\n\n ctx.save();\n ctx.strokeStyle = annotation.color ?? DEFAULT_STYLES.line.color;\n ctx.lineWidth = annotation.lineWidth ?? DEFAULT_STYLES.line.lineWidth;\n ctx.setLineDash(annotation.lineDash ?? DEFAULT_STYLES.line.lineDash);\n\n ctx.beginPath();\n ctx.moveTo(xStart, y);\n ctx.lineTo(xEnd, y);\n ctx.stroke();\n\n // Render label if present\n if (annotation.label) {\n this.renderLineLabel(\n ctx,\n annotation.label,\n xStart, xEnd, y,\n annotation.labelPosition ?? 'right',\n 'horizontal',\n annotation.labelBackground,\n latexAPI\n );\n }\n\n ctx.restore();\n }\n\n // ----------------------------------------\n // Render: Vertical Line\n // ----------------------------------------\n\n private renderVerticalLine(\n ctx: CanvasRenderingContext2D,\n annotation: VerticalLineAnnotation,\n plotArea: PlotArea,\n bounds: Bounds,\n latexAPI?: any\n ): void {\n const x = this.dataToPixelX(annotation.x, bounds, plotArea);\n\n // Skip if outside visible area\n if (x < plotArea.x || x > plotArea.x + plotArea.width) return;\n\n const yStart = annotation.yMin !== undefined\n ? Math.min(this.dataToPixelY(annotation.yMin, bounds, plotArea), plotArea.y + plotArea.height)\n : plotArea.y;\n const yEnd = annotation.yMax !== undefined\n ? Math.max(this.dataToPixelY(annotation.yMax, bounds, plotArea), plotArea.y)\n : plotArea.y + plotArea.height;\n\n ctx.save();\n ctx.strokeStyle = annotation.color ?? DEFAULT_STYLES.line.color;\n ctx.lineWidth = annotation.lineWidth ?? DEFAULT_STYLES.line.lineWidth;\n ctx.setLineDash(annotation.lineDash ?? DEFAULT_STYLES.line.lineDash);\n\n ctx.beginPath();\n ctx.moveTo(x, yStart);\n ctx.lineTo(x, yEnd);\n ctx.stroke();\n\n // Render label if present\n if (annotation.label) {\n this.renderLineLabel(\n ctx,\n annotation.label,\n yStart, yEnd, x,\n annotation.labelPosition ?? 'top',\n 'vertical',\n annotation.labelBackground,\n latexAPI\n );\n }\n\n ctx.restore();\n }\n\n // ----------------------------------------\n // Render: Rectangle\n // ----------------------------------------\n\n private renderRectangle(\n ctx: CanvasRenderingContext2D,\n annotation: RectangleAnnotation,\n plotArea: PlotArea,\n bounds: Bounds,\n latexAPI?: any\n ): void {\n const x1 = this.dataToPixelX(annotation.xMin, bounds, plotArea);\n const x2 = this.dataToPixelX(annotation.xMax, bounds, plotArea);\n const y1 = this.dataToPixelY(annotation.yMax, bounds, plotArea); // Note: Y is inverted\n const y2 = this.dataToPixelY(annotation.yMin, bounds, plotArea);\n\n const x = Math.min(x1, x2);\n const y = Math.min(y1, y2);\n const width = Math.abs(x2 - x1);\n const height = Math.abs(y2 - y1);\n\n ctx.save();\n\n // Fill\n if (annotation.fillColor) {\n ctx.fillStyle = annotation.fillColor;\n ctx.fillRect(x, y, width, height);\n }\n\n // Stroke\n if (annotation.strokeColor) {\n ctx.strokeStyle = annotation.strokeColor;\n ctx.lineWidth = annotation.strokeWidth ?? DEFAULT_STYLES.rectangle.strokeWidth;\n ctx.setLineDash(annotation.strokeDash ?? []);\n ctx.strokeRect(x, y, width, height);\n }\n\n // Label\n if (annotation.label) {\n this.renderCenteredLabel(ctx, annotation.label, x + width / 2, y + height / 2, latexAPI);\n }\n\n ctx.restore();\n }\n\n // ----------------------------------------\n // Render: Band\n // ----------------------------------------\n\n private renderBand(\n ctx: CanvasRenderingContext2D,\n annotation: BandAnnotation,\n plotArea: PlotArea,\n bounds: Bounds,\n latexAPI?: any\n ): void {\n // Determine band type and calculate bounds\n let x: number, y: number, width: number, height: number;\n\n if (annotation.xMin !== undefined && annotation.xMax !== undefined) {\n // Vertical band (spans full Y)\n const x1 = this.dataToPixelX(annotation.xMin, bounds, plotArea);\n const x2 = this.dataToPixelX(annotation.xMax, bounds, plotArea);\n x = Math.min(x1, x2);\n width = Math.abs(x2 - x1);\n y = plotArea.y;\n height = plotArea.height;\n\n if (annotation.yMin !== undefined) {\n const yPixel = this.dataToPixelY(annotation.yMin, bounds, plotArea);\n height = yPixel - y;\n }\n if (annotation.yMax !== undefined) {\n const yPixel = this.dataToPixelY(annotation.yMax, bounds, plotArea);\n y = yPixel;\n height = plotArea.y + plotArea.height - y;\n }\n } else if (annotation.yMin !== undefined && annotation.yMax !== undefined) {\n // Horizontal band (spans full X)\n const y1 = this.dataToPixelY(annotation.yMax, bounds, plotArea);\n const y2 = this.dataToPixelY(annotation.yMin, bounds, plotArea);\n y = Math.min(y1, y2);\n height = Math.abs(y2 - y1);\n x = plotArea.x;\n width = plotArea.width;\n } else {\n // Invalid band configuration\n return;\n }\n\n ctx.save();\n\n // Fill\n ctx.fillStyle = annotation.fillColor ?? DEFAULT_STYLES.rectangle.fillColor;\n ctx.fillRect(x, y, width, height);\n\n // Stroke\n if (annotation.strokeColor) {\n ctx.strokeStyle = annotation.strokeColor;\n ctx.lineWidth = annotation.strokeWidth ?? 1;\n ctx.strokeRect(x, y, width, height);\n }\n\n // Label\n if (annotation.label) {\n let labelX = x + width / 2;\n let labelY = y + height / 2;\n\n switch (annotation.labelPosition) {\n case 'top':\n labelY = y + 15;\n break;\n case 'bottom':\n labelY = y + height - 5;\n break;\n case 'left':\n labelX = x + 10;\n break;\n case 'right':\n labelX = x + width - 10;\n break;\n }\n\n this.renderCenteredLabel(ctx, annotation.label, labelX, labelY, latexAPI);\n }\n\n ctx.restore();\n }\n\n // ----------------------------------------\n // Render: Text\n // ----------------------------------------\n\n private renderText(\n ctx: CanvasRenderingContext2D,\n annotation: TextAnnotation,\n plotArea: PlotArea,\n bounds: Bounds,\n latexAPI?: any\n ): void {\n const x = this.dataToPixelX(annotation.x, bounds, plotArea);\n const y = this.dataToPixelY(annotation.y, bounds, plotArea);\n\n ctx.save();\n\n // Apply rotation if specified\n if (annotation.rotation) {\n ctx.translate(x, y);\n ctx.rotate((annotation.rotation * Math.PI) / 180);\n ctx.translate(-x, -y);\n }\n\n const fontSize = annotation.fontSize ?? DEFAULT_STYLES.text.fontSize;\n const fontFamily = annotation.fontFamily ?? DEFAULT_STYLES.text.fontFamily;\n const fontWeight = annotation.fontWeight ?? 'normal';\n const lineHeight = fontSize * 1.2;\n\n ctx.font = `${fontWeight} ${fontSize}px ${fontFamily}`;\n ctx.textAlign = 'center';\n ctx.textBaseline = 'middle';\n\n // Support multi-line text\n const lines = annotation.text.split('\\n');\n const padding = annotation.padding ?? DEFAULT_STYLES.text.padding;\n\n // Measure all lines to find max width\n let maxWidth = 0;\n for (const line of lines) {\n maxWidth = Math.max(maxWidth, ctx.measureText(line).width);\n }\n\n const textWidth = maxWidth + padding * 2;\n const textHeight = (lines.length * lineHeight) - (lineHeight - fontSize) + padding * 2;\n\n // Calculate position based on anchor\n let drawX = x;\n let drawY = y;\n\n switch (annotation.anchor) {\n case 'top-left':\n drawX += textWidth / 2;\n drawY += textHeight / 2;\n break;\n case 'top-right':\n drawX -= textWidth / 2;\n drawY += textHeight / 2;\n break;\n case 'bottom-left':\n drawX += textWidth / 2;\n drawY -= textHeight / 2;\n break;\n case 'bottom-right':\n drawX -= textWidth / 2;\n drawY -= textHeight / 2;\n break;\n case 'top-center':\n drawY += textHeight / 2;\n break;\n case 'bottom-center':\n drawY -= textHeight / 2;\n break;\n case 'left-center':\n drawX += textWidth / 2;\n break;\n case 'right-center':\n drawX -= textWidth / 2;\n break;\n }\n\n // Draw background\n if (annotation.backgroundColor) {\n ctx.fillStyle = annotation.backgroundColor;\n ctx.beginPath();\n ctx.roundRect(\n drawX - textWidth / 2,\n drawY - textHeight / 2,\n textWidth,\n textHeight,\n 4\n );\n ctx.fill();\n }\n\n // Draw text lines\n const color = annotation.color ?? DEFAULT_STYLES.text.color;\n const startY = drawY - (textHeight / 2) + padding + (fontSize / 2);\n\n lines.forEach((line, i) => {\n this.drawLatexOrText(ctx, line, drawX, startY + i * lineHeight, {\n fontSize,\n fontFamily,\n fontWeight,\n color,\n align: 'center',\n baseline: 'middle',\n latex: annotation.latex\n }, latexAPI);\n });\n\n ctx.restore();\n }\n\n // ----------------------------------------\n // Render: Arrow\n // ----------------------------------------\n\n private renderArrow(\n ctx: CanvasRenderingContext2D,\n annotation: ArrowAnnotation,\n plotArea: PlotArea,\n bounds: Bounds,\n latexAPI?: any\n ): void {\n const x1 = this.dataToPixelX(annotation.x1, bounds, plotArea);\n const y1 = this.dataToPixelY(annotation.y1, bounds, plotArea);\n const x2 = this.dataToPixelX(annotation.x2, bounds, plotArea);\n const y2 = this.dataToPixelY(annotation.y2, bounds, plotArea);\n\n ctx.save();\n ctx.strokeStyle = annotation.color ?? DEFAULT_STYLES.arrow.color;\n ctx.fillStyle = annotation.color ?? DEFAULT_STYLES.arrow.color;\n ctx.lineWidth = annotation.lineWidth ?? DEFAULT_STYLES.arrow.lineWidth;\n\n // Draw line\n ctx.beginPath();\n ctx.moveTo(x1, y1);\n ctx.lineTo(x2, y2);\n ctx.stroke();\n\n // Draw arrow head\n const headSize = annotation.headSize ?? DEFAULT_STYLES.arrow.headSize;\n const angle = Math.atan2(y2 - y1, x2 - x1);\n\n const headStyle = annotation.headStyle ?? 'filled';\n\n if (headStyle !== 'none') {\n ctx.beginPath();\n ctx.moveTo(x2, y2);\n ctx.lineTo(\n x2 - headSize * Math.cos(angle - Math.PI / 6),\n y2 - headSize * Math.sin(angle - Math.PI / 6)\n );\n\n if (headStyle === 'filled') {\n ctx.lineTo(\n x2 - headSize * Math.cos(angle + Math.PI / 6),\n y2 - headSize * Math.sin(angle + Math.PI / 6)\n );\n ctx.closePath();\n ctx.fill();\n } else {\n ctx.moveTo(x2, y2);\n ctx.lineTo(\n x2 - headSize * Math.cos(angle + Math.PI / 6),\n y2 - headSize * Math.sin(angle + Math.PI / 6)\n );\n ctx.stroke();\n }\n }\n\n // Draw tail arrow if specified\n if (annotation.showTail) {\n const tailAngle = angle + Math.PI;\n ctx.beginPath();\n ctx.moveTo(x1, y1);\n ctx.lineTo(\n x1 - headSize * Math.cos(tailAngle - Math.PI / 6),\n y1 - headSize * Math.sin(tailAngle - Math.PI / 6)\n );\n ctx.lineTo(\n x1 - headSize * Math.cos(tailAngle + Math.PI / 6),\n y1 - headSize * Math.sin(tailAngle + Math.PI / 6)\n );\n ctx.closePath();\n ctx.fill();\n }\n\n // Draw label if present\n if (annotation.label) {\n const midX = (x1 + x2) / 2;\n const midY = (y1 + y2) / 2;\n this.renderCenteredLabel(ctx, annotation.label, midX, midY - 10, latexAPI);\n }\n\n ctx.restore();\n }\n\n // ----------------------------------------\n // Helper: Render Labels\n // ----------------------------------------\n\n private renderLineLabel(\n ctx: CanvasRenderingContext2D,\n label: string,\n start: number,\n end: number,\n cross: number,\n position: string,\n orientation: 'horizontal' | 'vertical',\n backgroundColor?: string,\n latexAPI?: any\n ): void {\n ctx.save();\n\n ctx.font = `${DEFAULT_STYLES.text.fontSize}px ${DEFAULT_STYLES.text.fontFamily}`;\n const metrics = ctx.measureText(label);\n const padding = 4;\n const textWidth = metrics.width + padding * 2;\n const textHeight = DEFAULT_STYLES.text.fontSize + padding * 2;\n\n let x: number, y: number;\n\n if (orientation === 'horizontal') {\n y = cross;\n\n switch (position) {\n case 'left':\n x = start + 5;\n ctx.textAlign = 'left';\n break;\n case 'right':\n x = end - 5;\n ctx.textAlign = 'right';\n break;\n default:\n x = (start + end) / 2;\n ctx.textAlign = 'center';\n }\n\n ctx.textBaseline = 'bottom';\n y -= 4;\n } else {\n x = cross;\n\n switch (position) {\n case 'top':\n y = start + textHeight;\n break;\n case 'bottom':\n y = end - 5;\n break;\n default:\n y = (start + end) / 2;\n }\n\n ctx.textAlign = 'center';\n ctx.textBaseline = 'middle';\n }\n\n // Background\n if (backgroundColor ?? true) {\n ctx.fillStyle = backgroundColor ?? 'rgba(0, 0, 0, 0.7)';\n const bgX = ctx.textAlign === 'left' ? x - padding\n : ctx.textAlign === 'right' ? x - textWidth + padding\n : x - textWidth / 2;\n ctx.fillRect(bgX, y - textHeight + padding, textWidth, textHeight);\n }\n\n // Text\n this.drawLatexOrText(ctx, label, x, y, {\n fontSize: DEFAULT_STYLES.text.fontSize,\n fontFamily: DEFAULT_STYLES.text.fontFamily,\n color: DEFAULT_STYLES.text.color,\n align: ctx.textAlign,\n baseline: ctx.textBaseline,\n }, latexAPI);\n\n ctx.restore();\n }\n\n private renderCenteredLabel(\n ctx: CanvasRenderingContext2D,\n label: string,\n x: number,\n y: number,\n latexAPI?: any\n ): void {\n ctx.save();\n\n ctx.font = `${DEFAULT_STYLES.text.fontSize}px ${DEFAULT_STYLES.text.fontFamily}`;\n const metrics = ctx.measureText(label);\n const padding = 4;\n const textWidth = metrics.width + padding * 2;\n const textHeight = DEFAULT_STYLES.text.fontSize + padding * 2;\n\n // Background\n ctx.fillStyle = 'rgba(0, 0, 0, 0.7)';\n ctx.beginPath();\n ctx.roundRect(x - textWidth / 2, y - textHeight / 2, textWidth, textHeight, 3);\n ctx.fill();\n\n // Text\n this.drawLatexOrText(ctx, label, x, y, {\n fontSize: DEFAULT_STYLES.text.fontSize,\n fontFamily: DEFAULT_STYLES.text.fontFamily,\n color: DEFAULT_STYLES.text.color,\n align: 'center',\n baseline: 'middle',\n }, latexAPI);\n\n ctx.restore();\n }\n}\n","/**\n * Sci Plot - Annotations Plugin\n * \n * Provides annotation capabilities including:\n * - Line, Rectangle, Band, Text, Arrow annotations\n * - Annotation management and rendering\n * \n * @module plugins/annotations\n */\n\nimport { AnnotationManager } from \"../../core/annotations\";\nimport type { Annotation, AnnotationType } from \"../../core/annotations\";\nimport type { PluginManifest, ChartPlugin, PluginContext } from \"../types\";\n\nexport interface PluginAnnotationsConfig {\n /** Default styles for annotations */\n defaultStyles?: Record<string, any>;\n}\n\nconst manifestAnnotations: PluginManifest = {\n name: \"velo-plot-annotations\",\n version: \"1.0.0\",\n description: \"Annotation support for velo-plot\",\n provides: [\"annotation\"],\n tags: [\"annotation\", \"overlay\", \"label\"],\n};\n\n/**\n * SciPlot Annotations Plugin\n * \n * Adds support for drawing lines, shapes, and labels on the chart.\n */\nexport function PluginAnnotations(_config: PluginAnnotationsConfig = {}): ChartPlugin<PluginAnnotationsConfig> {\n let annotationManager: AnnotationManager;\n\n return {\n manifest: manifestAnnotations,\n\n onInit(ctx: PluginContext) {\n annotationManager = new AnnotationManager();\n\n // In a real implementation, we would register this manager in the context\n // so the chart can delegate annotation calls to it.\n // For now, we store it in storage for retrieval.\n ctx.storage.set(\"manager\", annotationManager);\n },\n\n onRenderOverlay(ctx) {\n const plotArea = ctx.render.plotArea;\n const viewBounds = ctx.data.getViewBounds();\n\n // Get LaTeX API if plugin is available\n const latexPlugin = ctx.getPlugin<any>(\"velo-plot-latex\");\n const latexAPI = latexPlugin?.api;\n\n // Render all annotations using the manager and provided contexts\n annotationManager.render(\n ctx.render.ctx2d!,\n plotArea,\n viewBounds,\n latexAPI\n );\n },\n\n onDestroy(_ctx: PluginContext) {\n annotationManager.clear();\n },\n\n api: {\n getManager() {\n return annotationManager;\n },\n add(annotation: Annotation) {\n return annotationManager.add(annotation);\n },\n remove(id: string) {\n return annotationManager.remove(id);\n },\n update(id: string, updates: Partial<Annotation>) {\n return annotationManager.update(id, updates);\n },\n get(id: string) {\n return annotationManager.get(id);\n },\n getAll() {\n return annotationManager.getAll();\n },\n clear() {\n annotationManager.clear();\n }\n }\n };\n}\n\nexport { AnnotationManager };\nexport type { Annotation, AnnotationType };\nexport default PluginAnnotations;\n"],"names":["DEFAULT_STYLES","AnnotationManager","__publicField","annotation","id","resolved","updates","existing","ctx","plotArea","bounds","latexAPI","sorted","a","b","text","x","y","options","dims","lx","ly","align","baseline","value","normalized","xStart","xEnd","yStart","yEnd","x1","x2","y1","y2","width","height","labelX","labelY","fontSize","fontFamily","fontWeight","lineHeight","lines","padding","maxWidth","line","textWidth","textHeight","drawX","drawY","color","startY","i","headSize","angle","headStyle","tailAngle","midX","midY","label","start","end","cross","position","orientation","backgroundColor","metrics","bgX","manifestAnnotations","PluginAnnotations","_config","annotationManager","viewBounds","latexPlugin","_ctx"],"mappings":";;;AAqBA,MAAMA,IAAiB;AAAA,EACrB,MAAM;AAAA,IACJ,OAAO;AAAA,IACP,WAAW;AAAA,IACX,UAAU,CAAA;AAAA,EAAC;AAAA,EAEb,WAAW;AAAA,IACT,WAAW;AAAA,IAEX,aAAa;AAAA,EAAA;AAAA,EAEf,MAAM;AAAA,IACJ,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,OAAO;AAAA,IAEP,SAAS;AAAA,EAAA;AAAA,EAEX,OAAO;AAAA,IACL,OAAO;AAAA,IACP,WAAW;AAAA,IACX,UAAU;AAAA,EAAA;AAEd;AAiBO,MAAMC,EAAkB;AAAA,EAAxB;AACG,IAAAC,EAAA,yCAA2C,IAAA;AAC3C,IAAAA,EAAA,mBAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUpB,IAAIC,GAAgC;AAClC,UAAMC,IAAKD,EAAW,MAAM,cAAc,EAAE,KAAK,SAAS,IACpDE,IAAuB;AAAA,MAC3B,GAAGF;AAAA,MACH,IAAAC;AAAA,MACA,SAASD,EAAW,WAAW;AAAA,MAC/B,aAAaA,EAAW,eAAe;AAAA,MACvC,QAAQA,EAAW,UAAU;AAAA,IAAA;AAG/B,gBAAK,YAAY,IAAIC,GAAIC,CAAQ,GAC1BD;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,OAAOA,GAAqB;AAC1B,WAAO,KAAK,YAAY,OAAOA,CAAE;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA,EAKA,OAAOA,GAAYE,GAAoC;AACrD,UAAMC,IAAW,KAAK,YAAY,IAAIH,CAAE;AACxC,IAAIG,KACF,KAAK,YAAY,IAAIH,GAAI,EAAE,GAAG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3C;AAAA,MACA,OAAOC,GAAY;AACf,eAAOmE,EAAkB,OAAOnE,CAAE;AAAA,MACtC;AAAA,MACA,OAAOA,GAAYE,GAA8B;AAC7C,eAAOiE,EAAkB,OAAOnE,GAAIE,CAAO;AAAA,MAC/C;AAAA,MACA,IAAIF,GAAY;AACZ,eAAOmE,EAAkB,IAAInE,CAAE;AAAA,MACnC;AAAA,MACA,SAAS;AACL,eAAOmE,EAAkB,OAAA;AAAA,MAC7B;AAAA,MACA,QAAQ;AACJ,QAAAA,EAAkB,MAAA;AAAA,MACtB;AAAA,IAAA;AAAA,EACJ;AAER;"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { AnomalyPoint, AnomalyMethod } from './types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Z-Score method: Standard statistical approach
|
|
5
|
+
* - Uses MEAN and STANDARD DEVIATION (parametric)
|
|
6
|
+
* - Assumes normal distribution
|
|
7
|
+
* - Sensitive to extreme outliers
|
|
8
|
+
* - Best for: Clean, normally distributed data
|
|
9
|
+
*/
|
|
10
|
+
export declare function detectZScore(x: Float32Array | Float64Array, y: Float32Array | Float64Array, threshold?: number): AnomalyPoint[];
|
|
11
|
+
/**
|
|
12
|
+
* MAD (Median Absolute Deviation) method: Robust statistical approach
|
|
13
|
+
* - Uses MEDIAN instead of mean (non-parametric)
|
|
14
|
+
* - Robust to outliers in the window
|
|
15
|
+
* - Doesn't assume normal distribution
|
|
16
|
+
* - Best for: Data with existing outliers, skewed distributions
|
|
17
|
+
*/
|
|
18
|
+
export declare function detectMAD(x: Float32Array | Float64Array, y: Float32Array | Float64Array, threshold?: number): AnomalyPoint[];
|
|
19
|
+
/**
|
|
20
|
+
* IQR (Interquartile Range) method: Quartile-based approach
|
|
21
|
+
* - Uses PERCENTILES (25th and 75th)
|
|
22
|
+
* - Classic box-plot outlier detection
|
|
23
|
+
* - Non-parametric, distribution-free
|
|
24
|
+
* - Best for: General purpose, well-understood method
|
|
25
|
+
*/
|
|
26
|
+
export declare function detectIQR(x: Float32Array | Float64Array, y: Float32Array | Float64Array, multiplier?: number): AnomalyPoint[];
|
|
27
|
+
/**
|
|
28
|
+
* Simplified Isolation Forest: Detects anomalies using random partitioning
|
|
29
|
+
* - Machine learning approach
|
|
30
|
+
* - Isolates anomalies through random splits
|
|
31
|
+
* - Works well with high-dimensional data
|
|
32
|
+
* - Best for: Complex patterns, unknown distributions
|
|
33
|
+
*/
|
|
34
|
+
export declare function detectIsolationForest(x: Float32Array | Float64Array, y: Float32Array | Float64Array, contamination?: number, numTrees?: number): AnomalyPoint[];
|
|
35
|
+
/**
|
|
36
|
+
* Main detection function - routes to appropriate algorithm
|
|
37
|
+
*/
|
|
38
|
+
export declare function detectAnomalies(x: Float32Array | Float64Array, y: Float32Array | Float64Array, method: AnomalyMethod, sensitivity: number): AnomalyPoint[];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ChartPlugin } from '../types';
|
|
2
|
+
import { PluginAnomalyDetectionConfig } from './types';
|
|
3
|
+
|
|
4
|
+
export type { PluginAnomalyDetectionConfig, AnomalyDetectionResult, AnomalyPoint, AnomalyMethod } from './types';
|
|
5
|
+
export declare const manifestAnomalyDetection: {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
version: `${number}.${number}.${number}`;
|
|
9
|
+
description: string;
|
|
10
|
+
author: string;
|
|
11
|
+
category: "analysis";
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Anomaly Detection Plugin Factory
|
|
15
|
+
*/
|
|
16
|
+
export declare function PluginAnomalyDetection(userConfig?: PluginAnomalyDetectionConfig): ChartPlugin<PluginAnomalyDetectionConfig>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anomaly Detection Plugin Types
|
|
3
|
+
*/
|
|
4
|
+
export type AnomalyMethod = 'zscore' | 'mad' | 'iqr' | 'isolation-forest';
|
|
5
|
+
export interface AnomalyPoint {
|
|
6
|
+
/** Index in the data array */
|
|
7
|
+
index: number;
|
|
8
|
+
/** X value */
|
|
9
|
+
x: number;
|
|
10
|
+
/** Y value */
|
|
11
|
+
y: number;
|
|
12
|
+
/** Anomaly score (higher = more anomalous) */
|
|
13
|
+
score: number;
|
|
14
|
+
/** Method used for detection */
|
|
15
|
+
method: AnomalyMethod;
|
|
16
|
+
}
|
|
17
|
+
export interface PluginAnomalyDetectionConfig {
|
|
18
|
+
/** Detection method (default: 'zscore') */
|
|
19
|
+
method?: AnomalyMethod;
|
|
20
|
+
/** Sensitivity threshold (default: 0.95)
|
|
21
|
+
* - For zscore: number of standard deviations (e.g., 3)
|
|
22
|
+
* - For mad: MAD multiplier (e.g., 3.5)
|
|
23
|
+
* - For iqr: IQR multiplier (e.g., 1.5)
|
|
24
|
+
* - For isolation-forest: contamination rate (e.g., 0.05)
|
|
25
|
+
*/
|
|
26
|
+
sensitivity?: number;
|
|
27
|
+
/** Enable real-time detection on data updates (default: false) */
|
|
28
|
+
realtime?: boolean;
|
|
29
|
+
/** Highlight anomalies on the chart (default: true) */
|
|
30
|
+
highlight?: boolean;
|
|
31
|
+
/** Highlight color (default: '#ff0000') */
|
|
32
|
+
highlightColor?: string;
|
|
33
|
+
/** Highlight marker size (default: 8) */
|
|
34
|
+
highlightSize?: number;
|
|
35
|
+
/** Minimum window size for detection (default: 30) */
|
|
36
|
+
minWindowSize?: number;
|
|
37
|
+
/** Use rolling window for real-time detection (default: false) */
|
|
38
|
+
rollingWindow?: boolean;
|
|
39
|
+
/** Rolling window size (default: 100) */
|
|
40
|
+
windowSize?: number;
|
|
41
|
+
/** Series IDs to monitor (empty = all series) */
|
|
42
|
+
seriesIds?: string[];
|
|
43
|
+
}
|
|
44
|
+
export interface AnomalyDetectionResult {
|
|
45
|
+
/** Series ID */
|
|
46
|
+
seriesId: string;
|
|
47
|
+
/** Detected anomalies */
|
|
48
|
+
anomalies: AnomalyPoint[];
|
|
49
|
+
/** Total points analyzed */
|
|
50
|
+
totalPoints: number;
|
|
51
|
+
/** Detection method used */
|
|
52
|
+
method: AnomalyMethod;
|
|
53
|
+
/** Threshold value used */
|
|
54
|
+
threshold: number;
|
|
55
|
+
/** Timestamp of detection */
|
|
56
|
+
timestamp: number;
|
|
57
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Scale } from '../../scales';
|
|
2
|
+
import { AxisBreak } from './types';
|
|
3
|
+
|
|
4
|
+
export declare class BrokenAxisScale implements Scale {
|
|
5
|
+
private breaks;
|
|
6
|
+
domain: [number, number];
|
|
7
|
+
range: [number, number];
|
|
8
|
+
readonly type = "linear";
|
|
9
|
+
private underlying;
|
|
10
|
+
private sortedBreaks;
|
|
11
|
+
private visibleRanges;
|
|
12
|
+
private availableVisualRatio;
|
|
13
|
+
constructor(originalScale: Scale, breaks: AxisBreak[]);
|
|
14
|
+
setDomain(min: number, max: number): void;
|
|
15
|
+
setRange(min: number, max: number): void;
|
|
16
|
+
updateBreaks(breaks: AxisBreak[]): void;
|
|
17
|
+
private refresh;
|
|
18
|
+
transform(value: number): number;
|
|
19
|
+
/** Map data value to 0-1 ratio space (handles breaks) */
|
|
20
|
+
mapToRatio(value: number): number;
|
|
21
|
+
invert(pixel: number): number;
|
|
22
|
+
ticks(count?: number): number[];
|
|
23
|
+
private generateSegmentTicks;
|
|
24
|
+
}
|