sy-stock-chart

Stock Chart

Combine price history with financial exploration controls.

sy-stock-chart

Build financial interfaces with range selection, Navigator, and flags.

Align date time zones and trading sessions. The example uses fictional data to demonstrate display features.

Base chart tier: Pro. Features such as additional renderers and custom branding have separate entitlement requirements.

InputData description
dataChronological OHLCV records.
session24x7 or a trading session.
flagsEvents with time, text, and title.
seriesStyleHow prices are drawn.

Complete implementation example

html
<div id="chart-container" style="width: 100%; min-width: 0;"></div>

<script type="module">
  import { defineCustomElement as define0 } from '@syidax/advanced-pro/components/sy-stock-chart.js';
  define0();

  // Pro: complete registerLicense at app startup using your issued certificate.
  // The website preview certificate is not for use in customer apps.
  const specs = [
    {
      "id": "example-chart",
      "tag": "sy-stock-chart",
      "props": {
        "data": [
          {
            "time": 1767225600000,
            "open": 100,
            "close": 95,
            "high": 103,
            "low": 92,
            "volume": 1200
          },
          {
            "time": 1767312000000,
            "open": 104,
            "close": 106,
            "high": 109,
            "low": 101,
            "volume": 1337
          },
          {
            "time": 1767398400000,
            "open": 107,
            "close": 105,
            "high": 110,
            "low": 102,
            "volume": 1474
          },
          {
            "time": 1767484800000,
            "open": 109,
            "close": 114,
            "high": 117,
            "low": 106,
            "volume": 1611
          },
          {
            "time": 1767571200000,
            "open": 108,
            "close": 109,
            "high": 112,
            "low": 105,
            "volume": 1748
          },
          {
            "time": 1767657600000,
            "open": 106,
            "close": 103,
            "high": 109,
            "low": 100,
            "volume": 1885
          },
          {
            "time": 1767744000000,
            "open": 102,
            "close": 106,
            "high": 109,
            "low": 99,
            "volume": 2022
          },
          {
            "time": 1767830400000,
            "open": 100,
            "close": 100,
            "high": 103,
            "low": 97,
            "volume": 2159
          },
          {
            "time": 1767916800000,
            "open": 98,
            "close": 94,
            "high": 101,
            "low": 91,
            "volume": 2296
          },
          {
            "time": 1768003200000,
            "open": 99,
            "close": 102,
            "high": 105,
            "low": 96,
            "volume": 2433
          },
          {
            "time": 1768089600000,
            "open": 101,
            "close": 100,
            "high": 104,
            "low": 97,
            "volume": 2570
          },
          {
            "time": 1768176000000,
            "open": 105,
            "close": 100,
            "high": 108,
            "low": 97,
            "volume": 2707
          },
          {
            "time": 1768262400000,
            "open": 109,
            "close": 111,
            "high": 114,
            "low": 106,
            "volume": 2844
          },
          {
            "time": 1768348800000,
            "open": 113,
            "close": 111,
            "high": 116,
            "low": 108,
            "volume": 2981
          },
          {
            "time": 1768435200000,
            "open": 115,
            "close": 120,
            "high": 123,
            "low": 112,
            "volume": 1318
          },
          {
            "time": 1768521600000,
            "open": 115,
            "close": 116,
            "high": 119,
            "low": 112,
            "volume": 1455
          },
          {
            "time": 1768608000000,
            "open": 114,
            "close": 111,
            "high": 117,
            "low": 108,
            "volume": 1592
          },
          {
            "time": 1768694400000,
            "open": 111,
            "close": 115,
            "high": 118,
            "low": 108,
            "volume": 1729
          },
          {
            "time": 1768780800000,
            "open": 108,
            "close": 108,
            "high": 111,
            "low": 105,
            "volume": 1866
          },
          {
            "time": 1768867200000,
            "open": 105,
            "close": 101,
            "high": 108,
            "low": 98,
            "volume": 2003
          },
          {
            "time": 1768953600000,
            "open": 105,
            "close": 108,
            "high": 111,
            "low": 102,
            "volume": 2140
          },
          {
            "time": 1769040000000,
            "open": 107,
            "close": 106,
            "high": 110,
            "low": 103,
            "volume": 2277
          },
          {
            "time": 1769126400000,
            "open": 110,
            "close": 105,
            "high": 113,
            "low": 102,
            "volume": 2414
          },
          {
            "time": 1769212800000,
            "open": 114,
            "close": 116,
            "high": 119,
            "low": 111,
            "volume": 2551
          },
          {
            "time": 1769299200000,
            "open": 119,
            "close": 117,
            "high": 122,
            "low": 114,
            "volume": 2688
          },
          {
            "time": 1769385600000,
            "open": 121,
            "close": 126,
            "high": 129,
            "low": 118,
            "volume": 2825
          },
          {
            "time": 1769472000000,
            "open": 123,
            "close": 124,
            "high": 127,
            "low": 120,
            "volume": 2962
          },
          {
            "time": 1769558400000,
            "open": 121,
            "close": 118,
            "high": 124,
            "low": 115,
            "volume": 1299
          },
          {
            "time": 1769644800000,
            "open": 119,
            "close": 123,
            "high": 126,
            "low": 116,
            "volume": 1436
          },
          {
            "time": 1769731200000,
            "open": 116,
            "close": 116,
            "high": 119,
            "low": 113,
            "volume": 1573
          },
          {
            "time": 1769817600000,
            "open": 113,
            "close": 109,
            "high": 116,
            "low": 106,
            "volume": 1710
          },
          {
            "time": 1769904000000,
            "open": 112,
            "close": 115,
            "high": 118,
            "low": 109,
            "volume": 1847
          }
        ],
        "session": "24x7",
        "seriesStyle": "candlestick",
        "showNavigator": true,
        "showRangeSelector": true,
        "width": 640,
        "height": 440,
        "brandPosition": "bottom-right",
        "brandLogo": ""
      }
    }
  ];
  const container = document.querySelector('#chart-container');
  const elements = specs.map(({ tag, id, props }) => {
    const element = document.createElement(tag);
    element.id = id;
    Object.assign(element, props);
    element.setAttribute('aria-label', 'stock-chart example chart');
    return element;
  });
  container.replaceChildren(...elements);
  const chart = elements.at(-1);
  const onEvent = event => {
    console.log('flagClick', event.detail);
  };
  chart.addEventListener('flagClick', onEvent);
  const observer = new ResizeObserver(([entry]) => {
    const width = Math.max(160, Math.floor(entry.contentRect.width));
    elements.forEach(element => { element.width = width; });
  });
  observer.observe(container);

  // In an SPA, call this function when the view is disposed.
  function disposeChart() {
    observer.disconnect();
    chart.removeEventListener('flagClick', onEvent);
    container.replaceChildren();
  }
