ag-charts-community
Version:
Advanced Charting / Charts supporting Javascript / Typescript / React / Angular / Vue
50 lines (49 loc) • 2.69 kB
TypeScript
import { AbstractModuleInstance, type AxisPluginModuleInstance, type DynamicContext, type NormalisedAxisCrossLineOptions } from 'ag-charts-core';
import type { AxisContext } from '../../module/axisContext';
import type { ChartAxisRegistry } from '../../module/moduleContext';
import type { CrossLine } from './crossLine';
/**
* Axis plugin that owns a per-axis runtime list of {@link CrossLine} instances along with the
* scene-graph groups they render into.
*
* Ownership model (post-refactor — the axis itself has no cross-line awareness):
* - The plugin creates its own per-axis `rangeGroup` / `lineGroup` / `labelGroup` and attaches
* them to the chart-level scene-graph zones owned by {@link AxisManager}. Those zones already
* sit at the correct z-indices for cross-line rendering.
* - Per-instance `CrossLine` runtime is constructed by reading `ctx.crossLine`, a factory
* installed via `DynamicContext.factory()` by `CrossLinesModule.register`. Community installs
* the cartesian implementation; the enterprise `CrossLinesModule` overrides with a polar-aware
* factory that branches on `axisCtx.axisType`.
* - Lifecycle is driven by the generic {@link AxisPluginModuleInstance} hooks
* ({@link update}, {@link layout}, {@link onScaleChange}, {@link onGridChange}). The axis
* invokes them generically without knowing what cross-lines are.
*
* `applyOptions` is called every `Chart.applyAxes` cycle (whether or not the cross-lines options
* changed), so the body short-circuits when the new options are structurally equivalent to the
* previous call — preserving the pre-refactor `jsonDiff`-gated setter behaviour and avoiding
* scene-graph detach/recreate churn on no-op updates. Per invariant I1 the options array is
* read-only — the plugin stores its own runtime state on the per-instance `CrossLine`s.
*/
export declare class CrossLinesPlugin extends AbstractModuleInstance implements AxisPluginModuleInstance {
static readonly className = "CrossLines";
private readonly ctx;
private readonly axisCtx;
private readonly rangeGroup;
private readonly lineGroup;
private readonly labelGroup;
private instances;
private lastOptions;
constructor(ctx: DynamicContext<ChartAxisRegistry<AxisContext>>);
applyOptions(options: NormalisedAxisCrossLineOptions[] | undefined): void;
onAxisUpdate(): void;
onAxisLayout(): void;
onScaleChange(): void;
onGridChange(): void;
setVisible(visible: boolean): void;
getInstances(): readonly CrossLine[];
destroy(): void;
private attachInstance;
private detachInstance;
private initInstance;
private optionsEquivalent;
}