Class: Chart

Chart

Chart instance, representing the actual chart being displayed by the CompactChart instance. A Chart will contain an x-axis, one or more y-axes, and one or more panels. Each of these is represented by their own class.

Since:
  • 9.4.0

Type Definitions


CallbackData

Data object passed to CallbackFunction.

Type:
  • object
Properties:
Name Type Argument Description
qc CompactChart <optional>

Compact Chart instance.

action string <optional>

If applicable, action performed that triggered the callback.

appending boolean <optional>

If applicable, indicate data is supplementing end of existing data.

appendToDate Date <optional>

If applicable, date to truncate existing data to so new data can be added from that date onward.

force boolean <optional>

If applicable, whether to force a load of new data after periodicity change.

prevPeriodicity Periodicity <optional>

If applicable, periodicity before the change.

symbol string <optional>

If applicable, symbol that triggered the callback.

Since:
  • 9.4.0


CallbackFunction( [data])

Listener function for CompactChart#addCallbackListener.

Parameters:
Name Type Argument Description
data CallbackData <optional>

Data object passed to listener function.

Since:
  • 9.4.0


ChartConfig

All configurations, including themeing, relating to the chart object go here. The chart object controls anything going on the canvas, though the x-axis and y-axis can be configured specifically in their own sections. Note: The ChartInit object this inherits from has all optional properties.

Type:
Properties:
Name Type Argument Description
color string <optional>

Default color for rendering.

backgroundColor string

Background color for chart.

gaplines GapFillTheme | string | boolean <optional>

Default configuration for gap rendering.

Since:
  • 9.4.0


ChartInit

Properties relating to the chart that are set by default to certain values. The chart object controls anything going on the canvas, though the x-axis and y-axis can be configured specifically in their own sections.

Type:
  • object
Properties:
Name Type Argument Default Description
candleColorByDirection boolean <optional>

Up/Down colors used for bar charts are determined based on the previous close. Set this flag to true to base it on the bar's open.

candleWidthPercent number <optional>
0.65

Ratio of candle body width to reserved area for the record. Note setting to 1 will cause adjacent candles to touch.

cleanupGaps string <optional>
<nullable>

Determines how gaps in the data are treated in the rendering. Not yet implemented.

currentPriceLine boolean <optional>

Set to true to enable the dotted line that appears across the chart at the current price position when looking at current data.

dataZone string <optional>
<nullable>

Specifies the time zone of the data in masterData, default is local time.

decimalPlaces number | DecimalPlacesFunction <optional>

Specifies minimum number of decimals to display on y-axes, can be overridden by setting on y-axis config.

defaultPlotField string <optional>
'Close'

The field which contains the data used to draw a line chart.

displayZone string <optional>
<nullable>

Specifies the time zone of the display (x-axis), default is local time.

dontRoll boolean <optional>

Set to true to accept weekly or monthly data from the quotefeed, otherwise this is rolled up from daily data.

extendLastTick boolean <optional>
<nullable>

For line-type charts, extend the line to the current date if the last point is in the past. Setting can be overridden by setting in line/mountain configuration.

focusable boolean <optional>

Set to true to enable focus on the chart container.

includeOverlaysInMinMax boolean <optional>

Set to false to exclude study data from computing the minimum/maximum y-axis values to display.

initialWhitespace number <optional>
60

Pixels to pad the right side of the chart.

label boolean <optional>
<nullable>

Set to true to force all axis labels to show on all plots, set to false to not show by default (but can be overridden by renderer config setting).

lineApproximation boolean <optional>

Set to false to prevent optimization of line drawing when minimum candleWidth < 1.

lockScroll boolean <optional>

Set to true to prevent y-axis scrolling when chart is panned.

maxDataSetSize number <optional>
20000

Maximum number of records to keep in data set.

maxTicks number <optional>

Initial number of bars to show on the chart, if not automatically calculated.

maximumCandleWidth number <optional>
100

