*Example of an options definition with the most common attributes:

this.prototype.options = {
'chartType': {
type: 'number',
[name: 'Name'],
[_set: function],
[value: 'line'], // options without value get forwarded to the _get callback
[_get: function], // either _get or value must be specified
[flags: BG.charts.Object.EOptionFlags.EXPOSED] // various flags; e.g. exposed => hint for ui; this option can be shown
},
};

Hierarchy (View Summary)

Constructors

  • The Controller is the main class of the charting package. It is built upon the features offered by BG.charts.ChartSet and BG.charts.Data. It provides an abstraction layer that simplifies many of the common tasks encountered when displaying a chart and offers prebuilt implementations for various additional features such as:

    • serialization/deserialization of complete charts
    • extensible data loading from arbitrary sources
    • automatic management of BG.charts.Tool, BG.charts.Indicator and BG.charts.Layer
    • an interface for BG.charts.ToolGenerator to integrate dynamic tools (e.g. chart patterns)

    Parameters

    Returns BG.charts.Controller

Properties

optionGroups: OptionGroup[]
options: { [key: string]: any }
converters: {
    "2": (oldConfig: any) => null | Record<string, any>;
    "3": (oldConfig: any) => null | Record<string, any>;
    "4": (oldConfig: any) => null | Record<string, any>;
}

