/** * @template {ChannelWithScale}[T=ChannelWithScale] * * @typedef {object} ScaleResolutionMember * @prop {import("../view/unitView.js").default} view TODO: Get rid of the view reference * @prop {T} channel * @prop {import("../spec/channel.js").ChannelDefWithScale} channelDef * @prop {boolean} contributesToDomain */ /** * Resolves a shared scale for a channel by merging scale properties and domains * across participating views, then coordinating range updates and zoom/pan * interactions. It is the central wiring point for scale-related state and * notifications, while delegating domain aggregation, scale instance setup, and * interaction logic to focused helpers. * * Documentation overview of current concerns this class (and its helpers) deal with: * - Resolution membership and rules (shared/independent/forced/excluded, visibility, registration). * - Scale property aggregation (merge props, channel overrides, unique scale names). * - Domain computation and caching (configured/data unions, defaults, indexer stability, subscriptions). * - Scale instance lifecycle (create, reconfigure props, apply domains, notify changes). * - Interaction and zoom (zoom/pan/reset coordination, snapshots, zoom extents). * - Rendering integration (range textures, axis sizing/positioning). * - Locus-specific conversions (complex intervals, genome extent bindings). * - Diagnostics and edge cases (ordinal unknown, nice/zero/padding, log warnings). * * @implements {ScaleResolutionApi} */ export default class ScaleResolution implements ScaleResolutionApi { /** * Executes a group of member registrations without refreshing derived * membership state until the callback completes. * * @template T * @param {Iterable} resolutions * @param {() => T} callback * @returns {T} */ static registerInBatch(resolutions: Iterable, callback: () => T): T; /** * @param {Channel} channel * @param {import("../view/view.js").default} [hostView] */ constructor(channel: import("../spec/channel.js").Channel, hostView?: import("../view/view.js").default); channel: import("../spec/channel.js").Channel; /** @type {import("../spec/channel.js").Type} Data type (quantitative, nominal, etc...) */ type: import("../spec/channel.js").Type; /** @type {string} An optional unique identifier for the scale */ name: string; get zoomExtent(): number[]; /** * Adds a listener that is called when the scale domain is changed, * e.g., zoomed. The call is synchronous and happens before the views * are rendered. * * @param {ScaleResolutionEventType} type * @param {ScaleResolutionListener} listener function */ addEventListener(type: import("../types/scaleResolutionApi.js").ScaleResolutionEventType, listener: import("../types/scaleResolutionApi.js").ScaleResolutionListener): void; /** * @param {ScaleResolutionEventType} type * @param {ScaleResolutionListener} listener function */ removeEventListener(type: import("../types/scaleResolutionApi.js").ScaleResolutionEventType, listener: import("../types/scaleResolutionApi.js").ScaleResolutionListener): void; syncLinkedSelectionFromDomain(): void; /** * @param {ScaleResolutionMember} member * @returns {() => boolean} */ registerMember(member: ScaleResolutionMember): () => boolean; dispose(): void; /** * @param {import("../data/collector.js").default} collector * @param {Iterable} accessors * @returns {() => void} */ registerCollectorSubscriptions(collector: import("../data/collector.js").default, accessors: Iterable): () => void; /** * Returns true if the domain has been defined explicitly, i.e. not extracted from the data. */ isDomainDefinedExplicitly(): boolean; isDomainInitialized(): boolean; /** * Returns locus assembly requirements without initializing the scale. * * This is intentionally side-effect free: it only inspects merged scale * properties from registered members and does not touch default domains or * instantiate scale instances. * * @returns {{ * assembly: import("../spec/scale.js").Scale["assembly"] | undefined, * needsDefaultAssembly: boolean * }} */ getAssemblyRequirement(): { assembly: import("../spec/scale.js").Scale["assembly"] | undefined; needsDefaultAssembly: boolean; }; /** * Returns the resolved scale type without instantiating the scale. * * Useful during view construction, before assembly preflight has loaded * URL-backed locus genomes. * * @returns {import("../spec/scale.js").Scale["type"] | undefined} */ getResolvedScaleType(): import("../spec/scale.js").Scale["type"] | undefined; /** * Reconfigures the scale: updates domain and other settings. * * Use this when the set of participating members changes (views added or removed), * or when scale properties are otherwise re-resolved from the view hierarchy. */ reconfigure(): void; /** * Reconfigures only the effective domain (configured + data-derived). * * Use this when data changes but the scale membership and properties are stable. * */ reconfigureDomain(): void; /** * @returns {ScaleWithProps} */ get scale(): import("../types/encoder.js").VegaScale & { props: import("../spec/scale.js").Scale; }; /** * Returns the scale instance, creating it if needed. * * Use this from call sites that may run before explicit initialization. * * @returns {ScaleWithProps} */ getScale(): import("../types/encoder.js").VegaScale & { props: import("../spec/scale.js").Scale; }; /** * Initializes the scale instance once resolution has stabilized. * * @returns {ScaleWithProps} */ initializeScale(): import("../types/encoder.js").VegaScale & { props: import("../spec/scale.js").Scale; }; getDomain(): any[]; /** * Extracts and unions the data domains of all participating views. * * @return { DomainArray } */ getDataDomain(): import("../utils/domainArray.js").DomainArray; /** * @returns {NumericDomain | ComplexDomain} */ getComplexDomain(): import("../spec/scale.js").NumericDomain | import("../spec/scale.js").ComplexDomain; /** * Returns metadata about a selection-linked domain, if present. */ getLinkedSelectionDomainInfo(): { param: string; encoding: "x" | "y"; persist: boolean; }; /** * Return true if the scale is zoomable and the current domain differs from the initial domain. * * @returns true if zoomed */ isZoomed(): boolean; /** * Returns true if zooming is supported and allowed in view spec. */ isZoomable(): boolean; /** * Pans (translates) and zooms using a specified scale factor. * * @param {number} scaleFactor * @param {number} scaleAnchor * @param {number} pan * @returns {boolean} true if the scale was zoomed */ zoom(scaleFactor: number, scaleAnchor: number, pan: number): boolean; /** * Immediately zooms to the given interval. * * @param {NumericDomain | ComplexDomain} domain * @param {boolean | number} [duration] an approximate duration for transition. * Zero duration zooms immediately. Boolean `true` indicates a default duration. */ zoomTo(domain: import("../spec/scale.js").NumericDomain | import("../spec/scale.js").ComplexDomain, duration?: boolean | number): Promise; /** * Resets the current domain to the initial one * * @returns true if the domain was changed */ resetZoom(): boolean; /** * Returns the zoom level with respect to the reference domain span (the original domain). * * In principle, this is highly specific to positional channels. However, zooming can * be generalized to other quantitative channels such as color, opacity, size, etc. */ getZoomLevel(): number; /** * Returns the length of the axis in pixels. Chooses the smallest of the views. * They should all be the same, but some exotic configuration might break that assumption. * * This method is needed because positional channels have unit ranges and the * length of the axis is not directly available from the scale. Ideally, ranges would * be configured as pixels, but that is yet to be materialized. */ getAxisLength(): number; /** * Inverts a value in range to a value on domain. Returns an object in * case of locus scale. * * @param {number} value */ invertToComplex(value: number): number | import("../spec/genome.js").ChromosomalLocus; /** * @param {number} value */ toComplex(value: number): number | import("../spec/genome.js").ChromosomalLocus; /** * @param {number | ChromosomalLocus} complex * @returns {number} */ fromComplex(complex: number | import("../spec/genome.js").ChromosomalLocus): number; /** * @param {ScalarDomain | ComplexDomain} interval * @returns {number[]} */ fromComplexInterval(interval: import("../spec/scale.js").ScalarDomain | import("../spec/scale.js").ComplexDomain): number[]; #private; } export type ScaleResolutionMember = { /** * TODO: Get rid of the view reference */ view: import("../view/unitView.js").default; channel: T; channelDef: import("../spec/channel.js").ChannelDefWithScale; contributesToDomain: boolean; }; import { INDEX } from "./scaleResolutionConstants.js"; import { LOCUS } from "./scaleResolutionConstants.js"; import { NOMINAL } from "./scaleResolutionConstants.js"; import { ORDINAL } from "./scaleResolutionConstants.js"; import { QUANTITATIVE } from "./scaleResolutionConstants.js"; export { INDEX, LOCUS, NOMINAL, ORDINAL, QUANTITATIVE }; //# sourceMappingURL=scaleResolution.d.ts.map