Candlestick.
PROShow four prices per period in a candlestick.
LIVE EXAMPLE
OHLC candles
Appearance and style10
Axes and grid lines11
Legend and interaction13
Title and dimensions3
Represent open, high, low, and close prices as candles. All values are sample data.
View code
<div id="chart-container" style="width: 100%; min-width: 0;"></div>
<script type="module">
import { defineCustomElement as define0 } from '@syidax/advanced-pro/components/sy-candlestick-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-candlestick-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
}
],
"timeScale": "ordinal",
"volume": "off",
"width": 640,
"height": 360,
"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', 'candlestick example chart');
return element;
});
container.replaceChildren(...elements);
const chart = elements.at(-1);
const onEvent = event => {
console.log('pointClick', event.detail);
};
chart.addEventListener('pointClick', 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('pointClick', onEvent);
container.replaceChildren();
}
</script>Usage and data
#Explore changes in opening, high, low, and closing prices.
The example uses fictional prices. Match time zones, trading sessions, and adjusted-price conventions to your actual data.
Data contract
| Property | Input format |
|---|---|
data | An array of { time, open, high, low, close, volume? }. |
timeScale | ordinal reflects trading order; linear reflects elapsed time. |
volume | Select pane to display volume alongside prices. |
Updating data
Assign a new array or object to the property instead of mutating values inside an array. Chart events provide selection results through event.detail. When disposing of the view, clean up ResizeObserver and event listeners registered by your app.
Feature examples
#Try 24 interactive feature examples and inspect their code. Select “Edit in preview” to combine more options in the settings panel above.
Hollow candlesPRO
Leave rising candle bodies unfilled to distinguish direction.
View code
Prices and volumePRO
Show a volume panel below the prices.
View code
Inspect values with the pointerPRO
Point to data to view the value at that location.
View code
Crosshair trackingPRO
Move the pointer to read horizontal and vertical coordinates alongside values.
View code
Drag to zoom and panPRO
Drag to zoom and hold Shift to pan. Use Ctrl + wheel to zoom in or out.
View code
Replay animationPRO
Redraw the same example to inspect its initial display animation.
View code
AnimationPRO
Compare 1 examples of Animation. Buttons and options update both the live result and source code.
View code
AxisPRO
Compare 5 examples of Axis. Buttons and options update both the live result and source code.
View code
BandsPRO
Compare 5 examples of Bands. Buttons and options update both the live result and source code.
View code
CrosshairPRO
Compare 5 examples of Crosshair. Buttons and options update both the live result and source code.
View code
Data inputPRO
Compare 1 examples of Data input. Buttons and options update both the live result and source code.
View code
Moving AveragesPRO
Compare 4 examples of Moving Averages. Buttons and options update both the live result and source code.
View code
Large datasetsPRO
Compare 1 examples of Large datasets. Buttons and options update both the live result and source code.
View code
SizePRO
Compare 1 examples of Size. Buttons and options update both the live result and source code.
View code
StylePRO
Compare 6 examples of Style. Buttons and options update both the live result and source code.
View code
Time ScalePRO
Compare 4 examples of Time Scale. Buttons and options update both the live result and source code.
View code
TooltipPRO
Compare 13 examples of Tooltip. Buttons and options update both the live result and source code.
View code
VolumePRO
Compare 3 examples of Volume. Buttons and options update both the live result and source code.
View code
Zoom and panPRO
Compare 6 examples of Zoom and pan. Buttons and options update both the live result and source code.
View code
Context menuPRO
Compare 1 examples of Context menu. Buttons and options update both the live result and source code.
View code
Data context menuPRO
Compare 1 examples of Data context menu. Buttons and options update both the live result and source code.
View code
Read coordinates and dataPRO
Compare 1 examples of Read coordinates and data. Buttons and options update both the live result and source code.
View code
OverviewPRO
Compare 4 examples of Overview. Buttons and options update both the live result and source code.
View code
Streaming · Add and update live dataPRO
Compare 6 examples of Add and update live data. Buttons and options update both the live result and source code.
View code
Add to your interface
#The code tabs below the preview contain the full data, options, event bindings, and responsive sizing for the current example. Copy them into an app project, such as Vite, that can resolve the installed packages.
API reference
#The full public API for sy-candlestick-chart. Pass objects and arrays as JavaScript properties. Select a name to view usage code and type definitions.
Key properties
| Attribute / Property | Type / Default | Description |
|---|---|---|
CandlestickDataDefault: undefined | An array of { time, open, high, low, close, volume? }. | |
numberDefault: 900 | Chart width in pixels. Update with ResizeObserver when the container changes. | |
numberDefault: 360 | Chart height in pixels. | |
| brandLogo | stringDefault: undefined | The default is the Syidax logo. With the Pro chart.branding entitlement, use none or a PNG, JPEG, or WebP data URL. |
| brandPosition | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'Default: 'bottom-right' | The corner where the logo is anchored. Applies equally to Community and Pro, on screen and in image exports. |
| xAxis | CartesianAxisInputDefault: undefined | The time axis (kind `time` by default; `min` / `max` in epoch ms set the visible window). |
| yAxis | YAxisInputDefault: undefined | The price axis, or `[left, right]` slots (the second a relabelled unit of the same price). |
| gridLines | CartesianGridLinesInputDefault: undefined | Allowed values: auto, off. Default: undefined. |
CartesianCrosshairInputDefault: undefined | Crosshair that follows the cursor across the plot. | |
CartesianZoomInputDefault: undefined | Settings for zooming and the visible range. | |
| upColor | stringDefault: DEFAULT_UP_COLOR | Set as an HTML attribute or JavaScript property. type: string. |
| downColor | stringDefault: DEFAULT_DOWN_COLOR | Set as an HTML attribute or JavaScript property. type: string. |
| candleWidth | numberDefault: CANDLE_DEFAULT_WIDTH_RATIO | The body's share of the bar pitch (0 … 1; default 0.7). |
| wickWidth | numberDefault: 1 | The wick width in CSS px. |
| barStyle | CandlestickBarStyleDefault: 'candle' | Allowed values: candle, ohlc, hlc, hilo. Default: 'candle'. |
| bodyStyle | CandlestickBodyStyleDefault: 'solid' | Allowed values: solid, hollow, hollow-up. Default: 'solid'. |
| timeScale | CandlestickTimeScaleDefault: 'ordinal' | ordinal reflects trading order; linear reflects elapsed time. |
CandlestickVolumeModeDefault: 'off' | Select pane to display volume alongside prices. | |
| volumeHeight | numberDefault: 0.25 | Set as an HTML attribute or JavaScript property. type: number. |
| volumeAlpha | numberDefault: 0.45 | Set as an HTML attribute or JavaScript property. type: number. |
| chartTitle | stringDefault: undefined | The title inside the chart. Explain the data's unit and meaning alongside it. |
| chartSubtitle | stringDefault: undefined | The subtitle inside the chart. |
CartesianTooltipInputDefault: undefined | Tooltip settings for pointer-driven values, position, and content. | |
| tooltipEnabled | booleanDefault: true | Set as an HTML attribute or JavaScript property. type: boolean. |
| animated | booleanDefault: false | Whether to animate initial display and data changes. |
| animationDuration | numberDefault: 600 | Animation duration in milliseconds. |
| animationEasing | CandlestickEasingDefault: 'ease-out' | Allowed values: linear, ease-out, ease-in, ease-in-out. Default: 'ease-out'. |
| animationType | CandlestickAnimationTypeDefault: undefined | Allowed values: initial, update. Default: undefined. |
Other properties 27
| Attribute / Property | Type / Default | Description |
|---|---|---|
| xMin | numberDefault: undefined | Explicit domain ends (an omitted end follows the bars; `x-axis` / `y-axis` `min` / `max` also set them). |
| xMax | numberDefault: undefined | Set as an HTML attribute or JavaScript property. type: number. |
| yMin | numberDefault: undefined | Set as an HTML attribute or JavaScript property. type: number. |
| yMax | numberDefault: undefined | Set as an HTML attribute or JavaScript property. type: number. |
numberDefault: 0.05 | The price padding above and below the bars (a fraction of the span; default 0.05). | |
| flatColor | stringDefault: DEFAULT_FLAT_COLOR | Set as an HTML attribute or JavaScript property. type: string. |
| candleMinPx | numberDefault: CANDLE_DEFAULT_MIN_PX | Set as an HTML attribute or JavaScript property. type: number. |
| candleMaxPx | numberDefault: CANDLE_DEFAULT_MAX_PX | Set as an HTML attribute or JavaScript property. type: number. |
| bodyMinPx | numberDefault: 1 | The minimum body height in CSS px (a doji stays visible). |
| tickLength | numberDefault: undefined | Set as an HTML attribute or JavaScript property. type: number. |
| fillAlpha | numberDefault: undefined | Set as an HTML attribute or JavaScript property. type: number. |
| bodyBorderPx | numberDefault: 1 | Set as an HTML attribute or JavaScript property. type: number. |
| wickColor | stringDefault: 'auto' | Set as an HTML attribute or JavaScript property. type: string. |
CandlestickAntialiasDefault: 'auto' | Allowed values: auto, off, on. Default: 'auto'. | |
| pixelSnap | booleanDefault: true | Set as an HTML attribute or JavaScript property. type: boolean. |
CandlestickSessionInput | stringDefault: '24x7' | Pass as a JavaScript property. type: CandlestickSessionInput | string. | |
| labelLocale | stringDefault: 'en-US' | Set as an HTML attribute or JavaScript property. type: string. |
| volumeUpColor | stringDefault: 'auto' | Set as an HTML attribute or JavaScript property. type: string. |
| volumeDownColor | stringDefault: 'auto' | Set as an HTML attribute or JavaScript property. type: string. |
CandlestickOverlayInput | stringDefault: undefined | Pass as a JavaScript property. type: CandlestickOverlayInput | string. | |
| enableMouseTracking | booleanDefault: true | Set as an HTML attribute or JavaScript property. type: boolean. |
| tooltipFormat | (detail: CandlestickPointEventDetail) => stringDefault: undefined | Pass as a JavaScript property. type: (detail: CandlestickPointEventDetail) => string. |
| streamSource | CandlestickStreamSourceDefault: undefined | A stream source for live data. Check the contract for the specific type. |
| streamMax | numberDefault: undefined | The maximum number of streaming data points to retain. |
| streamWindow | numberDefault: undefined | The streaming data range to keep visible. |
CandlestickEngineModeDefault: 'auto' | Renderer selection: auto, standard, or pro. Engine selection is separate from permission to use a Pro chart type. | |
CandlestickUnavailableBehaviourDefault: 'fallback' | Allowed values: fallback, error. Default: 'fallback'. |
Events 14
| Events | Detail type | Description |
|---|---|---|
CandlestickRenderResult & { tier: CandlestickEngineTier; engine?: ChartEngineStatus } | Emits rendering results in detail when chart drawing completes. | |
CandlestickPointEventDetail | A point selection event. Read the selected data and index from CustomEvent.detail. | |
CandlestickPointEventDetail | null | CustomEvent.detail type: CandlestickPointEventDetail | null. Event names are case-sensitive. | |
CartesianCrosshairEventDetail | null | CustomEvent.detail type: CartesianCrosshairEventDetail | null. Event names are case-sensitive. | |
ChartPointContextMenuEventDetail<CandlestickPointEventDetail> | CustomEvent.detail type: ChartPointContextMenuEventDetail<CandlestickPointEventDetail>. Event names are case-sensitive. | |
{ count: number; replaced: number } | CustomEvent.detail type: { count: number; replaced: number }. Event names are case-sensitive. | |
{ dropped: number } | CustomEvent.detail type: { dropped: number }. Event names are case-sensitive. | |
CartesianTooltipEventDetail | Whether to display the built-in tooltip. | |
void | CustomEvent.detail type: void. Event names are case-sensitive. | |
CartesianTooltipActionEventDetail | CustomEvent.detail type: CartesianTooltipActionEventDetail. Event names are case-sensitive. | |
void | CustomEvent.detail type: void. Event names are case-sensitive. | |
void | CustomEvent.detail type: void. Event names are case-sensitive. | |
void | CustomEvent.detail type: void. Event names are case-sensitive. | |
CartesianZoomChangeEventDetail | Fired after every zoom change (drag / pan / wheel / pinch / keyboard / api / reset) with the new state. |
Methods 35
Stencil methods return Promises. Use await within an async function to read the result.
| Method / Arguments | Return type | Description |
|---|---|---|
Promise<ChartDataTable> | Current normalized table, including the retained stream; independent of GPU availability. | |
Promise<CandlestickRenderResult> | Draws a frame now; rejects with the SyidaxLicenseError while the type is not entitled or the chart is frozen. | |
Promise<CandlestickEngineTier> | An asynchronous method. Check the argument and return types below. | |
Promise<string | undefined> | An asynchronous method. Check the argument and return types below. | |
| data: CandlestickData | Promise<void> | An asynchronous method. Check the argument and return types below. |
| bar: CandlestickBarInput | Promise<void> | Upsert one bar (a matching time replaces — the live candle). |
| bars: ReadonlyArray<CandlestickBarInput> | Promise<void> | An asynchronous method. Check the argument and return types below. |
| count: number | Promise<void> | Drop the oldest streamed bars (the `data` bars are not the stream). |
| bars: ReadonlyArray<CandlestickBarInput> | Promise<void> | An asynchronous method. Check the argument and return types below. |
Promise<CandlestickStreamSource | undefined> | An asynchronous method. Check the argument and return types below. | |
| options: { duration?: number; easing?: CandlestickEasing; enabled?: boolean; type?: CandlestickAnimationType } | Promise<void> | An asynchronous method. Check the argument and return types below. |
Promise<void> | An asynchronous method. Check the argument and return types below. | |
Promise<void> | An asynchronous method. Check the argument and return types below. | |
Promise<void> | An asynchronous method. Check the argument and return types below. | |
| cssX: number, cssY: number | Promise<CandlestickPointEventDetail | null> | The bar under a host-local point (the nearest bar within half a pitch, anywhere inside the plot's height). |
| index: number | Promise<CandlestickBar | null> | The normalised bar at an index (null outside). |
| time: number | Promise<(CandlestickBar & { index: number }) | null> | The bar nearest to a time (null for an empty series). |
Promise<number> | An asynchronous method. Check the argument and return types below. | |
Promise<CandlestickExtent> | An asynchronous method. Check the argument and return types below. | |
Promise<CandlestickDomain> | An asynchronous method. Check the argument and return types below. | |
Promise<CandlestickVisibleRange> | The bars the plot shows: the `x-axis` window, narrowed by the zoom when one is in place. | |
| index: number | Promise<CartesianTooltipEventDetail | null> | An asynchronous method. Check the argument and return types below. |
Promise<void> | An asynchronous method. Check the argument and return types below. | |
| index: number | Promise<CandlestickPointEventDetail | null> | An asynchronous method. Check the argument and return types below. |
Promise<CandlestickOverlayState[]> | An asynchronous method. Check the argument and return types below. | |
| index: number | Promise<Record<string, number | null>> | An asynchronous method. Check the argument and return types below. |
Promise<CandlestickPaneRects> | An asynchronous method. Check the argument and return types below. | |
Promise<CandlestickTimeScaleState> | An asynchronous method. Check the argument and return types below. | |
| request: CartesianZoomRequest | Promise<CartesianZoomChangeEventDetail | null> | Zoom to explicit windows: `x` / `y` as `{ min, max }` or `[min, max]` (`null` clears that orientation; x in slots under the ordinal scale — bar i sits at i — or epoch ms under linear, y in price); `xAxis` / `yAxis` name the axis by id or slot index (default: the primary axis). |
| factor: number, anchorFraction?: number | Promise<CartesianZoomChangeEventDetail | null> | Scale the current windows by `factor` (< 1 zooms in) around `anchorFraction` (0..1, default centre). |
| delta: { x?: number; y?: number } | Promise<CartesianZoomChangeEventDetail | null> | Slide the zoomed windows by data units (`{ x?, y? }` — x in slots or ms, y in price); a no-op at the full extent. |
Promise<CartesianZoomChangeEventDetail | null> | Back to the full extent. | |
Promise<CartesianZoomState | null> | The current zoom state (`null` = full extent). | |
| request?: CartesianZoomExtentRequest | Promise<CartesianZoomExtentDetail | null> | The full extent (and key) of the primary — or the named — master axes (x: the visible slot range −0.5 … n − 0.5 under ordinal, the ms window under linear; y: the fitted price domain). |
Promise<ChartEngineStatus> | Requested engine vs what runs, and why (CHART-ADD-08): the decision for the current inputs, read without side effects (ProChartLicense.engineStatus); a renderer that failed at run time reports engine-unsupported. |
No matching APIs.