</script>

Properties

width

Chart width in pixels. If the container width changes, update width from a ResizeObserver.

ItemValue
JavaScript propertywidth
HTML attributewidth
Typenumber
Default760

height

Chart height in pixels. Allow space for axes, titles, and the legend.

ItemValue
JavaScript propertyheight
HTML attributeheight
Typenumber
Default420

brandPosition

The corner where the logo is anchored. Community and Pro both support all four corners, using the same position on screen and in image exports.

ItemValue
JavaScript propertybrandPosition
HTML attributebrand-position
Type'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'
Default'bottom-right'
Allowed valuestop-left, top-right, bottom-left, bottom-right

data

Chronological OHLCV records.

ItemValue
JavaScript propertydata
HTML attributePass objects, arrays, and callbacks as JavaScript properties
TypeStockDataInput
Defaultundefined

undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.

session

24x7 or a trading session.

ItemValue
JavaScript propertysession
HTML attributePass objects, arrays, and callbacks as JavaScript properties
Type'24x7' | 'us-equity' | StockSessionInput
Default'24x7'
Literals in the type24x7, us-equity

visibleFrom

Visible bar range (indices; defaults to everything).

ItemValue
JavaScript propertyvisibleFrom
HTML attributevisible-from
Typenumber
Defaultundefined

undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.

visibleTo

Set as an HTML attribute or JavaScript property. type: number.

ItemValue
JavaScript propertyvisibleTo
HTML attributevisible-to
Typenumber
Defaultundefined

undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.

showNavigator

Show the full-tape navigator + scrollbar under the time axis ().

ItemValue
JavaScript propertyshowNavigator
HTML attributeshow-navigator
Typeboolean
Defaultfalse

showRangeSelector

Show the 1M/3M/6M/YTD/1Y/All + resolution button rows ().

ItemValue
JavaScript propertyshowRangeSelector
HTML attributeshow-range-selector
Typeboolean
Defaultfalse

resolution

Tape resolution: 1d raw / 1w / 1M calendar roll-ups.

ItemValue
JavaScript propertyresolution
HTML attributeresolution
TypeStockResolution
Default'1d'
Allowed values1d, 1w, 1M

