Chartbreaker
    Preparing search index...

    The ChartSet serves as a container around multiple individual Chart objects displaying data from the same timespan.

    For example, a typical finance chart consists of one chart displaying stock quotes in the form of candlesticks, and and another chart displaying the traded volume. These two charts are linked via their x-axis - if the viewed span is changed in one chart, it also changes in the other.

    The ChartSet is responsible for this synchronization by controlling the underlying Data object, basic event handling, the most general aspects of layout such as ordering charts. Visualization of the actual data and further event handling such as interaction with objects is then handled by the individual chart objects themselves.

    By default, the chartset is drawn with an opaque background. This can be changed - e.g. to display a logo in the background of the chart via CSS - by clearing the style value 'background-color' or setting it to 'none'.

    Hierarchy (View Summary)

    Index

    Constructors

    • Parameters

      • divId: string | HTMLDivElement

        id of the parent div

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

        backend specific options

      • data: Data
      • OptionalcanvasConstructor: (width: number, height: number, type?: "pdf" | "svg") => Canvas
          • (width: number, height: number, type?: "pdf" | "svg"): Canvas
          • Creates a Canvas instance. This function works in both Node.js and Web browsers, where there is no Canvas constructor.

            Parameters

            • width: number
            • height: number
            • Optionaltype: "pdf" | "svg"

              Optionally specify to create a PDF or SVG canvas. Defaults to an image canvas.

            Returns Canvas

      Returns ChartSet

    Properties

    Phantom data for type inference

    optionGroups?: ObjectOptionGroup[]
    options: { [key: string]: any }
    render: (meta?: ToolTCalculateParams) => void
    options: {
        action: {
            type: string[];
            _get(
                this: ChartSet,
            ): "none" | "picker" | "place" | "edit" | "zoom" | "measure" | "resize";
        };
        buttonsRatio: { name: string; type: string; value: number };
        height: {
            type: string;
            _get(this: ChartSet): number;
            _set(this: ChartSet, v: number): void;
        };
        i18nLanguage: {
            type: string;
            _get(this: ChartSet): string;
            _set(this: ChartSet, v: string): void;
        };
        i18nLocale: {
            type: string;
            _get(this: ChartSet): string;
            _set(this: ChartSet, v: string): void;
        };
        i18nTimezone: {
            type: string;
            _get(this: ChartSet): string;
            _set(this: ChartSet, v: string): void;
        };
        interaction: {
            type: string;
            _get(this: ChartSet): boolean;
            _set(this: ChartSet, v: boolean): void;
        };
        interactionActive: { type: string; _get(this: ChartSet): boolean };
        interactionChartButtons: {
            type: string;
            _get(this: ChartSet): boolean;
            _set(this: ChartSet, v: boolean): void;
        };
        interactionLegendButtons: {
            type: string;
            _get(this: ChartSet): boolean;
            _set(this: ChartSet, v: boolean): void;
        };
        interactionModify: {
            type: string;
            _get(this: ChartSet): boolean;
            _set(this: ChartSet, v: boolean): void;
        };
        interactionReorder: { type: string; value: boolean };
        interactionResize: {
            type: string;
            _get(this: ChartSet): boolean;
            _set(this: ChartSet, v: boolean): void;
        };
        interactionScroll: {
            type: string;
            _get(this: ChartSet): boolean;
            _set(this: ChartSet, v: boolean): void;
        };
        interactionZoom: {
            type: string;
            _get(this: ChartSet): boolean;
            _set(this: ChartSet, v: boolean): void;
        };
        interpolation: { type: string; _get(this: ChartSet): boolean };
        legend: {
            type: string;
            _get(this: ChartSet): boolean;
            _set(this: ChartSet, v: boolean): void;
        };
        picker: {
            type: string;
            _get(this: ChartSet): boolean;
            _set(this: ChartSet, v: boolean): void;
        };
        plotWidth: {
            type: string;
            _get(this: ChartSet): number;
            _set(this: ChartSet, v: number): void;
        };
        primaryYAxisPosition: { type: string[]; _get(this: ChartSet): any };
        ratio: {
            type: string;
            _get(this: ChartSet): number;
            _set(this: ChartSet, v: number): void;
        };
        resize: {
            type: string[];
            value: string;
            _set(this: ChartSet, v: "fixed" | "dynamic"): void;
        };
        secondaryYAxisPlaceholder: { type: string[]; _get(this: ChartSet): any };
        snap: { type: string; value: boolean };
        snapRange: {
            type: string;
            _get(this: ChartSet): number;
            _set(this: ChartSet, v: number): void;
        };
        width: {
            type: string;
            _get(this: ChartSet): number;
            _set(this: ChartSet, v: number): void;
        };
        xAxisLayout: { type: string[]; _get(this: ChartSet): any };
        xAxisSpacing: { type: string; _get(this: ChartSet): any };
        yAxisLayout: { type: string[]; _get(this: ChartSet): any };
    }

    Type Declaration

    • action: {
          type: string[];
          _get(
              this: ChartSet,
          ): "none" | "picker" | "place" | "edit" | "zoom" | "measure" | "resize";
      }

      currently active action (read only). Valid values:

      • ** none **
      • ** picker **
      • ** place **
      • ** edit **
      • ** zoom **
      • ** measure **
      • ** resize **

      action

    • buttonsRatio: { name: string; type: string; value: number }

      controls the size of buttons

      buttonsRatio

    • height: {
          type: string;
          _get(this: ChartSet): number;
          _set(this: ChartSet, v: number): void;
      }

      total height of the set

      height

    • i18nLanguage: {
          type: string;
          _get(this: ChartSet): string;
          _set(this: ChartSet, v: string): void;
      }

      i18n language

      i18nLanguage

    • i18nLocale: {
          type: string;
          _get(this: ChartSet): string;
          _set(this: ChartSet, v: string): void;
      }

      i18n locale

      i18nLocale

    • i18nTimezone: {
          type: string;
          _get(this: ChartSet): string;
          _set(this: ChartSet, v: string): void;
      }

      i18n timezone

      i18nTimezone

    • interaction: {
          type: string;
          _get(this: ChartSet): boolean;
          _set(this: ChartSet, v: boolean): void;
      }

      enable/disable mouse and keyboard interaction

      interaction

    • interactionActive: { type: string; _get(this: ChartSet): boolean }

      check if user interaction (click or touch) is currently in progress

      interactionActive

    • interactionChartButtons: {
          type: string;
          _get(this: ChartSet): boolean;
          _set(this: ChartSet, v: boolean): void;
      }

      enable/disable buttons in charts

      interactionChartButtons

    • interactionLegendButtons: {
          type: string;
          _get(this: ChartSet): boolean;
          _set(this: ChartSet, v: boolean): void;
      }

      enable/disable buttons in legends

      interactionLegendButtons

    • interactionModify: {
          type: string;
          _get(this: ChartSet): boolean;
          _set(this: ChartSet, v: boolean): void;
      }

      enable/disable modification of the chartsets content through mouse/touch interaction

      interactionModify

    • interactionReorder: { type: string; value: boolean }

      enable/disable manual interactive reordering of charts

      interactionReorder

    • interactionResize: {
          type: string;
          _get(this: ChartSet): boolean;
          _set(this: ChartSet, v: boolean): void;
      }

      enable/disable manual interactive resizing of charts

      interactionResize

    • interactionScroll: {
          type: string;
          _get(this: ChartSet): boolean;
          _set(this: ChartSet, v: boolean): void;
      }

      enable/disable manual interactive scrolling of the xAxis

      interactionScroll

    • interactionZoom: {
          type: string;
          _get(this: ChartSet): boolean;
          _set(this: ChartSet, v: boolean): void;
      }

      enable/disable manual interactive scrolling of the xAxis

      interactionZoom

    • interpolation: { type: string; _get(this: ChartSet): boolean }

      controls wether layers such as line and mountain use linear interpolation between data points disabling interpolation can make sense for some kinds of data such as measurements

      (can only be configured via stylesheet)

      interpolation

    • legend: {
          type: string;
          _get(this: ChartSet): boolean;
          _set(this: ChartSet, v: boolean): void;
      }

      enables/disables legend completely, regardless of the legendStyle configured for individual charts

      legendButtons

    • picker: {
          type: string;
          _get(this: ChartSet): boolean;
          _set(this: ChartSet, v: boolean): void;
      }

      enable/disable picker (value cursor)

      picker

    • plotWidth: {
          type: string;
          _get(this: ChartSet): number;
          _set(this: ChartSet, v: number): void;
      }

      width of the set usable for plotting (width excluding y axes on the outside)

      plotWidth

    • primaryYAxisPosition: { type: string[]; _get(this: ChartSet): any }

      (can only be configured via stylesheet)

      [primaryYAxisPosition=right]

    • ratio: {
          type: string;
          _get(this: ChartSet): number;
          _set(this: ChartSet, v: number): void;
      }

      scale factor affecting the size of the set (0.0 - 1.0)

      ratio

    • resize: {
          type: string[];
          value: string;
          _set(this: ChartSet, v: "fixed" | "dynamic"): void;
      }

      controls the ChartSets resizing behaviour Valid values:

      • ** fixed ** the height of the chartset is fixed
      • ** dynamic ** the height of the chartset can be changed

      [resize=dynamic]

    • secondaryYAxisPlaceholder: { type: string[]; _get(this: ChartSet): any }

      retrieves current y-axis placeholder mode When y-axes are placed on the outside, this option controls if the primary axis is rendered twice if a chart has no secondary y-axis.

      Valid values:

      • ** never ** Placeholder is never shown
      • ** always ** Placeholder is always shown
      • ** ondemand ** Placeholder is only shown when at least one chart has a secondary axis

      (can only be configured via stylesheet)

      [secondaryYAxisPlaceholder=never]

    • snap: { type: string; value: boolean }

      enable/disable automatic snapping to OHLC values or tool handles

      snap

    • snapRange: {
          type: string;
          _get(this: ChartSet): number;
          _set(this: ChartSet, v: number): void;
      }

      range in pixels for automatic snapping

      snapRange

    • width: {
          type: string;
          _get(this: ChartSet): number;
          _set(this: ChartSet, v: number): void;
      }

      width of the set

      width

    • xAxisLayout: { type: string[]; _get(this: ChartSet): any }

      retrieves current x-axis layout

      (can only be configured via stylesheet)

      xAxisLayout

    • xAxisSpacing: { type: string; _get(this: ChartSet): any }

      retrieves the initial amount of blank space between the last value and the yAxis.

      (can only be configured via stylesheet)

      this value is not used by the ChartSet implementation itself; it is just a hint for anyone who creates a layout for this ChartSet. ranges between 0% (no space) and 50% (50% empty space on the right).

      NOTE: displayed spacing might be slightly larger than the requested value due to layout constraints.

      xAxis

    • yAxisLayout: { type: string[]; _get(this: ChartSet): any }

      retrieves current y-axis layout

      (can only be configured via stylesheet)

      yAxisLayout

    Methods

    • Type Parameters

      • Type extends (keyof Object_Events) | (keyof ChartSet_Events)
      • Callback extends
            | (
                (
                    optionName: string,
                    attributeName: string,
                    oldValue: any,
                    newValue: any,
                ) => void
            )
            | ((optionName: string, oldValue?: any, newValue?: any) => void)
            | ((state: ObjectState, flags: ObjectStateEFlags) => void)
            | (() => void)
            | (() => void)
            | ((oldIndex: number, newIndex: number) => void)
            | ((chart: null | Chart) => void)
            | (() => void)

      Parameters

      Returns this

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

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

      Parameters

      Returns any

    • 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

    • Type Parameters

      • Type extends (keyof Object_Events) | (keyof ChartSet_Events)
      • Callback extends
            | (
                (
                    optionName: string,
                    attributeName: string,
                    oldValue: any,
                    newValue: any,
                ) => void
            )
            | ((optionName: string, oldValue?: any, newValue?: any) => void)
            | ((state: ObjectState, flags: ObjectStateEFlags) => void)
            | (() => void)
            | (() => void)
            | ((oldIndex: number, newIndex: number) => void)
            | ((chart: null | Chart) => void)
            | (() => void)

      Parameters

      Returns boolean

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

    • 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 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 sets data object

      Returns Data

    • returns the requested formatter

      available types are:

      • ChartSetEFormatter.NUMBER: generic number formatting. second argument is the precision.
      • ChartSetEFormatter.QUOTE: special quote formatting. second argument is the precision. when using precision 0 numbers like 1,000,000 are formatted as 1.00M etc
      • ChartSetEFormatter.TIME: timestamp formatter; second argument is the format string

      Parameters

      Returns (
          arg0: number,
          arg1?: number | ChartbreakerObject<Record<string, (...args: any) => void>>,
      ) => string

    • returns the requested formatter

      available types are:

      • ChartSetEFormatter.NUMBER: generic number formatting. second argument is the precision.
      • ChartSetEFormatter.QUOTE: special quote formatting. second argument is the precision. when using precision 0 numbers like 1,000,000 are formatted as 1.00M etc
      • ChartSetEFormatter.TIME: timestamp formatter; second argument is the format string

      Parameters

      Returns (
          arg0: number,
          arg1?: string | ChartbreakerObject<Record<string, (...args: any) => void>>,
      ) => null | string | number

    • return the sets current style object

      Returns null | Style

    • returns the translator instance used by this chart must not be cached/stored externally because it can change at any time

      Returns Translator

    • Automatically toggles the EXPOSED flag on dependent options when a 'parent' option changes value.

      For each entry in optionDependencies, whenever the parent option emits an optionChanged event, its dependents (listed in dependentNames) will be exposed (flag added) if the new value === exposeWhen, or hidden (flag removed) otherwise.

      Parameters

      • optionDependencies: OptionExposureRelations

        Map where:

        • key = name of the 'parent' option to watch
        • value = an object with:
          • exposeWhen: the boolean that triggers exposing the dependents or a function with the newValue for custom validation
          • dependentNames: array of dependent option names whose EXPOSED flag will be toggled

      Returns void

      class Test extends ChartbreakerObject {
      constructor() {
      super();
      this.registerOptionDependencyVisibility(new Map([
      ['showLine', { exposeWhen: true, dependentNames: ['lineColor', 'lineStyle'] }],
      ['advancedMode', { exposeWhen: false, dependentNames: ['simpleModeOnlyOption'] }],
      ['description'], { exposeWhen: (text) => !!text.length, ['fontSize', 'fontColor']}
      ]));
      }
      }
    • Type Parameters

      • Type extends (keyof Object_Events) | (keyof ChartSet_Events)
      • Callback extends
            | (
                (
                    optionName: string,
                    attributeName: string,
                    oldValue: any,
                    newValue: any,
                ) => void
            )
            | ((optionName: string, oldValue?: any, newValue?: any) => void)
            | ((state: ObjectState, flags: ObjectStateEFlags) => void)
            | (() => void)
            | (() => void)
            | ((oldIndex: number, newIndex: number) => void)
            | ((chart: null | Chart) => void)
            | (() => void)

      Parameters

      Returns Callback[]

      returns an array of listeners for the specified event.

    • Type Parameters

      • Type extends (keyof Object_Events) | (keyof ChartSet_Events)
      • Callback extends
            | (
                (
                    optionName: string,
                    attributeName: string,
                    oldValue: any,
                    newValue: any,
                ) => void
            )
            | ((optionName: string, oldValue?: any, newValue?: any) => void)
            | ((state: ObjectState, flags: ObjectStateEFlags) => void)
            | (() => void)
            | (() => void)
            | ((oldIndex: number, newIndex: number) => void)
            | ((chart: null | Chart) => void)
            | (() => void)

      Parameters

      Returns this

      alias for addListener

    • Type Parameters

      • Type extends (keyof Object_Events) | (keyof ChartSet_Events)
      • Callback extends
            | (
                (
                    optionName: string,
                    attributeName: string,
                    oldValue: any,
                    newValue: any,
                ) => void
            )
            | ((optionName: string, oldValue?: any, newValue?: any) => void)
            | ((state: ObjectState, flags: ObjectStateEFlags) => void)
            | (() => void)
            | (() => void)
            | ((oldIndex: number, newIndex: number) => void)
            | ((chart: null | Chart) => void)
            | (() => 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.

    • called when an object will be permanently discarded no other methods will be called on it ever again after this point

      IMPORTANT: this method should ONLY be called directly on the Controller all other objects will be destroyed automatically by the implementation

      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 RecoverableChartbreakerError, 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

    • 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

    • request redrawing of all charts

      Parameters

      • Optionaldelay: number

        an optional delay in milliseconds

      • OptionalredrawMode: ERedrawReason
      • Optionalindices: { from: number; to: number }

      Returns void

    • Type Parameters

      • Type extends (keyof Object_Events) | (keyof ChartSet_Events)

      Parameters

      Returns this

      removes all listeners, or those of the specified event.

    • Type Parameters

      • Type extends (keyof Object_Events) | (keyof ChartSet_Events)
      • Callback extends
            | (
                (
                    optionName: string,
                    attributeName: string,
                    oldValue: any,
                    newValue: any,
                ) => void
            )
            | ((optionName: string, oldValue?: any, newValue?: any) => void)
            | ((state: ObjectState, flags: ObjectStateEFlags) => void)
            | (() => void)
            | (() => void)
            | ((oldIndex: number, newIndex: number) => void)
            | ((chart: null | Chart) => void)
            | (() => void)

      Parameters

      Returns this

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

    • 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

    • 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.

    • 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

    • 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