ag-charts-enterprise
Version:
Advanced Charting / Charts supporting Javascript / Typescript / React / Angular / Vue
175 lines (174 loc) • 8.79 kB
TypeScript
import { type AgRangeBarSeriesOptions, type AgRangeBarSeriesStyle, type SelectionState, _ModuleSupport } from 'ag-charts-community';
import { ChartAxisDirection, type DomainWithMetadata, type DynamicContext, type FillStrokeMorph, type Normalised, type NormalisedTextOrSegments, type Point } from 'ag-charts-core';
import type { AgNumericValue } from 'ag-charts-types';
import { type RangeBarSeriesDataAggregationFilter } from './rangeBarAggregation';
import { RangeBarProperties } from './rangeBarProperties';
interface RangeBarNodeLabelDatum extends Readonly<Point> {
datumIndex: number;
text: NormalisedTextOrSegments;
textAlign: CanvasTextAlign;
textBaseline: CanvasTextBaseline;
datum: any;
itemType: 'high' | 'low';
series: _ModuleSupport.CartesianSeriesNodeDatum['series'];
}
type RangeBarItemId = `${string}-${string}`;
type NormalisedRangeBarSeriesStyle = Normalised<AgRangeBarSeriesStyle, never, FillStrokeMorph>;
/**
* Shared context for creating/updating RangeBarNodeDatum instances.
* Instantiated once per createNodeData() call and reused across all datum operations
* to minimize memory allocations. Only contains values that are expensive to compute
* or resolve - cheap property lookups use `this` directly in methods.
*/
interface RangeBarSeriesNodeDatumContext extends _ModuleSupport.CartesianCreateNodeDataContext<RangeBarNodeDatum> {
readonly yLowValues: AgNumericValue[];
readonly yHighValues: AgNumericValue[];
readonly barWidth: number;
readonly groupOffset: number;
readonly barOffset: number;
readonly barAlongX: boolean;
readonly crisp: boolean;
readonly yLowKey: string;
readonly yHighKey: string;
readonly labelEnabled: boolean;
readonly labelPlacement: 'inside' | 'outside';
readonly labelPadding: number;
readonly dataAggregationFilter: RangeBarSeriesDataAggregationFilter | undefined;
}
interface RangeBarNodeDatum extends Omit<_ModuleSupport.CartesianSeriesNodeDatum, 'yKey' | 'yValue'>, Readonly<Point> {
readonly index: number;
readonly yLowKey: string;
readonly yHighKey: string;
readonly yLowValue: AgNumericValue;
readonly yHighValue: AgNumericValue;
readonly width: number;
readonly height: number;
readonly labels: RangeBarNodeLabelDatum[];
readonly crisp: boolean;
readonly clipBBox?: _ModuleSupport.BBox;
readonly opacity?: number;
style?: Required<NormalisedRangeBarSeriesStyle>;
}
type RangeBarAnimationData = _ModuleSupport.AbstractBarSeriesAnimationData<RangeBarSeriesTypes>;
declare class RangeBarSeriesNodeEvent<TEvent extends string = _ModuleSupport.SeriesNodeEventTypes> extends _ModuleSupport.SeriesNodeEvent<RangeBarNodeDatum, TEvent> {
readonly xKey?: string;
readonly yLowKey?: string;
readonly yHighKey?: string;
constructor(type: TEvent, nativeEvent: Event, datum: RangeBarNodeDatum, series: RangeBarSeries, selectionState: SelectionState | undefined);
}
interface RangeBarSeriesNodeDataContext extends _ModuleSupport.AbstractBarSeriesNodeDataContext<RangeBarNodeDatum, RangeBarNodeLabelDatum> {
itemId: RangeBarItemId;
styles: _ModuleSupport.SeriesNodeStyleContext<NormalisedRangeBarSeriesStyle>;
}
/**
* Consolidated type interface for RangeBarSeries.
* Defines all type parameters in one place for the series.
*/
interface RangeBarSeriesTypes extends _ModuleSupport.AbstractBarSeriesTypes {
readonly node: _ModuleSupport.Rect<RangeBarNodeDatum>;
readonly options: AgRangeBarSeriesOptions;
readonly properties: RangeBarProperties;
readonly datum: RangeBarNodeDatum;
readonly label: RangeBarNodeLabelDatum;
readonly context: RangeBarSeriesNodeDataContext;
readonly stackContext: never;
readonly createNodeDataContext: RangeBarSeriesNodeDatumContext;
}
export declare class RangeBarSeries extends _ModuleSupport.AbstractBarSeries<RangeBarSeriesTypes> {
static readonly className = "RangeBarSeries";
static readonly type: "range-bar";
properties: RangeBarProperties;
private readonly aggregationManager;
protected readonly NodeEvent: typeof RangeBarSeriesNodeEvent;
constructor(moduleCtx: DynamicContext<_ModuleSupport.ChartRegistry>);
processData(dataController: _ModuleSupport.DataController): Promise<void>;
private aggregateData;
protected createBucketLookupFeature(): _ModuleSupport.BucketLookupFeature;
private estimateTargetRange;
getSeriesDomain(direction: ChartAxisDirection): DomainWithMetadata<any>;
getSeriesRange(_direction: ChartAxisDirection, visibleRange: [number, number]): [number, number];
/**
* Creates shared context for node datum creation/update operations.
* This context is instantiated once and reused across all datum operations
* to minimize memory allocations. Only caches values that are expensive to
* compute - cheap property lookups use `this` directly.
*/
protected createNodeDatumContext(xAxis: _ModuleSupport.ChartAxis, yAxis: _ModuleSupport.ChartAxis): RangeBarSeriesNodeDatumContext | undefined;
/**
* Validates and prepares state needed for node creation/update.
* Returns undefined if datum should be skipped.
*/
private prepareNodeDatumState;
/**
* Creates a minimal skeleton node - actual values set by updateNodeDatum.
*/
private createSkeletonNodeDatum;
/**
* Creates a new node: skeleton + update.
*/
private createNodeDatum;
/**
* Updates node properties in-place.
* Shared by both create (skeleton + update) and incremental update paths.
*/
private updateNodeDatum;
/**
* Creates node data using aggregation filters for large datasets.
*/
private createNodeDataWithAggregation;
/**
* Creates node data for simple (ungrouped) data processing.
*/
private createNodeDataSimple;
/**
* Creates node data for grouped data processing.
*/
private createNodeDataGrouped;
protected populateNodeData(ctx: RangeBarSeriesNodeDatumContext): void;
protected finalizeNodeData(ctx: RangeBarSeriesNodeDatumContext): void;
protected initializeResult(ctx: RangeBarSeriesNodeDatumContext): RangeBarSeriesNodeDataContext;
protected assembleResult(ctx: RangeBarSeriesNodeDatumContext, result: RangeBarSeriesNodeDataContext): RangeBarSeriesNodeDataContext;
/**
* Updates existing label data in place or creates new labels if needed.
* This avoids array allocations during incremental updates.
* Uses positional params (no destructuring) for performance in hot path.
*/
private updateLabelData;
protected nodeFactory(): _ModuleSupport.Rect<RangeBarNodeDatum>;
private getStyle;
private makeStylerParams;
protected updateDatumSelection(opts: {
nodeData: RangeBarNodeDatum[];
datumSelection: _ModuleSupport.Selection<RangeBarNodeDatum, _ModuleSupport.Rect<RangeBarNodeDatum>>;
}): _ModuleSupport.Selection<RangeBarNodeDatum, _ModuleSupport.Rect<RangeBarNodeDatum>>;
private getItemStyle;
private makeItemStylerParams;
protected updateDatumStyles(opts: {
datumSelection: _ModuleSupport.Selection<RangeBarNodeDatum, _ModuleSupport.Rect<RangeBarNodeDatum>>;
isHighlight: boolean;
}): void;
protected updateDatumNodes({ datumSelection, isHighlight, }: {
datumSelection: _ModuleSupport.Selection<RangeBarNodeDatum, _ModuleSupport.Rect<RangeBarNodeDatum>>;
isHighlight: boolean;
}): void;
protected updateLabelSelection(opts: {
labelData: RangeBarNodeLabelDatum[];
labelSelection: RangeBarAnimationData['labelSelection'];
}): _ModuleSupport.Selection<RangeBarNodeLabelDatum, _ModuleSupport.Text<RangeBarNodeLabelDatum>>;
protected updateLabelNodes(opts: {
labelSelection: _ModuleSupport.Selection<RangeBarNodeLabelDatum, _ModuleSupport.Text<RangeBarNodeLabelDatum>>;
isHighlight?: boolean;
}): void;
protected getHighlightLabelData(labelData: RangeBarNodeLabelDatum[], highlightedItem: RangeBarNodeDatum): RangeBarNodeLabelDatum[] | undefined;
getTooltipContent(datumIndex: number): _ModuleSupport.TooltipContent | undefined;
private legendItemSymbol;
getLegendData(legendType: _ModuleSupport.ChartLegendType): _ModuleSupport.CategoryLegendDatum[];
protected resetDatumAnimation(data: RangeBarAnimationData): void;
animateEmptyUpdateReady({ datumSelection, labelSelection }: RangeBarAnimationData): void;
animateWaitingUpdateReady(data: RangeBarAnimationData): void;
private getDatumId;
protected isLabelEnabled(): boolean;
protected computeFocusBounds({ datumIndex }: _ModuleSupport.PickFocusInputs): _ModuleSupport.BBox | undefined;
protected hasItemStylers(): boolean;
}
export {};