dataGrouping

View-density grouping: auto (default) / off / a forced factor.

ItemValue
JavaScript propertydataGrouping
HTML attributedata-grouping
Typestring
Default'auto'

historyLoader

Older-history provider (): (oldestTime, count) => bars. Called automatically when the window nears the tape head; an empty return marks the history exhausted.

ItemValue
JavaScript propertyhistoryLoader
HTML attributePass objects, arrays, and callbacks as JavaScript properties
Type(oldestTime: number, count: number) => Promise<ReadonlyArray<StockBarInput>> | ReadonlyArray<StockBarInput>
Defaultundefined

undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.

historyThreshold

Bars from the head that trigger a history load (default 30).

ItemValue
JavaScript propertyhistoryThreshold
HTML attributehistory-threshold
Typenumber
Default30

panes

Pane stack (): [{id, weight, label?}], price first by convention. Weights are proportions; separators drag live.

ItemValue
JavaScript propertypanes
HTML attributePass objects, arrays, and callbacks as JavaScript properties
TypeReadonlyArray<PaneSpecInput>
Defaultundefined

undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.

seriesStyle

How prices are drawn.

ItemValue
JavaScript propertyseriesStyle
HTML attributeseries-style
TypeStockSeriesStyle | DerivedStockStyle
Default'candlestick'
Allowed valuesarea, ohlc, hlc, hilo, hollow, line, candlestick, column-range, baseline, hlc-area, volume-candle, heikin-ashi, renko, kagi, point-figure, line-break

brickSize

Renko brick size in price units (default auto — close range/50, nice).

ItemValue
JavaScript propertybrickSize
HTML attributebrick-size
Typenumber
Defaultundefined

undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.

reversalPct

Kagi reversal, percent (default 4).

ItemValue
JavaScript propertyreversalPct
HTML attributereversal-pct
Typenumber
Default4

boxSize

Point & Figure box size (default auto) and reversal boxes (default 3).

ItemValue
JavaScript propertyboxSize
HTML attributebox-size
Typenumber
Defaultundefined

undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.

reversalBoxes

Set as an HTML attribute or JavaScript property. type: number.

ItemValue
JavaScript propertyreversalBoxes
HTML attributereversal-boxes
Typenumber
Default3

lineBreakCount

Line Break lookback (default 3-line break).

ItemValue
JavaScript propertylineBreakCount
HTML attributeline-break-count
Typenumber
Default3

upColor

Up/down candle colours (close ≥ open → up).

ItemValue
JavaScript propertyupColor
HTML attributeup-color
Typestring
Default'#16a34a'

downColor

Set as an HTML attribute or JavaScript property. type: string.

ItemValue
JavaScript propertydownColor
HTML attributedown-color
Typestring
Default'#dc2626'

baselineValue

Baseline anchor for series-style="baseline" (default first visible close).

ItemValue
JavaScript propertybaselineValue
HTML attributebaseline-value
Typenumber
Defaultundefined

undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.

lineColor

Line/area/hilo ink.

ItemValue
JavaScript propertylineColor
HTML attributeline-color
Typestring
Default'#2563eb'

priceScaleMode

Right-scale space: linear (default) / log / percent / indexed.

ItemValue
JavaScript propertypriceScaleMode
HTML attributeprice-scale
Typestring
Default'linear'

referenceLines

Reference lines, comma list: current,previous-close,high,low,bid,ask.

ItemValue
JavaScript propertyreferenceLines
HTML attributereference-lines
Typestring
Defaultundefined

undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.

bid

Quotes for the bid/ask reference lines.

ItemValue
JavaScript propertybid
HTML attributebid
Typenumber
Defaultundefined

undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.

ask

Set as an HTML attribute or JavaScript property. type: number.

ItemValue
JavaScript propertyask
HTML attributeask
Typenumber
Defaultundefined

undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.

crosshair

Crosshair + OHLC legend on hover ().

ItemValue
JavaScript propertycrosshair
HTML attributecrosshair
Typeboolean
Defaulttrue

showLegend

Set as an HTML attribute or JavaScript property. type: boolean.

ItemValue
JavaScript propertyshowLegend
HTML attributeshow-legend
Typeboolean
Defaulttrue

compareSymbols

Compare overlays (): [{id, name?, color?, data}]. Any active compare FORCES the percent scale — every series reads vs its own first visible close.