Methods

  • adds a new BG.charts.ToolGenerator to the chartset generators always appear in the same chart as the timeseries they target

    the specified type string is resolved via the internal generator registry custom generators can be registered via BG.charts.utils.setGenerator

    NOTE: generators can not be added to chartsets that do not currently contain a timeseries

    Parameters

    • type: string
    • Optionalinput: null | string

      optional identifier of a timeseries

    Returns null | BG.charts.ToolGenerator

  • add an indicator the provided type is resolved via the internal indicator registry custom indicators can be registered via BG.charts.utils.setIndicator

    Parameters

    • type: string
    • Optionalinput: null | string | string[]
    • Optionaltarget: null | number | boolean | BG.charts.Chart
    • OptionaltargetScale: null | number | boolean
    • OptionaltargetOrder: null | number | boolean

    Returns null | BG.charts.Indicator

  • Type Parameters

    • Type extends (keyof Events) | (keyof Events)
    • Callback extends
          | (
              optionName: string,
              attributeName: string,
              oldValue: any,
              newValue: any,
          ) => void
          | (optionName: string, oldValue?: any, newValue?: any) => void
          | (
              state: BG.charts.Object.State,
              flags: BG.charts.Object.State.EFlags,
          ) => void
          | () => void
          | (object: null | BG.charts.Object) => void
          | (
              legendEntry: null | BG.charts.LegendEntry,
              object: null | BG.charts.Object,
          ) => void
          | (
              event: null | Event,
              point: Point,
              objects: BG.charts.Object[],
              chart: BG.charts.Chart,
              menuId?: null | string,
          ) => void
          | (event: null | Event, point: Point, object: BG.charts.Object) => void
          | (
              event: null | Event,
              point: Point,
              objects: BG.charts.Object[],
              cb: (object: BG.charts.Object) => void,
          ) => void
          | (object: null | BG.charts.Object) => void
          | (object: BG.charts.Object) => void
          | (object: BG.charts.Object) => void
          | (
              event: null | Event,
              object: BG.charts.Object,
              finished: boolean,
          ) => void
          | (object: BG.charts.Object) => void
          | (object: BG.charts.Object, parent?: null | BG.charts.Object) => void
          | (
              object: BG.charts.Object,
              parent: null | BG.charts.Object,
              index: number,
          ) => void
          | (
              object: BG.charts.Object,
              oldParent: null | BG.charts.Object,
              oldScaleId: number,
              oldIndex: number,
              newParent: null | BG.charts.Object,
              newScaleId: number,
              newIndex: number,
          ) => void
          | (
              id: string,
              message: string | I18NString,
              context: null | BG.charts.Object,
          ) => void
          | (object: BG.charts.Object) => void
          | (
              ts: BG.charts.TimeSeries,
              value: number,
              relativeChange: number,
              absoluteChange: number,
          ) => void
          | (
              event: null | Event,
              point: Point,
              object: BG.charts.Object,
              button?: null | string,
          ) => void
          | (flags: EChangeFlags, interactionActive: boolean) => void
          | (object: BG.charts.Object) => void
          | (error: null | Error) => void
          | () => void
          | (object: null | BG.charts.Object) => void
          | () => void
          | () => void
          | () => void
          | (object: BG.charts.Object, oldIdentifier: string) => void
          | (oldIdentifier: string, newIdentifier: string) => void

    Parameters

    Returns this

    adds a listener to the end of the listeners array for the specified event.

  • adds a new BG.charts.TimeSeries

    if no target parameter is specified, timeseries will be automatically added to the main chart alternatively, you can specify true to add it as a new chart, or pass a specific chart instance or id

    if no targetScale parameter is specified, timeseries will automatically be added to the right scale alternatively, you can specify true to add it to a new scale, or pass a specific scale id if scale id is invalid, right scale will be used

    if no targetOrder parameter is specified, the timeseries will automatically be appended after the last object.

    the provided identifier is resolved to a data loader class via the internal loader registry custom loaders can be registered via BG.charts.utils.setLoader

    identifiers are formatted like this: "Instrument(133962,4)", "CFD(CFD_GDAXI,mid)", "Portfolio(1234)"

    if a timeseries matching the specified identifier already exists in the chart, it is added again with an automatically appended unique id; e.g. "Instrument(133962,4)#42"

    Parameters

    • identifier: string
    • Optionaltarget: null | number | boolean | BG.charts.Chart
    • OptionaltargetScale: null | number | boolean
    • OptionaltargetOrder: null | number | boolean

    Returns null | BG.charts.TimeSeries

  • add a new tool to the chart

    this method has three modes; depending on the supplied parameters it will

    a) initiate interactive placement of the specified tool (default behaviour, only first parameter required) b) initiate placement at a predefined point in a specific chart. If tool has more than one handle, additional handles will be placed interactively; if it has just one, placement is non-interactive. (first three parameters required, second parameter must be an instance of BG.charts.Point) c) place a tool directly without any interaction required; coordinates all handles must be specified (first three parameters required, last two parameters optional, second parameter must be an array of handles)

    Handles are specified as an array of numbers, either in the format [timestamp, value], or [timestamp, offset, value]. The number and layout constraints of handles depends on the type of the tool being added. Layout can be changed at a later time using BG.charts.Tool.setHandles See the documentation of the respective tool class for detailed information.

    the tool type is resolved via the internal tool registry (full list available via BG.charts.utils.list) additional custom tools can be registered via BG.charts.setTool

    Parameters

    • type: string

      identifier of the tool to be added

    • Optionalhandles: Point | number[][]
    • Optionaltarget: null | number | BG.charts.Chart
    • OptionaltargetScale: null | number | boolean

      [not currently used, tools are always placed on the primary scale]

    • OptionaltargetOrder: null | number | boolean

      [not currently used, tools are always appended at top most position]

    Returns null | BG.charts.Tool

  • returns or sets the attribute of an option this function should be used with care - modifications of internal properties might break stuff!

    Parameters

    • this: BG.charts.Object<Record<string, (...args: any) => void>>
    • s: string
    • a: string
    • Optionalv: any

    Returns any

  • clears the chart

    Parameters

    • OptionalclearTimeSeries: boolean
    • OptionalclearIndicators: boolean
    • OptionalclearTools: boolean
    • OptionalclearGenerators: boolean

    Returns number

  • clones the specified object

    Note: Only TimeSeries, Indicators and Tools (not generated ones) can be cloned

    cloned objects will inherit all properties from the original they will be placed directly "after" the original (e.g. in terms of position for charts, or visual order for other objects)

    returns the cloned object if successful, null otherwise

    Parameters

    Returns null | BG.charts.Object

  • creates a new chart

    • resets all options to the default
    • clears the selected style

    Parameters

    • Optionalidentifier: null | string
    • Optionalspan: number
    • Optionalinterval: number

    Returns boolean

  • deserializes a previously serialized chart from an object different aspects of deserialization can be controlled using the optional parameters

    NOTE: If data is modified (e.g. changing span, interval, or timeseries') after deserialization and before the controller has finished loading, the viewport is NOT restored.

    Parameters

    • config: { [key: string]: any }
    • OptionalasTemplate: boolean

      if true, the currently active timeseries are kept, and only applicable settings are loaded from the config

    • OptionalrestoreView: boolean

      if true, the position and bounds of the X- and Y-axis are restored automatically

    • OptionalkeepTools: boolean

      if true, tools are restored if the config is loaded as a template

    • OptionalnoNewQuotes: boolean

      if true, quotes that did not exist when the chart was stored are not loaded

    Returns boolean

  • deserializes a previously serialized object

    the optional second and third parameter control where the deserialized object is placed or if options are applied to an existing object

    • if target is object of same type, options are directly applied to it

    otherwise:

    • if none of the two parameters is specified: interactive placement is started for tools; other objects are automatically placed
    • if only a target is specified: object is placed into the specified target
    • if both a target and a point are specified: interactive placement is started at the specified point

    NOTE: interactive placement using a point is only supported for tools. When deserializing other object types, the point parameter is simply ignored

    NOTE: when deserializing timeseries, the relative option is ignored; deserialization behaves the same way as using addTimeseries; instead, deserialization uses the benchmarkMode setting of the Controller.

    NOTE: because this method is intended for being used by a user interface, objects are always appended at the end, and visual order index can not be specified directly; if you want to modify this, use ::moveObject or even better use the individual methods intended for programmatic placement (::addIndicator, ::addTool, ..., combined with ::set, ::moveObject, etc)

    Parameters

    Returns null | BG.charts.Object<Record<string, (...args: any) => void>>

  • destroys the controller will unregister all subscriptions of contained generators, data sources, etc

    Returns void

  • must be called after willUpdateOptions once all actions that might potentially changed values of any options are done

    IMPORTANT: methods must be called in balance; e.g. for each call to willUpdateOptions, you must call didUpdateOptions exactly once.

    Parameters

    Returns void

  • disables/enables pivot zoom, where the amount of candles is kept the same after interval changes

    Parameters

    • v: boolean

    Returns void

  • Type Parameters

    • Type extends (keyof Events) | (keyof Events)
    • Callback extends
          | (
              optionName: string,
              attributeName: string,
              oldValue: any,
              newValue: any,
          ) => void
          | (optionName: string, oldValue?: any, newValue?: any) => void
          | (
              state: BG.charts.Object.State,
              flags: BG.charts.Object.State.EFlags,
          ) => void
          | () => void
          | (object: null | BG.charts.Object) => void
          | (
              legendEntry: null | BG.charts.LegendEntry,
              object: null | BG.charts.Object,
          ) => void
          | (
              event: null | Event,
              point: Point,
              objects: BG.charts.Object[],
              chart: BG.charts.Chart,
              menuId?: null | string,
          ) => void
          | (event: null | Event, point: Point, object: BG.charts.Object) => void
          | (
              event: null | Event,
              point: Point,
              objects: BG.charts.Object[],
              cb: (object: BG.charts.Object) => void,
          ) => void
          | (object: null | BG.charts.Object) => void
          | (object: BG.charts.Object) => void
          | (object: BG.charts.Object) => void
          | (
              event: null | Event,
              object: BG.charts.Object,
              finished: boolean,
          ) => void
          | (object: BG.charts.Object) => void
          | (object: BG.charts.Object, parent?: null | BG.charts.Object) => void
          | (
              object: BG.charts.Object,
              parent: null | BG.charts.Object,
              index: number,
          ) => void
          | (
              object: BG.charts.Object,
              oldParent: null | BG.charts.Object,
              oldScaleId: number,
              oldIndex: number,
              newParent: null | BG.charts.Object,
              newScaleId: number,
              newIndex: number,
          ) => void
          | (
              id: string,
              message: string | I18NString,
              context: null | BG.charts.Object,
          ) => void
          | (object: BG.charts.Object) => void
          | (
              ts: BG.charts.TimeSeries,
              value: number,
              relativeChange: number,
              absoluteChange: number,
          ) => void
          | (
              event: null | Event,
              point: Point,
              object: BG.charts.Object,
              button?: null | string,
          ) => void
          | (flags: EChangeFlags, interactionActive: boolean) => void
          | (object: BG.charts.Object) => void
          | (error: null | Error) => void
          | () => void
          | (object: null | BG.charts.Object) => void
          | () => void
          | () => void
          | () => void
          | (object: BG.charts.Object, oldIdentifier: string) => void
          | (oldIdentifier: string, newIdentifier: string) => void

    Parameters

    Returns boolean

    execute each of the listeners in order with the supplied parameters.

  • enumerate all objects in the controllers hierarchy

    The provided callback will be called with each object, its parent, and the depth in the hierarchy. The callback can return true at any time to cancel enumeration

    the optional filter parameter can be used to filter by option values (null or empty object matches all)

    the optional parent parameter can be used to limit the scope to only children of the specified object(s) (null matches descendants of controller, e.g. Charts)

    the optional third parameter can include various flags to modify the query behaviour

    Parameters

    Returns void

  • execute an objects' action with the specified id actionId references an action provided by getObjectActions

    Parameters

    Returns null | { result: any; type: string }

  • returns a flat representation of all available config options in the form of a key-value-object optionally only values that are not read-only can be returned

    IMPORTANT: this method will always convert I18NStrings to strings, so for displaying strings in a UI use individual calls to BG.charts.Object:get instead

    Parameters

    • OptionalreadWriteOnly: boolean

      default: true

    • OptionalmodifiedOnly: boolean

      default: true

    • OptionalnonEphemeralOnly: boolean

      default: true

    Returns { [key: string]: any }

  • returns the value of the requested option, or a list of all available config options if no parameter is specified.

    Parameters

    • Optionals: string
    • Optionalflags: number

    Returns any

  • returns the categorization of the objects options can be used for displaying a more structured user interface

    Returns OptionGroup[]

  • retrieve one object matching the specified filter

    the optional parent parameter can be used to limit the scope to only children of the specified object(s) (null matches descendants of controller, e.g. Charts)

    the optional index parameter can be used to specify which object should be retrieved if more than one object matches the filter and scope

    the optional fourth parameter can include various flags to modify the query behaviour

    Parameters

    Returns null | BG.charts.Object

  • retrieves a list of object specific actions provided by the specified object E.g. trend lines provide an action to convert themselves to channels.

    If the optional menuId parameter is not specified, the returned actions are for the default "right click" contextmenu. Different objects can support additional menus with other actions; possible values will be provided for example as a parameter in the "contextMenu" event

    Note: Non-object specific generic actions such as "clone", "delete" etc are NOT included in the returned list.

    Parameters

    Returns BG.charts.Tool.Action[]

  • retrieves objects current index in charts visual order.

    As charts scales are always first in the object hierarchy even though they technically appear as the top most drawing, they have negative order indices.

    Therefore, the object that is drawn first is always at index zero.

    if the requested object is not in the controllers hierarchy, method returns null

    Parameters

    Returns null | number

  • retrieve objects and return them in an array

    the optional filter parameter can be used to filter by option values (null or empty object matches all)

    the optional parent parameter can be used to limit the scope to only children of the specified object(s) (null matches descendants of controller, e.g. Charts)

    the optional third parameter can include various flags to modify the query behaviour

    Parameters

    Returns BG.charts.Object[]

  • retrieve the scale of the specified object (identified by numeric id, layer or identifier)

    NOTE: result is always non-null, except if the specified object is not part of the controllers hierarchy

    Parameters

    Returns null | BG.charts.Scale

  • return an objects parent

    if the optional filter is not specified, always returns the immediate parent. if the optional filter is specified, the parent is only returend if it matches the filter

    via the optional flags the matching can be extended:

    • EQueryFlags.MATCH_ALL_PARENTS: consider all parents in the hierarchy
    • EQueryFlags.MATCH_SELF: also consider object itself as a possible match

    Parameters

    • Optionalid: null | number | BG.charts.Object
    • Optionalfilter: { [key: string]: any }

      an optional filter to match against parent objects' options

    • Optionalflags: EQueryFlags

    Returns null | BG.charts.Object

  • Returns a BG.charts.Profiler instance if run in a node environment

    Returns undefined | Profiler

  • returns the style of the chart

    Returns null | Style

  • highlight an object

    automatically highlights all layers belonging to the same timeseries or indicator when the second parameter is not set to true

    Parameters

    Returns void

  • Type Parameters

    • Type extends (keyof Events) | (keyof Events)
    • Callback extends
          | (
              optionName: string,
              attributeName: string,
              oldValue: any,
              newValue: any,
          ) => void
          | (optionName: string, oldValue?: any, newValue?: any) => void
          | (
              state: BG.charts.Object.State,
              flags: BG.charts.Object.State.EFlags,
          ) => void
          | () => void
          | (object: null | BG.charts.Object) => void
          | (
              legendEntry: null | BG.charts.LegendEntry,
              object: null | BG.charts.Object,
          ) => void
          | (
              event: null | Event,
              point: Point,
              objects: BG.charts.Object[],
              chart: BG.charts.Chart,
              menuId?: null | string,
          ) => void
          | (event: null | Event, point: Point, object: BG.charts.Object) => void
          | (
              event: null | Event,
              point: Point,
              objects: BG.charts.Object[],
              cb: (object: BG.charts.Object) => void,
          ) => void
          | (object: null | BG.charts.Object) => void
          | (object: BG.charts.Object) => void
          | (object: BG.charts.Object) => void
          | (
              event: null | Event,
              object: BG.charts.Object,
              finished: boolean,
          ) => void
          | (object: BG.charts.Object) => void
          | (object: BG.charts.Object, parent?: null | BG.charts.Object) => void
          | (
              object: BG.charts.Object,
              parent: null | BG.charts.Object,
              index: number,
          ) => void
          | (
              object: BG.charts.Object,
              oldParent: null | BG.charts.Object,
              oldScaleId: number,
              oldIndex: number,
              newParent: null | BG.charts.Object,
              newScaleId: number,
              newIndex: number,
          ) => void
          | (
              id: string,
              message: string | I18NString,
              context: null | BG.charts.Object,
          ) => void
          | (object: BG.charts.Object) => void
          | (
              ts: BG.charts.TimeSeries,
              value: number,
              relativeChange: number,
              absoluteChange: number,
          ) => void
          | (
              event: null | Event,
              point: Point,
              object: BG.charts.Object,
              button?: null | string,
          ) => void
          | (flags: EChangeFlags, interactionActive: boolean) => void
          | (object: BG.charts.Object) => void
          | (error: null | Error) => void
          | () => void
          | (object: null | BG.charts.Object) => void
          | () => void
          | () => void
          | () => void
          | (object: BG.charts.Object, oldIdentifier: string) => void
          | (oldIdentifier: string, newIdentifier: string) => void

    Parameters

    Returns Callback[]

    returns an array of listeners for the specified event.

  • move an object to another position. Position is defined as the tuple of [chart, scale, visual order]. All of these properties can be changed invididually, or at the same time. By specifying null or false for any of them, the property is kept (e.g. just changing scale, but not chart), or determined automatically (e.g. when not specifying a scale, but moving to a new chart)

    Numeric target values are interpreted as a relative offset (e.g. +1 means one chart down) by default. Alternatively absolute values can be used if EQueryFlags.ABSOLUTE_VALUES is set in flags.

    By default, objects are "merged" into the charts at the target position. When EQueryFlags.UNMERGE is set in flags, objects are instead moved to newly created charts that are inserted at the target position. This flag only works when target chart is specified numerically.

    When moving charts the target must always be numeric, and the scale and unmerge parameters are ignored

    Parameters

    • object:
          | string
          | number
          | BG.charts.Chart
          | BG.charts.Tool
          | BG.charts.TimeSeries
          | BG.charts.Indicator
          | BG.charts.ToolGenerator
    • target: null | number | BG.charts.Chart

      chart object, or numerical offset from current position (automatically determined if null or 0)

    • targetScale: null | number | boolean | BG.charts.Scale

      id of target scale (automatically determined if null/false or not specified)

    • OptionaltargetOrder: null | number | boolean

      visual order in chart (automatically determined if null/false or not specified)

    • Optionalflags: EQueryFlags

      optional flags for modifying behaviour

    Returns boolean

  • Type Parameters

    • Type extends (keyof Events) | (keyof Events)
    • Callback extends
          | (
              optionName: string,
              attributeName: string,
              oldValue: any,
              newValue: any,
          ) => void
          | (optionName: string, oldValue?: any, newValue?: any) => void
          | (
              state: BG.charts.Object.State,
              flags: BG.charts.Object.State.EFlags,
          ) => void
          | () => void
          | (object: null | BG.charts.Object) => void
          | (
              legendEntry: null | BG.charts.LegendEntry,
              object: null | BG.charts.Object,
          ) => void
          | (
              event: null | Event,
              point: Point,
              objects: BG.charts.Object[],
              chart: BG.charts.Chart,
              menuId?: null | string,
          ) => void
          | (event: null | Event, point: Point, object: BG.charts.Object) => void
          | (
              event: null | Event,
              point: Point,
              objects: BG.charts.Object[],
              cb: (object: BG.charts.Object) => void,
          ) => void
          | (object: null | BG.charts.Object) => void
          | (object: BG.charts.Object) => void
          | (object: BG.charts.Object) => void
          | (
              event: null | Event,
              object: BG.charts.Object,
              finished: boolean,
          ) => void
          | (object: BG.charts.Object) => void
          | (object: BG.charts.Object, parent?: null | BG.charts.Object) => void
          | (
              object: BG.charts.Object,
              parent: null | BG.charts.Object,
              index: number,
          ) => void
          | (
              object: BG.charts.Object,
              oldParent: null | BG.charts.Object,
              oldScaleId: number,
              oldIndex: number,
              newParent: null | BG.charts.Object,
              newScaleId: number,
              newIndex: number,
          ) => void
          | (
              id: string,
              message: string | I18NString,
              context: null | BG.charts.Object,
          ) => void
          | (object: BG.charts.Object) => void
          | (
              ts: BG.charts.TimeSeries,
              value: number,
              relativeChange: number,
              absoluteChange: number,
          ) => void
          | (
              event: null | Event,
              point: Point,
              object: BG.charts.Object,
              button?: null | string,
          ) => void
          | (flags: EChangeFlags, interactionActive: boolean) => void
          | (object: BG.charts.Object) => void
          | (error: null | Error) => void
          | () => void
          | (object: null | BG.charts.Object) => void
          | () => void
          | () => void
          | () => void
          | (object: BG.charts.Object, oldIdentifier: string) => void
          | (oldIdentifier: string, newIdentifier: string) => void

    Parameters

    Returns this

    alias for addListener

  • Type Parameters

    • Type extends (keyof Events) | (keyof Events)
    • Callback extends
          | (
              optionName: string,
              attributeName: string,
              oldValue: any,
              newValue: any,
          ) => void
          | (optionName: string, oldValue?: any, newValue?: any) => void
          | (
              state: BG.charts.Object.State,
              flags: BG.charts.Object.State.EFlags,
          ) => void
          | () => void
          | (object: null | BG.charts.Object) => void
          | (
              legendEntry: null | BG.charts.LegendEntry,
              object: null | BG.charts.Object,
          ) => void
          | (
              event: null | Event,
              point: Point,
              objects: BG.charts.Object[],
              chart: BG.charts.Chart,
              menuId?: null | string,
          ) => void
          | (event: null | Event, point: Point, object: BG.charts.Object) => void
          | (
              event: null | Event,
              point: Point,
              objects: BG.charts.Object[],
              cb: (object: BG.charts.Object) => void,
          ) => void
          | (object: null | BG.charts.Object) => void
          | (object: BG.charts.Object) => void
          | (object: BG.charts.Object) => void
          | (
              event: null | Event,
              object: BG.charts.Object,
              finished: boolean,
          ) => void
          | (object: BG.charts.Object) => void
          | (object: BG.charts.Object, parent?: null | BG.charts.Object) => void
          | (
              object: BG.charts.Object,
              parent: null | BG.charts.Object,
              index: number,
          ) => void
          | (
              object: BG.charts.Object,
              oldParent: null | BG.charts.Object,
              oldScaleId: number,
              oldIndex: number,
              newParent: null | BG.charts.Object,
              newScaleId: number,
              newIndex: number,
          ) => void
          | (
              id: string,
              message: string | I18NString,
              context: null | BG.charts.Object,
          ) => void
          | (object: BG.charts.Object) => void
          | (
              ts: BG.charts.TimeSeries,
              value: number,
              relativeChange: number,
              absoluteChange: number,
          ) => void
          | (
              event: null | Event,
              point: Point,
              object: BG.charts.Object,
              button?: null | string,
          ) => void
          | (flags: EChangeFlags, interactionActive: boolean) => void
          | (object: BG.charts.Object) => void
          | (error: null | Error) => void
          | () => void
          | (object: null | BG.charts.Object) => void
          | () => void
          | () => void
          | () => void
          | (object: BG.charts.Object, oldIdentifier: string) => void
          | (oldIdentifier: string, newIdentifier: string) => void

    Parameters

    Returns this

    adds a one time listener for the event. This listener is invoked only the next time the event is fired, after which it is removed.

  • destroys the controller will unregister all subscriptions of contained generators, data sources, etc

    Returns void

  • life cycle method; called when the object should recover from an error and resume normal operation

    this will only be called if the object encountered a RecoverableError, and is always triggered by a manual user interaction

    always called between start and stop

    Returns void

  • life cycle method; called when the object should start normal operation at this point is is already completely initialized

    Parameters

    Returns void

  • life cycle method; called when the object should stop normal operation if objects have any pending subscriptions/requests, they should all be stopped here

    the object is also responsible for clearing the loading flag from it's state if it is currently active failing to do so will trigger a fatal error

    object might be started again afterwards (start) or destroyed (destroy) this is not known yet at this point

    called after start or restart

    Returns void

  • Parameters

    Returns null | { [key: string]: any }

    use Controller.peek instead of this instance-specific implementation

  • can be called to tell the object that it should recover from an error and resume will have no effect if no retryable error is currently associated with the object

    Returns boolean

  • reload the chart all cached data is invalidated and requested again

    Returns void

  • Type Parameters

    • Type extends (keyof Events) | (keyof Events)

    Parameters

    Returns this

    removes all listeners, or those of the specified event.

  • Type Parameters

    • Type extends (keyof Events) | (keyof Events)
    • Callback extends
          | (
              optionName: string,
              attributeName: string,
              oldValue: any,
              newValue: any,
          ) => void
          | (optionName: string, oldValue?: any, newValue?: any) => void
          | (
              state: BG.charts.Object.State,
              flags: BG.charts.Object.State.EFlags,
          ) => void
          | () => void
          | (object: null | BG.charts.Object) => void
          | (
              legendEntry: null | BG.charts.LegendEntry,
              object: null | BG.charts.Object,
          ) => void
          | (
              event: null | Event,
              point: Point,
              objects: BG.charts.Object[],
              chart: BG.charts.Chart,
              menuId?: null | string,
          ) => void
          | (event: null | Event, point: Point, object: BG.charts.Object) => void
          | (
              event: null | Event,
              point: Point,
              objects: BG.charts.Object[],
              cb: (object: BG.charts.Object) => void,
          ) => void
          | (object: null | BG.charts.Object) => void
          | (object: BG.charts.Object) => void
          | (object: BG.charts.Object) => void
          | (
              event: null | Event,
              object: BG.charts.Object,
              finished: boolean,
          ) => void
          | (object: BG.charts.Object) => void
          | (object: BG.charts.Object, parent?: null | BG.charts.Object) => void
          | (
              object: BG.charts.Object,
              parent: null | BG.charts.Object,
              index: number,
          ) => void
          | (
              object: BG.charts.Object,
              oldParent: null | BG.charts.Object,
              oldScaleId: number,
              oldIndex: number,
              newParent: null | BG.charts.Object,
              newScaleId: number,
              newIndex: number,
          ) => void
          | (
              id: string,
              message: string | I18NString,
              context: null | BG.charts.Object,
          ) => void
          | (object: BG.charts.Object) => void
          | (
              ts: BG.charts.TimeSeries,
              value: number,
              relativeChange: number,
              absoluteChange: number,
          ) => void
          | (
              event: null | Event,
              point: Point,
              object: BG.charts.Object,
              button?: null | string,
          ) => void
          | (flags: EChangeFlags, interactionActive: boolean) => void
          | (object: BG.charts.Object) => void
          | (error: null | Error) => void
          | () => void
          | (object: null | BG.charts.Object) => void
          | () => void
          | () => void
          | () => void
          | (object: BG.charts.Object, oldIdentifier: string) => void
          | (oldIdentifier: string, newIdentifier: string) => void

    Parameters

    Returns this

    remove a listener from the listener array for the specified event.

  • remove an object

    Parameters

    Returns boolean

  • replace a timeseries identified by oldIdentifier with a new one if oldIdentifier is not specified, the main timeseries is replaced by default

    Parameters

    • identifier: string
    • OptionaloldIdentifier: string

    Returns boolean

  • changes the main timeseries of the controller

    Parameters

    Returns boolean

  • selects specified object and enables edit mode

    Currently only tools (instances of BG.charts.Tool) can be edited. For all other objects, this will basically just emit the objectSelected event.

    You can specify an optional action to directly start moving a tool or one of it's handles Valid values for action parameter:

    ** move **: Move the whole tool ** handle **: Move an individual handle (handle index can be specified via optional third parameter)

    Parameters

    • object: null | string | number | BG.charts.Object
    • Optionalaction: "handle" | "move"
    • OptionalhandleIndex: number
    • Optionalpoint: Point

    Returns void

  • serializes the currently displayed chart along with all objects contained within to an object the resulting object can be used with the deserialize function to restore the chart

    depending on the current state of the controller, serialization might not always work (e.g. it is not a good idea to serialize during loading); therefore, it is adviced to use serialize inside of a try catch block

    Returns { [key: string]: any }

  • serializes the specified chart object (currently supported: timeseries, indicator, tool or generator) along with all options and position information (tools only)

    Parameters

    Returns null | { [key: string]: any }

  • will set validate and then set the specified option(s) to the provided value(s) after validation

    NOTE: if multiple options are used, will return false if at least one value is not valid values are applied individually however, so one option might be set even if the value for another is invalid

    Parameters

    Returns boolean

  • set the ActivityIndicator class responsible for rendering the loading animation

    You can pass null to disable the loading animation e.g. you could implement a html/css based loader controlled by the optionChanged event for the loading option

    Parameters

    Returns boolean

  • specify a custom layout function to use instead of the default logic the provided callback is used everytime the controller wants to generate a new initial layout

    to clear/unset a previously specified layout function, simply call this method with null

    NOTE: if the callback "does nothing" the chart will simply show ALL available data NOTE: a new initial layout is only generated when timeseries data is initially loaded (data updates via push are not considered)

    simple layouts (e.g. if you just want to focus on a specific area of the chart and do not care about plotarea width etc) can just apply the desired ranges to the X-Axis and scales directly within the callback; the callback should not return anything.

    ADVANCED MODE: for more complex layouts depending on properties such as the bounds of an axis or the final size of a charts plotarea it is also possible to use multiple passes that are applied directly from within the rendering pass to make use of this advanced mode, the layout callback should return a multi-pass-layout callback (a function returning a boolean)

    for every pass, the logic is as follows:

    • the ChartSet updates the bounds of all charts
    • the ChartSet updates the layout (size of the plotarea) of all charts
    • the multipass-layout-callback is called

    the multi-pass-layout-callback MUST return true if it modifies the layout. The above steps are then repeated until the callback returns false.

    NOTE: it is possible to create an endless loop here; make sure the callback returns false at some point.

    Parameters

    • callback: () => null | () => boolean

    Returns void

  • Parameters

    • maxListeners: number

    Returns this

    by default EventEmitters will print a warning if more than 10 listeners are added for a particular event. This is a useful default which helps finding memory leaks. Obviously not all Emitters should be limited to 10. This function allows that limit to be increased. Set to zero for unlimited.

  • updates the safe area insets with the provided values

    Parameters

    • top: number
    • left: number
    • bottom: number
    • right: number

    Returns void

  • sets the style of the chart

    Parameters

    • Optionalstyle: null | string

    Returns void

  • style overwrites can be used to specify a set of selectors that always get applied on top of the style selected by setStyle

    exemplary usecase: a frontend might want to enforce a specific font to make charts fit into it's UI

    overwrites should be used with care; e.g. setting a fixed white background color could result in "invisible" lines, if the stylesheet uses black backgrounds and white lines...

    Parameters

    • style: null | { selector: string; values: { [key: string]: any } }[]

      the new style object or a path to a stylesheet

    Returns void

  • Sets the objName and objType of the Object reverts to the default ones if no arguments are given

    Parameters

    • OptionalobjType: string
    • OptionalobjName: string

    Returns void

  • clears the chart and shows the specified error

    Parameters

    Returns boolean

  • suspend push updates

    Parameters

    • mode: boolean

    Returns boolean

  • Returns a string representation of an object.

    Returns string

  • update the chart

    Parameters

    • Optionalmode: boolean

    Returns boolean

  • will set validate value(s) for the specified option(s)

    NOTE: if multiple options are used, will return false if at least one value is not valid

    Parameters

    Returns boolean

  • when using custom getters/setters (via _get/_set) in options, the values of options can change without .set being called - or there might not even be a setter for readonly options; for example, if the getter simply returns the value of a member variable this variable could be modified directly. In this case, events such as optionChanged would not be fired, and listeners would not be informed about the change.

    To account for such cases, the methods willUpdateOptions and didUpdateOptions should be called directly BEFORE and AFTER actions that might potentially change values of options. the correct events will then automatically be triggered when calling didUpdateOptions.

    if the options that could change are known, they can be supplied via the optional parameter. This provides a small performance gain in most situations.

    IMPORTANT: methods must be called in balance; e.g. for each call to willUpdateOptions, you must call didUpdateOptions exactly once.

    Parameters

    • Optionaloptions: string | string[]

    Returns void

  • zoom visible area to the specified span zooming based on time spans is only supported when using time based mergers

    Parameters

    • Optionala: string | number
    • Optionalb: string | number
    • OptionalnoConversion: boolean

      do not convert numbers to indices

    Returns
        | null
        | {
            end: readonly [number, number];
            first: readonly [number, number];
            last: readonly [number, number];
            left: readonly [number, number];
            right: readonly [number, number];
            start: readonly [number, number];
        }

  • Method to retrieve the number of currently active charts. Useful for debugging.

    Returns number

  • Utility function to find out which tools may be pruned if a config is opened after a specific date Tools will only be pruned when the data sources use shifting histories (e.g. always the last 3 months), which causes the firstTimestamp in the config to no longer be available

    Parameters

    • config: Record<string, any>
    • firstTimestamp: number

    Returns any[]

  • Parameters

    • cb: Function

    Returns void

    set custom error handler for event listeners

  • "peek" into a serialized configuration or a serialized object to retrieve information about contained objects this can for example be used to load required plugins on demand before actually deserializing a chart

    the output can be configured with the optional flags parameter; see BG.charts.Controller.EPeekFlags for details

    Parameters

    Returns null | { [key: string]: any }

  • Parameters

    • maxListeners: number

    Returns void

    set default amount for limit warning