@kumo-charts/core
API 레퍼런스는 소스 코드의 주석에서 생성되며 영어로만 제공됩니다.
import { … } from '@kumo-charts/core';
Functions
canBuildTimeframefunction소스
function canBuildTimeframe(timeframe: IntervalInput, source: IntervalInput): boolean
Whether bars of timeframe can be built from bars of the source interval: a multiple of it,
or days, weeks and months from bars that divide a day. canBuildTimeframe('4h', '1h') is true.
checkColorfunction소스
function checkColor(path: string, value: unknown): string
Checks a color as the chart takes it: hex, rgb() or rgba(), or any other CSS color the
browser's canvas paints. Without a canvas, as in Node, nothing is painted, and any text is
taken.
checkTimeframefunction소스
function checkTimeframe(timeframe: IntervalInput, source: IntervalInput): void
Throws unless bars of timeframe can be built from bars of the source interval, saying why,
as chart.setTimeframe() does: checkTimeframe('1W', '2D') throws, as weeks are built from
1D bars.
createCalendarfunction소스
function createCalendar(input: CalendarInput = {}): Calendar
Creates the calendar the chart uses to build timeframes, for aligning your own data. Options
are those of the chart's calendar option; timeZone defaults to UTC, as there.
const calendar = createCalendar({ timeZone: 'Asia/Shanghai', sessions: ['09:30-11:30', '13:00-15:00'] });
calendar.bucket('2024-05-06T02:15:00Z', '1h'); // 09:30 Shanghai time, the bar 10:15 falls increateChartfunction소스
function createChart<const M extends readonly ChartModule[] = readonly []>(
container: HTMLElement,
options?: CreateChartOptions<M>
): Chart<M>
Creates a chart inside container with the given modules. The chart fills the container and
follows its size unless autoSize is off.
const chart = createChart(document.getElementById('chart')!, {
modules: [indicators(allIndicators)],
locale: 'zh-CN'
});
chart.data.set(bars);
chart.indicators.add({ type: 'MACD' });createModulefunction소스
function createModule<
Types extends ModuleTypes = ModuleTypes,
Api extends object = NonNullable<Types['api']>
>(definition: ModuleDefinition<Types, Api>): ChartModule<Types & { readonly api: Api }>
A module of an application or another package, such as one registering its own indicator or
drawing types: install runs on the chart once the chart and the library's modules given with it
are there, before the chart uses its options, so the options can use the types it registers.
What it returns joins the chart as namespaces, e.g. { footprint: footprintApi } becomes
chart.footprint. A module may add a section of options, emit events of its own and keep a
part of the saved state; Types says what it adds, as ChartModule<Types> does. Without
Types, the namespaces are those install returns.
interface StampTypes {
api: { stamp: { count(): number } };
options: { stamp: { text: string } };
events: { stampChange: { text: string } };
}
const stamp = createModule<StampTypes>({
name: 'stamp',
options: { key: 'stamp', defaults: () => ({ text: '' }), validate: () => {} },
install: (chart, context) => {
chart.on('optionsChange', ({ options, previous }) => {
if (options.stamp.text !== previous.stamp.text) {
context.emit('stampChange', { text: context.options().text });
}
});
return { stamp: { count: () => context.options().text.length } };
}
});formatIntervalfunction소스
function formatInterval(interval: IntervalInput): string
The canonical shorthand of an interval: 15s, 5m, 4h, 1D, 1W, 3M.
intervalDurationfunction소스
function intervalDuration(interval: IntervalInput): number | null
The length in milliseconds of an interval of seconds, minutes or hours, such as '15m';
null for days, weeks and months, whose lengths the trading calendar gives.
parseBarfunction소스
function parseBar(input: BarInput, label = 'bar', index?: number): Bar
Checks a bar as the chart does and returns it normalized: the time in epoch milliseconds and
the volume 0 when absent. Errors name the bar label, or label[index] with an index, such
as bars[3].high must be a finite number, received null.
parseIntervalfunction소스
function parseInterval(input: IntervalInput, label = 'interval'): Interval
Parses an interval such as '5m', '4h', '1D' or { unit: 'week', count: 1 }. Throws a
ChartError for anything else.
withAlphafunction소스
function withAlpha(color: string, alpha: number): string
Returns color with its alpha multiplied by alpha.
Classes
ChartErrorclass소스
class ChartError extends Error
Error thrown for every invalid argument, unknown id or illegal state reported by the library.
override readonly name = 'ChartError'constructor(message: string)Interfaces
AreaStyleinterface소스
interface AreaStyle
lineColor: stringlineWidth: numbertopColor: stringbottomColor: stringBarinterface소스
interface Bar
A normalized candlestick. time is epoch milliseconds.
readonly time: numberreadonly open: numberreadonly high: numberreadonly low: numberreadonly close: numberreadonly volume: numberBarColorContextinterface소스
interface BarColorContext
What mainSeries.barColor receives for one bar.
readonly index: numberIndex of the displayed bar.
readonly bar: Barreadonly indicator: (id: string, key?: string) => numberOutput key (default: the first) of an indicator drawn on this bar; NaN where it has none.
BarInputinterface소스
interface BarInput
A candlestick as accepted by the data APIs.
BarsChangeEventinterface소스
interface BarsChangeEvent
The displayed bars changed: data was set, streamed or prepended, the timeframe or transform changed, or a replay revealed or hid bars.
readonly change: BarChangetail: only bars from from on changed or were appended; reset: any bar may have.
BarsViewinterface소스
interface BarsView
Read-only, columnar access to bars, for plugins and custom drawings. Accessors take an index
from 0 to length - 1.
readonly length: numberreadonly revision: numberChanges whenever the bars change; key caches by it.
time(index: number): numberopen(index: number): numberhigh(index: number): numberlow(index: number): numberclose(index: number): numbervolume(index: number): numberbar(index: number): Bar | nullThe bar at index, or null outside the bars.
lowerBound(time: number): numberFirst index whose time is at or after time, or length when every bar is earlier.
BarTransformDefinitioninterface소스
interface BarTransformDefinition<P extends object = Record<string, unknown>>
Builds the displayed bars from the bars of the timeframe, such as Heikin-Ashi candles or Renko
bricks. Register custom transforms with chart.transforms.register().
readonly type: stringThe type the transform is set by, such as renko.
readonly name: stringDisplay name, such as Renko.
readonly keepsTime: booleanWhether every input bar becomes one output bar with the same time, like Heikin-Ashi. The chart then keeps the features that rely on the timeframe, such as the bar countdown.
create(params: P, input: BarsView, from: 'bars' | 'trades'): BarTransformStreamValidates the parameters and starts a stream. input holds the bars the stream is about to
receive, for statistics such as an automatic box size; from says what they are, the bars of
the timeframe or the trades. The chart calls it again whenever the input is rebuilt (new
data, timeframe, history or replay start); appended and updated bars resume the running
stream.
BarTransformInputinterface소스
interface BarTransformInput
type: stringparams?: Record<string, unknown>input?: 'bars' | 'trades'What the transform reads: bars, the bars of the timeframe (default), or trades, every
trade passed to data.addTrades() that the chart keeps (performance.maxTrades), each as a
bar whose open, high, low and close are its price and whose volume is its size.
BarTransformStateinterface소스
interface BarTransformState extends Required<BarTransformInput>
The transform building the displayed bars, as chart.transforms.get() reports it.
resolved: Readonly<Record<string, unknown>> | nullThe parameters the bars are built with, as the transform reports them: defaults and sizes
worked out from the bars filled in, such as { reversal: 2500 } for Kagi lines whose
reversal follows the average true range. null for transforms that do not report them, and
while the bars do not tell them yet.
BarTransformStreaminterface소스
interface BarTransformStream
A running transform: receives the input bars in order and builds the output bars.
Takes the next input bar; returns the output bars it completed, oldest first. A transform
built from the trades gets the side of each trade's taker, null when unknown; one built
from bars gets null.
current(): Bar | nullThe output bar still forming after the latest input bar, or null.
clone(): BarTransformStreamAn independent copy, which the chart uses to resume from before the latest input bar.
resolved?(): Readonly<Record<string, unknown>> | nullThe parameters the stream builds with, defaults and sizes worked out from the bars filled
in, such as { box: 2500, reversal: 3 } for an automatic box; null while the bars do not
tell them yet. Optional: transforms.get() reports them as resolved, and a series type
drawing the transform's bars reads them, as point & figure reads its box size.
BaselineStyleinterface소스
interface BaselineStyle
baseValue: number | nullValues above it use the top colors. null uses the first visible value.
lineWidth: numbertopLineColor: stringtopFillColor: stringbottomLineColor: stringbottomFillColor: stringButtonClickEventinterface소스
interface ButtonClickEvent
A button in the label of an object, such as an order or an alert, was clicked.
Calendarinterface소스
interface Calendar
Buckets times into bars of any interval, following a trading calendar.
bucket(time: TimeInput, interval: IntervalInput): number | nullStart of the bar of interval that time belongs to, or null when the calendar drops it.
range(time: TimeInput, interval: IntervalInput): CalendarRange | nullThe bar of interval that time belongs to and the run of times around time that belong
to it too, or null when the calendar drops the time. Every time from start up to end
has the same bucket, so a caller going through times in order asks again only from end
on. A bar can take several runs, such as a day bar its morning and afternoon sessions. The
run is the millisecond of time alone with the bucket option, whose results cannot be
foreseen, and where a daylight-saving change comes close to a bar boundary.
CalendarOptionsinterface소스
interface CalendarOptions
The trading calendar that aggregates source bars and trades into timeframes.
timeZone: stringZone the trading calendar is defined in, as the data times its bars: UTC (the default), as
crypto exchanges do, or the zone of an exchange, such as America/New_York. The chart's
timeZone only shows the times.
sessions: readonly string[]Trading sessions of a trading day as 'HH:MM-HH:MM'; an end before its start crosses
midnight. Times outside every session are dropped. Empty: trading around the clock.
dayStart: stringWall-clock time a trading day starts. From this time on, times belong to the next date, e.g.
'21:00' for night sessions or '17:00' for FX.
weekdays: readonly number[]Weekdays that are trading days (0 = Sunday). A trading date on another weekday moves to the next trading weekday, so a Friday night session belongs to Monday.
weekStart: numberFirst day of a week bar (0 = Sunday).
bucket: CalendarBucket | nullCalendarRangeinterface소스
interface CalendarRange
A run of times that the calendar puts into one bar, from Calendar.range.
readonly bucket: numberStart of the bar, as bucket() returns it.
readonly start: numberThe first time of the run.
readonly end: numberThe end of the run, excluded.
CandleStyleinterface소스
interface CandleStyle
upColor: stringdownColor: stringupWickColor: stringdownWickColor: stringupBorderColor: stringdownBorderColor: stringwick: booleanborder: booleanbodyRatio: numberBody width as a fraction of the bar spacing.
hollowUp: booleanCandles that close above their open are drawn hollow, their bodies outlined in upBorderColor
whether border is on or not, as many traders read them. Candles and volume candles. Default
false.
hollowDown: booleanCandles that close below their open are drawn hollow, outlined in downBorderColor. Default false.
ChartBaseinterface소스
interface ChartBase<Options = unknown, Events = unknown, State = unknown>
The chart without the namespaces of its modules, which Chart adds.
readonly element: HTMLElementThe element the chart created inside its container.
options(): Readonly<ChartOptions & Options>The resolved options.
applyOptions(options: DeepPartial<ChartOptions & Options>): voidDeep-merges option changes; arrays and functions are replaced.
layout(): LayoutRectangles of the panes, the price axis and the time axis, for positioning custom overlays.
legendBounds(paneId?: string): Rect | nullWhere the legend of a pane (the main one by default) was last painted, in CSS pixels as layout() gives them, such
as for a button under it; null while it shows no row there.
resize(width: number, height: number): voidSets the size in CSS pixels; with autoSize the container size wins on its next change.
batch(operation: () => void): voidRuns several API calls and dispatches their events once afterwards.
on<K extends keyof (ChartEventMap & Events)>(
type: K,
listener: (event: (ChartEventMap & Events)[K]) => void
): Unsubscribereadonly data: DataApireadonly transforms: TransformsApireadonly timeScale: TimeScaleApipriceScale(paneId?: string, scaleId?: string): PriceScaleApiA price scale of a pane (default: the main pane): right (default), left, or an overlay
scale named by the series and indicators placed on it.
readonly panes: PanesApireadonly series: SeriesApireadonly crosshair: CrosshairApireadonly plugins: PluginsApimodules(): string[]The names of the chart's modules, in the order they were given.
select(selection: Selection | null): voidSelects a drawing, order, alert or marker, or clears the selection with null.
selection(): Selection | nullThe selected object, or null.
saveState(): ChartState & StateThe user-editable layout: main series type, view, panes, and what the modules keep.
loadState(state: ChartState): voidRestores a saved layout atomically; an invalid state throws and changes nothing.
screenshot(): HTMLCanvasElementRenders pending changes and returns a canvas with the whole chart; an empty one when the chart has no size, as in a container that is hidden.
destroy(): voidRemoves the chart's element and releases every listener, observer and timer. Every other call on the chart throws afterwards, a read as well as a change; calling it again does nothing.
ChartEventMapinterface소스
interface ChartEventMap
crosshairMove: CrosshairMoveEventvisibleRangeChange: VisibleRangeChangeEventloadMore: LoadMoreEventclick: ChartPointerEventdoubleClick: ChartPointerEventcontextMenu: ChartPointerEventListening suppresses the browser's context menu over the chart.
selectionChange: SelectionChangeEventpaneResize: PaneResizeEventbuttonClick: ButtonClickEventlegendButtonClick: LegendButtonClickEventbarsChange: BarsChangeEventtypesChange: TypesChangeEventReports every registration, by the API too: no one feeds it back.
optionsChange: OptionsChangeEventChartModuleinterface소스
interface ChartModule<Types extends ModuleTypes = ModuleTypes>
A part of the chart beyond its core, such as indicators or drawings, given to
createChart(container, { modules }). Each module adds its namespace to the chart, e.g.
chart.indicators, and may add options and events.
readonly name: stringUnique among the modules of a chart, such as indicators.
readonly '~types'?: TypesWhat the module adds, for the chart's types only: never set.
ChartOptionsinterface소스
interface ChartOptions
autoSize: booleanFollows the container size with a ResizeObserver. When false, call chart.resize().
locale: string | nullBCP 47 locale for numbers and dates; null (default) uses the runtime's.
timeZone: string | nullIANA time zone such as Asia/Shanghai; null (default) uses the local time zone.
theme: ThemeThe chart's colors: lightTheme by default, or darkTheme, or one of your own.
font: FontOptionsgrid: GridOptionscrosshair: CrosshairOptionsmainSeries: MainSeriesOptionstimeScale: TimeScaleOptionspriceScale: PriceScaleOptionslatestPrice: LatestPriceOptionslegend: LegendOptionsinteraction: InteractionOptionspanes: PaneOptionscalendar: CalendarOptionsperformance: PerformanceOptionstexts: TextOverrides<ChartTexts>Overrides of the words the chart paints, such as the legend's labels; null keeps a word.
ChartPlugininterface소스
interface ChartPlugin
Extends a chart from the outside: paints in the panes and uses the public API, e.g. to
register drawing types or listen to events. Add it with chart.plugins.add().
readonly name: stringUnique among the chart's plugins.
attach?(host: PluginHost): voidCalled when the plugin is added.
detach?(): voidCalled when the plugin is removed or the chart is destroyed.
paint?(context: PluginPaintContext): voidCalled for every pane, once per layer, whenever the chart repaints its series.
ChartPointerEventinterface소스
interface ChartPointerEvent
A click, double click or context menu on the chart.
readonly x: numberCSS pixel position inside the chart.
readonly y: numberreadonly area: ChartAreareadonly paneId: string | nullThe pane whose plot or price axis is under the pointer.
readonly scaleId: string | nullOver a price axis, its scale, such as right or left, for chart.priceScale().
readonly index: number | nullLogical bar index under the pointer, over a plot or the time axis.
readonly time: number | nullreadonly price: number | nullThe value at y in the pane's scale, or in the scale of the price axis under the pointer.
readonly target: ObjectTarget | nullChartStateinterface소스
interface ChartState
The user-editable layout of a chart: main series type, view and panes, and what the modules
keep of theirs under their keys, such as indicators and drawings. Market data, series,
orders, markers and alerts belong to the application and are not included.
readonly version: 1readonly mainSeries: { readonly type: SeriesType; readonly source: PriceSource }readonly transform?: BarTransformInput | nullThe transform building the displayed bars, such as Renko, or null for the bars of the
timeframe. saveState() always writes it; a state without it leaves the transform as it is.
readonly view: { readonly barSpacing: number; readonly offset: number }readonly panes: ReadonlyArray<{
readonly id: string;
readonly title: string;
readonly height: number;
readonly auto: boolean;
readonly mode: PriceScaleMode;
readonly inverted: boolean;
/** Manual range in scale space, or `null` while auto-scaling. */
readonly range: PriceRange | null;
/** The right scale's margins, or `null` to follow `priceScale.margins`. */
readonly margins?: ScaleMargins | null;
/** The left and overlay scales. */
readonly scales?: ReadonlyArray<SavedScale>;
}>readonly [part: string]: unknownWhat the modules keep, by their keys.
ChartTextsinterface소스
interface ChartTexts
Words the chart paints on the canvas, alike in every language unless they are set.
legendOpen: stringLabels of the main series' open, high, low, close and volume in the legend: O, H, …
legendHigh: stringlegendLow: stringlegendClose: stringlegendVolume: stringdays: (count: number) => stringWhole days of the countdown to the bar's close, 2d in 2d 03:15:00.
CollectionApiinterface소스
interface CollectionApi<Input, Item>
What the API offers of a collection of objects drawn on the objects layer.
set(inputs: readonly Input[]): voidReplaces every object, e.g. with the latest state from the broker. An invalid input throws and changes nothing.
add(input: Input): stringAdds an object and returns its id: the one it has, or one the chart numbers for it.
update(id: string, patch: Partial<Omit<Input, 'id'>>): voidChanges an object; what the patch leaves out stays. Throws for an unknown id.
remove(id: string): voidThrows for an unknown id.
clear(): voidRemoves every object.
get(id: string): Item | nullThe object of an id, or null.
list(): Item[]Every object, in the order they were added.
ColumnsStyleinterface소스
interface ColumnsStyle
upColor: stringdownColor: stringbase: number | nullColumns grow from this value; null from the bottom of the pane, as price columns do, and
so does a value the scale cannot show, such as 0 on a logarithmic one.
widthRatio: numberColumn width as a fraction of the bar spacing.
CrosshairApiinterface소스
interface CrosshairApi
get(): CrosshairState | nullWhere the crosshair is, or null while it is hidden.
set(position: { time: TimeInput; price?: number; pane?: string } | null): voidShows the crosshair at a time (and optionally a value of a pane) without a pointer, for
example to mirror another chart, or hides it with null. Pointer movement takes over again.
CrosshairLabelOptionsinterface소스
interface CrosshairLabelOptions
The crosshair's labels on the axes, of the time and the price at it.
visible: booleanpriceLines: CrosshairPriceLines | nullLines of text under the price label on the right price axis, such as how far the price is from the latest: given
the price at the pointer and the id of its pane, in the label's colors, the whole label centered on the pointer.
None, or null, for the price alone.
avoidLatest: booleanKeeps the price label on the right price axis clear of the labels there of the latest price and the latest values: where it would cover them it sits against them, above or below, on the side of the pointer, and stays there as the pointer moves over them. Otherwise it is at the pointer, over them.
CrosshairOptionsinterface소스
interface CrosshairOptions
mode: 'magnet' | 'free'magnet snaps the horizontal line to the close of the hovered bar.
vertical: booleanhorizontal: booleanstyle: LineStylesnapToBars: booleanPuts the vertical line on the middle of the bar under the pointer, so that it steps from bar to bar; off, it follows the pointer smoothly, its time label and the legend those of the bar under it all the same.
labels: CrosshairLabelOptionssyncedOpacity: numberHow opaque the crosshair is where the code sets it (crosshair.set()), such as the one another chart's pointer
shows on a chart synced to it: its lines and its labels, from 0 to 1. Lighter than the pointer's own, it does not
draw the eye from the chart the user is on.
CrosshairStateinterface소스
interface CrosshairState
Where the crosshair points.
readonly x: numberCSS pixel position inside the chart.
readonly y: numberreadonly paneId: string | nullPane under the pointer, or null over the time axis.
readonly index: numberLogical bar index under the pointer; may lie beyond the data.
readonly time: number | nullreadonly price: number | nullValue at y in the pane's scale, or null outside the panes.
readonly bar: Bar | nullThe hovered bar, or null outside the data.
DataApiinterface소스
interface DataApi
The main OHLCV series. Writes go to the source data; reads return the displayed bars, aggregated to the timeframe and clipped by a running replay. Inputs are validated and copied; the chart never mutates them.
set(bars: readonly BarInput[], options?: DataSetOptions): voidReplaces the source bars. Bars must be sorted by strictly ascending time. The view stays where it is, at its zoom: following the latest bar, the new latest bar shows where the old one did; looking back at history, the time at the right edge of the plot stays there, as far as the bars reach.
Streams source bars: a bar with the time of the last bar replaces it, newer bars are
appended. Older bars are rejected; use set() or prepend() for history.
addTrades(trade: TradeInput | readonly TradeInput[]): numberStreams trades, folded into the source bars: a trade in the last bar's period updates it, a later one opens a new bar. Needs a source interval. Trades the calendar drops (outside the sessions) are skipped, and so are late ones, before the last bar or the latest trade, as a stream may deliver after it reconnects; returns how many were applied.
prepend(bars: readonly BarInput[]): numberAdds older source bars before the first one, typically in response to loadMore. Bars at or
after the current first bar are ignored. Returns how many bars were inserted.
clear(): voidRemoves the bars and ends a running replay; the source interval and timeframe stay.
sourceInterval(): Interval | nullResolution of the source bars, or null when they are displayed as given.
calendar(): CalendarThe trading calendar the chart builds timeframes with: the calendar option, in the chart's
timeZone unless it names one. A new one once the options change; read it when needed.
timeframe(): Interval | nullThe displayed timeframe, or null for the source resolution.
setTimeframe(timeframe: IntervalInput | null): voidDisplays the source bars aggregated to a coarser timeframe, or at the source resolution with
null. Needs a source interval; the timeframe must be built from whole source bars. The view
stays where it is in time, as with set().
readonly length: numberNumber of displayed bars.
readonly bars: BarsViewThe displayed bars as a read-only, columnar view, without copying.
readonly source: BarsViewThe source bars as a view: up to the cursor while replaying, at the source interval.
at(index: number): Bar | nulllast(): Bar | nullindexOf(time: TimeInput): numberIndex of the displayed bar with exactly this time, or -1.
toArray(): Bar[]DataSetOptionsinterface소스
interface DataSetOptions
interval?: IntervalInputResolution of the bars, such as '1m'. Declaring it lets the chart build coarser
timeframes and fold trades into bars through the trading calendar. Bars of minutes and hours
must start where the calendar starts one, or they throw; bars of days, weeks and months go by
their trading date. Without it the bars are displayed as given.
FontOptionsinterface소스
interface FontOptions
family: stringsize: numberAxis and label font size in CSS pixels.
GridOptionsinterface소스
interface GridOptions
HighLowStyleinterface소스
interface HighLowStyle
upColor: stringdownColor: stringlineWidth: numberHlcAreaStyleinterface소스
interface HlcAreaStyle
highColor: stringlowColor: stringcloseColor: stringhighFillColor: stringBetween the highs and the closes.
lowFillColor: stringBetween the closes and the lows.
lineWidth: numberInteractionOptionsinterface소스
interface InteractionOptions
pan: booleanDrag the plot to scroll through time.
wheelZoom: booleanMouse wheel and trackpad zoom.
pinchZoom: booleanTwo-finger pinch zoom on touch screens.
axisScale: booleanDrag the axes to scale them; double-click the price axis to reset auto-scale.
kineticScroll: booleanKeeps scrolling briefly after a quick pan is released.
keyboard: booleanArrow keys, +/-, Delete, Escape and undo/redo shortcuts while the chart has focus.
longPressMs: numberTouch press duration that switches a touch into crosshair mode.
touchMagnifier: booleanShows a magnifying loupe above the finger while placing anchors or dragging objects by touch.
hitTolerance: numberPointer distance in CSS pixels that counts as a hit on an object, such as a drawing.
Intervalinterface소스
interface Interval
A bar resolution, such as 5 minutes or 1 day.
readonly unit: IntervalUnitreadonly count: numberA positive integer.
KagiStyleinterface소스
interface KagiStyle
Kagi lines: yang (thick) from where a line passes the last shoulder, yin (thin) under the last waist.
upColor: stringYang lines.
downColor: stringYin lines.
upWidth: numberdownWidth: numberLabelDragEventinterface소스
interface LabelDragEvent
readonly id: stringreadonly phase: DragPhasereadonly position: numberWhere along its line the label is at this phase, from 0 at the left of the plot to 1 at its right (where it was for cancel).
readonly initialPosition: numberWhere it was before the drag started.
LatestPriceOptionsinterface소스
interface LatestPriceOptions
line: booleanlabel: booleancountdown: booleanShows the time left until the current bar closes under the price label, for bars of periods of time, not while replaying, and not once the bar has closed.
style: LineStylecolor: string | nullColor of the line and the label; null follows the latest bar, rising or falling, in the
main series' colors.
Layoutinterface소스
interface Layout
width: numberheight: numberplotWidth: numberaxisWidth: numberleftAxisWidth: numberWidth of the left price axis; 0 without one.
panes: PaneLayout[]separators: SeparatorLayout[]timeAxis: Rect | nullLegendButtoninterface소스
interface LegendButton
A button of a legend row.
readonly id: stringreadonly icon: stringSVG path data drawn in a 24 × 24 box, e.g. from an icon set.
LegendButtonClickEventinterface소스
interface LegendButtonClickEvent
A button of a legend row was clicked.
readonly item: LegendItemreadonly buttonId: stringLegendExtraRowinterface소스
interface LegendExtraRow
A row of the application's own in the legend, such as of what it draws apart from the indicators.
readonly id: stringNames the row in rows, buttons and legendButtonClick, where its item is of kind extra.
readonly type?: stringWhat it stands for, for rows and buttons to tell rows apart, such as VPVR.
readonly paneId: stringThe pane whose legend lists it, after its indicators.
readonly visible: booleanHidden, it is listed only if rows asks for it, dimmed.
readonly title: stringWhat the row says, in the color of the titles.
LegendIteminterface소스
interface LegendItem
A row of the legend: the main series, an indicator, a series added to the chart, or a row of the application's own
(extraRows).
readonly kind: 'main' | 'indicator' | 'series' | 'extra'readonly id: stringThe id of the indicator, the series or the application's row; main for the main series.
readonly type: string | nullThe indicator's type, or the type the application gave its row; null for the others.
readonly paneId: stringreadonly visible: booleanHidden indicators and series are listed only if rows asks for them, dimmed.
LegendOptionsinterface소스
interface LegendOptions
visible: booleanShows the OHLC values and indicator values of the hovered (or latest) bar in each pane.
rows: ((item: LegendItem) => boolean) | nullWhich rows to list, the main series' row of its values among them; null (default) lists the
main series and the visible indicators and series. List hidden ones too, and they show dimmed,
e.g. for a button that shows them again; leave the main series out to put its values away.
buttons: ((item: LegendItem) => readonly LegendButton[]) | nullButtons shown after the title of the row under the pointer, such as hide, settings and remove.
A click emits legendButtonClick. null (default) shows none.
extraRows: (() => readonly LegendExtraRow[]) | nullRows of the application's own, listed after the indicators of their pane as rows and
buttons have them, such as of what it draws over the bars apart from the indicators, to set
or remove it from its buttons. null (default) adds none.
hideValuesOnHover: booleanHides the values of the row under the pointer while its buttons show.
top: numberRoom above the legend of the main pane, in CSS pixels, for what the application shows over
the chart there, such as buttons to trade. Default 0.
LineMarkersStyleinterface소스
interface LineMarkersStyle extends LineSeriesStyle
markerRadius: numberLineSeriesStyleinterface소스
interface LineSeriesStyle
LoadMoreEventinterface소스
interface LoadMoreEvent
The view approaches the oldest bar: load bars before before and pass them to data.prepend().
readonly before: numberThe time of the first source bar: older bars go before it.
readonly bars: numberHow many more of the bars shown the view wants before the first: those it lacks of
loadMoreThreshold, and the room left empty on the left. Bars built from many, as Kagi lines
or Renko bricks are, need as many more source bars as each takes.
LogicalRangeinterface소스
interface LogicalRange
from: numberLogical index at the left edge of the plot. Bar i is centered on index i.
to: numberLogical index at the right edge of the plot.
MainSeriesOptionsinterface소스
interface MainSeriesOptions
type: SeriesTypeA built-in series type such as candles, line or area, or a registered custom type.
source: PriceSourceThe price a line-like main series plots.
styles: SeriesStyleOverridesStyle overrides keyed by series type, so switching types keeps each type's style.
barColor: ((bar: BarColorContext) => string | null) | nullColors single bars: return a color, or null for the style's up or down color. Called for
every visible bar when the chart repaints; candles, hollow candles, OHLC and high-low bars
use it.
ModuleContextinterface소스
interface ModuleContext<Types extends ModuleTypes = ModuleTypes>
What a module made with createModule() gets, beside the chart, as it joins one.
options(): NonNullable<Types['options']>[keyof NonNullable<Types['options']>]The module's section of the chart's options, as they are now; a module without one throws.
emit<K extends keyof NonNullable<Types['events']> & string>(
type: K,
event: NonNullable<Types['events']>[K]
): voidEmits one of the module's events to the listeners chart.on() registers.
keepState<K extends keyof NonNullable<Types['state']> & string>(
part: ModuleStatePart<K, NonNullable<NonNullable<Types['state']>[K]>>
): voidKeeps a part of the chart's layout in its saved state, which loadState() brings back.
ModuleDefinitioninterface소스
interface ModuleDefinition<
Types extends ModuleTypes = ModuleTypes,
Api extends object = NonNullable<Types['api']>
>
A module of an application or another package, as createModule() takes it.
readonly name: stringUnique among the modules of a chart.
readonly options?: ModuleOptionsOf<Types>install(chart: Chart, context: ModuleContext<Types>): Api | undefinedJoins the chart once the chart and the library's modules given with it are there, before the chart uses its options; returns the namespaces the module adds, or nothing.
ModuleOptionsinterface소스
interface ModuleOptions<Key extends string = string, Section extends object = object>
The options a module adds to the chart's, as a section of them: options.<key>.
readonly key: Keydefaults(): SectionThe section's defaults, which the options given are merged over.
validate(section: Section, label: string): voidThrows for an invalid section, as merged; label names it, e.g. options.footprint.
ModuleStatePartinterface소스
interface ModuleStatePart<Key extends string = string, State = unknown>
A part of a chart's saved layout that a module keeps: saveState()[key].
readonly key: Keysave(): StateWhat the module keeps now, as plain data.
read(saved: unknown, label: string): StateThe part of a state to load, checked: throws for an invalid one, and changes nothing.
load(state: State | null): voidApplies a part read gave, or null for a state without one.
ModuleTypesinterface소스
interface ModuleTypes
What a module adds to the chart's types: namespaces of the API, options, events, and what it keeps of the chart's layout in a saved state.
readonly api?: objectreadonly options?: objectreadonly events?: objectreadonly state?: objectObjectTargetinterface소스
interface ObjectTarget
The object under the pointer when it was clicked.
readonly kind: ObjectKindreadonly id: stringreadonly part: stringThe part that was hit, such as line, label, handle:0 or button:close.
OhlcStyleinterface소스
interface OhlcStyle
upColor: stringdownColor: stringlineWidth: numberticks: booleanDraws the open (left) and close (right) ticks.
OptionsChangeEventinterface소스
interface OptionsChangeEvent
Options applied, by applyOptions() or loadState(): those now, and those before.
readonly options: ChartOptionsreadonly previous: ChartOptionsPaneinterface소스
interface Pane
A pane as reported by the API.
readonly id: stringreadonly title: stringreadonly height: numberreadonly auto: booleanCreated for an indicator or series and removed with its last occupant.
PaneInputinterface소스
interface PaneInput
id?: stringThe chart numbers one, pane-1 on, when it is left out.
title?: stringShown in the legend.
height?: numberHeight in CSS pixels. Ignored for the main pane, which takes the remaining space.
PaneLayoutinterface소스
interface PaneLayout
Rectangles are relative to the left edge of the plots and the top of the chart: the plots start
at x 0, and a left price axis lies at negative x. chart.layout() reports them relative to the
chart's left edge.
PaneOptionsinterface소스
interface PaneOptions
defaultHeight: numberHeight in CSS pixels of a newly created pane.
minHeight: numberPanes never shrink below this height while resizing.
separatorHeight: numberHeight of the draggable separator between panes.
separatorWidth: numberWidth in CSS pixels of the line drawn along the separator; 0 draws none.
separatorColor: string | nullColor of that line; null (default) takes the theme's border.
separatorHoverColor: string | nullColor of the line under the pointer and while it is dragged; null (default) takes the
theme's crosshair.
PaneResizeEventinterface소스
interface PaneResizeEvent
The user finished resizing a pane by dragging a separator.
readonly paneId: stringreadonly height: numberPanesApiinterface소스
interface PanesApi
list(): Pane[]Panes from top to bottom; the main pane comes first.
get(id: string): Pane | nullThe pane of an id, or null.
add(pane: PaneInput): stringAdds a pane below the others and returns its id.
update(id: string, patch: Omit<PaneInput, 'id'>): voidChanges a pane's title or height. Throws for an unknown id.
remove(id: string): voidRemoves a pane and its drawings. Remove its indicators and series first; the main pane cannot be removed. Throws for an unknown id.
move(id: string, index: number): voidMoves a pane to position index (the main pane stays at 0).
PerformanceOptionsinterface소스
interface PerformanceOptions
maxPixelRatio: numberCaps the canvas pixel ratio to limit memory use on very dense screens.
maxTrades: numberHow many of the latest trades passed to data.addTrades() the chart keeps for bar types
built from trades, such as tick bars; older ones go, the bars built from them staying until
the bars are rebuilt. 0 keeps none.
PluginHostinterface소스
interface PluginHost
What attach() receives.
PluginPaintContextinterface소스
interface PluginPaintContext
readonly ctx: CanvasRenderingContext2DClipped to the pane's plot and translated to its top left corner, in CSS pixels.
readonly pixelRatio: numberreadonly layer: PluginLayerreadonly pane: PluginPanereadonly bars: BarsViewThe displayed bars.
readonly source: BarsViewThe source bars a running replay has revealed (all of them otherwise).
readonly cutoff: numberSource data after this time is hidden, as a replay hides what has not happened yet;
Infinity while the chart shows all of it.
readonly visible: { readonly from: number; readonly to: number } | nullIndices of the displayed bars intersecting the plot, or null.
readonly barSpacing: numberindexToX(index: number): numberX of the center of the bar at a (continuous) index.
xToIndex(x: number): numbertimeToX(time: number): numberX of a time, interpolated between bars and extrapolated outside them; NaN without bars.
readonly theme: Themereadonly font: { readonly family: string; readonly size: number }PluginPaneinterface소스
interface PluginPane
A pane as a plugin sees it. Coordinates are relative to the pane's plot.
readonly id: stringreadonly width: numberreadonly height: numbervalueToY(value: number): numberyToValue(y: number): numberformatValue(value: number): stringFormats a value like the pane's price axis.
PluginsApiinterface소스
interface PluginsApi
add(plugin: ChartPlugin): voidAttaches a plugin; its name must be unique.
remove(name: string): voidDetaches a plugin.
get(name: string): ChartPlugin | nullThe plugin of a name, or null.
list(): ChartPlugin[]The plugins, in the order they paint.
Pointinterface소스
interface Point
readonly x: numberreadonly y: numberPointFigureStyleinterface소스
interface PointFigureStyle
Point & figure columns: X's rising, O's falling, one in each box.
upColor: stringdownColor: stringlineWidth: numberwidthRatio: numberWidth of a box as a fraction of the bar spacing.
box: number | nullThe box size; null takes the one the transform building the bars reports.
PriceDragEventinterface소스
interface PriceDragEvent
readonly id: stringreadonly phase: DragPhasereadonly price: numberPrice at this phase (the restored price for cancel).
readonly initialPrice: numberPrice before the drag started.
PriceFormatContextinterface소스
interface PriceFormatContext
paneId: stringmode: PriceScaleModeprecision: numberlocale: stringThe locale the chart writes in: its locale, or the runtime's.
PriceLineButtoninterface소스
interface PriceLineButton
A button inside an order or alert label. Clicking it emits buttonClick.
id: stringtext?: stringShort text such as ✕ or TP.
icon?: stringSVG path data drawn in a 24 × 24 box, e.g. from an icon set.
width?: numberWidth in CSS pixels; defaults to fit the content.
PriceRangeinterface소스
interface PriceRange
min: numbermax: numberPriceScaleApiinterface소스
interface PriceScaleApi
One price scale of a pane. Coordinates are relative to the chart's top-left corner. A right scale with nothing of its own in a pane where the left one has something shows the left one: setting its range or auto-scaling it changes the left one.
range(): PriceRange | nullVisible value range, or null when nothing is drawn in the pane.
setRange(range: PriceRange): voidFixes the range and turns auto-scaling off.
autoScale(): voidTurns auto-scaling back on.
isAutoScale(): booleanmode(): PriceScaleModeThe configured mode; percent/indexed/log fall back to normal while their base is unusable.
setMode(mode: PriceScaleMode): voidisInverted(): booleansetInverted(inverted: boolean): voidmargins(): ScaleMarginsSpace above and below the auto-scaled data, as fractions of the pane.
setMargins(margins: ScaleMargins | null): voidSets the margins of this scale, e.g. { top: 0.8, bottom: 0 } for volume at the bottom; null follows priceScale.margins.
priceToY(price: number): number | nullyToPrice(y: number): number | nullPriceScaleOptionsinterface소스
interface PriceScaleOptions
visible: booleanmargins: ScaleMarginsEmpty space above and below the auto-scaled range.
precision: number | 'auto'Decimals of main-series prices, or auto to infer them from the data.
formatter: PriceFormatter | nullminWidth: numberMinimum axis width in CSS pixels; the axis grows to fit its labels.
pinLabels: booleanKeeps the label of an order or an alert whose line lies above or below the plot at its top or bottom edge, with an arrow, where a click brings the line into view. Otherwise it is out of sight with its line.
Rectinterface소스
interface Rect
x: numbery: numberwidth: numberheight: numberSavedScaleinterface소스
interface SavedScale
readonly id: stringreadonly mode: PriceScaleModereadonly inverted: booleanreadonly margins: ScaleMargins | nullreadonly range: PriceRange | nullScaleMarginsinterface소스
interface ScaleMargins
Empty space above and below the auto-scaled range of a price scale, as fractions of the pane height: each at least 0, and together at most 0.9.
top: numberbottom: numberSelectioninterface소스
interface Selection
The single selected object of a chart.
readonly kind: ObjectKindreadonly id: stringSelectionChangeEventinterface소스
interface SelectionChangeEvent
The user changed the selection by clicking.
readonly selection: Selection | nullSeparatorLayoutinterface소스
interface SeparatorLayout
above: stringbelow: stringy: numberheight: numberSeriesinterface소스
interface Series
A series as reported by the API (without its data).
readonly id: stringreadonly type: stringreadonly pane: stringreadonly scale: stringreadonly title: stringreadonly visible: booleanreadonly precision: number | nullreadonly lastValueLabel: booleanreadonly style: Readonly<Record<string, unknown>>SeriesApiinterface소스
interface SeriesApi
Additional series aligned to the main bars by time, such as comparison symbols.
set(series: readonly SeriesInput[]): voidReplaces every series, with the points each brings. What reads a series, such as an alert, must find it among them. An invalid input throws and changes nothing.
add(series: SeriesInput): stringAdds a series and returns its id: the one it has, or one the chart numbers for it.
update(id: string, patch: SeriesPatch): voidThrows for an unknown id.
remove(id: string): voidThrows for an unknown id, and while something, such as an alert, reads the series.
clear(): voidRemoves every series; throws while something, such as an alert, reads one.
get(id: string): Series | nullThe series of an id, or null.
list(): Series[]setData(id: string, points: readonly SeriesPointInput[]): voidupdateData(id: string, point: SeriesPointInput | readonly SeriesPointInput[]): voidReplaces the last point or appends newer points.
prependData(id: string, points: readonly SeriesPointInput[]): voidaddTrades(id: string, trades: TradeInput | readonly TradeInput[]): numberFolds trades into a series, such as a symbol compared, as data.addTrades() folds them into
the main bars: its bars of the source interval take them, or, for a series of values, a value
per source interval takes the price of its last trade; shown in the chart's timeframe.
Returns how many it kept: not those outside the sessions, nor late ones.
register<Style extends object>(definition: SeriesTypeDefinition<Style>): voidAdds a series type to this chart, named by its type, for series and the main series.
unregister(type: string): voidRemoves a series type. Fails for the types of every chart, while the main series is of it and while series of it are on the chart.
types(): string[]Every series type the chart has.
definition(type: string): Readonly<SeriesTypeDefinition<object>> | nullThe definition of a type, or null for an unknown type.
SeriesInputinterface소스
interface SeriesInput
id?: stringGenerated when omitted.
type: stringA series type such as line, area, columns or candles.
pane?: stringmain, new (a pane of its own) or the id of an existing pane. Defaults to main.
scale?: stringPrice scale in the pane: right (default), left, or any other name for an overlay scale
of its own without an axis, e.g. to compare symbols at different prices.
title?: stringvisible?: booleanprecision?: number | nullDecimals of its values in the legend and on an axis of its own, such as those of a symbol
compared with the bars; null (default) for the main series'.
lastValueLabel?: booleanA label of its latest value on the axis of its scale, in its color; off by default.
style?: Record<string, unknown>Style overrides merged on top of the type's theme-derived defaults.
data?: readonly SeriesPointInput[]SeriesPaintContextinterface소스
interface SeriesPaintContext<Style>
readonly ctx: CanvasRenderingContext2Dreadonly pixelRatio: numberreadonly width: numberPlot width and height; the context is translated to the plot's top-left corner.
readonly height: numberreadonly barSpacing: numberreadonly style: Stylereadonly points: SeriesPointsreadonly valueToY: (value: number) => numberConverts a data value into a y coordinate of the plot.
readonly bars: BarsView | nullEvery bar of an OHLC series, not only those in view, for types whose look follows from the
bars before, such as Kagi lines, thick from where they pass the last shoulder. null for
value series.
readonly first: numberPosition of the first point in the series' data: point i is bar first + i.
readonly transform: Readonly<Record<string, unknown>> | nullWhat the transform building the main series' bars reports it builds them with
(chart.transforms.get().resolved), such as the box size of point & figure columns; null for
other series and for bars no transform builds.
SeriesPointsinterface소스
interface SeriesPoints
Render-ready points of a series in plot coordinates, ordered from left to right.
readonly count: numberx(index: number): numberBar center.
open(index: number): numbery of open, high, low and close for OHLC input.
high(index: number): numberlow(index: number): numberclose(index: number): numbervolume(index: number): numberVolume of OHLC input, as traded (not a coordinate); NaN for value input.
value(index: number): numbery of the value for value input; NaN marks a gap.
isUp(index: number): booleanRising point: close ≥ open, or value ≥ the previous value.
color(index: number): string | nullA color chosen for this point (the main series' barColor), or null for the style's.
SeriesStyleMapinterface소스
interface SeriesStyleMap
Resolved style of every series type. Plugins add their own types through declaration merging:
declare module '@kumo-charts/core' {
interface SeriesStyleMap { renko: { boxColor: string } }
}candles: CandleStyle'hollow-candles': CandleStyle'volume-candles': CandleStyleOf the chart types module.
ohlc: OhlcStyle'high-low': HighLowStyleline: LineSeriesStyle'step-line': LineSeriesStyle'line-markers': LineMarkersStylearea: AreaStylebaseline: BaselineStyle'hlc-area': HlcAreaStylecolumns: ColumnsStylekagi: KagiStyleOf the chart types module: the lines of the kagi transform.
'point-figure': PointFigureStyleOf the chart types module: the columns of the point-figure transform.
SeriesTypeDefinitioninterface소스
interface SeriesTypeDefinition<Style extends object = Record<string, unknown>>
Describes how a series type is drawn. Register custom types with chart.series.register().
readonly type: stringThe type series of it name, such as candles.
readonly input: 'ohlc' | 'value'ohlc series plot open/high/low/close; value series plot one value per point.
defaultStyle(theme: Theme, color: string): StyleFull style derived from the theme; user overrides are merged on top.
extraExtents?(style: Style): readonly number[]Values the price scale must include in addition to the data, such as a column base.
paint(context: SeriesPaintContext<Style>): voidThemeinterface소스
interface Theme
Colors used across the chart. Series, indicator and object styles derive their defaults from it.
background: stringtext: stringtextMuted: stringgrid: stringborder: stringcrosshair: stringcrosshairLabelBackground: stringcrosshairLabelText: stringup: stringBullish candles, rising values.
down: stringBearish candles, falling values.
volumeUp: stringvolumeDown: stringaccent: stringSelection handles and highlighted objects.
palette: readonly [string, ...string[]]Default colors for drawings, indicators and additional series, in order; at least one.
buy: stringsell: stringalert: stringTimeFormatContextinterface소스
interface TimeFormatContext
kind: 'axis' | 'crosshair'unit: TimeUnitFor axis labels: the calendar boundary the tick sits on.
locale: stringThe locale the chart writes in: its locale, or the runtime's.
timeZone: stringThe zone the chart shows times in: its timeZone, or the local one.
TimeRangeinterface소스
interface TimeRange
readonly from: numberTime of the first visible bar.
readonly to: numberTime of the last visible bar.
TimeScaleApiinterface소스
interface TimeScaleApi
visibleRange(): TimeRange | nullTimes of the first and last visible bars, or null when none is visible.
visibleLogicalRange(): LogicalRange | nullLogical indices at the left and right edges of the plot, or null without bars.
setVisibleLogicalRange(range: LogicalRange): voidscrollToIndex(index: number, align?: ViewAlign): voidscrollToRealTime(): voidMoves back to the latest bar, at the configured right offset.
isFollowing(): booleanWhether the latest bar is in view, so new bars scroll into view as they arrive.
fitContent(): voidzoomIn(): voidWidens the bars, keeping the latest bar in place while the view follows it, else the bar in the middle of the plot.
zoomOut(): voidNarrows the bars, around the same bar as zoomIn().
barSpacing(): numberDistance between the centers of two bars, in CSS pixels.
setBarSpacing(spacing: number): voidreset(): voidRestores the configured bar spacing and the real-time position.
timeToX(time: TimeInput): number | nullx of the bar at time (interpolated between bars), or null without data.
xToTime(x: number): number | nullindexToX(index: number): number | nullxToIndex(x: number): number | nullLogical index at x; fractional between bar centers.
TimeScaleOptionsinterface소스
interface TimeScaleOptions
visible: booleanheight: numberAxis height in CSS pixels.
barSpacing: numberInitial distance between bars in CSS pixels.
minBarSpacing: numbermaxBarSpacing: numberrightOffset: numberEmpty space after the latest bar, in CSS pixels, when the chart follows real time.
loadMoreThreshold: numberloadMore fires when fewer than this many bars remain hidden on the left.
formatter: TimeFormatter | nullTradeInputinterface소스
interface TradeInput
A single trade (tick) folded into the source bars by data.addTrades().
TransformsApiinterface소스
interface TransformsApi
The transform building the displayed bars from the bars of the timeframe, such as Renko bricks, and the transform types the chart has.
set(transform: BarTransformInput | null): voidBuilds the displayed bars with a transform, e.g. { type: 'renko', params: { box: 50 } },
or shows the bars of the timeframe again with null. The view stays where it is in time, as
with data.set().
get(): BarTransformState | nullThe transform building the displayed bars, or null when they are the bars of the timeframe;
resolved holds what it builds with, such as the box size it worked out from the bars.
register<P extends object>(definition: BarTransformDefinition<P>): voidAdds a transform type to this chart, named by its type.
unregister(type: string): voidRemoves a transform type. Fails while it builds the displayed bars.
types(): string[]Every transform type the chart has.
definition(type: string): Readonly<BarTransformDefinition> | nullThe definition of a type, or null for an unknown type.
TypesChangeEventinterface소스
interface TypesChangeEvent
A series type, transform type, indicator type or drawing type was registered or unregistered, for lists of the types to follow.
readonly kind: 'series' | 'transform' | 'indicator' | 'drawing'readonly type: stringreadonly registered: booleanfalse when it was unregistered.
ValuePointInputinterface소스
interface ValuePointInput
A point of a value series.
time: TimeInputvalue: number | nullnull leaves a gap.
VisibleRangeChangeEventinterface소스
interface VisibleRangeChangeEvent
readonly range: TimeRange | nullTimes of the first and last visible bars, or null when no bar is visible.
readonly logicalRange: LogicalRange | nullTypes
BarChangetype소스
type BarChange =
/** Every index may have changed (set, prepend or clear). */
| { readonly kind: 'reset' }
/** Only bars from `from` (inclusive) to the end changed or were appended. */
| { readonly kind: 'tail'; readonly from: number }
How the bars changed since a revision a consumer has seen.
CalendarBuckettype소스
type CalendarBucket = (
time: number,
interval: Interval,
fallback: (time: number) => number | null
) => number | null
Overrides the built-in bucketing: returns the start of the bucket time belongs to, or null
to drop the time (a holiday or a halt). fallback is the built-in result for the same interval.
Buckets must not decrease with time.
CalendarInputtype소스
type CalendarInput = Partial<CalendarOptions>
Options of createCalendar; timeZone defaults to the runtime's local zone.
Charttype소스
type Chart<M extends readonly ChartModule[] = readonly []> = ChartBase<
ModulesOptions<M>,
ModulesEvents<M>,
ModulesState<M>
> &
ModulesApi<M>
A chart with the modules M, such as Chart<[typeof indicators]>: the core and the namespaces,
options and events of the modules. Chart alone is the chart without modules, which every
chart is.
ChartAreatype소스
type ChartArea = 'plot' | 'price-axis' | 'time-axis' | 'separator' | 'outside'
The part of the chart under the pointer: the plot of a pane, a price axis, the time axis, the separator between two panes, or none of them, such as the corner below the price axis.
ChartCommandtype소스
type ChartCommand = 'escape' | 'delete' | 'undo' | 'redo' | 'enter' | 'copy' | 'paste'
A command of the keyboard or the context menu that modules run: Escape, Delete, undo, redo, Enter, copy and paste.
ChartOptionsInputtype소스
type ChartOptionsInput = DeepPartial<ChartOptions>
CreateChartOptionstype소스
type CreateChartOptions<M extends readonly ChartModule[]> = DeepPartial<
ChartOptions & ModulesOptions<M>
> & {
/** The parts of the chart beyond its core, such as `indicators(allIndicators)`. */
readonly modules?: M;
}
What createChart() takes: the modules of the chart, and its options.
CrosshairMoveEventtype소스
type CrosshairMoveEvent =
({ readonly visible: true } & CrosshairState) | { readonly visible: false }
The pointer moved over the chart (visible: true) or left it.
CrosshairPriceLinestype소스
type CrosshairPriceLines = (price: number, paneId: string) => readonly string[]
The lines under the crosshair's price label (crosshair.labels.priceLines), of the price at the pointer in a pane.
DeepPartialtype소스
type DeepPartial<T> = T extends (...args: never[]) => unknown
? T
: T extends readonly unknown[]
? T
: T extends object
? { [K in keyof T]?: DeepPartial<T[K]> }
: T
Recursively optional version of T. Functions and arrays are replaced, never merged.
DragPhasetype소스
type DragPhase = 'start' | 'move' | 'end' | 'cancel'
IntervalInputtype소스
type IntervalInput = Interval | string
An Interval or its shorthand <count><unit>: s second, m minute, h hour, D day,
W week, M month (H, d and w work too; only m and M differ by case). The count may
be omitted: 'D' is '1D'.
IntervalUnittype소스
type IntervalUnit = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month'
LineStyletype소스
type LineStyle = (typeof LINE_STYLES)[number]
MarkerShapetype소스
type MarkerShape =
'arrow-up' | 'arrow-down' | 'triangle-up' | 'triangle-down' | 'circle' | 'square'
Shapes of markers: on the chart's markers and on indicator values.
ModuleOptionsOftype소스
type ModuleOptionsOf<Types extends ModuleTypes> = {
[K in keyof NonNullable<Types['options']> & string]: ModuleOptions<
K,
NonNullable<Types['options']>[K] & object
>;
}[keyof NonNullable<Types['options']> & string]
The section of options a module of Types may add.
ModulesApitype소스
type ModulesApi<M extends readonly ChartModule[]> =
ModulesTypes<M> extends { readonly api: infer A } ? A : unknown
The namespaces the modules add to the chart.
ModulesEventstype소스
type ModulesEvents<M extends readonly ChartModule[]> =
ModulesTypes<M> extends { readonly events: infer E } ? E : unknown
The events the modules add to the chart's.
ModulesOptionstype소스
type ModulesOptions<M extends readonly ChartModule[]> =
ModulesTypes<M> extends { readonly options: infer O } ? O : unknown
The options the modules add to the chart's.
ModulesStatetype소스
type ModulesState<M extends readonly ChartModule[]> =
ModulesTypes<M> extends { readonly state: infer S } ? S : unknown
What the modules keep in the chart's saved state.
ModulesTypestype소스
type ModulesTypes<M extends readonly ChartModule[]> = (
NonNullable<M[number]['~types']> extends infer T
? T extends unknown
? (value: T) => void
: never
: never
) extends (value: infer I) => void
? I
: never
What the modules add to the chart, merged: their API, options, events and saved state. The union of what each adds becomes an intersection through the parameter of a function type.
ObjectKindtype소스
type ObjectKind = 'drawing' | 'order' | 'alert' | 'marker'
PluginLayertype소스
type PluginLayer = 'below' | 'above'
Where a plugin paints: under the series (after the grid) or over them (under the objects).
PriceFormattertype소스
type PriceFormatter = (value: number, context: PriceFormatContext) => string
Formats a price label. value is already converted for percent/indexed scales.
PriceScaleModetype소스
type PriceScaleMode = 'normal' | 'log' | 'percent' | 'indexed'
PriceSourcetype소스
type PriceSource = (typeof PRICE_SOURCES)[number]
Price fields a line-like series or an indicator can read from a bar.
SeriesPatchtype소스
type SeriesPatch = Pick<
SeriesInput,
'title' | 'visible' | 'precision' | 'lastValueLabel' | 'style' | 'scale'
>
What series.update() changes of a series.
SeriesPointInputtype소스
type SeriesPointInput = ValuePointInput | BarInput
SeriesStyleOverridestype소스
type SeriesStyleOverrides = { [K in SeriesType]?: Partial<SeriesStyleMap[K]> | null }
Partial style overrides keyed by series type; null drops those of a type.
SeriesTypetype소스
type SeriesType = keyof SeriesStyleMap
TextOverridestype소스
type TextOverrides<Texts> = { [K in keyof Texts]: Texts[K] | null }
Words that replace those a chart or a module paints, each null while it is not replaced.
TimeFormattertype소스
type TimeFormatter = (time: number, context: TimeFormatContext) => string
Formats a time label. kind tells where the label is shown.
TimeInputtype소스
type TimeInput = number | string | Date
A point in time: epoch milliseconds, an ISO-8601 string or a Date.
TimeUnittype소스
type TimeUnit = 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second'
TradeSidetype소스
type TradeSide = 'buy' | 'sell'
The side of the taker of a trade.
Unsubscribetype소스
type Unsubscribe = () => void
ValueSourcetype소스
type ValueSource =
| { readonly kind: 'price'; readonly field?: PriceSource }
/** An output of an indicator; `key` defaults to its first output. */
| { readonly kind: 'indicator'; readonly id: string; readonly key?: string }
| { readonly kind: 'series'; readonly id: string }
/** A line of a drawing at each bar, e.g. a trend line; `level` defaults to its first line. */
| { readonly kind: 'drawing'; readonly id: string; readonly level?: string }
A value at each bar, which alerts watch and mainSeries.barColor reads.
ViewAligntype소스
type ViewAlign = 'left' | 'center' | 'right'
Variables
darkThemevariable소스
const darkTheme: Theme
lightThemevariable소스
const lightTheme: Theme
LINE_STYLESvariable소스
const LINE_STYLES: readonly ["solid", "dashed", "dotted"]
The ways a line is stroked.
PRICE_SOURCESvariable소스
const PRICE_SOURCES: readonly ["open", "high", "low", "close", "hl2", "hlc3", "ohlc4"]
The prices a bar gives, in the order forms list them.