ItemValue
JavaScript propertycompareSymbols
HTML attributePass objects, arrays, and callbacks as JavaScript properties
TypeReadonlyArray<CompareSymbolInput>
Defaultundefined

undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.

flags

Events with time, text, and title.

ItemValue
JavaScript propertyflags
HTML attributePass objects, arrays, and callbacks as JavaScript properties
TypeReadonlyArray<StockFlagInput>
Defaultundefined

undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.

indicators

Indicator instances (): [{kind, params?, color?, linkedTo?, pane?}] against the registry (registerIndicator). Overlay kinds paint into the price pane; pane kinds own a synthesized pane.

ItemValue
JavaScript propertyindicators
HTML attributePass objects, arrays, and callbacks as JavaScript properties
TypeReadonlyArray<StockIndicatorInput>
Defaultundefined

undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.

drawings

Drawing seed (): [{tool, anchors: [{time, price}], style?}] — DATA-coordinate anchors survive pan/zoom/grouping/resolution. Assigning the prop resets the document (and its undo history); the method surface mutates it with full undo/redo.

ItemValue
JavaScript propertydrawings
HTML attributePass objects, arrays, and callbacks as JavaScript properties
TypeReadonlyArray<StockDrawingInput>
Defaultundefined

undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.

showToolbar

Show the left drawing-tools toolbar ().

ItemValue
JavaScript propertyshowToolbar
HTML attributeshow-toolbar
Typeboolean
Defaultfalse

exportScale

PNG export pixel scale ().

ItemValue
JavaScript propertyexportScale
HTML attributeexport-scale
Typenumber
Default2

locale

BCP-47 locale (): month labels + price/P&L number formats.

ItemValue
JavaScript propertylocale
HTML attributelocale
Typestring
Default'en-US'

trades

Executed trades (): [{time, side: buy|sell, price, quantity?}].

ItemValue
JavaScript propertytrades
HTML attributePass objects, arrays, and callbacks as JavaScript properties
TypeReadonlyArray<StockTradeInput>
Defaultundefined

undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.

positions

Open positions (): [{side: long|short, entryPrice, quantity}] — live P&L badges.

ItemValue
JavaScript propertypositions
HTML attributePass objects, arrays, and callbacks as JavaScript properties
TypeReadonlyArray<StockPositionInput>
Defaultundefined

undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.

chartTitle

The title inside the chart. Explain the data's unit and meaning alongside it.

ItemValue
JavaScript propertychartTitle
HTML attributechart-title
Typestring
Defaultundefined

undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.

chartSubtitle

The subtitle inside the chart.

ItemValue
JavaScript propertychartSubtitle
HTML attributechart-subtitle
Typestring
Defaultundefined

undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.

Events

rendered

Emits rendering results in detail when chart drawing completes.

Event name: rendered. Names are case-sensitive. Read the payload from detail on CustomEvent<{ bars: number; visibleBars: number; renderMs: number }>.

javascript
chart.addEventListener('rendered', event => {
  console.log(event.detail); // { bars: number; visibleBars: number; renderMs: number }
});

paneLayoutChanged

The pane stack changed (drag, add/remove/reorder, weight set).

Event name: paneLayoutChanged. Names are case-sensitive. Read the payload from detail on CustomEvent<{ panes: Array<{ id: string; weight: number }> }>.

javascript
chart.addEventListener('paneLayoutChanged', event => {
  console.log(event.detail); // { panes: Array<{ id: string; weight: number }> }
});

visibleRangeChanged

The visible window changed (navigator/scrollbar; fires on release).

Event name: visibleRangeChanged. Names are case-sensitive. Read the payload from detail on CustomEvent<{ from: number; to: number }>.

javascript
chart.addEventListener('visibleRangeChanged', event => {
  console.log(event.detail); // { from: number; to: number }
});

rangeSelected

A range button was applied.

Event name: rangeSelected. Names are case-sensitive. Read the payload from detail on CustomEvent<{ range: StockRangeKey; from: number; to: number }>.

javascript
chart.addEventListener('rangeSelected', event => {
  console.log(event.detail); // { range: StockRangeKey; from: number; to: number }
});

resolutionChanged

The resolution changed.

Event name: resolutionChanged. Names are case-sensitive. Read the payload from detail on CustomEvent<{ resolution: StockResolution }>.

javascript
chart.addEventListener('resolutionChanged', event => {
  console.log(event.detail); // { resolution: StockResolution }
});

historyRequested

A history load started / finished.

Event name: historyRequested. Names are case-sensitive. Read the payload from detail on CustomEvent<{ oldestTime: number; count: number }>.

