chartgpu 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -3
- package/dist/core/createRenderCoordinator.d.ts.map +1 -1
- 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 +68 -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/index.js +5726 -5347
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tooltip and legend helper utilities.
|
|
3
|
+
*
|
|
4
|
+
* Provides utilities for managing tooltip state, caching content to avoid
|
|
5
|
+
* unnecessary DOM updates, and computing tooltip anchor positions for special
|
|
6
|
+
* chart types like candlesticks.
|
|
7
|
+
*
|
|
8
|
+
* @module tooltipLegendHelpers
|
|
9
|
+
*/
|
|
10
|
+
import type { OHLCDataPoint } from '../../../config/types';
|
|
11
|
+
import type { LinearScale } from '../../../utils/scales';
|
|
12
|
+
/**
|
|
13
|
+
* Tooltip anchor position in canvas-local CSS pixels.
|
|
14
|
+
*/
|
|
15
|
+
export interface TooltipAnchor {
|
|
16
|
+
readonly x: number;
|
|
17
|
+
readonly y: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Cached tooltip state for content deduplication.
|
|
21
|
+
*
|
|
22
|
+
* Tracks the last displayed content and position to avoid unnecessary DOM updates
|
|
23
|
+
* when the tooltip hasn't actually changed.
|
|
24
|
+
*/
|
|
25
|
+
export interface TooltipCache {
|
|
26
|
+
content: string | null;
|
|
27
|
+
x: number | null;
|
|
28
|
+
y: number | null;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new empty tooltip cache.
|
|
32
|
+
*
|
|
33
|
+
* @returns Fresh tooltip cache with null values
|
|
34
|
+
*/
|
|
35
|
+
export declare function createTooltipCache(): TooltipCache;
|
|
36
|
+
/**
|
|
37
|
+
* Checks if tooltip content or position has changed.
|
|
38
|
+
*
|
|
39
|
+
* Returns true if any of the values differ from the cache, indicating that
|
|
40
|
+
* a DOM update is needed.
|
|
41
|
+
*
|
|
42
|
+
* @param cache - Current cached state
|
|
43
|
+
* @param content - New content to display
|
|
44
|
+
* @param x - New X position in CSS pixels
|
|
45
|
+
* @param y - New Y position in CSS pixels
|
|
46
|
+
* @returns True if update is needed (values differ from cache)
|
|
47
|
+
*/
|
|
48
|
+
export declare function shouldUpdateTooltip(cache: TooltipCache, content: string, x: number, y: number): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Updates the tooltip cache with new values.
|
|
51
|
+
*
|
|
52
|
+
* Should be called after successfully updating the DOM to keep cache in sync.
|
|
53
|
+
*
|
|
54
|
+
* @param cache - Tooltip cache to update (mutated)
|
|
55
|
+
* @param content - New content that was displayed
|
|
56
|
+
* @param x - New X position that was set
|
|
57
|
+
* @param y - New Y position that was set
|
|
58
|
+
*/
|
|
59
|
+
export declare function updateTooltipCache(cache: TooltipCache, content: string, x: number, y: number): void;
|
|
60
|
+
/**
|
|
61
|
+
* Clears the tooltip cache.
|
|
62
|
+
*
|
|
63
|
+
* Should be called when the tooltip is hidden to ensure fresh state
|
|
64
|
+
* when it's shown again.
|
|
65
|
+
*
|
|
66
|
+
* @param cache - Tooltip cache to clear (mutated)
|
|
67
|
+
*/
|
|
68
|
+
export declare function clearTooltipCache(cache: TooltipCache): void;
|
|
69
|
+
/**
|
|
70
|
+
* Computes container-local CSS pixel anchor coordinates for a candlestick tooltip.
|
|
71
|
+
*
|
|
72
|
+
* The anchor is positioned near the candle body center for stable tooltip positioning
|
|
73
|
+
* even when the cursor is at the edge of the candlestick.
|
|
74
|
+
*
|
|
75
|
+
* Coordinate transformations:
|
|
76
|
+
* 1. Extract O/H/L/C from data point (tuple: [timestamp, open, close, low, high])
|
|
77
|
+
* 2. Compute body center Y = (open + close) / 2
|
|
78
|
+
* 3. Transform to clip space via scales
|
|
79
|
+
* 4. Convert clip space to canvas-local CSS pixels
|
|
80
|
+
* 5. Add container offset for absolute positioning
|
|
81
|
+
*
|
|
82
|
+
* Returns null if any coordinate computation fails (non-finite values).
|
|
83
|
+
*
|
|
84
|
+
* @param point - OHLC data point (tuple or object format)
|
|
85
|
+
* @param xScale - Linear scale for X axis
|
|
86
|
+
* @param yScale - Linear scale for Y axis
|
|
87
|
+
* @param canvasCssWidth - Canvas width in CSS pixels
|
|
88
|
+
* @param canvasCssHeight - Canvas height in CSS pixels
|
|
89
|
+
* @param offsetX - Container offset X in CSS pixels (default: 0)
|
|
90
|
+
* @param offsetY - Container offset Y in CSS pixels (default: 0)
|
|
91
|
+
* @returns Tooltip anchor position or null if computation fails
|
|
92
|
+
*/
|
|
93
|
+
export declare function computeCandlestickTooltipAnchor(point: OHLCDataPoint, xScale: LinearScale, yScale: LinearScale, canvasCssWidth: number, canvasCssHeight: number, offsetX?: number, offsetY?: number): TooltipAnchor | null;
|
|
94
|
+
/**
|
|
95
|
+
* Determines if a data point is an OHLC/candlestick point.
|
|
96
|
+
*
|
|
97
|
+
* Checks if the point is a 5-element tuple (timestamp, open, close, low, high)
|
|
98
|
+
* or an object with OHLC properties.
|
|
99
|
+
*
|
|
100
|
+
* @param point - Data point to check
|
|
101
|
+
* @returns True if point is OHLC format
|
|
102
|
+
*/
|
|
103
|
+
export declare function isOHLCDataPoint(point: any): point is OHLCDataPoint;
|
|
104
|
+
//# sourceMappingURL=tooltipLegendHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tooltipLegendHelpers.d.ts","sourceRoot":"","sources":["../../../../src/core/renderCoordinator/ui/tooltipLegendHelpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAIzD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAClB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,YAAY,CAMjD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,MAAM,EACf,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,GACR,OAAO,CAET;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,MAAM,EACf,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,GACR,IAAI,CAIN;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAI3D;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,WAAW,EACnB,cAAc,EAAE,MAAM,EACtB,eAAe,EAAE,MAAM,EACvB,OAAO,GAAE,MAAU,EACnB,OAAO,GAAE,MAAU,GAClB,aAAa,GAAG,IAAI,CA0CtB;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,aAAa,CAclE"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Axis and grid utilities for the RenderCoordinator.
|
|
3
|
+
*
|
|
4
|
+
* These pure functions handle coordinate transformations between different spaces:
|
|
5
|
+
* - CSS pixels (DOM layout)
|
|
6
|
+
* - Device pixels (canvas.width/height)
|
|
7
|
+
* - Normalized device coordinates / clip space (WebGPU [-1, 1])
|
|
8
|
+
*
|
|
9
|
+
* @module axisUtils
|
|
10
|
+
*/
|
|
11
|
+
import type { GPUContextLike } from '../types';
|
|
12
|
+
import type { ResolvedChartGPUOptions } from '../../../config/OptionResolver';
|
|
13
|
+
import type { GridArea } from '../../../renderers/createGridRenderer';
|
|
14
|
+
/**
|
|
15
|
+
* Computes grid area with margins and canvas dimensions for rendering layout.
|
|
16
|
+
* GridArea uses:
|
|
17
|
+
* - Margins (left, right, top, bottom) in CSS pixels
|
|
18
|
+
* - Canvas dimensions (canvasWidth, canvasHeight) in DEVICE pixels
|
|
19
|
+
* - devicePixelRatio for CSS-to-device conversion (worker-compatible)
|
|
20
|
+
*
|
|
21
|
+
* @param gpuContext - GPU context with canvas and device pixel ratio
|
|
22
|
+
* @param options - Resolved chart options with grid margins
|
|
23
|
+
* @returns GridArea object with margins, canvas dimensions, and DPR
|
|
24
|
+
* @throws If canvas is null or has invalid dimensions
|
|
25
|
+
*/
|
|
26
|
+
export declare const computeGridArea: (gpuContext: GPUContextLike, options: ResolvedChartGPUOptions) => GridArea;
|
|
27
|
+
/**
|
|
28
|
+
* Converts RGBA normalized [0-1] values to CSS rgba() string.
|
|
29
|
+
*
|
|
30
|
+
* @param rgba - Array of [r, g, b, a] in range [0, 1]
|
|
31
|
+
* @returns CSS rgba() string
|
|
32
|
+
*/
|
|
33
|
+
export declare const rgba01ToCssRgba: (rgba: readonly [number, number, number, number]) => string;
|
|
34
|
+
/**
|
|
35
|
+
* Applies alpha multiplier to CSS color.
|
|
36
|
+
* Parses color, multiplies alpha channel, and returns new CSS rgba() string.
|
|
37
|
+
*
|
|
38
|
+
* @param cssColor - CSS color string
|
|
39
|
+
* @param alphaMultiplier - Alpha multiplier in range [0, 1]
|
|
40
|
+
* @returns CSS rgba() string with modified alpha, or original color if parse fails
|
|
41
|
+
*/
|
|
42
|
+
export declare const withAlpha: (cssColor: string, alphaMultiplier: number) => string;
|
|
43
|
+
/**
|
|
44
|
+
* Converts grid margins to normalized device clip coordinates for WebGPU.
|
|
45
|
+
* Output is in WebGPU clip space: [-1, 1] for both x and y.
|
|
46
|
+
* Y-axis is flipped (top is positive, bottom is negative).
|
|
47
|
+
*
|
|
48
|
+
* @param gridArea - Grid area with margins and canvas dimensions
|
|
49
|
+
* @returns Clip rect with left, right, top, bottom in range [-1, 1]
|
|
50
|
+
*/
|
|
51
|
+
export declare const computePlotClipRect: (gridArea: GridArea) => {
|
|
52
|
+
readonly left: number;
|
|
53
|
+
readonly right: number;
|
|
54
|
+
readonly top: number;
|
|
55
|
+
readonly bottom: number;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Clamps value to [0, 1] range.
|
|
59
|
+
*
|
|
60
|
+
* @param v - Value to clamp
|
|
61
|
+
* @returns Clamped value
|
|
62
|
+
*/
|
|
63
|
+
export declare const clamp01: (v: number) => number;
|
|
64
|
+
/**
|
|
65
|
+
* Linear interpolation between two values with clamped t.
|
|
66
|
+
*
|
|
67
|
+
* @param a - Start value
|
|
68
|
+
* @param b - End value
|
|
69
|
+
* @param t01 - Interpolation parameter in range [0, 1]
|
|
70
|
+
* @returns Interpolated value
|
|
71
|
+
*/
|
|
72
|
+
export declare const lerp: (a: number, b: number, t01: number) => number;
|
|
73
|
+
/**
|
|
74
|
+
* Interpolates between two domains (min/max pairs).
|
|
75
|
+
* Ensures result is a valid domain (min ≤ max, both finite).
|
|
76
|
+
*
|
|
77
|
+
* @param from - Start domain
|
|
78
|
+
* @param to - End domain
|
|
79
|
+
* @param t01 - Interpolation parameter in range [0, 1]
|
|
80
|
+
* @returns Interpolated domain
|
|
81
|
+
*/
|
|
82
|
+
export declare const lerpDomain: (from: {
|
|
83
|
+
readonly min: number;
|
|
84
|
+
readonly max: number;
|
|
85
|
+
}, to: {
|
|
86
|
+
readonly min: number;
|
|
87
|
+
readonly max: number;
|
|
88
|
+
}, t01: number) => {
|
|
89
|
+
readonly min: number;
|
|
90
|
+
readonly max: number;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Computes scissor rect in device pixels from grid margins.
|
|
94
|
+
* Used for WebGPU scissor testing to clip rendering to plot area.
|
|
95
|
+
*
|
|
96
|
+
* @param gridArea - Grid area with margins and canvas dimensions
|
|
97
|
+
* @returns Scissor rect with x, y, w, h in device pixels
|
|
98
|
+
*/
|
|
99
|
+
export declare const computePlotScissorDevicePx: (gridArea: GridArea) => {
|
|
100
|
+
readonly x: number;
|
|
101
|
+
readonly y: number;
|
|
102
|
+
readonly w: number;
|
|
103
|
+
readonly h: number;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Converts clip-space X to canvas CSS pixels (from normalized [-1, 1]).
|
|
107
|
+
*
|
|
108
|
+
* @param xClip - X coordinate in clip space [-1, 1]
|
|
109
|
+
* @param canvasCssWidth - Canvas width in CSS pixels
|
|
110
|
+
* @returns X coordinate in canvas CSS pixels
|
|
111
|
+
*/
|
|
112
|
+
export declare const clipXToCanvasCssPx: (xClip: number, canvasCssWidth: number) => number;
|
|
113
|
+
/**
|
|
114
|
+
* Converts clip-space Y to canvas CSS pixels (from normalized [-1, 1]).
|
|
115
|
+
* Y-axis is flipped (1 is top, -1 is bottom).
|
|
116
|
+
*
|
|
117
|
+
* @param yClip - Y coordinate in clip space [-1, 1]
|
|
118
|
+
* @param canvasCssHeight - Canvas height in CSS pixels
|
|
119
|
+
* @returns Y coordinate in canvas CSS pixels
|
|
120
|
+
*/
|
|
121
|
+
export declare const clipYToCanvasCssPx: (yClip: number, canvasCssHeight: number) => number;
|
|
122
|
+
//# sourceMappingURL=axisUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axisUtils.d.ts","sourceRoot":"","sources":["../../../../src/core/renderCoordinator/utils/axisUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AAKtE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,GAAI,YAAY,cAAc,EAAE,SAAS,uBAAuB,KAAG,QA4C9F,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAI,MAAM,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,KAAG,MAMjF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GAAI,UAAU,MAAM,EAAE,iBAAiB,MAAM,KAAG,MAKrE,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAC9B,UAAU,QAAQ,KACjB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAA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data arrays
|
|
5
|
+
* and aggregate bounds across series. They handle edge cases like empty data,
|
|
6
|
+
* NaN/Infinity values, and zero-span domains.
|
|
7
|
+
*
|
|
8
|
+
* @module boundsComputation
|
|
9
|
+
*/
|
|
10
|
+
import type { DataPoint, OHLCDataPoint } from '../../../config/types';
|
|
11
|
+
import type { ResolvedChartGPUOptions } from '../../../config/OptionResolver';
|
|
12
|
+
/**
|
|
13
|
+
* Bounds type for min/max x and y values.
|
|
14
|
+
*/
|
|
15
|
+
export type Bounds = Readonly<{
|
|
16
|
+
xMin: number;
|
|
17
|
+
xMax: number;
|
|
18
|
+
yMin: number;
|
|
19
|
+
yMax: number;
|
|
20
|
+
}>;
|
|
21
|
+
/**
|
|
22
|
+
* Computes xMin/xMax/yMin/yMax bounds from cartesian data array.
|
|
23
|
+
* Skips non-finite values. Returns null if no finite points found.
|
|
24
|
+
* Ensures xMin !== xMax and yMin !== yMax for scale derivation.
|
|
25
|
+
*
|
|
26
|
+
* @param data - Array of data points (tuple or object format)
|
|
27
|
+
* @returns Bounds object or null if no finite points
|
|
28
|
+
*/
|
|
29
|
+
export declare const computeRawBoundsFromData: (data: ReadonlyArray<DataPoint>) => Bounds | null;
|
|
30
|
+
/**
|
|
31
|
+
* Extends existing bounds with new cartesian data points.
|
|
32
|
+
* If bounds is null and points are valid, seeds bounds from points.
|
|
33
|
+
*
|
|
34
|
+
* @param bounds - Existing bounds or null
|
|
35
|
+
* @param points - New points to extend bounds with
|
|
36
|
+
* @returns Updated bounds or null if no finite points
|
|
37
|
+
*/
|
|
38
|
+
export declare const extendBoundsWithDataPoints: (bounds: Bounds | null, points: ReadonlyArray<DataPoint>) => Bounds | null;
|
|
39
|
+
/**
|
|
40
|
+
* Extends bounds with OHLC candlestick data using low/high values.
|
|
41
|
+
* If bounds is null, initializes bounds from OHLC points.
|
|
42
|
+
*
|
|
43
|
+
* @param bounds - Existing bounds or null
|
|
44
|
+
* @param points - OHLC points (timestamp, open, high, low, close)
|
|
45
|
+
* @returns Updated bounds or original bounds if no finite points
|
|
46
|
+
*/
|
|
47
|
+
export declare const extendBoundsWithOHLCDataPoints: (bounds: Bounds | null, points: ReadonlyArray<OHLCDataPoint>) => Bounds | null;
|
|
48
|
+
/**
|
|
49
|
+
* Aggregates bounds across all series, handling pie/candlestick special cases.
|
|
50
|
+
* Prefers precomputed rawBounds from OptionResolver when available to avoid O(n) scans.
|
|
51
|
+
*
|
|
52
|
+
* @param series - Resolved series configurations
|
|
53
|
+
* @param runtimeRawBoundsByIndex - Optional runtime bounds (used for streaming appends)
|
|
54
|
+
* @returns Global bounds across all series, defaults to (0,1) x (0,1) if no finite data
|
|
55
|
+
*/
|
|
56
|
+
export declare const computeGlobalBounds: (series: ResolvedChartGPUOptions["series"], runtimeRawBoundsByIndex?: ReadonlyArray<Bounds | null> | null) => Bounds;
|
|
57
|
+
/**
|
|
58
|
+
* Ensures min ≤ max, handles infinities with defaults (0,1), handles zero-span domains.
|
|
59
|
+
* Returns a usable domain for scale derivation.
|
|
60
|
+
*
|
|
61
|
+
* @param minCandidate - Candidate minimum value
|
|
62
|
+
* @param maxCandidate - Candidate maximum value
|
|
63
|
+
* @returns Normalized domain with min ≤ max, both finite
|
|
64
|
+
*/
|
|
65
|
+
export declare const normalizeDomain: (minCandidate: number, maxCandidate: number) => {
|
|
66
|
+
readonly min: number;
|
|
67
|
+
readonly max: number;
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=boundsComputation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boundsComputation.d.ts","sourceRoot":"","sources":["../../../../src/core/renderCoordinator/utils/boundsComputation.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAG9E;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG,QAAQ,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAE1F;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,GAAI,MAAM,aAAa,CAAC,SAAS,CAAC,KAAG,MAAM,GAAG,IAwBlF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B,GAAI,QAAQ,MAAM,GAAG,IAAI,EAAE,QAAQ,aAAa,CAAC,SAAS,CAAC,KAAG,MAAM,GAAG,IA8B7G,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,8BAA8B,GAAI,QAAQ,MAAM,GAAG,IAAI,EAAE,QAAQ,aAAa,CAAC,aAAa,CAAC,KAAG,MAAM,GAAG,IA8BrH,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAC9B,QAAQ,uBAAuB,CAAC,QAAQ,CAAC,EACzC,0BAA0B,aAAa,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,IAAI,KAC5D,MAuGF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAC1B,cAAc,MAAM,EACpB,cAAc,MAAM,KACnB;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAkB9C,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canvas sizing and measurement utilities for the RenderCoordinator.
|
|
3
|
+
*
|
|
4
|
+
* These pure functions handle canvas dimension retrieval with special handling
|
|
5
|
+
* for device pixel ratio and GPU overlay coordinate conversions.
|
|
6
|
+
*
|
|
7
|
+
* @module canvasUtils
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Gets canvas CSS width - clientWidth for HTMLCanvasElement.
|
|
11
|
+
*
|
|
12
|
+
* @param canvas - The canvas element to measure, or null
|
|
13
|
+
* @returns CSS width in pixels, or 0 if canvas is null
|
|
14
|
+
*/
|
|
15
|
+
export declare function getCanvasCssWidth(canvas: HTMLCanvasElement | null): number;
|
|
16
|
+
/**
|
|
17
|
+
* Gets canvas CSS height - clientHeight for HTMLCanvasElement.
|
|
18
|
+
*
|
|
19
|
+
* @param canvas - The canvas element to measure, or null
|
|
20
|
+
* @returns CSS height in pixels, or 0 if canvas is null
|
|
21
|
+
*/
|
|
22
|
+
export declare function getCanvasCssHeight(canvas: HTMLCanvasElement | null): number;
|
|
23
|
+
/**
|
|
24
|
+
* Gets canvas CSS size derived strictly from device-pixel dimensions and DPR.
|
|
25
|
+
*
|
|
26
|
+
* This is intentionally different from `getCanvasCssWidth/Height(...)`:
|
|
27
|
+
* - HTMLCanvasElement: `clientWidth/clientHeight` reflect DOM layout and can diverge (rounding, zoom, async resize)
|
|
28
|
+
* from the WebGPU render target size (`canvas.width/height` in device pixels).
|
|
29
|
+
* - For GPU overlays that round-trip CSS↔device pixels in-shader, we must derive CSS size from
|
|
30
|
+
* `canvas.width/height` + DPR to keep transforms consistent with the render target.
|
|
31
|
+
*
|
|
32
|
+
* NOTE: Use this for GPU overlay coordinate conversion only (reference lines, markers).
|
|
33
|
+
* Keep DOM overlays (labels/tooltips) using `clientWidth/clientHeight` for layout correctness.
|
|
34
|
+
*
|
|
35
|
+
* @param canvas - The canvas element to measure, or null
|
|
36
|
+
* @param devicePixelRatio - The device pixel ratio (defaults to window.devicePixelRatio or 1)
|
|
37
|
+
* @returns Object with width and height in CSS pixels derived from device pixels
|
|
38
|
+
*/
|
|
39
|
+
export declare function getCanvasCssSizeFromDevicePixels(canvas: HTMLCanvasElement | null, devicePixelRatio?: number): Readonly<{
|
|
40
|
+
width: number;
|
|
41
|
+
height: number;
|
|
42
|
+
}>;
|
|
43
|
+
/**
|
|
44
|
+
* Clamps a value to an integer within [lo, hi] range.
|
|
45
|
+
*
|
|
46
|
+
* @param v - Value to clamp
|
|
47
|
+
* @param lo - Lower bound (inclusive)
|
|
48
|
+
* @param hi - Upper bound (inclusive)
|
|
49
|
+
* @returns Clamped integer value
|
|
50
|
+
*/
|
|
51
|
+
export declare function clampInt(v: number, lo: number, hi: number): number;
|
|
52
|
+
//# sourceMappingURL=canvasUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canvasUtils.d.ts","sourceRoot":"","sources":["../../../../src/core/renderCoordinator/utils/canvasUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI,GAAG,MAAM,CAM1E;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI,GAAG,MAAM,CAM3E;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,iBAAiB,GAAG,IAAI,EAChC,gBAAgB,GAAE,MAAoE,GACrF,QAAQ,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAK7C;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAElE"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data point type guards and utilities for the RenderCoordinator.
|
|
3
|
+
*
|
|
4
|
+
* These pure functions handle the dual data format system (tuple vs object)
|
|
5
|
+
* and provide type-safe access to point coordinates.
|
|
6
|
+
*
|
|
7
|
+
* @module dataPointUtils
|
|
8
|
+
*/
|
|
9
|
+
import type { DataPoint, DataPointTuple, OHLCDataPoint, OHLCDataPointTuple } from '../../../config/types';
|
|
10
|
+
/**
|
|
11
|
+
* Validates that a number is finite, returning the number or null.
|
|
12
|
+
*
|
|
13
|
+
* @param v - Value to validate
|
|
14
|
+
* @returns The number if finite, otherwise null
|
|
15
|
+
*/
|
|
16
|
+
export declare const finiteOrNull: (v: number | null | undefined) => number | null;
|
|
17
|
+
/**
|
|
18
|
+
* Validates that a number is finite, returning the number or undefined.
|
|
19
|
+
*
|
|
20
|
+
* @param v - Value to validate
|
|
21
|
+
* @returns The number if finite, otherwise undefined
|
|
22
|
+
*/
|
|
23
|
+
export declare const finiteOrUndefined: (v: number | undefined) => number | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Compile-time exhaustiveness check for error handling.
|
|
26
|
+
* Used in switch statements to ensure all cases are handled.
|
|
27
|
+
*
|
|
28
|
+
* @param value - The value that should be of type `never` if all cases are handled
|
|
29
|
+
* @throws Always throws an error if called
|
|
30
|
+
*/
|
|
31
|
+
export declare const assertUnreachable: (value: never) => never;
|
|
32
|
+
/**
|
|
33
|
+
* Type guard: checks if a DataPoint is in tuple form `[x, y]`.
|
|
34
|
+
*
|
|
35
|
+
* @param p - The data point to check
|
|
36
|
+
* @returns True if the point is a tuple, false if it's an object
|
|
37
|
+
*/
|
|
38
|
+
export declare const isTupleDataPoint: (p: DataPoint) => p is DataPointTuple;
|
|
39
|
+
/**
|
|
40
|
+
* Extracts x,y coordinates from either tuple or object point format.
|
|
41
|
+
*
|
|
42
|
+
* @param p - The data point (either tuple or object format)
|
|
43
|
+
* @returns Object with x and y properties
|
|
44
|
+
*/
|
|
45
|
+
export declare const getPointXY: (p: DataPoint) => {
|
|
46
|
+
readonly x: number;
|
|
47
|
+
readonly y: number;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Type guard: checks if a data point is in tuple OHLC form `[timestamp, open, high, low, close]`.
|
|
51
|
+
*
|
|
52
|
+
* @param p - The OHLC data point to check
|
|
53
|
+
* @returns True if the point is a tuple, false if it's an object
|
|
54
|
+
*/
|
|
55
|
+
export declare const isTupleOHLCDataPoint: (p: OHLCDataPoint) => p is OHLCDataPointTuple;
|
|
56
|
+
/**
|
|
57
|
+
* Type guard: checks if a data point is in tuple form `[x, y]` (for individual points).
|
|
58
|
+
*
|
|
59
|
+
* @param p - The point to check
|
|
60
|
+
* @returns True if the point is a tuple array
|
|
61
|
+
*/
|
|
62
|
+
export declare const isTuplePoint: (p: unknown) => p is readonly [number, number];
|
|
63
|
+
/**
|
|
64
|
+
* Type guard: checks if entire data array is in tuple format.
|
|
65
|
+
* Only checks the first element for performance.
|
|
66
|
+
*
|
|
67
|
+
* @param data - Array of data points to check
|
|
68
|
+
* @returns True if first element (and therefore likely all) is a tuple
|
|
69
|
+
*/
|
|
70
|
+
export declare const isTupleDataArray: (data: ReadonlyArray<DataPoint>) => data is ReadonlyArray<DataPointTuple>;
|
|
71
|
+
//# sourceMappingURL=dataPointUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataPointUtils.d.ts","sourceRoot":"","sources":["../../../../src/core/renderCoordinator/utils/dataPointUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE1G;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,KAAG,MAAM,GAAG,IACb,CAAC;AAEzD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,GAAG,MAAM,GAAG,SAAS,KAAG,MAAM,GAAG,SACN,CAAC;AAE9D;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAI,OAAO,KAAK,KAAG,KAGhD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,GAAG,SAAS,KAAG,CAAC,IAAI,cAAkC,CAAC;AAExF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,GAAG,SAAS,KAAG;IAAE,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;CAGjF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,GAAG,aAAa,KAAG,CAAC,IAAI,kBAAsC,CAAC;AAEpG;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,SAAS,CAAC,MAAM,EAAE,MAAM,CAAqB,CAAC;AAE7F;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,aAAa,CAAC,SAAS,CAAC,KAAG,IAAI,IAAI,aAAa,CAAC,cAAc,CACxD,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for the RenderCoordinator.
|
|
3
|
+
* Pure, stateless helper functions organized by category.
|
|
4
|
+
*
|
|
5
|
+
* @module utils
|
|
6
|
+
*/
|
|
7
|
+
export * from './canvasUtils';
|
|
8
|
+
export * from './dataPointUtils';
|
|
9
|
+
export * from './boundsComputation';
|
|
10
|
+
export * from './axisUtils';
|
|
11
|
+
export * from './timeAxisUtils';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/renderCoordinator/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,eAAe,CAAC;AAG9B,cAAc,kBAAkB,CAAC;AAGjC,cAAc,qBAAqB,CAAC;AAGpC,cAAc,aAAa,CAAC;AAG5B,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Time axis and formatting utilities for the RenderCoordinator.
|
|
3
|
+
*
|
|
4
|
+
* These pure functions handle time-based tick generation, adaptive label formatting,
|
|
5
|
+
* and number/percentage parsing for pie chart configuration.
|
|
6
|
+
*
|
|
7
|
+
* @module timeAxisUtils
|
|
8
|
+
*/
|
|
9
|
+
import type { LinearScale } from '../../../utils/scales';
|
|
10
|
+
import type { PieCenter, PieRadius } from '../../../config/types';
|
|
11
|
+
/**
|
|
12
|
+
* Time constants for axis formatting decisions.
|
|
13
|
+
*/
|
|
14
|
+
export declare const MS_PER_DAY: number;
|
|
15
|
+
export declare const MS_PER_MONTH_APPROX: number;
|
|
16
|
+
export declare const MS_PER_YEAR_APPROX: number;
|
|
17
|
+
/**
|
|
18
|
+
* Tick configuration constants.
|
|
19
|
+
*/
|
|
20
|
+
export declare const MAX_TIME_X_TICK_COUNT = 9;
|
|
21
|
+
export declare const MIN_TIME_X_TICK_COUNT = 1;
|
|
22
|
+
export declare const MIN_X_LABEL_GAP_CSS_PX = 6;
|
|
23
|
+
export declare const DEFAULT_MAX_TICK_FRACTION_DIGITS = 6;
|
|
24
|
+
export declare const DEFAULT_TICK_COUNT = 5;
|
|
25
|
+
/**
|
|
26
|
+
* English month abbreviations for time axis labels.
|
|
27
|
+
*/
|
|
28
|
+
export declare const MONTH_SHORT_EN: readonly string[];
|
|
29
|
+
/**
|
|
30
|
+
* Parses value as number or percentage string, returns null if invalid.
|
|
31
|
+
* Used for pie chart center and radius configuration.
|
|
32
|
+
*
|
|
33
|
+
* @param value - Number or percentage string (e.g. "50%", "120", 120)
|
|
34
|
+
* @param basis - Basis value for percentage calculation
|
|
35
|
+
* @returns Parsed number or null if invalid
|
|
36
|
+
*/
|
|
37
|
+
export declare const parseNumberOrPercent: (value: number | string, basis: number) => number | null;
|
|
38
|
+
/**
|
|
39
|
+
* Resolves pie center from mixed number/string/percent format.
|
|
40
|
+
* Defaults to center of plot area (50%, 50%).
|
|
41
|
+
*
|
|
42
|
+
* @param center - Pie center configuration or undefined
|
|
43
|
+
* @param plotWidthCss - Plot area width in CSS pixels
|
|
44
|
+
* @param plotHeightCss - Plot area height in CSS pixels
|
|
45
|
+
* @returns Resolved center coordinates in CSS pixels
|
|
46
|
+
*/
|
|
47
|
+
export declare const resolvePieCenterPlotCss: (center: PieCenter | undefined, plotWidthCss: number, plotHeightCss: number) => {
|
|
48
|
+
readonly x: number;
|
|
49
|
+
readonly y: number;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Type guard for pie radius tuple format `[inner, outer]`.
|
|
53
|
+
*
|
|
54
|
+
* @param radius - Pie radius configuration
|
|
55
|
+
* @returns True if radius is a tuple
|
|
56
|
+
*/
|
|
57
|
+
export declare const isPieRadiusTuple: (radius: PieRadius) => radius is readonly [inner: number | string, outer: number | string];
|
|
58
|
+
/**
|
|
59
|
+
* Resolves pie inner/outer radii with defaults, bounds checking.
|
|
60
|
+
* Default outer radius is 70% of max, inner radius is 0 (full pie).
|
|
61
|
+
*
|
|
62
|
+
* @param radius - Pie radius configuration or undefined
|
|
63
|
+
* @param maxRadiusCss - Maximum radius in CSS pixels
|
|
64
|
+
* @returns Resolved inner and outer radii in CSS pixels
|
|
65
|
+
*/
|
|
66
|
+
export declare const resolvePieRadiiCss: (radius: PieRadius | undefined, maxRadiusCss: number) => {
|
|
67
|
+
readonly inner: number;
|
|
68
|
+
readonly outer: number;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Calculates decimal precision needed for clean tick formatting from tick step.
|
|
72
|
+
* Prefers "clean" decimal representations (e.g. 2.5, 0.25, 0.125) without relying on magnitude alone.
|
|
73
|
+
*
|
|
74
|
+
* @param tickStep - Step size between ticks
|
|
75
|
+
* @param cap - Maximum fraction digits to return (default 6)
|
|
76
|
+
* @returns Number of fraction digits for formatting
|
|
77
|
+
*/
|
|
78
|
+
export declare const computeMaxFractionDigitsFromStep: (tickStep: number, cap?: number) => number;
|
|
79
|
+
/**
|
|
80
|
+
* Creates Intl.NumberFormat instance for consistent tick formatting.
|
|
81
|
+
* Automatically computes appropriate fraction digits from tick step.
|
|
82
|
+
*
|
|
83
|
+
* @param tickStep - Step size between ticks
|
|
84
|
+
* @returns NumberFormat instance
|
|
85
|
+
*/
|
|
86
|
+
export declare const createTickFormatter: (tickStep: number) => Intl.NumberFormat;
|
|
87
|
+
/**
|
|
88
|
+
* Formats numeric value using NumberFormat, handles -0 and NaN edge cases.
|
|
89
|
+
*
|
|
90
|
+
* @param nf - NumberFormat instance
|
|
91
|
+
* @param v - Value to format
|
|
92
|
+
* @returns Formatted string or null if invalid
|
|
93
|
+
*/
|
|
94
|
+
export declare const formatTickValue: (nf: Intl.NumberFormat, v: number) => string | null;
|
|
95
|
+
/**
|
|
96
|
+
* Pads single-digit numbers with leading zero (used by time formatting).
|
|
97
|
+
*
|
|
98
|
+
* @param n - Number to pad
|
|
99
|
+
* @returns Zero-padded string (minimum 2 digits)
|
|
100
|
+
*/
|
|
101
|
+
export declare const pad2: (n: number) => string;
|
|
102
|
+
/**
|
|
103
|
+
* Formats millisecond timestamps with adaptive precision based on visible range.
|
|
104
|
+
* Format tiers:
|
|
105
|
+
* - < 1 day: HH:mm
|
|
106
|
+
* - 1-7 days: MM/DD HH:mm
|
|
107
|
+
* - 1-12 weeks (up to ~3 months): MM/DD
|
|
108
|
+
* - 3-12 months: MMM DD
|
|
109
|
+
* - > 1 year: YYYY/MM
|
|
110
|
+
*
|
|
111
|
+
* @param timestampMs - Timestamp in milliseconds
|
|
112
|
+
* @param visibleRangeMs - Visible range width in milliseconds
|
|
113
|
+
* @returns Formatted time string or null if invalid
|
|
114
|
+
*/
|
|
115
|
+
export declare const formatTimeTickValue: (timestampMs: number, visibleRangeMs: number) => string | null;
|
|
116
|
+
/**
|
|
117
|
+
* Generates evenly-spaced tick values across domain.
|
|
118
|
+
*
|
|
119
|
+
* @param domainMin - Domain minimum value
|
|
120
|
+
* @param domainMax - Domain maximum value
|
|
121
|
+
* @param tickCount - Number of ticks to generate
|
|
122
|
+
* @returns Array of tick values
|
|
123
|
+
*/
|
|
124
|
+
export declare const generateLinearTicks: (domainMin: number, domainMax: number, tickCount: number) => number[];
|
|
125
|
+
/**
|
|
126
|
+
* Computes optimal tick count + values to avoid label overlap on time x-axis.
|
|
127
|
+
* Uses text measurement context to test label widths.
|
|
128
|
+
* Tries tick counts from MAX (9) down to MIN (1) until labels fit without overlap.
|
|
129
|
+
*
|
|
130
|
+
* @param params - Configuration object with axis, scale, canvas, and measurement settings
|
|
131
|
+
* @returns Object with tickCount and tickValues
|
|
132
|
+
*/
|
|
133
|
+
export declare const computeAdaptiveTimeXAxisTicks: (params: {
|
|
134
|
+
readonly axisMin: number | null;
|
|
135
|
+
readonly axisMax: number | null;
|
|
136
|
+
readonly xScale: LinearScale;
|
|
137
|
+
readonly plotClipLeft: number;
|
|
138
|
+
readonly plotClipRight: number;
|
|
139
|
+
readonly canvasCssWidth: number;
|
|
140
|
+
readonly visibleRangeMs: number;
|
|
141
|
+
readonly measureCtx: CanvasRenderingContext2D | null;
|
|
142
|
+
readonly measureCache?: Map<string, number>;
|
|
143
|
+
readonly fontSize: number;
|
|
144
|
+
readonly fontFamily: string;
|
|
145
|
+
}) => {
|
|
146
|
+
readonly tickCount: number;
|
|
147
|
+
readonly tickValues: readonly number[];
|
|
148
|
+
};
|
|
149
|
+
//# sourceMappingURL=timeAxisUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeAxisUtils.d.ts","sourceRoot":"","sources":["../../../../src/core/renderCoordinator/utils/timeAxisUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIlE;;GAEG;AACH,eAAO,MAAM,UAAU,QAAsB,CAAC;AAC9C,eAAO,MAAM,mBAAmB,QAAkB,CAAC;AACnD,eAAO,MAAM,kBAAkB,QAAmB,CAAC;AAEnD;;GAEG;AACH,eAAO,MAAM,qBAAqB,IAAI,CAAC;AACvC,eAAO,MAAM,qBAAqB,IAAI,CAAC;AACvC,eAAO,MAAM,sBAAsB,IAAI,C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