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.
| Input | Data description |
|---|---|
data | Chronological OHLCV records. |
session | 24x7 or a trading session. |
flags | Events with time, text, and title. |
seriesStyle | How prices are drawn. |
- Run in Components
Change options and view framework-specific code
- Shared installation and integration
Complete implementation example
<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.
| Item | Value |
|---|---|
| JavaScript property | width |
| HTML attribute | width |
| Type | number |
| Default | 760 |
height
Chart height in pixels. Allow space for axes, titles, and the legend.
| Item | Value |
|---|---|
| JavaScript property | height |
| HTML attribute | height |
| Type | number |
| Default | 420 |
brandLogo
The default is the Syidax symbol and wordmark. With the Pro chart.branding entitlement, set none to remove it or provide a PNG, JPEG, or WebP data URL to replace it.
| Item | Value |
|---|---|
| JavaScript property | brandLogo |
| HTML attribute | brand-logo |
| Type | string |
| Default | undefined |
undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.
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.
| Item | Value |
|---|---|
| JavaScript property | brandPosition |
| HTML attribute | brand-position |
| Type | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' |
| Default | 'bottom-right' |
| Allowed values | top-left, top-right, bottom-left, bottom-right |
data
Chronological OHLCV records.
| Item | Value |
|---|---|
| JavaScript property | data |
| HTML attribute | Pass objects, arrays, and callbacks as JavaScript properties |
| Type | StockDataInput |
| Default | undefined |
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.
| Item | Value |
|---|---|
| JavaScript property | session |
| HTML attribute | Pass objects, arrays, and callbacks as JavaScript properties |
| Type | '24x7' | 'us-equity' | StockSessionInput |
| Default | '24x7' |
| Literals in the type | 24x7, us-equity |
- StockSessionInput
Type definition
visibleFrom
Visible bar range (indices; defaults to everything).
| Item | Value |
|---|---|
| JavaScript property | visibleFrom |
| HTML attribute | visible-from |
| Type | number |
| Default | undefined |
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.
| Item | Value |
|---|---|
| JavaScript property | visibleTo |
| HTML attribute | visible-to |
| Type | number |
| Default | undefined |
undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.
showRangeSelector
Show the 1M/3M/6M/YTD/1Y/All + resolution button rows ().
| Item | Value |
|---|---|
| JavaScript property | showRangeSelector |
| HTML attribute | show-range-selector |
| Type | boolean |
| Default | false |
resolution
Tape resolution: 1d raw / 1w / 1M calendar roll-ups.
| Item | Value |
|---|---|
| JavaScript property | resolution |
| HTML attribute | resolution |
| Type | StockResolution |
| Default | '1d' |
| Allowed values | 1d, 1w, 1M |
- StockResolution
Type definition
dataGrouping
View-density grouping: auto (default) / off / a forced factor.
| Item | Value |
|---|---|
| JavaScript property | dataGrouping |
| HTML attribute | data-grouping |
| Type | string |
| 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.
| Item | Value |
|---|---|
| JavaScript property | historyLoader |
| HTML attribute | Pass objects, arrays, and callbacks as JavaScript properties |
| Type | (oldestTime: number, count: number) => Promise<ReadonlyArray<StockBarInput>> | ReadonlyArray<StockBarInput> |
| Default | undefined |
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).
| Item | Value |
|---|---|
| JavaScript property | historyThreshold |
| HTML attribute | history-threshold |
| Type | number |
| Default | 30 |
panes
Pane stack (): [{id, weight, label?}], price first by convention. Weights are proportions; separators drag live.
| Item | Value |
|---|---|
| JavaScript property | panes |
| HTML attribute | Pass objects, arrays, and callbacks as JavaScript properties |
| Type | ReadonlyArray<PaneSpecInput> |
| Default | undefined |
undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.
- PaneSpecInput
Type definition
seriesStyle
How prices are drawn.
| Item | Value |
|---|---|
| JavaScript property | seriesStyle |
| HTML attribute | series-style |
| Type | StockSeriesStyle | DerivedStockStyle |
| Default | 'candlestick' |
| Allowed values | area, ohlc, hlc, hilo, hollow, line, candlestick, column-range, baseline, hlc-area, volume-candle, heikin-ashi, renko, kagi, point-figure, line-break |
- StockSeriesStyle
Type definition
- DerivedStockStyle
Type definition
brickSize
Renko brick size in price units (default auto — close range/50, nice).
| Item | Value |
|---|---|
| JavaScript property | brickSize |
| HTML attribute | brick-size |
| Type | number |
| Default | undefined |
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).
| Item | Value |
|---|---|
| JavaScript property | reversalPct |
| HTML attribute | reversal-pct |
| Type | number |
| Default | 4 |
boxSize
Point & Figure box size (default auto) and reversal boxes (default 3).
| Item | Value |
|---|---|
| JavaScript property | boxSize |
| HTML attribute | box-size |
| Type | number |
| Default | undefined |
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.
| Item | Value |
|---|---|
| JavaScript property | reversalBoxes |
| HTML attribute | reversal-boxes |
| Type | number |
| Default | 3 |
lineBreakCount
Line Break lookback (default 3-line break).
| Item | Value |
|---|---|
| JavaScript property | lineBreakCount |
| HTML attribute | line-break-count |
| Type | number |
| Default | 3 |
upColor
Up/down candle colours (close ≥ open → up).
| Item | Value |
|---|---|
| JavaScript property | upColor |
| HTML attribute | up-color |
| Type | string |
| Default | '#16a34a' |
downColor
Set as an HTML attribute or JavaScript property. type: string.
| Item | Value |
|---|---|
| JavaScript property | downColor |
| HTML attribute | down-color |
| Type | string |
| Default | '#dc2626' |
baselineValue
Baseline anchor for series-style="baseline" (default first visible close).
| Item | Value |
|---|---|
| JavaScript property | baselineValue |
| HTML attribute | baseline-value |
| Type | number |
| Default | undefined |
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.
| Item | Value |
|---|---|
| JavaScript property | lineColor |
| HTML attribute | line-color |
| Type | string |
| Default | '#2563eb' |
priceScaleMode
Right-scale space: linear (default) / log / percent / indexed.
| Item | Value |
|---|---|
| JavaScript property | priceScaleMode |
| HTML attribute | price-scale |
| Type | string |
| Default | 'linear' |
referenceLines
Reference lines, comma list: current,previous-close,high,low,bid,ask.
| Item | Value |
|---|---|
| JavaScript property | referenceLines |
| HTML attribute | reference-lines |
| Type | string |
| Default | undefined |
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.
| Item | Value |
|---|---|
| JavaScript property | bid |
| HTML attribute | bid |
| Type | number |
| Default | undefined |
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.
| Item | Value |
|---|---|
| JavaScript property | ask |
| HTML attribute | ask |
| Type | number |
| Default | undefined |
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 ().
| Item | Value |
|---|---|
| JavaScript property | crosshair |
| HTML attribute | crosshair |
| Type | boolean |
| Default | true |
showLegend
Set as an HTML attribute or JavaScript property. type: boolean.
| Item | Value |
|---|---|
| JavaScript property | showLegend |
| HTML attribute | show-legend |
| Type | boolean |
| Default | true |
compareSymbols
Compare overlays (): [{id, name?, color?, data}]. Any active compare FORCES the percent scale — every series reads vs its own first visible close.
| Item | Value |
|---|---|
| JavaScript property | compareSymbols |
| HTML attribute | Pass objects, arrays, and callbacks as JavaScript properties |
| Type | ReadonlyArray<CompareSymbolInput> |
| Default | undefined |
undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.
- CompareSymbolInput
Type definition
flags
Events with time, text, and title.
| Item | Value |
|---|---|
| JavaScript property | flags |
| HTML attribute | Pass objects, arrays, and callbacks as JavaScript properties |
| Type | ReadonlyArray<StockFlagInput> |
| Default | undefined |
undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.
- StockFlagInput
Type definition
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.
| Item | Value |
|---|---|
| JavaScript property | indicators |
| HTML attribute | Pass objects, arrays, and callbacks as JavaScript properties |
| Type | ReadonlyArray<StockIndicatorInput> |
| Default | undefined |
undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.
- StockIndicatorInput
Type definition
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.
| Item | Value |
|---|---|
| JavaScript property | drawings |
| HTML attribute | Pass objects, arrays, and callbacks as JavaScript properties |
| Type | ReadonlyArray<StockDrawingInput> |
| Default | undefined |
undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.
- StockDrawingInput
Type definition
showToolbar
Show the left drawing-tools toolbar ().
| Item | Value |
|---|---|
| JavaScript property | showToolbar |
| HTML attribute | show-toolbar |
| Type | boolean |
| Default | false |
exportScale
PNG export pixel scale ().
| Item | Value |
|---|---|
| JavaScript property | exportScale |
| HTML attribute | export-scale |
| Type | number |
| Default | 2 |
locale
BCP-47 locale (): month labels + price/P&L number formats.
| Item | Value |
|---|---|
| JavaScript property | locale |
| HTML attribute | locale |
| Type | string |
| Default | 'en-US' |
trades
Executed trades (): [{time, side: buy|sell, price, quantity?}].
| Item | Value |
|---|---|
| JavaScript property | trades |
| HTML attribute | Pass objects, arrays, and callbacks as JavaScript properties |
| Type | ReadonlyArray<StockTradeInput> |
| Default | undefined |
undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.
- StockTradeInput
Type definition
positions
Open positions (): [{side: long|short, entryPrice, quantity}] — live P&L badges.
| Item | Value |
|---|---|
| JavaScript property | positions |
| HTML attribute | Pass objects, arrays, and callbacks as JavaScript properties |
| Type | ReadonlyArray<StockPositionInput> |
| Default | undefined |
undefined means this property was not explicitly set. The effective value may depend on the chart type and other settings.
- StockPositionInput
Type definition
chartTitle
The title inside the chart. Explain the data's unit and meaning alongside it.
| Item | Value |
|---|---|
| JavaScript property | chartTitle |
| HTML attribute | chart-title |
| Type | string |
| Default | undefined |
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.
| Item | Value |
|---|---|
| JavaScript property | chartSubtitle |
| HTML attribute | chart-subtitle |
| Type | string |
| Default | undefined |
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 }>.
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 }> }>.
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 }>.
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 }>.
chart.addEventListener('rangeSelected', event => {
console.log(event.detail); // { range: StockRangeKey; from: number; to: number }
});- StockRangeKey
Type definition
resolutionChanged
The resolution changed.
Event name: resolutionChanged. Names are case-sensitive. Read the payload from detail on CustomEvent<{ resolution: StockResolution }>.
chart.addEventListener('resolutionChanged', event => {
console.log(event.detail); // { resolution: StockResolution }
});- StockResolution
Type definition
historyRequested
A history load started / finished.
Event name: historyRequested. Names are case-sensitive. Read the payload from detail on CustomEvent<{ oldestTime: number; count: number }>.
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 }>.
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>.
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[] }>.
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 }>.
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>.
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[] }>.
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 }>.
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>.
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 }>.
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 }>.
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 }>.
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[] }>.
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 }>.
chart.addEventListener('exported', event => {
console.log(event.detail); // { format: string; filename: string }
});Methods
addCompare
Add a compare overlay (duplicate ids replace).
addCompare(symbol: CompareSymbolInput): Promise<void>| Arguments | Type | Required |
|---|---|---|
symbol | CompareSymbolInput | Required |
Return type: Promise<void>. Call the method after element registration and await its Promise result.
- CompareSymbolInput
Type definition
removeCompare
Remove a compare overlay by id.
removeCompare(id: string): Promise<void>| Arguments | Type | Required |
|---|---|---|
id | string | Required |
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.
addIndicator(spec: StockIndicatorInput): Promise<StockIndicatorInput>| Arguments | Type | Required |
|---|---|---|
spec | StockIndicatorInput | Required |
Return type: Promise<StockIndicatorInput>. Call the method after element registration and await its Promise result.
- StockIndicatorInput
Type definition
removeIndicator
Remove an indicator by resolved id (its synthesized pane goes with it).
removeIndicator(id: string): Promise<void>| Arguments | Type | Required |
|---|---|---|
id | string | Required |
Return type: Promise<void>. Call the method after element registration and await its Promise result.
updateIndicator
Merge params into an instance (by resolved id).
updateIndicator(id: string, params: Record<string, number | string>): Promise<void>| Arguments | Type | Required |
|---|---|---|
id | string | Required |
params | Record<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).
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).
defineIndicator(definition: IndicatorDefinition): Promise<{ ok: boolean; errors: string[] }>| Arguments | Type | Required |
|---|---|---|
definition | IndicatorDefinition | Required |
Return type: Promise<{ ok: boolean; errors: string[] }>. Call the method after element registration and await its Promise result.
- IndicatorDefinition
Type definition
undefineIndicator
Remove a definition; live instances of the kind resolve away.
undefineIndicator(kind: string): Promise<{ removed: boolean }>| Arguments | Type | Required |
|---|---|---|
kind | string | Required |
Return type: Promise<{ removed: boolean }>. Call the method after element registration and await its Promise result.
getIndicatorKinds
Registered indicator kinds (built-ins + custom), sorted.
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.
getIndicatorValues(id: string): Promise<Record<string, Array<number | null>> | null>| Arguments | Type | Required |
|---|---|---|
id | string | Required |
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.
addDrawing(input: StockDrawingInput): Promise<StockDrawing | null>| Arguments | Type | Required |
|---|---|---|
input | StockDrawingInput | Required |
Return type: Promise<StockDrawing | null>. Call the method after element registration and await its Promise result.
- StockDrawing
Type definition
- StockDrawingInput
Type definition
updateDrawing
Merge a patch (anchors/style/meta/visible/locked) into a drawing.
updateDrawing(id: string, patch: Partial<Omit<StockDrawing, 'id'>>): Promise<void>| Arguments | Type | Required |
|---|---|---|
id | string | Required |
patch | Partial<Omit<StockDrawing, 'id'>> | Required |
Return type: Promise<void>. Call the method after element registration and await its Promise result.
- StockDrawing
Type definition
moveDrawing
Translate a drawing by data-space deltas (locked drawings hold).
moveDrawing(id: string, deltaTime: number, deltaPrice: number): Promise<void>| Arguments | Type | Required |
|---|---|---|
id | string | Required |
deltaTime | number | Required |
deltaPrice | number | Required |
Return type: Promise<void>. Call the method after element registration and await its Promise result.
removeDrawing
remove one drawing.
removeDrawing(id: string): Promise<void>| Arguments | Type | Required |
|---|---|---|
id | string | Required |
Return type: Promise<void>. Call the method after element registration and await its Promise result.
clearDrawings
clear the document (undoable).
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.
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.
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).
getDrawings(): Promise<StockDrawing[]>Return type: Promise<StockDrawing[]>. Call the method after element registration and await its Promise result.
- StockDrawing
Type definition
exportDrawings
Versioned JSON export of the document.
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).
loadDrawings(json: string): Promise<number>| Arguments | Type | Required |
|---|---|---|
json | string | Required |
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.
getDrawingPoints(id: string): Promise<Array<{ x: number; y: number }> | null>| Arguments | Type | Required |
|---|---|---|
id | string | Required |
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).
setActiveTool(tool: string | null): Promise<void>| Arguments | Type | Required |
|---|---|---|
tool | string | null | Required |
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.
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).
zoomBy(scale: number, anchorFraction?: number): Promise<{ from: number; to: number }>| Arguments | Type | Required |
|---|---|---|
scale | number | Required |
anchorFraction | number | Optional |
Return type: Promise<{ from: number; to: number }>. Call the method after element registration and await its Promise result.
panByBars
Pan programmatically by (ungrouped) bars.
panByBars(bars: number): Promise<{ from: number; to: number }>| Arguments | Type | Required |
|---|---|---|
bars | number | Required |
Return type: Promise<{ from: number; to: number }>. Call the method after element registration and await its Promise result.
setData
Replace the bar set.
setData(data: StockDataInput): Promise<void>| Arguments | Type | Required |
|---|---|---|
data | StockDataInput | Required |
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).
appendTick(tick: StockTickInput): Promise<{ appended: boolean; time: number } | null>| Arguments | Type | Required |
|---|---|---|
tick | StockTickInput | Required |
Return type: Promise<{ appended: boolean; time: number } | null>. Call the method after element registration and await its Promise result.
- StockTickInput
Type definition
appendTicks
Batch ticks in ONE repaint (returns the last applied result).
appendTicks(ticks: ReadonlyArray<StockTickInput>): Promise<{ appended: boolean; time: number } | null>| Arguments | Type | Required |
|---|---|---|
ticks | ReadonlyArray<StockTickInput> | Required |
Return type: Promise<{ appended: boolean; time: number } | null>. Call the method after element registration and await its Promise result.
- StockTickInput
Type definition
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).
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).
importTemplate(json: string): Promise<{ ok: boolean; applied: string[] }>| Arguments | Type | Required |
|---|---|---|
json | string | Required |
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).
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).
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.
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).
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).
exportCSV(): Promise<void>Return type: Promise<void>. Call the method after element registration and await its Promise result.
Print view with the inlined snapshot (the facade print mirror), opened under a confirmed grant.
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).
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).
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).
addPane(pane: PaneSpecInput, at?: number): Promise<void>| Arguments | Type | Required |
|---|---|---|
pane | PaneSpecInput | Required |
at | number | Optional |
Return type: Promise<void>. Call the method after element registration and await its Promise result.
- PaneSpecInput
Type definition
removePane
Remove a pane by id (the last pane stays).
removePane(id: string): Promise<void>| Arguments | Type | Required |
|---|---|---|
id | string | Required |
Return type: Promise<void>. Call the method after element registration and await its Promise result.
reorderPane
Move a pane to a new stack position.
reorderPane(id: string, to: number): Promise<void>| Arguments | Type | Required |
|---|---|---|
id | string | Required |
to | number | Required |
Return type: Promise<void>. Call the method after element registration and await its Promise result.
setPaneWeight
Set a pane's weight directly.
setPaneWeight(id: string, weight: number): Promise<void>| Arguments | Type | Required |
|---|---|---|
id | string | Required |
weight | number | Required |
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.
loadOlderHistory(count?: number): Promise<number>| Arguments | Type | Required |
|---|---|---|
count | number | Optional |
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.
applyRange(range: StockRangeKey): Promise<{ from: number; to: number }>| Arguments | Type | Required |
|---|---|---|
range | StockRangeKey | Required |
Return type: Promise<{ from: number; to: number }>. Call the method after element registration and await its Promise result.
- StockRangeKey
Type definition
setResolution
Switch the tape resolution (resets the window — indices change).
setResolution(resolution: StockResolution): Promise<void>| Arguments | Type | Required |
|---|---|---|
resolution | StockResolution | Required |
Return type: Promise<void>. Call the method after element registration and await its Promise result.
- StockResolution
Type definition