javascript
chart.addEventListener('historyRequested', event => {
  console.log(event.detail); // { oldestTime: number; count: number }
});

historyLoaded

CustomEvent.detail type: { added: number; exhausted: boolean }. Event names are case-sensitive.

Event name: historyLoaded. Names are case-sensitive. Read the payload from detail on CustomEvent<{ added: number; exhausted: boolean }>.

javascript
chart.addEventListener('historyLoaded', event => {
  console.log(event.detail); // { added: number; exhausted: boolean }
});

crosshairMoved

The crosshair moved to a bar (null on leave).

Event name: crosshairMoved. Names are case-sensitive. Read the payload from detail on CustomEvent<{ index: number; time: number; price: number } | null>.

javascript
chart.addEventListener('crosshairMoved', event => {
  console.log(event.detail); // { index: number; time: number; price: number } | null
});

compareChanged

The compare set changed.

Event name: compareChanged. Names are case-sensitive. Read the payload from detail on CustomEvent<{ ids: string[] }>.

javascript
chart.addEventListener('compareChanged', event => {
  console.log(event.detail); // { ids: string[] }
});

flagClick

A flag was clicked / hovered (null on hover leave).

Event name: flagClick. Names are case-sensitive. Read the payload from detail on CustomEvent<{ id: string; time: number; text: string; title?: string }>.

javascript
chart.addEventListener('flagClick', event => {
  console.log(event.detail); // { id: string; time: number; text: string; title?: string }
});

flagHover

CustomEvent.detail type: { id: string; time: number; text: string; title?: string } | null. Event names are case-sensitive.

Event name: flagHover. Names are case-sensitive. Read the payload from detail on CustomEvent<{ id: string; time: number; text: string; title?: string } | null>.

javascript
chart.addEventListener('flagHover', event => {
  console.log(event.detail); // { id: string; time: number; text: string; title?: string } | null
});

indicatorsChanged

The indicator set changed (add/remove/update).

Event name: indicatorsChanged. Names are case-sensitive. Read the payload from detail on CustomEvent<{ ids: string[] }>.

javascript
chart.addEventListener('indicatorsChanged', event => {
  console.log(event.detail); // { ids: string[] }
});

drawingsChanged

The drawing document changed (add/update/move/remove/undo/redo/load).

Event name: drawingsChanged. Names are case-sensitive. Read the payload from detail on CustomEvent<{ count: number; canUndo: boolean; canRedo: boolean }>.

javascript
chart.addEventListener('drawingsChanged', event => {
  console.log(event.detail); // { count: number; canUndo: boolean; canRedo: boolean }
});

drawingSelect

A drawing was selected (null on deselect).

Event name: drawingSelect. Names are case-sensitive. Read the payload from detail on CustomEvent<{ id: string } | null>.

javascript
chart.addEventListener('drawingSelect', event => {
  console.log(event.detail); // { id: string } | null
});

toolChanged

The active placement tool changed (null = the cursor).

Event name: toolChanged. Names are case-sensitive. Read the payload from detail on CustomEvent<{ tool: string | null }>.

javascript
chart.addEventListener('toolChanged', event => {
  console.log(event.detail); // { tool: string | null }
});

tickApplied

A live tick was applied (appended = a new bar opened).

Event name: tickApplied. Names are case-sensitive. Read the payload from detail on CustomEvent<{ appended: boolean; time: number; close: number; bars: number }>.

javascript
chart.addEventListener('tickApplied', event => {
  console.log(event.detail); // { appended: boolean; time: number; close: number; bars: number }
});

tradeClick

A trade marker was clicked.

Event name: tradeClick. Names are case-sensitive. Read the payload from detail on CustomEvent<{ id: string; time: number; side: 'buy' | 'sell'; price: number; quantity?: number }>.

javascript
chart.addEventListener('tradeClick', event => {
  console.log(event.detail); // { id: string; time: number; side: 'buy' | 'sell'; price: number; quantity?: number }
});

templateApplied

A template was imported (applied names the fields that landed).

Event name: templateApplied. Names are case-sensitive. Read the payload from detail on CustomEvent<{ applied: string[] }>.

javascript
chart.addEventListener('templateApplied', event => {
  console.log(event.detail); // { applied: string[] }
});

exported

An export finished (png | svg | csv).

Event name: exported. Names are case-sensitive. Read the payload from detail on CustomEvent<{ format: string; filename: string }>.