Maximum width allowed for a bar in pixels.

minimumCandleWidth number <optional>
1

Minimum width allowed for a bar in pixels.

minimumZoomTicks number <optional>
9

Minimum number of bars allowed on a screen when zooming in.

noWicksOnCandles Array.<string> <optional>

List of chart types which should not have wicks drawn on their candles.

preserveCandleWidthOnResize boolean <optional>

Set to true to lock candle width when resizing the chart, otherwise number of bars is locked.

scroll number <optional>

Initial number of bars back to start on the left of the chart, if not automatically calculated.

tension number <optional>
<nullable>

Set to a number between 0 and 1 to draw smooth curves between data points.

useInflectionPointForIntraday boolean <optional>

Set to true to cause consolidation to occur from the point on the left of the span.

yaxisPaddingLeft number <optional>
<nullable>

If set, will control width of left y-axis. Setting to 0 will cause floating effect.

yaxisPaddingRight number <optional>
<nullable>

If set, will control width of right y-axis. Setting to 0 will cause floating effect.

Since:
  • 9.4.0 Introduced
  • 10.1.0 added decimalPlaces, label and extendLastTick.

ColorFunction(qc, quote, isGap)

Returns a color given a set of conditions.

Parameters:
Name Type Description
qc CompactChart

The CompactChart instance.

quote DataRecord

A quote record to examine. A DataRecord is an internal object which represents data for a specific time.

isGap boolean

Whether the record represents a gap in the data.

Since:
  • 9.4.0

Returns:

A color or color object, or null.

Type
LineTheme | string | null

DataRecord

Record that holds data for a given time. The data can take the form of many different objects. The key can be either a symbol, under which another data object is found, or a study value, or a meta field for the data. The following fields will always be present at the top level:

Type:
  • Record.<string, *>
Properties:
Name Type Description
dT Date

Date of record.

tick number

Tick number, this matches the index of this record in the data set.

Since:
  • 9.4.0


DecimalPlacesFunction( [masterData] [, symbolObject])

Function used to determine number of decimal places to display on y-axis. This is set in the ChartInit when the number of decimals depends on the symbol or the actual data present. If the decimal places is to be a constant, do not set this function.

Parameters:
Name Type Argument Description
masterData Array.<MasterRecord> <optional>

Data records.

symbolObject object <optional>

A symbol object.

Properties
Name Type Description
symbol string

Ticker symbol.

Since:
  • 10.1.0

Returns:

Number of decimal places do display.

Type
number

GapFillTheme

Defines an object that represents the rendering of a gap area on the chart.

Type:
Properties:
Name Type Argument Description
fillMountain boolean <optional>

True to fill in underneath the gap region of a mountain chart.

Since:
  • 9.4.0


LineTheme

Defines an object that represents the rendering of a line.

Type:
  • object
Properties:
Name Type Argument Default Description
color string

Line color in a valid css format.

pattern 'solid' | 'dashed' | 'dotted' | Array.<number> <optional>
'solid'

Line pattern expressed either as "solid", "dashed", "dotted"; or an array of numbers representing number of pixels to turn plotter on and off.

width number <optional>
1

Line width in pixels.

Since:
  • 9.4.0


MasterRecord

Aggregated data from data sources, which is eventually formatted, considated, and used to create a data set. Data is stored in an array, and a Master Record represents the data for one point in time.

Type:
Properties:
Name Type Argument Description
dT Date

The date of the record.

displayDate Date <optional>

Date in user-selected time zone (internally generated).

consolidatedTicks number <optional>

Number of ticks consolidated into this record (internally generated).

_key_ MasterRecord | undefined

Any symbol representing fields of data. There can be multiple keys, each unique to a security. If the key is the symbol, such as "IBM" or "ORCL", then the value will be a MasterRecord but with all fields optional.

_field_ number

Any field representing data. There can be multiple field keys, each unique to a data point, such as "Close", "High".

Since:
  • 9.4.0