@devexperts/dxcharts-lite
Version:
93 lines (92 loc) • 3.19 kB
TypeScript
/*
* Copyright (C) 2019 - 2025 Devexperts Solutions IE Limited
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
import { ChartBaseElement } from '../../model/chart-base-element';
import { LinkedList } from '../../utils/linkedList.utils';
import { DynamicModelDrawer } from './dynamic-objects.drawer';
import { CanvasModel } from '../../model/canvas.model';
export type PaneId = string;
export type DynamicObjectId = string | number;
export interface DynamicObject<T = unknown> {
readonly id: DynamicObjectId;
readonly drawer: DynamicModelDrawer<T>;
readonly paneId: PaneId;
readonly model?: T;
readonly parentId?: DynamicObjectId;
}
export declare class DynamicObjectsModel extends ChartBaseElement {
private canvasModel;
private _objects;
private modelIdToObjectMap;
private _uniqueObjects;
constructor(canvasModel: CanvasModel);
/**
* @returns the `DynamicObject` itself and pane `LinkedList` where the object is stored.
*
*/
getObjectInfoById(id: DynamicObjectId): [DynamicObject, LinkedList<DynamicObject>] | undefined;
/**
* @returns `DynamicObject` position in associated pane `LinkedList`
* @returns `-1` if an object was not found
*
*/
getObjectPosition(id: DynamicObjectId): number;
/**
* Adds an object from outside chart-core into model
* @param obj
*/
addObject(obj: DynamicObject): void;
/**
* Removes an object from model
* @param id
*/
removeObject(id: DynamicObjectId): void;
/**
* Updates an object
* @param obj
*/
updateObject(obj: DynamicObject): void;
/**
* Moves the object inside the associated LinkedList to the specified position
*/
moveToPosition(id: DynamicObjectId, position: number): void;
/**
* Moves the object inside the drawing order so it's being drawn before the other elements
* @param paneId
* @param listNode
*/
bringToFront(id: DynamicObjectId): void;
/**
* Moves the object inside the drawing order so it's being drawn after the other elements
* @param paneId
* @param listNode
*/
bringToBack(id: DynamicObjectId): void;
/**
* Moves the object inside the drawing order so it's being drawn one layer ahead
* @param obj
* @param paneId
*/
moveForward(id: DynamicObjectId): void;
/**
* Moves the object inside the drawing order so it's being drawn one layer closer to the back
* @param obj
* @param paneId
*/
moveBackwards(id: DynamicObjectId): void;
/**
* Getter for the objects
*/
get objects(): Record<string, LinkedList<DynamicObject<unknown>>>;
/**
* Getter for the unique objects, unique object is an entity which is either dynamic object itself, or its parent
*/
get uniqueObjects(): Record<string, Set<DynamicObjectId>>;
/**
* Sets the objects
* @param objects
*/
setDynamicObjects(objects: Record<PaneId, LinkedList<DynamicObject>>): void;
}