javascript
chart.addEventListener('exported', event => {
  console.log(event.detail); // { format: string; filename: string }
});

Methods

addCompare

Add a compare overlay (duplicate ids replace).

typescript
addCompare(symbol: CompareSymbolInput): Promise<void>
ArgumentsTypeRequired
symbolCompareSymbolInputRequired

Return type: Promise<void>. Call the method after element registration and await its Promise result.

removeCompare

Remove a compare overlay by id.

typescript
removeCompare(id: string): Promise<void>
ArgumentsTypeRequired
idstringRequired

Return type: Promise<void>. Call the method after element registration and await its Promise result.

addIndicator

Add an indicator instance (an explicit duplicate id replaces). A missing id is minted HERE and persisted into the spec, so later removals never re-number method-added instances.

typescript
addIndicator(spec: StockIndicatorInput): Promise<StockIndicatorInput>
ArgumentsTypeRequired
specStockIndicatorInputRequired

Return type: Promise<StockIndicatorInput>. Call the method after element registration and await its Promise result.

removeIndicator

Remove an indicator by resolved id (its synthesized pane goes with it).

typescript
removeIndicator(id: string): Promise<void>
ArgumentsTypeRequired
idstringRequired

Return type: Promise<void>. Call the method after element registration and await its Promise result.

updateIndicator

Merge params into an instance (by resolved id).

typescript
updateIndicator(id: string, params: Record<string, number | string>): Promise<void>
ArgumentsTypeRequired
idstringRequired
paramsRecord<string, number | string>Required

Return type: Promise<void>. Call the method after element registration and await its Promise result.

getIndicators

Resolved indicator list (serialisable — no definition objects).

typescript
getIndicators(): Promise<Array<{
    id: string; kind: string; params: Record<string, number>; linkedTo: string; paneId: string | null; label: string;
  }>>

Return type: `Promise<Array<{ id: string; kind: string; params: Record<string, number>; linkedTo: string; paneId: string | null; label: string; }>>`. Call the method after element registration and await its Promise result.

defineIndicator

Register a CUSTOM indicator definition at runtime () — the component-level gate over the sy/stock registerIndicator core: strictly validated, re-register replaces, existing instances of the kind re-compute on the forced re-render. Definitions live in the page-global registry (every chart on the page sees them).

typescript
defineIndicator(definition: IndicatorDefinition): Promise<{ ok: boolean; errors: string[] }>
ArgumentsTypeRequired
definitionIndicatorDefinitionRequired

Return type: Promise<{ ok: boolean; errors: string[] }>. Call the method after element registration and await its Promise result.

undefineIndicator

Remove a definition; live instances of the kind resolve away.

typescript
undefineIndicator(kind: string): Promise<{ removed: boolean }>
ArgumentsTypeRequired
kindstringRequired

Return type: Promise<{ removed: boolean }>. Call the method after element registration and await its Promise result.

getIndicatorKinds

Registered indicator kinds (built-ins + custom), sorted.

typescript
getIndicatorKinds(): Promise<string[]>

Return type: Promise<string[]>. Call the method after element registration and await its Promise result.

getIndicatorValues

Computed columns for one instance over the current render tape.

typescript
getIndicatorValues(id: string): Promise<Record<string, Array<number | null>> | null>
ArgumentsTypeRequired
idstringRequired

Return type: Promise<Record<string, Array<number | null>> | null>. Call the method after element registration and await its Promise result.

addDrawing

Add a drawing (data-coordinate anchors); returns it with the minted id.

typescript
addDrawing(input: StockDrawingInput): Promise<StockDrawing | null>
ArgumentsTypeRequired
inputStockDrawingInputRequired

Return type: Promise<StockDrawing | null>. Call the method after element registration and await its Promise result.

updateDrawing

Merge a patch (anchors/style/meta/visible/locked) into a drawing.

typescript
updateDrawing(id: string, patch: Partial<Omit<StockDrawing, 'id'>>): Promise<void>
ArgumentsTypeRequired
idstringRequired
patchPartial<Omit<StockDrawing, 'id'>>Required

Return type: Promise<void>. Call the method after element registration and await its Promise result.

moveDrawing

Translate a drawing by data-space deltas (locked drawings hold).

typescript
moveDrawing(id: string, deltaTime: number, deltaPrice: number): Promise<void>
ArgumentsTypeRequired
idstringRequired
deltaTimenumberRequired
deltaPricenumberRequired

Return type: Promise<void>. Call the method after element registration and await its Promise result.

removeDrawing

