Skip to content

core - documentation.js

Table of Contents

TradeXchart

The root class for the entire chart

start

Target element has been validated as a mount point, let’s start building

Parameters

  • cfg object chart configuration

on

Subscribe to a topic

Parameters

  • topic String The topic name
  • handler Function The function or method that is called
  • context Object The context the function(s) belongs to

off

Unsubscribe from a topic

Parameters

emit

Publish an topic

Parameters

  • topic String The topic name
  • data Object The data to publish

execute

Execute a task

Parameters

  • channel
  • data Object The data that gets published
  • cb Function callback method
  • topic String The topic name

delayedSetRange

When chart is empty postpone range setting until first candle, then position on last

updateRange

Calculate new range index / position from position difference typically mouse drag or cursor keys

Parameters

  • pos array [x2, y2, x1, y1, xdelta, ydelta]

isIndicator

validate indicator

Parameters

  • i class indicator class

setIndicators

import Indicators

Parameters

  • i object indicators {id, name, event, ind}
  • flush boolean expunge default indicators (optional, default false)

Returns any boolean

addIndicator

add an indicator - default or registered user defined

Parameters

  • i string indicator
  • name string identifier (optional, default i)
  • params object {settings, data} (optional, default {})

Returns (Indicator | false) indicator instance or false

getIndicator

retrieve indicator by ID

Parameters

removeIndicator

remove an indicator - default or registered user defined

Parameters

  • i (string | Indicator) indicator id or Indicator instance

Returns boolean success / failure

indicatorSettings

set or get indicator settings

Parameters

  • i (string | Indicator) indicator id or Indicator instance
  • s object settings

Returns boolean success / failure

hasStateIndicator

Does current chart state have indicator

Parameters

  • i string indicator id or name
  • dataset string (optional, default "searchAll")

Returns any indicator or false

create

Create a new TradeXchart instance

Parameters

  • txCfg object chart config (optional, default {})
  • container DOM_element HTML element to mount the chart on
  • state object chart state

Returns instance

destroy

Destroy a chart instance, clean up and remove data

Parameters

  • chart instance

destroy

Stop all chart event processing and remove the chart from DOM. In other words, destroy the chart.

setDimensions

Set chart width and height

Parameters

setPricePrecision

Set the price accuracy

Parameters

  • pricePrecision number Price accuracy

setVolumePrecision

Set the volume accuracy

Parameters

  • volumePrecision number Volume accuracy

addTheme

Add a theme to the chart, if no current theme is set, make this the current one.

Parameters

  • theme object Volume accuracy

Returns instance theme instance

setTheme

Set the chart theme

Parameters

  • ID
  • theme string theme identifier

setStream

specify a chart stream

Parameters

Returns instance

getRange

initialize range

Parameters

  • start number index (optional, default 0)
  • end number index (optional, default 0)
  • config (optional, default {})

setRange

set start and end of range

Parameters

  • start number index (optional, default 0)
  • end number index (optional, default this.rangeLimit)

mergeData

Merge a block of data into the chart state. Used for populating a chart with back history. Merge data must be formatted to a Chart State. Optionally set a new range upon merge.

Parameters

  • merge object merge data must be formatted to a Chart State
  • newRange (boolean | object) false | {start: number, end: number} (optional, default false)
  • calc (optional, default true)

resize

Resize the chart

Parameters

Returns boolean success or failure

refresh

refresh / redraw the chart