a collection of utility functions used by the chart classes

Constructors

Methods

  • set flag for the specified object has no effect if flag is already set For a list of flags and a detailed explanation see BG.charts.Object.EFlags

    Parameters

    Returns void

  • set flag for the specified objects option has no effect if flag is already set For a list of flags and a detailed explanation see BG.charts.Object.EOptionFlags

    Parameters

    Returns void

  • add watermark drawing function to watermark registry implementations can be set active by calling BG.charts.utils.set('activeWatermark', $name); Additionally, it needs to be enabled for each BG.charts.Controller-instance by setting the showWatermark-setting to true.

    Parameters

    Returns void

  • adjust interval for span

    Parameters

    • interval: number
    • span: string | number

    Returns number

  • adjust span for interval

    Parameters

    • span: string | number
    • interval: number

    Returns string | number

  • Parameters

    • proto: any

    Returns any

  • compare an object identifier returns true if identifiers match, false otherwise the optional parameter controls wether ids should be considered for comparison (default = true)

    Parameters

    • a: string
    • b: string
    • OptionalconsiderIds: boolean

    Returns boolean

  • Parameters

    • t: number

      timestamp

    • fromTZ: string

      timezone identifier of source timezone

    • toTZ: string

      timezone identifier of destination timezone

    Returns number

  • abbreviate text to specified maximum length by cutting of and appending an ellipsis

    Parameters

    Returns string

  • compares two objects

    Parameters

    • objectA: { [key: string]: any }
    • objectB: { [key: string]: any }

    Returns boolean

  • modern fetch with timeout

    Type Parameters

    • T

    Parameters

    • context: BG.charts.TContext
    • url: RequestInfo | URL
    • Optionaltimeout: number
    • Optionaloptions: RequestInit

    Returns Promise<T>

  • Max function for Float64 buffers

    Parameters

    • array: Float64Array

    Returns number

  • Min function for Float64 buffers

    Parameters

    • array: Float64Array

    Returns number

  • builds a string using the supplied format and key value callback

    supports variables like {NAME} variables can supply default values like {NAME:DEFAULT} if the value retrieved from the callback matches the default it will be skipped, same as if there was no value at all

    multiple variables can be joined with {SEPARATOR|VARIABLE|VARIABLE|...}

    also supports conditionals that are only displayed when at least one enclosed variable has a non-default value: "[Currency: {currency}]"

    available variables depend on used data loader that has to provide them in the properties object as part of the metadata

    Example: "{name}[ ({, |currency|qs})]" => "DAX (XXP, Last)" or "Foo (Bid)" or "Foo ($)" or "Foo"

    Parameters

    • format: string
    • cb: (args: string) => string

    Returns string

  • returns the requested configuration option

    Parameters

    • option: string

    Returns
        | null
        | string
        | number
        | string[]
        | { selector: string; values: { [key: string]: any } }[]

  • check if a flag is set for the specified object For a list of flags and a detailed explanation see BG.charts.Object.EFlags

    Parameters

    Returns number

  • check if a flag is set for the specified objects option For a list of flags and a detailed explanation see BG.charts.Object.EOptionFlags

    Parameters

    Returns number

  • replace special characters by html entities

    Parameters

    • value: string | number

    Returns string

  • a list containing all available objects of the specified type lists are available for the following types: indicator, tool, generator, loader, layer NOTE: the map can contain duplicates, as one clazz might be registered for multiple types

    Parameters

    • type: string

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

  • merges properties of the second object into the first one

    non-existing properties are simply added to the first object. if properties exist in both objects:

    • scalar properties are overwritten with values from second object
    • arrays are concatenated
    • if types of properties do not match, value from the second object is used

    Parameters

    • obj1: any
    • obj2: any

    Returns { [key: string]: any }

  • returns the nearest predefined span for an arbitrary time span when passing a custom span array, the values need to be sorted in ascending order

    Parameters

    • span: string | number
    • Optionalspans: number[]

    Returns null | string

  • normalize an object identifier (see parseIdentifier) Example: Instrument => Instrument Instrument() => Instrument Instrument(1, 2) => Instrument(1,2) Instrument( ) => Instrument

    Parameters

    • identifier: string

    Returns string

  • parse an object identifier identifiers consist of a type, optional params enclosed by parenthesis, and an optional resolution prefixed with @

    Example: Instrument(133962,4)@86400000 => {type:"Instrument", params:[133962,4], resolution:86400000, id:null} SMA(20) => {type:"SMA", params:[20], resolution:86400000, id:null} MACD => {type:"MACD", params:[], resolution:86400000, id:null} Expression(A/(B+C))@3600000 => {type:"Expression", params:["A/(B+C)"], resolution:3600000, id:null} Instrument(133962)#Foo => {type:"Instrument", params:[133962], resolution:86400000, id:Foo}

    Parameters

    • identifier: string

    Returns
        | null
        | {
            id?: null
            | string;
            params: (string | number)[];
            resolution: number;
            type: string;
        }

  • remove a flag from the specified object Has no effect if flag is not set. For a list of flags and a detailed explanation see BG.charts.Object.EFlags

    Parameters

    Returns void

  • remove a flag from the specified objects option Has no effect if flag is not set. For a list of flags and a detailed explanation see BG.charts.Object.EOptionFlags

    Parameters

    Returns void

  • store the specified global configuration values

    Parameters

    • options: string | { [key: string]: any }
    • Optionalvalue: any

    Returns void

  • set flag for the specified object For a list of flags and a detailed explanation see BG.charts.Object.EFlags

    Parameters

    Returns void

  • set flag for the specified objects option For a list of flags and a detailed explanation see BG.charts.Object.EOptionFlags

    Parameters

    • object: BG.charts.Object
    • option: string
    • flag: number
    • Optionalstate: boolean

    Returns void

  • shift box boxStart by offset shiftCount

    Parameters

    • boxStart: number

      box

    • shiftCount: number

      offset

    • boxSize: number

      box size

    • absolute: boolean

      absolute mode flag

    Returns number

  • strip html tags from a string

    Parameters

    • html: string

    Returns string

  • checks if the specified tick is already complete

    Parameters

    • t: number

      a timestamp (UTC)

    • i: number

      interval to match with

    • tz: string

      timezone identifier for grouping

    • startTime: number

      daily start time in milliseconds

    • endTime: number

      daily end time in milliseconds

    Returns boolean

    flag indicating if tick is complete

  • Finds the nearest timestamp before the referenceTick that indicates a border between intervals of the given length

    Parameters

    • referenceTick: number

      a timestamp (UTC)

    • interval: number

      interval to match with

    • timezone: string

      timezone identifier for grouping

    • startTime: number

      daily start time in milliseconds

    Returns number

    the matched timestamp (UTC)

  • Parameters

    • value: any

    Returns
        | "string"
        | "number"
        | "bigint"
        | "boolean"
        | "symbol"
        | "undefined"
        | "object"
        | "function"
        | "array"
        | "date"
        | "null"

  • returns a uri encoded url query string is generated from the provided optional objects keys and values

    Parameters

    • url: string
    • Optionalparams: Record<string, string | number>

    Returns string

  • validate expression

    Parameters

    • type: string
    • value: string | number

    Returns boolean