@chartgpu/chartgpu 0.2.5
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 +208 -0
- package/dist/ChartGPU.d.ts +146 -0
- package/dist/ChartGPU.d.ts.map +1 -0
- package/dist/components/createAnnotationConfigDialog.d.ts +24 -0
- package/dist/components/createAnnotationConfigDialog.d.ts.map +1 -0
- package/dist/components/createDataZoomSlider.d.ts +14 -0
- package/dist/components/createDataZoomSlider.d.ts.map +1 -0
- package/dist/components/createLegend.d.ts +9 -0
- package/dist/components/createLegend.d.ts.map +1 -0
- package/dist/components/createTextOverlay.d.ts +17 -0
- package/dist/components/createTextOverlay.d.ts.map +1 -0
- package/dist/components/createTooltip.d.ts +12 -0
- package/dist/components/createTooltip.d.ts.map +1 -0
- package/dist/components/formatTooltip.d.ts +19 -0
- package/dist/components/formatTooltip.d.ts.map +1 -0
- package/dist/config/OptionResolver.d.ts +137 -0
- package/dist/config/OptionResolver.d.ts.map +1 -0
- package/dist/config/defaults.d.ts +56 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/types.d.ts +553 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/core/GPUContext.d.ts +242 -0
- package/dist/core/GPUContext.d.ts.map +1 -0
- package/dist/core/RenderScheduler.d.ts +174 -0
- package/dist/core/RenderScheduler.d.ts.map +1 -0
- package/dist/core/createAnimationController.d.ts +15 -0
- package/dist/core/createAnimationController.d.ts.map +1 -0
- package/dist/core/createRenderCoordinator.d.ts +78 -0
- package/dist/core/createRenderCoordinator.d.ts.map +1 -0
- package/dist/core/renderCoordinator/animation/animationHelpers.d.ts +183 -0
- package/dist/core/renderCoordinator/animation/animationHelpers.d.ts.map +1 -0
- package/dist/core/renderCoordinator/annotations/processAnnotations.d.ts +88 -0
- package/dist/core/renderCoordinator/annotations/processAnnotations.d.ts.map +1 -0
- package/dist/core/renderCoordinator/axis/axisLabelHelpers.d.ts +91 -0
- package/dist/core/renderCoordinator/axis/axisLabelHelpers.d.ts.map +1 -0
- package/dist/core/renderCoordinator/axis/computeAxisTicks.d.ts +53 -0
- package/dist/core/renderCoordinator/axis/computeAxisTicks.d.ts.map +1 -0
- package/dist/core/renderCoordinator/data/computeVisibleSlice.d.ts +66 -0
- package/dist/core/renderCoordinator/data/computeVisibleSlice.d.ts.map +1 -0
- package/dist/core/renderCoordinator/gpu/textureManager.d.ts +69 -0
- package/dist/core/renderCoordinator/gpu/textureManager.d.ts.map +1 -0
- package/dist/core/renderCoordinator/interaction/interactionHelpers.d.ts +160 -0
- package/dist/core/renderCoordinator/interaction/interactionHelpers.d.ts.map +1 -0
- package/dist/core/renderCoordinator/render/renderAnnotationLabels.d.ts +36 -0
- package/dist/core/renderCoordinator/render/renderAnnotationLabels.d.ts.map +1 -0
- package/dist/core/renderCoordinator/render/renderAxisLabels.d.ts +40 -0
- package/dist/core/renderCoordinator/render/renderAxisLabels.d.ts.map +1 -0
- package/dist/core/renderCoordinator/render/renderOverlays.d.ts +70 -0
- package/dist/core/renderCoordinator/render/renderOverlays.d.ts.map +1 -0
- package/dist/core/renderCoordinator/render/renderSeries.d.ts +146 -0
- package/dist/core/renderCoordinator/render/renderSeries.d.ts.map +1 -0
- package/dist/core/renderCoordinator/renderers/rendererPool.d.ts +112 -0
- package/dist/core/renderCoordinator/renderers/rendererPool.d.ts.map +1 -0
- package/dist/core/renderCoordinator/types.d.ts +19 -0
- package/dist/core/renderCoordinator/types.d.ts.map +1 -0
- package/dist/core/renderCoordinator/ui/tooltipLegendHelpers.d.ts +104 -0
- package/dist/core/renderCoordinator/ui/tooltipLegendHelpers.d.ts.map +1 -0
- package/dist/core/renderCoordinator/utils/axisUtils.d.ts +122 -0
- package/dist/core/renderCoordinator/utils/axisUtils.d.ts.map +1 -0
- package/dist/core/renderCoordinator/utils/boundsComputation.d.ts +69 -0
- package/dist/core/renderCoordinator/utils/boundsComputation.d.ts.map +1 -0
- package/dist/core/renderCoordinator/utils/canvasUtils.d.ts +52 -0
- package/dist/core/renderCoordinator/utils/canvasUtils.d.ts.map +1 -0
- package/dist/core/renderCoordinator/utils/dataPointUtils.d.ts +71 -0
- package/dist/core/renderCoordinator/utils/dataPointUtils.d.ts.map +1 -0
- package/dist/core/renderCoordinator/utils/index.d.ts +12 -0
- package/dist/core/renderCoordinator/utils/index.d.ts.map +1 -0
- package/dist/core/renderCoordinator/utils/timeAxisUtils.d.ts +149 -0
- package/dist/core/renderCoordinator/utils/timeAxisUtils.d.ts.map +1 -0
- package/dist/core/renderCoordinator/zoom/zoomHelpers.d.ts +129 -0
- package/dist/core/renderCoordinator/zoom/zoomHelpers.d.ts.map +1 -0
- package/dist/data/cartesianData.d.ts +72 -0
- package/dist/data/cartesianData.d.ts.map +1 -0
- package/dist/data/createDataStore.d.ts +27 -0
- package/dist/data/createDataStore.d.ts.map +1 -0
- package/dist/data/createStreamBuffer.d.ts +20 -0
- package/dist/data/createStreamBuffer.d.ts.map +1 -0
- package/dist/data/lttbSample.d.ts +5 -0
- package/dist/data/lttbSample.d.ts.map +1 -0
- package/dist/data/ohlcSample.d.ts +21 -0
- package/dist/data/ohlcSample.d.ts.map +1 -0
- package/dist/data/packDataPoints.d.ts +65 -0
- package/dist/data/packDataPoints.d.ts.map +1 -0
- package/dist/data/sampleSeries.d.ts +20 -0
- package/dist/data/sampleSeries.d.ts.map +1 -0
- package/dist/esm/ChartGPUWorkerController-B50J-8sx.js +772 -0
- package/dist/esm/ChartGPUWorkerController-B50J-8sx.js.map +1 -0
- package/dist/esm/OptionResolver-R_gJDRSD.js +7150 -0
- package/dist/esm/OptionResolver-R_gJDRSD.js.map +1 -0
- package/dist/esm/assets/worker-entry-Wg897auv.js +779 -0
- package/dist/esm/assets/worker-entry-Wg897auv.js.map +1 -0
- package/dist/esm/createChartInWorker-C4fEeJL8.js +1224 -0
- package/dist/esm/createChartInWorker-C4fEeJL8.js.map +1 -0
- package/dist/esm/index.js +795 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/index.cjs +1270 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10504 -0
- package/dist/index.js.map +1 -0
- package/dist/interaction/createAnnotationAuthoring.d.ts +115 -0
- package/dist/interaction/createAnnotationAuthoring.d.ts.map +1 -0
- package/dist/interaction/createAnnotationDragHandler.d.ts +28 -0
- package/dist/interaction/createAnnotationDragHandler.d.ts.map +1 -0
- package/dist/interaction/createAnnotationHitTester.d.ts +32 -0
- package/dist/interaction/createAnnotationHitTester.d.ts.map +1 -0
- package/dist/interaction/createChartSync.d.ts +27 -0
- package/dist/interaction/createChartSync.d.ts.map +1 -0
- package/dist/interaction/createEventManager.d.ts +24 -0
- package/dist/interaction/createEventManager.d.ts.map +1 -0
- package/dist/interaction/createHoverState.d.ts +20 -0
- package/dist/interaction/createHoverState.d.ts.map +1 -0
- package/dist/interaction/createInsideZoom.d.ts +14 -0
- package/dist/interaction/createInsideZoom.d.ts.map +1 -0
- package/dist/interaction/createZoomState.d.ts +63 -0
- package/dist/interaction/createZoomState.d.ts.map +1 -0
- package/dist/interaction/findCandlestick.d.ts +41 -0
- package/dist/interaction/findCandlestick.d.ts.map +1 -0
- package/dist/interaction/findNearestPoint.d.ts +61 -0
- package/dist/interaction/findNearestPoint.d.ts.map +1 -0
- package/dist/interaction/findPieSlice.d.ts +36 -0
- package/dist/interaction/findPieSlice.d.ts.map +1 -0
- package/dist/interaction/findPointsAtX.d.ts +37 -0
- package/dist/interaction/findPointsAtX.d.ts.map +1 -0
- package/dist/renderers/createAnnotationMarkerRenderer.d.ts +58 -0
- package/dist/renderers/createAnnotationMarkerRenderer.d.ts.map +1 -0
- package/dist/renderers/createAreaRenderer.d.ts +19 -0
- package/dist/renderers/createAreaRenderer.d.ts.map +1 -0
- package/dist/renderers/createAxisRenderer.d.ts +19 -0
- package/dist/renderers/createAxisRenderer.d.ts.map +1 -0
- package/dist/renderers/createBarRenderer.d.ts +20 -0
- package/dist/renderers/createBarRenderer.d.ts.map +1 -0
- package/dist/renderers/createCandlestickRenderer.d.ts +19 -0
- package/dist/renderers/createCandlestickRenderer.d.ts.map +1 -0
- package/dist/renderers/createCrosshairRenderer.d.ts +43 -0
- package/dist/renderers/createCrosshairRenderer.d.ts.map +1 -0
- package/dist/renderers/createGridRenderer.d.ts +45 -0
- package/dist/renderers/createGridRenderer.d.ts.map +1 -0
- package/dist/renderers/createHighlightRenderer.d.ts +41 -0
- package/dist/renderers/createHighlightRenderer.d.ts.map +1 -0
- package/dist/renderers/createLineRenderer.d.ts +18 -0
- package/dist/renderers/createLineRenderer.d.ts.map +1 -0
- package/dist/renderers/createPieRenderer.d.ts +18 -0
- package/dist/renderers/createPieRenderer.d.ts.map +1 -0
- package/dist/renderers/createReferenceLineRenderer.d.ts +81 -0
- package/dist/renderers/createReferenceLineRenderer.d.ts.map +1 -0
- package/dist/renderers/createScatterDensityRenderer.d.ts +14 -0
- package/dist/renderers/createScatterDensityRenderer.d.ts.map +1 -0
- package/dist/renderers/createScatterRenderer.d.ts +20 -0
- package/dist/renderers/createScatterRenderer.d.ts.map +1 -0
- package/dist/renderers/rendererUtils.d.ts +100 -0
- package/dist/renderers/rendererUtils.d.ts.map +1 -0
- package/dist/themes/darkTheme.d.ts +11 -0
- package/dist/themes/darkTheme.d.ts.map +1 -0
- package/dist/themes/index.d.ts +8 -0
- package/dist/themes/index.d.ts.map +1 -0
- package/dist/themes/lightTheme.d.ts +11 -0
- package/dist/themes/lightTheme.d.ts.map +1 -0
- package/dist/themes/types.d.ts +14 -0
- package/dist/themes/types.d.ts.map +1 -0
- package/dist/types/ChartGPU.d.ts +99 -0
- package/dist/types/ChartGPU.d.ts.map +1 -0
- package/dist/types/components/createDataZoomSlider.d.ts +14 -0
- package/dist/types/components/createDataZoomSlider.d.ts.map +1 -0
- package/dist/types/components/createLegend.d.ts +9 -0
- package/dist/types/components/createLegend.d.ts.map +1 -0
- package/dist/types/components/createTextOverlay.d.ts +17 -0
- package/dist/types/components/createTextOverlay.d.ts.map +1 -0
- package/dist/types/components/createTooltip.d.ts +12 -0
- package/dist/types/components/createTooltip.d.ts.map +1 -0
- package/dist/types/components/formatTooltip.d.ts +19 -0
- package/dist/types/components/formatTooltip.d.ts.map +1 -0
- package/dist/types/config/OptionResolver.d.ts +134 -0
- package/dist/types/config/OptionResolver.d.ts.map +1 -0
- package/dist/types/config/defaults.d.ts +55 -0
- package/dist/types/config/defaults.d.ts.map +1 -0
- package/dist/types/config/types.d.ts +485 -0
- package/dist/types/config/types.d.ts.map +1 -0
- package/dist/types/core/GPUContext.d.ts +242 -0
- package/dist/types/core/GPUContext.d.ts.map +1 -0
- package/dist/types/core/RenderScheduler.d.ts +174 -0
- package/dist/types/core/RenderScheduler.d.ts.map +1 -0
- package/dist/types/core/createAnimationController.d.ts +15 -0
- package/dist/types/core/createAnimationController.d.ts.map +1 -0
- package/dist/types/core/createRenderCoordinator.d.ts +129 -0
- package/dist/types/core/createRenderCoordinator.d.ts.map +1 -0
- package/dist/types/data/createDataStore.d.ts +33 -0
- package/dist/types/data/createDataStore.d.ts.map +1 -0
- package/dist/types/data/createStreamBuffer.d.ts +20 -0
- package/dist/types/data/createStreamBuffer.d.ts.map +1 -0
- package/dist/types/data/lttbSample.d.ts +5 -0
- package/dist/types/data/lttbSample.d.ts.map +1 -0
- package/dist/types/data/ohlcSample.d.ts +21 -0
- package/dist/types/data/ohlcSample.d.ts.map +1 -0
- package/dist/types/data/packDataPoints.d.ts +79 -0
- package/dist/types/data/packDataPoints.d.ts.map +1 -0
- package/dist/types/data/sampleSeries.d.ts +3 -0
- package/dist/types/data/sampleSeries.d.ts.map +1 -0
- package/dist/types/index.d.ts +35 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/interaction/createChartSync.d.ts +12 -0
- package/dist/types/interaction/createChartSync.d.ts.map +1 -0
- package/dist/types/interaction/createEventManager.d.ts +24 -0
- package/dist/types/interaction/createEventManager.d.ts.map +1 -0
- package/dist/types/interaction/createHoverState.d.ts +20 -0
- package/dist/types/interaction/createHoverState.d.ts.map +1 -0
- package/dist/types/interaction/createInsideZoom.d.ts +14 -0
- package/dist/types/interaction/createInsideZoom.d.ts.map +1 -0
- package/dist/types/interaction/createZoomState.d.ts +63 -0
- package/dist/types/interaction/createZoomState.d.ts.map +1 -0
- package/dist/types/interaction/findCandlestick.d.ts +41 -0
- package/dist/types/interaction/findCandlestick.d.ts.map +1 -0
- package/dist/types/interaction/findNearestPoint.d.ts +61 -0
- package/dist/types/interaction/findNearestPoint.d.ts.map +1 -0
- package/dist/types/interaction/findPieSlice.d.ts +36 -0
- package/dist/types/interaction/findPieSlice.d.ts.map +1 -0
- package/dist/types/interaction/findPointsAtX.d.ts +37 -0
- package/dist/types/interaction/findPointsAtX.d.ts.map +1 -0
- package/dist/types/renderers/createAreaRenderer.d.ts +18 -0
- package/dist/types/renderers/createAreaRenderer.d.ts.map +1 -0
- package/dist/types/renderers/createAxisRenderer.d.ts +19 -0
- package/dist/types/renderers/createAxisRenderer.d.ts.map +1 -0
- package/dist/types/renderers/createBarRenderer.d.ts +20 -0
- package/dist/types/renderers/createBarRenderer.d.ts.map +1 -0
- package/dist/types/renderers/createCandlestickRenderer.d.ts +19 -0
- package/dist/types/renderers/createCandlestickRenderer.d.ts.map +1 -0
- package/dist/types/renderers/createCrosshairRenderer.d.ts +43 -0
- package/dist/types/renderers/createCrosshairRenderer.d.ts.map +1 -0
- package/dist/types/renderers/createGridRenderer.d.ts +45 -0
- package/dist/types/renderers/createGridRenderer.d.ts.map +1 -0
- package/dist/types/renderers/createHighlightRenderer.d.ts +41 -0
- package/dist/types/renderers/createHighlightRenderer.d.ts.map +1 -0
- package/dist/types/renderers/createLineRenderer.d.ts +18 -0
- package/dist/types/renderers/createLineRenderer.d.ts.map +1 -0
- package/dist/types/renderers/createPieRenderer.d.ts +18 -0
- package/dist/types/renderers/createPieRenderer.d.ts.map +1 -0
- package/dist/types/renderers/createScatterDensityRenderer.d.ts +14 -0
- package/dist/types/renderers/createScatterDensityRenderer.d.ts.map +1 -0
- package/dist/types/renderers/createScatterRenderer.d.ts +19 -0
- package/dist/types/renderers/createScatterRenderer.d.ts.map +1 -0
- package/dist/types/renderers/rendererUtils.d.ts +100 -0
- package/dist/types/renderers/rendererUtils.d.ts.map +1 -0
- package/dist/types/themes/darkTheme.d.ts +11 -0
- package/dist/types/themes/darkTheme.d.ts.map +1 -0
- package/dist/types/themes/index.d.ts +8 -0
- package/dist/types/themes/index.d.ts.map +1 -0
- package/dist/types/themes/lightTheme.d.ts +11 -0
- package/dist/types/themes/lightTheme.d.ts.map +1 -0
- package/dist/types/themes/types.d.ts +14 -0
- package/dist/types/themes/types.d.ts.map +1 -0
- package/dist/types/utils/axisLabelStyling.d.ts +27 -0
- package/dist/types/utils/axisLabelStyling.d.ts.map +1 -0
- package/dist/types/utils/checkWebGPU.d.ts +39 -0
- package/dist/types/utils/checkWebGPU.d.ts.map +1 -0
- package/dist/types/utils/colors.d.ts +14 -0
- package/dist/types/utils/colors.d.ts.map +1 -0
- package/dist/types/utils/easing.d.ts +9 -0
- package/dist/types/utils/easing.d.ts.map +1 -0
- package/dist/types/utils/scales.d.ts +79 -0
- package/dist/types/utils/scales.d.ts.map +1 -0
- package/dist/utils/axisLabelStyling.d.ts +20 -0
- package/dist/utils/axisLabelStyling.d.ts.map +1 -0
- package/dist/utils/checkWebGPU.d.ts +39 -0
- package/dist/utils/checkWebGPU.d.ts.map +1 -0
- package/dist/utils/colors.d.ts +14 -0
- package/dist/utils/colors.d.ts.map +1 -0
- package/dist/utils/easing.d.ts +9 -0
- package/dist/utils/easing.d.ts.map +1 -0
- package/dist/utils/scales.d.ts +79 -0
- package/dist/utils/scales.d.ts.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Annotation authoring helper for ChartGPU instances.
|
|
3
|
+
*
|
|
4
|
+
* Provides right-click context menu for adding vertical lines and text annotations,
|
|
5
|
+
* with undo/redo, JSON export, drag-to-reposition, and editing capabilities.
|
|
6
|
+
*/
|
|
7
|
+
import type { ChartGPUInstance } from '../ChartGPU';
|
|
8
|
+
import type { AnnotationConfig } from '../config/types';
|
|
9
|
+
/**
|
|
10
|
+
* Configuration options for annotation authoring.
|
|
11
|
+
*/
|
|
12
|
+
export interface AnnotationAuthoringOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Z-index for the context menu (default: 1000).
|
|
15
|
+
*/
|
|
16
|
+
readonly menuZIndex?: number;
|
|
17
|
+
/**
|
|
18
|
+
* Enable right-click context menu (default: true).
|
|
19
|
+
*/
|
|
20
|
+
readonly enableContextMenu?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Annotation authoring instance returned by `createAnnotationAuthoring`.
|
|
24
|
+
*
|
|
25
|
+
* Provides programmatic control over annotations and manages UI lifecycle.
|
|
26
|
+
*/
|
|
27
|
+
export interface AnnotationAuthoringInstance {
|
|
28
|
+
/**
|
|
29
|
+
* Programmatically add a vertical line annotation.
|
|
30
|
+
*
|
|
31
|
+
* @param x - X-coordinate in data domain units
|
|
32
|
+
*/
|
|
33
|
+
addVerticalLine(x: number): void;
|
|
34
|
+
/**
|
|
35
|
+
* Programmatically add a text annotation.
|
|
36
|
+
*
|
|
37
|
+
* @param x - X-coordinate (domain units for 'data' space, fraction [0-1] for 'plot' space)
|
|
38
|
+
* @param y - Y-coordinate (domain units for 'data' space, fraction [0-1] for 'plot' space)
|
|
39
|
+
* @param text - Annotation text content
|
|
40
|
+
* @param space - Coordinate space: 'data' (default) or 'plot'
|
|
41
|
+
*/
|
|
42
|
+
addTextNote(x: number, y: number, text: string, space?: 'data' | 'plot'): void;
|
|
43
|
+
/**
|
|
44
|
+
* Undo the last annotation change.
|
|
45
|
+
*
|
|
46
|
+
* @returns `true` if undo was successful, `false` if nothing to undo
|
|
47
|
+
*/
|
|
48
|
+
undo(): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Redo a previously undone change.
|
|
51
|
+
*
|
|
52
|
+
* @returns `true` if redo was successful, `false` if nothing to redo
|
|
53
|
+
*/
|
|
54
|
+
redo(): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Export current annotations as JSON string.
|
|
57
|
+
*
|
|
58
|
+
* @returns JSON string representation of annotations array
|
|
59
|
+
*/
|
|
60
|
+
exportJSON(): string;
|
|
61
|
+
/**
|
|
62
|
+
* Get the current annotations array.
|
|
63
|
+
*
|
|
64
|
+
* @returns Readonly copy of current annotations
|
|
65
|
+
*/
|
|
66
|
+
getAnnotations(): readonly AnnotationConfig[];
|
|
67
|
+
/**
|
|
68
|
+
* Clean up event listeners and DOM elements.
|
|
69
|
+
*
|
|
70
|
+
* Safe to call multiple times. After disposal, the instance should not be used.
|
|
71
|
+
*/
|
|
72
|
+
dispose(): void;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Creates an annotation authoring helper for a chart instance.
|
|
76
|
+
*
|
|
77
|
+
* Features:
|
|
78
|
+
* - Right-click context menu for adding vertical lines and text annotations
|
|
79
|
+
* - Optional toolbar with undo/redo/export buttons
|
|
80
|
+
* - Undo/redo history (50 entries max)
|
|
81
|
+
* - JSON export with clipboard integration
|
|
82
|
+
* - Automatic coordinate conversion (data-space and plot-space)
|
|
83
|
+
* - Event listener cleanup on dispose
|
|
84
|
+
*
|
|
85
|
+
* Annotations are persisted by calling `chart.setOption({ ...options, annotations })`,
|
|
86
|
+
* so they integrate seamlessly with the chart's option system.
|
|
87
|
+
*
|
|
88
|
+
* @param container - The chart container element (must contain the chart canvas)
|
|
89
|
+
* @param chart - The ChartGPU instance
|
|
90
|
+
* @param options - Optional configuration for menu/toolbar z-index and visibility
|
|
91
|
+
* @returns Annotation authoring instance with programmatic API and dispose method
|
|
92
|
+
* @throws Error if canvas is not found
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* const chart = await ChartGPU.create(container, options);
|
|
97
|
+
* const authoring = createAnnotationAuthoring(container, chart, {
|
|
98
|
+
* showToolbar: true,
|
|
99
|
+
* enableContextMenu: true,
|
|
100
|
+
* });
|
|
101
|
+
*
|
|
102
|
+
* // Programmatic API
|
|
103
|
+
* authoring.addVerticalLine(Date.now());
|
|
104
|
+
* authoring.addTextNote(x, y, 'Peak', 'data');
|
|
105
|
+
* authoring.undo();
|
|
106
|
+
* authoring.redo();
|
|
107
|
+
* const json = authoring.exportJSON();
|
|
108
|
+
*
|
|
109
|
+
* // Cleanup
|
|
110
|
+
* authoring.dispose();
|
|
111
|
+
* chart.dispose();
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
export declare function createAnnotationAuthoring(container: HTMLElement, chart: ChartGPUInstance, options?: AnnotationAuthoringOptions): AnnotationAuthoringInstance;
|
|
115
|
+
//# sourceMappingURL=createAnnotationAuthoring.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createAnnotationAuthoring.d.ts","sourceRoot":"","sources":["../../src/interaction/createAnnotationAuthoring.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAyB,MAAM,aAAa,CAAC;AAC3E,OAAO,KAAK,EAAE,gBAAgB,EAAgE,MAAM,iBAAiB,CAAC;AActH;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC;;OAEG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B;;OAEG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC;CACtC;AAED;;;;GAIG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;;;OAIG;IACH,eAAe,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC;;;;;;;OAOG;IACH,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC/E;;;;OAIG;IACH,IAAI,IAAI,OAAO,CAAC;IAChB;;;;OAIG;IACH,IAAI,IAAI,OAAO,CAAC;IAChB;;;;OAIG;IACH,UAAU,IAAI,MAAM,CAAC;IACrB;;;;OAIG;IACH,cAAc,IAAI,SAAS,gBAAgB,EAAE,CAAC;IAC9C;;;;OAIG;IACH,OAAO,IAAI,IAAI,CAAC;CACjB;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,WAAW,EACtB,KAAK,EAAE,gBAAgB,EACvB,OAAO,GAAE,0BAA+B,GACvC,2BAA2B,CA2pB7B"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drag handler for repositioning annotations
|
|
3
|
+
*
|
|
4
|
+
* Handles dragging annotations to reposition them:
|
|
5
|
+
* - lineX: constrained to horizontal movement
|
|
6
|
+
* - lineY: constrained to vertical movement
|
|
7
|
+
* - text: free 2D movement (data or plot space)
|
|
8
|
+
* - point: free 2D movement (data space)
|
|
9
|
+
*
|
|
10
|
+
* Uses optimistic updates during drag for 60 FPS performance.
|
|
11
|
+
*/
|
|
12
|
+
import type { AnnotationConfig } from '../config/types.js';
|
|
13
|
+
import type { ChartGPUInstance } from '../ChartGPU.js';
|
|
14
|
+
export interface AnnotationDragCallbacks {
|
|
15
|
+
onDragMove: (index: number, updates: Partial<AnnotationConfig>) => void;
|
|
16
|
+
onDragEnd: (index: number, updates: Partial<AnnotationConfig>) => void;
|
|
17
|
+
onDragCancel: () => void;
|
|
18
|
+
}
|
|
19
|
+
export interface AnnotationDragHandler {
|
|
20
|
+
startDrag(annotationIndex: number, annotation: AnnotationConfig, startPointerX: number, startPointerY: number): void;
|
|
21
|
+
isDragging(): boolean;
|
|
22
|
+
dispose(): void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Creates a drag handler for repositioning annotations
|
|
26
|
+
*/
|
|
27
|
+
export declare function createAnnotationDragHandler(chart: ChartGPUInstance, canvas: HTMLCanvasElement, callbacks: AnnotationDragCallbacks): AnnotationDragHandler;
|
|
28
|
+
//# sourceMappingURL=createAnnotationDragHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createAnnotationDragHandler.d.ts","sourceRoot":"","sources":["../../src/interaction/createAnnotationDragHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAa,MAAM,oBAAoB,CAAC;AACtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IACxE,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IACvE,YAAY,EAAE,MAAM,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,qBAAqB;IACpC,SAAS,CACP,eAAe,EAAE,MAAM,EACvB,UAAU,EAAE,gBAAgB,EAC5B,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,GACpB,IAAI,CAAC;IACR,UAAU,IAAI,OAAO,CAAC;IACtB,OAAO,IAAI,IAAI,CAAC;CACjB;AAUD;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,gBAAgB,EACvB,MAAM,EAAE,iBAAiB,EACzB,SAAS,EAAE,uBAAuB,GACjC,qBAAqB,CAyXvB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hit testing for chart annotations
|
|
3
|
+
*
|
|
4
|
+
* Detects which annotation (if any) the user clicked or hovered over.
|
|
5
|
+
* Uses canvas-space coordinates and configurable hit tolerances.
|
|
6
|
+
*/
|
|
7
|
+
import type { AnnotationConfig } from '../config/types.js';
|
|
8
|
+
import type { ChartGPUInstance } from '../ChartGPU.js';
|
|
9
|
+
export interface AnnotationHitTestResult {
|
|
10
|
+
readonly annotationIndex: number;
|
|
11
|
+
readonly annotation: AnnotationConfig;
|
|
12
|
+
readonly hitType: 'line' | 'text' | 'point' | 'label';
|
|
13
|
+
readonly distanceCssPx: number;
|
|
14
|
+
}
|
|
15
|
+
export interface AnnotationHitTesterOptions {
|
|
16
|
+
readonly lineTolerance?: number;
|
|
17
|
+
readonly textTolerance?: number;
|
|
18
|
+
readonly pointTolerance?: number;
|
|
19
|
+
readonly labelTolerance?: number;
|
|
20
|
+
readonly spatialGridThreshold?: number;
|
|
21
|
+
}
|
|
22
|
+
export interface AnnotationHitTester {
|
|
23
|
+
hitTest(canvasX: number, canvasY: number): AnnotationHitTestResult | null;
|
|
24
|
+
updateTextBounds(textBounds: Map<number, DOMRect>): void;
|
|
25
|
+
invalidateCache(): void;
|
|
26
|
+
dispose(): void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Creates an annotation hit tester for detecting pointer interactions
|
|
30
|
+
*/
|
|
31
|
+
export declare function createAnnotationHitTester(chart: ChartGPUInstance, canvas: HTMLCanvasElement, options?: AnnotationHitTesterOptions): AnnotationHitTester;
|
|
32
|
+
//# sourceMappingURL=createAnnotationHitTester.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createAnnotationHitTester.d.ts","sourceRoot":"","sources":["../../src/interaction/createAnnotationHitTester.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAa,MAAM,oBAAoB,CAAC;AACtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC;IACtC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;IACtD,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC;CACxC;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,uBAAuB,GAAG,IAAI,CAAC;IAC1E,gBAAgB,CAAC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACzD,eAAe,IAAI,IAAI,CAAC;IACxB,OAAO,IAAI,IAAI,CAAC;CACjB;AASD;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,gBAAgB,EACvB,MAAM,EAAE,iBAAiB,EACzB,OAAO,GAAE,0BAA+B,GACvC,mBAAmB,CAgarB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ChartGPU } from '../ChartGPU';
|
|
2
|
+
export type DisconnectCharts = () => void;
|
|
3
|
+
export type ChartSyncOptions = Readonly<{
|
|
4
|
+
/**
|
|
5
|
+
* Sync crosshair + tooltip (interaction-x) across charts.
|
|
6
|
+
*x
|
|
7
|
+
* @default true
|
|
8
|
+
*/
|
|
9
|
+
readonly syncCrosshair?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Sync zoom/pan across charts (percent-space zoom range).
|
|
12
|
+
*
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
readonly syncZoom?: boolean;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* Connects multiple charts so pointer movement in one chart drives crosshair/tooltip x
|
|
19
|
+
* in the other charts (domain x sync). Returns a `disconnect()` function.
|
|
20
|
+
*
|
|
21
|
+
* Notes:
|
|
22
|
+
* - By default, syncs interaction only (crosshair + tooltip x), not zoom/options.
|
|
23
|
+
* - Enable zoom sync via `{ syncZoom: true }`.
|
|
24
|
+
* - Uses a per-connection loop guard to prevent feedback.
|
|
25
|
+
*/
|
|
26
|
+
export declare function connectCharts(charts: ChartGPU[], options?: ChartSyncOptions): DisconnectCharts;
|
|
27
|
+
//# sourceMappingURL=createChartSync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createChartSync.d.ts","sourceRoot":"","sources":["../../src/interaction/createChartSync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAgE,MAAM,aAAa,CAAC;AAE1G,MAAM,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC;AAE1C,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACtC;;;;OAIG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;IACjC;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC,CAAC;AAEH;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,gBAAgB,CAwF9F"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { GridArea } from '../renderers/createGridRenderer';
|
|
2
|
+
export type ChartGPUEventName = 'mousemove' | 'click' | 'mouseleave';
|
|
3
|
+
export type ChartGPUEventPayload = {
|
|
4
|
+
readonly x: number;
|
|
5
|
+
readonly y: number;
|
|
6
|
+
readonly gridX: number;
|
|
7
|
+
readonly gridY: number;
|
|
8
|
+
/** Plot (grid) width in CSS pixels. */
|
|
9
|
+
readonly plotWidthCss: number;
|
|
10
|
+
/** Plot (grid) height in CSS pixels. */
|
|
11
|
+
readonly plotHeightCss: number;
|
|
12
|
+
readonly isInGrid: boolean;
|
|
13
|
+
readonly originalEvent: PointerEvent;
|
|
14
|
+
};
|
|
15
|
+
export type ChartGPUEventCallback = (payload: ChartGPUEventPayload) => void;
|
|
16
|
+
export interface EventManager {
|
|
17
|
+
readonly canvas: HTMLCanvasElement;
|
|
18
|
+
on(event: ChartGPUEventName, callback: ChartGPUEventCallback): void;
|
|
19
|
+
off(event: ChartGPUEventName, callback: ChartGPUEventCallback): void;
|
|
20
|
+
updateGridArea(gridArea: GridArea): void;
|
|
21
|
+
dispose(): void;
|
|
22
|
+
}
|
|
23
|
+
export declare function createEventManager(canvas: HTMLCanvasElement, initialGridArea: GridArea): EventManager;
|
|
24
|
+
//# sourceMappingURL=createEventManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createEventManager.d.ts","sourceRoot":"","sources":["../../src/interaction/createEventManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAEhE,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,OAAO,GAAG,YAAY,CAAC;AAErE,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,uCAAuC;IACvC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,wCAAwC;IACxC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,aAAa,EAAE,YAAY,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,EAAE,oBAAoB,KAAK,IAAI,CAAC;AAE5E,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,EAAE,CAAC,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,qBAAqB,GAAG,IAAI,CAAC;IACpE,GAAG,CAAC,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,qBAAqB,GAAG,IAAI,CAAC;IACrE,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IACzC,OAAO,IAAI,IAAI,CAAC;CACjB;AAcD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,iBAAiB,EAAE,eAAe,EAAE,QAAQ,GAAG,YAAY,CA6KrG"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type HoverTarget = Readonly<{
|
|
2
|
+
seriesIndex: number;
|
|
3
|
+
dataIndex: number;
|
|
4
|
+
}>;
|
|
5
|
+
export type HoverChangeCallback = (hovered: HoverTarget | null) => void;
|
|
6
|
+
export interface HoverState {
|
|
7
|
+
setHovered(seriesIndex: number, dataIndex: number): void;
|
|
8
|
+
clearHovered(): void;
|
|
9
|
+
getHovered(): HoverTarget | null;
|
|
10
|
+
onChange(callback: HoverChangeCallback): () => void;
|
|
11
|
+
destroy?: () => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Tracks hovered series/data indices and notifies listeners on changes.
|
|
15
|
+
*
|
|
16
|
+
* - Updates are debounced to avoid spamming downstream work during rapid pointer movement.
|
|
17
|
+
* - Listeners fire only when the hovered target actually changes.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createHoverState(): HoverState;
|
|
20
|
+
//# sourceMappingURL=createHoverState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createHoverState.d.ts","sourceRoot":"","sources":["../../src/interaction/createHoverState.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC;AAExE,MAAM,WAAW,UAAU;IACzB,UAAU,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzD,YAAY,IAAI,IAAI,CAAC;IACrB,UAAU,IAAI,WAAW,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,GAAG,MAAM,IAAI,CAAC;IACpD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAmBD;;;;;GAKG;AACH,wBAAgB,gBAAgB,IAAI,UAAU,CAgE7C"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { EventManager } from './createEventManager';
|
|
2
|
+
import type { ZoomState } from './createZoomState';
|
|
3
|
+
export type InsideZoom = Readonly<{
|
|
4
|
+
enable(): void;
|
|
5
|
+
disable(): void;
|
|
6
|
+
dispose(): void;
|
|
7
|
+
}>;
|
|
8
|
+
/**
|
|
9
|
+
* Internal “inside” zoom interaction:
|
|
10
|
+
* - wheel zoom centered at cursor-x (only when inside grid)
|
|
11
|
+
* - shift+left drag OR middle-mouse drag pans left/right (only when inside grid)
|
|
12
|
+
*/
|
|
13
|
+
export declare function createInsideZoom(eventManager: EventManager, zoomState: ZoomState): InsideZoom;
|
|
14
|
+
//# sourceMappingURL=createInsideZoom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createInsideZoom.d.ts","sourceRoot":"","sources":["../../src/interaction/createInsideZoom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAwB,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,MAAM,IAAI,IAAI,CAAC;IACf,OAAO,IAAI,IAAI,CAAC;IAChB,OAAO,IAAI,IAAI,CAAC;CACjB,CAAC,CAAC;AAuDH;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,GAAG,UAAU,CAmI7F"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export type ZoomRange = Readonly<{
|
|
2
|
+
start: number;
|
|
3
|
+
end: number;
|
|
4
|
+
}>;
|
|
5
|
+
export type ZoomRangeChangeCallback = (range: ZoomRange) => void;
|
|
6
|
+
export interface ZoomState {
|
|
7
|
+
/**
|
|
8
|
+
* Returns the current zoom window in percent space, clamped to [0, 100].
|
|
9
|
+
*/
|
|
10
|
+
getRange(): ZoomRange;
|
|
11
|
+
/**
|
|
12
|
+
* Sets the zoom window in percent space.
|
|
13
|
+
*/
|
|
14
|
+
setRange(start: number, end: number): void;
|
|
15
|
+
/**
|
|
16
|
+
* Zooms in around `center` by shrinking the span by `factor`.
|
|
17
|
+
*
|
|
18
|
+
* `factor <= 1` is treated as a no-op.
|
|
19
|
+
*/
|
|
20
|
+
zoomIn(center: number, factor: number): void;
|
|
21
|
+
/**
|
|
22
|
+
* Zooms out around `center` by growing the span by `factor`.
|
|
23
|
+
*
|
|
24
|
+
* `factor <= 1` is treated as a no-op.
|
|
25
|
+
*/
|
|
26
|
+
zoomOut(center: number, factor: number): void;
|
|
27
|
+
/**
|
|
28
|
+
* Pans the zoom window by `delta` percent points (preserving span).
|
|
29
|
+
*/
|
|
30
|
+
pan(delta: number): void;
|
|
31
|
+
/**
|
|
32
|
+
* Subscribes to changes. Returns an unsubscribe function.
|
|
33
|
+
*/
|
|
34
|
+
onChange(callback: ZoomRangeChangeCallback): () => void;
|
|
35
|
+
}
|
|
36
|
+
export type ZoomSpanConstraints = Readonly<{
|
|
37
|
+
/**
|
|
38
|
+
* Minimum allowed span (percent points in [0, 100]).
|
|
39
|
+
*/
|
|
40
|
+
readonly minSpan?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Maximum allowed span (percent points in [0, 100]).
|
|
43
|
+
*/
|
|
44
|
+
readonly maxSpan?: number;
|
|
45
|
+
}>;
|
|
46
|
+
export type ZoomRangeAnchor = 'start' | 'end' | 'center' | Readonly<{
|
|
47
|
+
center: number;
|
|
48
|
+
ratio: number;
|
|
49
|
+
}>;
|
|
50
|
+
export interface ZoomStateWithConstraints extends ZoomState {
|
|
51
|
+
/**
|
|
52
|
+
* Updates span constraints at runtime (used by coordinator on setOption/appendData).
|
|
53
|
+
*
|
|
54
|
+
* Passing `undefined` leaves that constraint unchanged.
|
|
55
|
+
*/
|
|
56
|
+
setSpanConstraints(minSpan?: number, maxSpan?: number): void;
|
|
57
|
+
/**
|
|
58
|
+
* Sets a range with an explicit anchor for clamping (used by slider handles).
|
|
59
|
+
*/
|
|
60
|
+
setRangeAnchored(start: number, end: number, anchor: ZoomRangeAnchor): void;
|
|
61
|
+
}
|
|
62
|
+
export declare function createZoomState(initialStart: number, initialEnd: number, constraints?: ZoomSpanConstraints): ZoomStateWithConstraints;
|
|
63
|
+
//# sourceMappingURL=createZoomState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createZoomState.d.ts","sourceRoot":"","sources":["../../src/interaction/createZoomState.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,QAAQ,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEjE,MAAM,MAAM,uBAAuB,GAAG,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;AAEjE,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,QAAQ,IAAI,SAAS,CAAC;IACtB;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3C;;;;OAIG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7C;;;;OAIG;IACH,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9C;;OAEG;IACH,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,uBAAuB,GAAG,MAAM,IAAI,CAAC;CACzD;AAED,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC;IACzC;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC,CAAC;AAEH,MAAM,MAAM,eAAe,GACvB,OAAO,GACP,KAAK,GACL,QAAQ,GACR,QAAQ,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEhD,MAAM,WAAW,wBAAyB,SAAQ,SAAS;IACzD;;;;OAIG;IACH,kBAAkB,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7D;;OAEG;IACH,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,GAAG,IAAI,CAAC;CAC7E;AAgBD,wBAAgB,eAAe,CAC7B,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,WAAW,CAAC,EAAE,mBAAmB,GAChC,wBAAwB,CA0M1B"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ResolvedCandlestickSeriesConfig } from '../config/OptionResolver';
|
|
2
|
+
import type { OHLCDataPoint } from '../config/types';
|
|
3
|
+
import type { LinearScale } from '../utils/scales';
|
|
4
|
+
export interface CandlestickMatch {
|
|
5
|
+
seriesIndex: number;
|
|
6
|
+
dataIndex: number;
|
|
7
|
+
point: OHLCDataPoint;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Computes the candlestick body width in xScale **range-space** units.
|
|
11
|
+
*
|
|
12
|
+
* Notes:
|
|
13
|
+
* - This mirrors `createCandlestickRenderer.ts` bar width semantics, but stays in range units
|
|
14
|
+
* (CSS pixels in ChartGPU interaction usage).
|
|
15
|
+
* - No DPR conversions are applied here.
|
|
16
|
+
*/
|
|
17
|
+
export declare function computeCandlestickBodyWidthRange(series: ResolvedCandlestickSeriesConfig, data: ReadonlyArray<OHLCDataPoint>, xScale: LinearScale, plotWidthFallback?: number): number;
|
|
18
|
+
/**
|
|
19
|
+
* Finds the candlestick body under the given cursor position.
|
|
20
|
+
*
|
|
21
|
+
* Coordinate system contract:
|
|
22
|
+
* - `x`/`y` MUST be in the same units as `xScale`/`yScale` **range-space**
|
|
23
|
+
* (ChartGPU interaction uses grid-local CSS pixels).
|
|
24
|
+
*
|
|
25
|
+
* Hit-test semantics:
|
|
26
|
+
* - Body-only hit-testing (wicks ignored).
|
|
27
|
+
* - A candle hits if:
|
|
28
|
+
* - `abs(x - xCenter) <= barWidth / 2`, AND
|
|
29
|
+
* - `y` is between the scaled `open` and `close` (inclusive).
|
|
30
|
+
*
|
|
31
|
+
* Performance:
|
|
32
|
+
* - Per-series lower-bound binary search on timestamp, then scans left/right while x-distance alone can still hit.
|
|
33
|
+
* - If timestamps are not monotonic non-decreasing finite numbers, falls back to an O(n) scan for correctness.
|
|
34
|
+
*
|
|
35
|
+
* Edge cases:
|
|
36
|
+
* - Skips non-finite timestamps/open/close.
|
|
37
|
+
* - If `barWidthClip` is non-finite or <= 0, returns null.
|
|
38
|
+
* - Returns the closest in x (min abs dx) among hits; ties broken by smaller `dataIndex` (then smaller `seriesIndex`).
|
|
39
|
+
*/
|
|
40
|
+
export declare function findCandlestick(series: ReadonlyArray<ResolvedCandlestickSeriesConfig>, x: number, y: number, xScale: LinearScale, yScale: LinearScale, barWidthClip: number): CandlestickMatch | null;
|
|
41
|
+
//# sourceMappingURL=findCandlestick.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findCandlestick.d.ts","sourceRoot":"","sources":["../../src/interaction/findCandlestick.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,KAAK,EAAE,aAAa,EAAsB,MAAM,iBAAiB,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,aAAa,CAAC;CACtB;AA0CD;;;;;;;GAOG;AACH,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,+BAA+B,EACvC,IAAI,EAAE,aAAa,CAAC,aAAa,CAAC,EAClC,MAAM,EAAE,WAAW,EACnB,iBAAiB,CAAC,EAAE,MAAM,GACzB,MAAM,CAkDR;AAqCD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,aAAa,CAAC,+BAA+B,CAAC,EACtD,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,WAAW,EACnB,YAAY,EAAE,MAAM,GACnB,gBAAgB,GAAG,IAAI,CA2GzB"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { DataPoint } from '../config/types';
|
|
2
|
+
import type { ResolvedBarSeriesConfig, ResolvedSeriesConfig } from '../config/OptionResolver';
|
|
3
|
+
import type { LinearScale } from '../utils/scales';
|
|
4
|
+
export type NearestPointMatch = Readonly<{
|
|
5
|
+
seriesIndex: number;
|
|
6
|
+
dataIndex: number;
|
|
7
|
+
point: DataPoint;
|
|
8
|
+
/** Euclidean distance in range units. */
|
|
9
|
+
distance: number;
|
|
10
|
+
}>;
|
|
11
|
+
export type BarBounds = {
|
|
12
|
+
left: number;
|
|
13
|
+
right: number;
|
|
14
|
+
top: number;
|
|
15
|
+
bottom: number;
|
|
16
|
+
};
|
|
17
|
+
export declare function isPointInBar(x: number, y: number, barBounds: BarBounds): boolean;
|
|
18
|
+
export type BarClusterSlots = Readonly<{
|
|
19
|
+
clusterIndexBySeries: ReadonlyArray<number>;
|
|
20
|
+
clusterCount: number;
|
|
21
|
+
stackIdBySeries: ReadonlyArray<string>;
|
|
22
|
+
}>;
|
|
23
|
+
export declare function computeBarClusterSlots(seriesConfigs: ReadonlyArray<ResolvedBarSeriesConfig>): BarClusterSlots;
|
|
24
|
+
export declare function computeBarCategoryStep(seriesConfigs: ReadonlyArray<ResolvedBarSeriesConfig>): number;
|
|
25
|
+
export declare function computeCategoryWidthPx(seriesConfigs: ReadonlyArray<ResolvedBarSeriesConfig>, xScale: LinearScale, categoryStep: number): number;
|
|
26
|
+
export type BarLayoutPx = Readonly<{
|
|
27
|
+
categoryStep: number;
|
|
28
|
+
categoryWidthPx: number;
|
|
29
|
+
barWidthPx: number;
|
|
30
|
+
gapPx: number;
|
|
31
|
+
clusterWidthPx: number;
|
|
32
|
+
clusterSlots: BarClusterSlots;
|
|
33
|
+
}>;
|
|
34
|
+
export declare function computeBarLayoutPx(seriesConfigs: ReadonlyArray<ResolvedBarSeriesConfig>, xScale: LinearScale): BarLayoutPx;
|
|
35
|
+
export declare function inferPlotHeightPxForBarHitTesting(seriesConfigs: ReadonlyArray<ResolvedBarSeriesConfig>, yScale: LinearScale): number;
|
|
36
|
+
export declare function computeBaselineDomainAndPx(seriesConfigs: ReadonlyArray<ResolvedBarSeriesConfig>, yScale: LinearScale, plotHeightPx: number): Readonly<{
|
|
37
|
+
baselineDomain: number;
|
|
38
|
+
baselinePx: number;
|
|
39
|
+
}>;
|
|
40
|
+
export declare function bucketStackedXKey(xCenterPx: number, categoryWidthPx: number, xDomain: number, categoryStep: number): number;
|
|
41
|
+
/**
|
|
42
|
+
* Finds the nearest data point to the given cursor position across all series.
|
|
43
|
+
*
|
|
44
|
+
* Coordinate system contract:
|
|
45
|
+
* - `x`/`y` MUST be in the same units as `xScale`/`yScale` **range**.
|
|
46
|
+
* - If you pass **grid-local CSS pixels** (e.g. `payload.gridX` / `payload.gridY` from `createEventManager`),
|
|
47
|
+
* then `xScale.range()` / `yScale.range()` must also be in **CSS pixels**.
|
|
48
|
+
* - If your scales are in **clip space** (e.g. \([-1, 1]\)), pass cursor coordinates in clip space too.
|
|
49
|
+
*
|
|
50
|
+
* DPR/WebGPU note:
|
|
51
|
+
* - Pointer events are naturally in CSS pixels; WebGPU rendering often uses device pixels or clip space.
|
|
52
|
+
* This helper stays agnostic and only computes Euclidean distance in the provided **range-space**.
|
|
53
|
+
*
|
|
54
|
+
* Performance notes:
|
|
55
|
+
* - Assumes each series is sorted by increasing x in domain space.
|
|
56
|
+
* - Uses per-series lower-bound binary search on x, then expands outward while x-distance alone can still win.
|
|
57
|
+
* - Uses squared distance comparisons and computes `sqrt` only for the final match.
|
|
58
|
+
* - Skips non-finite points and any points whose scaled coordinates are NaN.
|
|
59
|
+
*/
|
|
60
|
+
export declare function findNearestPoint(series: ReadonlyArray<ResolvedSeriesConfig>, x: number, y: number, xScale: LinearScale, yScale: LinearScale, maxDistance?: number): NearestPointMatch | null;
|
|
61
|
+
//# sourceMappingURL=findNearestPoint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findNearestPoint.d.ts","sourceRoot":"","sources":["../../src/interaction/findNearestPoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAA0D,MAAM,iBAAiB,CAAC;AACzG,OAAO,KAAK,EACV,uBAAuB,EAEvB,oBAAoB,EACrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAyBnD,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,SAAS,CAAC;IACjB,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAErF,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,GAAG,OAAO,CAShF;AAqED,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC;IACrC,oBAAoB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC5C,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CACxC,CAAC,CAAC;AAEH,wBAAgB,sBAAsB,CACpC,aAAa,EAAE,aAAa,CAAC,uBAAuB,CAAC,GACpD,eAAe,CAgCjB;AAED,wBAAgB,sBAAsB,CAAC,aAAa,EAAE,aAAa,CAAC,uBAAuB,CAAC,GAAG,MAAM,CAoBpG;AAED,wBAAgB,sBAAsB,CACpC,aAAa,EAAE,aAAa,CAAC,uBAAuB,CAAC,EACrD,MAAM,EAAE,WAAW,EACnB,YAAY,EAAE,MAAM,GACnB,MAAM,CAgCR;AAyBD,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,eAAe,CAAC;CAC/B,CAAC,CAAC;AAEH,wBAAgB,kBAAkB,CAChC,aAAa,EAAE,aAAa,CAAC,uBAAuB,CAAC,EACrD,MAAM,EAAE,WAAW,GAClB,WAAW,CAyCb;AAsBD,wBAAgB,iCAAiC,CAC/C,aAAa,EAAE,aAAa,CAAC,uBAAuB,CAAC,EACrD,MAAM,EAAE,WAAW,GAClB,MAAM,CAgBR;AAED,wBAAgB,0BAA0B,CACxC,aAAa,EAAE,aAAa,CAAC,uBAAuB,CAAC,EACrD,MAAM,EAAE,WAAW,EACnB,YAAY,EAAE,MAAM,GACnB,QAAQ,CAAC;IAAE,cAAc,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAgC1D;AAED,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,GACnB,MAAM,CAWR;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,aAAa,CAAC,oBAAoB,CAAC,EAC3C,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,WAAW,EACnB,WAAW,GAAE,MAAgC,GAC5C,iBAAiB,GAAG,IAAI,CAoU1B"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ResolvedPieSeriesConfig } from '../config/OptionResolver';
|
|
2
|
+
export type PieSliceMatch = Readonly<{
|
|
3
|
+
seriesIndex: number;
|
|
4
|
+
dataIndex: number;
|
|
5
|
+
slice: ResolvedPieSeriesConfig['data'][number];
|
|
6
|
+
}>;
|
|
7
|
+
export type PieHitTestConfig = Readonly<{
|
|
8
|
+
seriesIndex: number;
|
|
9
|
+
series: ResolvedPieSeriesConfig;
|
|
10
|
+
}>;
|
|
11
|
+
export type PieCenterCssPx = Readonly<{
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
}>;
|
|
15
|
+
export type PieRadiusCssPx = Readonly<{
|
|
16
|
+
inner: number;
|
|
17
|
+
outer: number;
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* Finds the pie slice under a given pointer position.
|
|
21
|
+
*
|
|
22
|
+
* Coordinate contract:
|
|
23
|
+
* - `x`/`y` are plot/grid-local CSS pixels (origin at plot top-left, +y down).
|
|
24
|
+
* - `center` is plot-local CSS pixels.
|
|
25
|
+
* - `radius` is CSS pixels (inner/outer). Points within the donut hole are not hoverable.
|
|
26
|
+
*
|
|
27
|
+
* Angle conventions:
|
|
28
|
+
* - Uses +y up for polar angle (to match `pie.wgsl` atan2(p.y, p.x)).
|
|
29
|
+
* - Wraps angles to [0, 2π).
|
|
30
|
+
* - Matches `createPieRenderer.ts` start angle default (90°).
|
|
31
|
+
*
|
|
32
|
+
* Value conventions:
|
|
33
|
+
* - Ignores non-finite and non-positive slice values (mirrors renderer).
|
|
34
|
+
*/
|
|
35
|
+
export declare function findPieSlice(x: number, y: number, pieConfig: PieHitTestConfig, center: PieCenterCssPx, radius: PieRadiusCssPx): PieSliceMatch | null;
|
|
36
|
+
//# sourceMappingURL=findPieSlice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findPieSlice.d.ts","sourceRoot":"","sources":["../../src/interaction/findPieSlice.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAUxE,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,uBAAuB,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;CAChD,CAAC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,uBAAuB,CAAC;CACjC,CAAC,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAChE,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAExE;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAC1B,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,SAAS,EAAE,gBAAgB,EAC3B,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,cAAc,GACrB,aAAa,GAAG,IAAI,CAoFtB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { DataPoint } from '../config/types';
|
|
2
|
+
import type { ResolvedSeriesConfig } from '../config/OptionResolver';
|
|
3
|
+
import type { LinearScale } from '../utils/scales';
|
|
4
|
+
export type PointsAtXMatch = Readonly<{
|
|
5
|
+
seriesIndex: number;
|
|
6
|
+
dataIndex: number;
|
|
7
|
+
point: DataPoint;
|
|
8
|
+
}>;
|
|
9
|
+
/**
|
|
10
|
+
* Finds (at most) one nearest point per series at a given x position.
|
|
11
|
+
*
|
|
12
|
+
* Coordinate system contract (mirrors `findNearestPoint`):
|
|
13
|
+
* - `xValue` and optional `tolerance` MUST be in the same units as `xScale` **range**.
|
|
14
|
+
* (Example: if your `xScale.range()` is in grid-local CSS pixels, pass `payload.gridX` from `createEventManager`.)
|
|
15
|
+
* Note: ChartGPU's internal renderer scales are currently in clip space (NDC, typically \[-1, 1\]); in that case
|
|
16
|
+
* convert your pointer x into clip space before calling this helper.
|
|
17
|
+
*
|
|
18
|
+
* Behavior:
|
|
19
|
+
* - Assumes each series is sorted by increasing x in domain space.
|
|
20
|
+
* - Uses a lower-bound binary search in domain-x, then expands outward while x-distance alone can still improve.
|
|
21
|
+
* - Skips points with non-finite domain x or non-finite scaled x. If a series contains any NaN x values, this helper
|
|
22
|
+
* falls back to an O(n) scan for correctness (NaN breaks total ordering for binary search).
|
|
23
|
+
* - Stable tie-breaking: for equal distance, chooses the smaller `dataIndex`.
|
|
24
|
+
*
|
|
25
|
+
* If `tolerance` is provided, it is interpreted in **xScale range units**. Matches beyond tolerance are omitted.
|
|
26
|
+
* If `tolerance` is omitted (or non-finite), the nearest point per series is returned when possible.
|
|
27
|
+
*
|
|
28
|
+
* Bar series special-case:
|
|
29
|
+
* - Bars occupy x-intervals \([left, right)\) in **xScale range units** (grid-local CSS px for interaction scales),
|
|
30
|
+
* using the same shared layout math as the bar renderer (grouping + stacking slots).
|
|
31
|
+
* - If `tolerance` is finite, a bar match is only returned when `xValue` falls inside the bar interval expanded by
|
|
32
|
+
* `tolerance` on both sides: \([left - tolerance, right + tolerance)\).
|
|
33
|
+
* - If `tolerance` is omitted / non-finite, we first attempt an exact interval hit (no expansion) and otherwise fall
|
|
34
|
+
* back to the existing nearest-x behavior (so axis-trigger tooltips still work away from bars).
|
|
35
|
+
*/
|
|
36
|
+
export declare function findPointsAtX(series: ReadonlyArray<ResolvedSeriesConfig>, xValue: number, xScale: LinearScale, tolerance?: number): ReadonlyArray<PointsAtXMatch>;
|
|
37
|
+
//# sourceMappingURL=findPointsAtX.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findPointsAtX.d.ts","sourceRoot":"","sources":["../../src/interaction/findPointsAtX.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAuB,MAAM,iBAAiB,CAAC;AACtE,OAAO,KAAK,EAA2B,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC9F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAInD,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,SAAS,CAAC;CAClB,CAAC,CAAC;AAuFH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,aAAa,CAAC,oBAAoB,CAAC,EAC3C,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,WAAW,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB,aAAa,CAAC,cAAc,CAAC,CAgM/B"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export type AnnotationMarkerInstance = Readonly<{
|
|
2
|
+
/**
|
|
3
|
+
* Center in CANVAS-LOCAL CSS pixels.
|
|
4
|
+
* (0,0) is the canvas top-left in CSS pixel coordinates.
|
|
5
|
+
*/
|
|
6
|
+
xCssPx: number;
|
|
7
|
+
yCssPx: number;
|
|
8
|
+
/** Marker diameter in CSS pixels. */
|
|
9
|
+
sizeCssPx: number;
|
|
10
|
+
/** Fill color RGBA in 0..1 (straight alpha). */
|
|
11
|
+
fillRgba: readonly [r: number, g: number, b: number, a: number];
|
|
12
|
+
/** Optional stroke width in CSS pixels (0 disables stroke). */
|
|
13
|
+
strokeWidthCssPx?: number;
|
|
14
|
+
/** Optional stroke color RGBA in 0..1 (straight alpha). */
|
|
15
|
+
strokeRgba?: readonly [r: number, g: number, b: number, a: number];
|
|
16
|
+
}>;
|
|
17
|
+
export interface AnnotationMarkerRenderer {
|
|
18
|
+
/**
|
|
19
|
+
* Uploads marker instances and prepares uniforms for rendering.
|
|
20
|
+
*
|
|
21
|
+
* Coordinate contract:
|
|
22
|
+
* - `instances[*].xCssPx/yCssPx` are CANVAS-LOCAL CSS pixels.
|
|
23
|
+
* - `canvasWidth/canvasHeight` are in *device pixels* (same as render target size).
|
|
24
|
+
* - `devicePixelRatio` is used to convert CSS px to device px inside the shader.
|
|
25
|
+
*
|
|
26
|
+
* Scissor contract:
|
|
27
|
+
* - This renderer intentionally does NOT set or reset scissor state.
|
|
28
|
+
* The caller must set scissor for plot clipping before invoking `render()`.
|
|
29
|
+
*/
|
|
30
|
+
prepare(params: Readonly<{
|
|
31
|
+
canvasWidth: number;
|
|
32
|
+
canvasHeight: number;
|
|
33
|
+
devicePixelRatio: number;
|
|
34
|
+
instances: readonly AnnotationMarkerInstance[];
|
|
35
|
+
}>): void;
|
|
36
|
+
/** Draws all prepared instances (if any). */
|
|
37
|
+
render(passEncoder: GPURenderPassEncoder, firstInstance?: number, instanceCount?: number): void;
|
|
38
|
+
/** Cleans up GPU resources (best-effort). */
|
|
39
|
+
dispose(): void;
|
|
40
|
+
}
|
|
41
|
+
export interface AnnotationMarkerRendererOptions {
|
|
42
|
+
/**
|
|
43
|
+
* Must match the canvas context format used for the render pass color attachment.
|
|
44
|
+
* Usually this is `gpuContext.preferredFormat`.
|
|
45
|
+
*
|
|
46
|
+
* Defaults to `'bgra8unorm'` for backward compatibility.
|
|
47
|
+
*/
|
|
48
|
+
readonly targetFormat?: GPUTextureFormat;
|
|
49
|
+
/**
|
|
50
|
+
* Multisample count for the render pipeline.
|
|
51
|
+
*
|
|
52
|
+
* Must match the render pass color attachment sampleCount.
|
|
53
|
+
* Defaults to 1 (no MSAA).
|
|
54
|
+
*/
|
|
55
|
+
readonly sampleCount?: number;
|
|
56
|
+
}
|
|
57
|
+
export declare function createAnnotationMarkerRenderer(device: GPUDevice, options?: AnnotationMarkerRendererOptions): AnnotationMarkerRenderer;
|
|
58
|
+
//# sourceMappingURL=createAnnotationMarkerRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createAnnotationMarkerRenderer.d.ts","sourceRoot":"","sources":["../../src/renderers/createAnnotationMarkerRenderer.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,wBAAwB,GAAG,QAAQ,CAAC;IAC9C;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IAEf,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAC;IAElB,gDAAgD;IAChD,QAAQ,EAAE,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;IAEhE,+DAA+D;IAC/D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,2DAA2D;IAC3D,UAAU,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;CACpE,CAAC,CAAC;AAEH,MAAM,WAAW,wBAAwB;IACvC;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC;QACvB,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;QACrB,gBAAgB,EAAE,MAAM,CAAC;QACzB,SAAS,EAAE,SAAS,wBAAwB,EAAE,CAAC;KAChD,CAAC,GAAG,IAAI,CAAC;IAEV,6CAA6C;IAC7C,MAAM,CAAC,WAAW,EAAE,oBAAoB,EAAE,aAAa,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEhG,6CAA6C;IAC7C,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,+BAA+B;IAC9C;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAEzC;;;;;OAKG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAiBD,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,+BAA+B,GAAG,wBAAwB,CA8MrI"}
|