@amcharts/amcharts5
Version:
amCharts 5
86 lines • 2.1 kB
JavaScript
/**
* @ignore
*/
export class Registry {
constructor() {
/**
* Currently running version of amCharts.
*/
this.version = "5.20.6";
/**
* List of applied licenses.
* @ignore
*/
this.licenses = [];
/**
* Entities that have their `id` setting set.
*/
this.entitiesById = {};
/**
* All created [[Root]] elements.
*/
this.rootElements = [];
/**
* Automatically dispose a [[Root]] element if it exists in the target container.
*
* @since 5.14.4
*/
this.autoDispose = false;
/**
* Functions that build a geometry from a few numbers, by the name they are
* serialized under. Registered by the map module; read when a config is
* parsed, so that a shape can be stored as the call that made it rather than
* as the coordinates it produced.
*
* @ignore
*/
this.geometryFunctions = {};
}
}
/**
* @ignore
*/
export const registry = new Registry();
/**
* Adds a license, e.g.:
*
* ```TypeScript
* am5.addLicense("xxxxxxxx");
* ```
* ```JavaScript
* am5.addLicense("xxxxxxxx");
* ```
*
* Multiple licenses can be added to cover for multiple products.
*
* @param license License key
*/
export function addLicense(license) {
registry.licenses.push(license);
}
/**
* Disposes all [[Root]] elements.
*/
export function disposeAllRootElements() {
let root;
while ((root = registry.rootElements.pop())) {
root.dispose();
}
}
/**
* Finds and returns a `Root` element assigned to a container with `id`.
*
* @param id Container ID
* @return Root
* @since 5.9.2
*/
export function getRootById(id) {
let found;
registry.rootElements.forEach((item) => {
if (item.dom.id == id) {
found = item;
}
});
return found;
}
//# sourceMappingURL=Registry.js.map