remove one drawing.

typescript
removeDrawing(id: string): Promise<void>
ArgumentsTypeRequired
idstringRequired

Return type: Promise<void>. Call the method after element registration and await its Promise result.

clearDrawings

clear the document (undoable).

typescript
clearDrawings(): Promise<void>

Return type: Promise<void>. Call the method after element registration and await its Promise result.

undoDrawings

An asynchronous method. Check the argument and return types below.

typescript
undoDrawings(): Promise<{ count: number; canUndo: boolean; canRedo: boolean }>

Return type: Promise<{ count: number; canUndo: boolean; canRedo: boolean }>. Call the method after element registration and await its Promise result.

redoDrawings

An asynchronous method. Check the argument and return types below.

typescript
redoDrawings(): Promise<{ count: number; canUndo: boolean; canRedo: boolean }>

Return type: Promise<{ count: number; canUndo: boolean; canRedo: boolean }>. Call the method after element registration and await its Promise result.

getDrawings

The current document (deep-copied, serialisable).

typescript
getDrawings(): Promise<StockDrawing[]>

Return type: Promise<StockDrawing[]>. Call the method after element registration and await its Promise result.

exportDrawings

Versioned JSON export of the document.

typescript
exportDrawings(): Promise<string>

Return type: Promise<string>. Call the method after element registration and await its Promise result.

loadDrawings

Restore a serialized document (undoable — it goes through the history).

typescript
loadDrawings(json: string): Promise<number>
ArgumentsTypeRequired
jsonstringRequired

Return type: Promise<number>. Call the method after element registration and await its Promise result.

getDrawingPoints

Projected css-px points for one drawing on the CURRENT render tape.

typescript
getDrawingPoints(id: string): Promise<Array<{ x: number; y: number }> | null>
ArgumentsTypeRequired
idstringRequired

Return type: Promise<Array<{ x: number; y: number }> | null>. Call the method after element registration and await its Promise result.

setActiveTool

Activate a placement tool (null = the select cursor).

typescript
setActiveTool(tool: string | null): Promise<void>
ArgumentsTypeRequired
toolstring | nullRequired

Return type: Promise<void>. Call the method after element registration and await its Promise result.

getActiveTool

An asynchronous method. Check the argument and return types below.

typescript
getActiveTool(): Promise<string | null>

Return type: Promise<string | null>. Call the method after element registration and await its Promise result.

zoomBy

Zoom programmatically around an anchor fraction (default centre).

typescript
zoomBy(scale: number, anchorFraction?: number): Promise<{ from: number; to: number }>
ArgumentsTypeRequired
scalenumberRequired
anchorFractionnumberOptional

Return type: Promise<{ from: number; to: number }>. Call the method after element registration and await its Promise result.

panByBars

Pan programmatically by (ungrouped) bars.

typescript
panByBars(bars: number): Promise<{ from: number; to: number }>
ArgumentsTypeRequired
barsnumberRequired

Return type: Promise<{ from: number; to: number }>. Call the method after element registration and await its Promise result.

setData

Replace the bar set.

typescript
setData(data: StockDataInput): Promise<void>
ArgumentsTypeRequired
dataStockDataInputRequired

Return type: Promise<void>. Call the method after element registration and await its Promise result.

appendTick

Live tick streaming (): roll a feed update into the tape — inside the last bar's interval it UPDATES the live candle (close replaces, extremes widen, volume accumulates); past it a new bar opens. A tail-pinned window auto-follows the new bar; stale out-of-order ticks drop (returns null).

typescript
appendTick(tick: StockTickInput): Promise<{ appended: boolean; time: number } | null>
ArgumentsTypeRequired
tickStockTickInputRequired

Return type: Promise<{ appended: boolean; time: number } | null>. Call the method after element registration and await its Promise result.

appendTicks

Batch ticks in ONE repaint (returns the last applied result).

typescript
appendTicks(ticks: ReadonlyArray<StockTickInput>): Promise<{ appended: boolean; time: number } | null>
ArgumentsTypeRequired
ticksReadonlyArray<StockTickInput>Required

Return type: Promise<{ appended: boolean; time: number } | null>. Call the method after element registration and await its Promise result.

exportTemplate

Export the chart CONFIGURATION as a versioned JSON template () — style/params, scale, panes, indicators, drawings, compares, flags, window/resolution/grouping. The data tape stays out (templates travel between symbols).

typescript
exportTemplate(): Promise<string>

Return type: Promise<string>. Call the method after element registration and await its Promise result.

