Skip to content

Template

Type class

Settings, states, adapters and events shared by many objects, such as all columns of a series. A setting on the template reaches every object that uses it, unless the object has its own value.

Sources

Template can be used (imported) via one of the following packages.

// Import Template
import * as am5 from "@amcharts/amcharts5";
// Create Template
am5.Template.new(root, {
// ... config if applicable
});

Inheritance

Template does not extend any other symbol.

Template is not extended by any other symbol.

Settings

Set these settings on a Template object using its set() and setAll() methods. Read about settings concept.

Template does not have any settings.

Properties

adapters

Type TemplateAdaptersDefault new TemplateAdapters()

Adapters added to the objects that use the template.

entities

Type Array

The objects that use the template.

events

Type EventDispatcherDefault new EventDispatcher()

Event listeners added to the objects that use the template.

setup

Type (entity: O) => void | undefined

A function called once for each object that uses the template, when the template is first applied to it.

states

Type TemplateStatesDefault new TemplateStates(this)

States passed on to the objects that use the template.

Methods

constructor(settings: IESettings,
isReal: boolean
)

Returns Template

dispose()

Returns void

Disposes the template, along with any disposable objects in its settings.

get(key: Key)

Returns [""]

Returns the template's value of setting key, or fallback if it has none.

getPrivate(key: Key,
fallback: F
)

Returns NonNullable | F

Returns the template's value of private setting key, or fallback if it has none.

isDisposed()

Returns boolean

Returns true if the template has been disposed.

new(settings: IESettings)

StaticReturns Template

Creates a template with settings.

More info: Getting started: new element syntax

on(key: Key,
callback: (value: [""], target: E, key: Key) => void
)

Returns IDisposer

Calls callback each time setting key changes on an object that uses the template.

onPrivate(key: Key,
callback: (value: [""], target: E, key: Key) => void
)

Returns IDisposer

Calls callback each time private setting key changes on an object that uses the template.

remove(key: Key)

Returns void

Removes setting key from the template. The objects that use it go back to a value from a theme or other template, if there is one.

removeAll()

Returns void

Removes all settings from the template, as remove() does for each one.

removePrivate(key: Key)

Returns void

Removes private setting key from the template.

set(key: Key,
value: [""]
)

Returns void

Sets setting key on the template, and on every object that uses it and has no value of its own.

setAll(value: Partial)

Returns void

Sets several settings at once, as set() does for each one.

setPrivate(key: Key,
value: Value
)

Returns Value

Sets private setting key on the template, and on every object that uses it and has no value of its own. Returns value.

setPrivateRaw(key: Key,
value: Value
)

Returns Value

Sets private setting key on the template only, without passing it on to the objects that use it. Returns value.

setRaw(key: Key,
value: [""]
)

Returns void

Sets setting key on the template only, without passing it on to the objects that use it.

Events

Template does not have any events.