import type { ColumnDataMap } from "../../data/view-reader"; import type { WebGLContextManager } from "../../webgl/context-manager"; import { CategoricalYChart } from "../common/categorical-y-chart"; import { type CandleColumns, type CandleSeriesInfo, type NumericCategoryDomain } from "./candlestick-build"; import { BodyWickGlyph } from "./glyphs/draw-candlesticks"; import { OHLCGlyph } from "./glyphs/draw-ohlc"; /** * Per-frame memo of the auto-fit Y extent for a {@link CandlestickChart}, * keyed on the visible X window. Hover-only redraws hit the cache. */ export interface CandlestickAutoFitCache { xMin: number; xMax: number; min: number; max: number; hasFit: boolean; } export interface CandlestickLocations { u_proj_left: WebGLUniformLocation | null; u_proj_right: WebGLUniformLocation | null; u_hover_series: WebGLUniformLocation | null; a_corner: number; a_x_center: number; a_half_width: number; a_y0: number; a_y1: number; a_color: number; a_series_id: number; a_axis: number; } /** * Candlestick / OHLC chart. Both plugins (`y-candlestick`, `y-ohlc`) * share this class — the only per-plugin difference is * `_defaultChartType` (`"candlestick"` vs `"ohlc"`), which * {@link renderCandlestickFrame} uses to pick the glyph draw function. * * Fields are package-internal (no `private`) so helper modules in this * folder can read/write them. */ export declare class CandlestickChart extends CategoricalYChart { _locations: CandlestickLocations | null; _splitPrefixes: string[]; _series: CandleSeriesInfo[]; /** * Columnar candle records. Indexed in `[0, _candles.count)`. * Replaces the legacy `CandleRecord[]` to avoid per-record POJO * allocation on data load. */ _candles: CandleColumns; _yDomain: { min: number; max: number; }; /** * `domain_mode: "expand"` accumulators. Hold the running union of * the value-axis (and, in numeric-category mode, category-axis) * extent across data loads. Cleared in `resetExpandedDomain` — * wired from the worker's `resetAllZooms` and from view-config * mutations on `AbstractChart`. `null` whenever the option is * `"fit"` or the accumulator has just been cleared. */ _expandedYDomain: { min: number; max: number; } | null; _expandedCategoryDomain: { min: number; max: number; } | null; /** * Numeric category-axis state (single non-string group_by). */ _categoryAxisMode: "category" | "numeric"; _numericCategoryDomain: NumericCategoryDomain | null; _categoryPositions: Float64Array | null; _lastCatTicks: number[] | null; /** * Origin used to rebase candle xCenters before f32 narrowing — see {@link SeriesChart._categoryOrigin}. */ _categoryOrigin: number; /** * Gradient-sampled colors for the up (close ≥ open) / down sides. * Cached via `_upDownColorKey` — only `restyle()` (which clears the * theme cache) or a data load forces re-sampling. */ _upColor: [number, number, number]; _downColor: [number, number, number]; /** * Identity of the gradient-stops reference last used to sample the * up/down colors. When this matches the current `theme.gradientStops` * reference, `ensureUpDownColors` short-circuits. */ _upDownColorKey: unknown; _hoveredIdx: number; _pinnedIdx: number; /** * Typed glyph composition. Each glyph owns its own program cache * and persistent vertex buffers privately; the chart routes * draw/rebuild/invalidate via `_glyphs`. `_defaultChartType` * (`"candlestick"` vs `"ohlc"`) selects which glyph the frame * builder dispatches to. */ readonly _glyphs: { readonly bodyWick: BodyWickGlyph; readonly ohlc: OHLCGlyph; }; /** * Auto-fit the price (Y) axis to the `low`/`high` extent of * candles whose `xCenter` falls inside the visible X window. Pairs * with the locked Y axis: the lock means user input can't zoom Y * directly, auto-fit is what actually moves it as the user scrolls * through time. Default: on (financial-chart convention). */ _autoFitValue: boolean; /** * Per-frame memo of the auto-fit Y extent keyed on the visible X * window. Hover-only redraws (X window unchanged) hit the cache. * Reset to null on data upload. */ _autoFitCache: CandlestickAutoFitCache | null; protected tooltipCallbacks(): { onHover: (mx: number, my: number) => void; onLeave: () => void; onPin: (mx: number, my: number) => void; onUnpin: () => void; }; /** * Resolve a clicked candle into a `PerspectiveClickDetail` and * emit both `perspective-click` and * `perspective-global-filter selected:true`. * * One candle per (catIdx, splitIdx). Like the series pipeline, * `catIdx + _rowOffset` is the source-view row; the column name is * the Close column (the canonical "y" target for OHLC). Group-by * values come from `_rowPaths`; split-by values come from * `_splitPrefixes[splitIdx]` split on `|`. */ private _emitCandleClickSelect; invalidateTheme(): void; uploadAndRender(glManager: WebGLContextManager, columns: ColumnDataMap, startRow: number, endRow: number): Promise; _fullRender(glManager: WebGLContextManager): void; resetExpandedDomain(): void; protected destroyInternal(): void; }