importTemplate

Apply a template (per-field whitelist; drawings land undoably).

typescript
importTemplate(json: string): Promise<{ ok: boolean; applied: string[] }>
ArgumentsTypeRequired
jsonstringRequired

Return type: Promise<{ ok: boolean; applied: string[] }>. Call the method after element registration and await its Promise result.

getSnapshotSVG

The composed standalone SVG snapshot (canvas raster + SVG chrome + the brand).

typescript
getSnapshotSVG(): Promise<string | null>

Return type: Promise<string | null>. Call the method after element registration and await its Promise result.

getCSV

The tape as a CSV table (ISO time, OHLC, volume).

typescript
getCSV(): Promise<string>

Return type: Promise<string>. Call the method after element registration and await its Promise result.

exportPNG

Download the composed snapshot as a PNG at export-scale. The grant is confirmed again after the rasterisation await: one lost (or changed) meanwhile rejects with the §4.1 stale refusal — no download, no exported.

typescript
exportPNG(): Promise<void>

Return type: Promise<void>. Call the method after element registration and await its Promise result.

exportSVG

Download the composed snapshot as an SVG file (composed and saved in one turn, under a confirmed grant).

typescript
exportSVG(): Promise<void>

Return type: Promise<void>. Call the method after element registration and await its Promise result.

exportCSV

Download the tape as a CSV file (under a confirmed grant; getCSV stays the ungated read).

typescript
exportCSV(): Promise<void>

Return type: Promise<void>. Call the method after element registration and await its Promise result.

print

Print view with the inlined snapshot (the facade print mirror), opened under a confirmed grant.

typescript
print(): Promise<void>

Return type: Promise<void>. Call the method after element registration and await its Promise result.

getBarCounts

Normalised bar count + visible range (diagnostics/tooling).

typescript
getBarCounts(): Promise<{ bars: number; from: number; to: number }>

Return type: Promise<{ bars: number; from: number; to: number }>. Call the method after element registration and await its Promise result.

getPaneLayout

Current pane rects (layout-local px).

typescript
getPaneLayout(): Promise<{ panes: Array<{ id: string; top: number; height: number }> }>

Return type: Promise<{ panes: Array<{ id: string; top: number; height: number }> }>. Call the method after element registration and await its Promise result.

addPane

Append a pane (default at the bottom).

typescript
addPane(pane: PaneSpecInput, at?: number): Promise<void>
ArgumentsTypeRequired
panePaneSpecInputRequired
atnumberOptional

Return type: Promise<void>. Call the method after element registration and await its Promise result.

removePane

Remove a pane by id (the last pane stays).

typescript
removePane(id: string): Promise<void>
ArgumentsTypeRequired
idstringRequired

Return type: Promise<void>. Call the method after element registration and await its Promise result.

reorderPane

Move a pane to a new stack position.

typescript
reorderPane(id: string, to: number): Promise<void>
ArgumentsTypeRequired
idstringRequired
tonumberRequired

Return type: Promise<void>. Call the method after element registration and await its Promise result.

setPaneWeight

Set a pane's weight directly.

typescript
setPaneWeight(id: string, weight: number): Promise<void>
ArgumentsTypeRequired
idstringRequired
weightnumberRequired

Return type: Promise<void>. Call the method after element registration and await its Promise result.

loadOlderHistory

Pull older bars through historyLoader and keep the view anchored. chart.stock: when the grant ends (or changes) while the loader runs, nothing merges into the frozen tape and the call rejects with the §4.1 stale refusal. The licenseFeatureRefused event (code stale, method loadOlderHistory) is dispatched FIRST; the request then still ends with historyLoaded { added: 0, exhausted: false } so a loading state the app shows for historyRequested clears.

typescript
loadOlderHistory(count?: number): Promise<number>
ArgumentsTypeRequired
countnumberOptional

Return type: Promise<number>. Call the method after element registration and await its Promise result.

applyRange

Apply a range button: window the CURRENT tape by calendar maths.

typescript
applyRange(range: StockRangeKey): Promise<{ from: number; to: number }>
ArgumentsTypeRequired
rangeStockRangeKeyRequired

Return type: Promise<{ from: number; to: number }>. Call the method after element registration and await its Promise result.

setResolution

Switch the tape resolution (resets the window — indices change).

typescript
setResolution(resolution: StockResolution): Promise<void>
ArgumentsTypeRequired
resolutionStockResolutionRequired

Return type: Promise<void>. Call the method after element registration and await its Promise result.