Methods

Call these on the ApexStock instance you created with new ApexStock(el, options), unless marked as static, which are called on the ApexStock class itself.

Static Methods

ApexStock.setLicense (key)

Register a license key globally, before any chart renders. An invalid, expired, or missing key shows a watermark overlay on the chart.

ApexStock.setLicense('APEX-XXXX...')

ApexStock.aggregateOHLC (series, interval)

Roll a fine-grained OHLC series up into a coarser time frame. Pure helper; pass the result to the constructor or update({ series }). See Time-frame Aggregation.

const hourly = ApexStock.aggregateOHLC(oneMinuteSeries, '1h')

ApexStock.INTERVALS lists the accepted interval strings (e.g. "1m", "5m", "1h", "1d").


ApexStock.setApexCharts (ctor)

Register the ApexCharts constructor once for the whole app, instead of relying on window.ApexCharts or injecting per chart. See Installation & Usage.

import ApexCharts from 'apexcharts'
ApexStock.setApexCharts(ApexCharts)

The other statics

StaticDoes
ApexStock.registerIndicator(name, def)Adds a custom indicator globally
ApexStock.registerDrawingTool(name, def)Adds a custom drawing type
ApexStock.registerTheme(name, def)Adds a theme preset
ApexStock.getThemePresets()Every registered preset name
ApexStock.sync(instances, opts?)Links instances' zoom and crosshair. See Cross-Chart Sync
ApexStock.statsThe headless analysis engine, no chart or DOM required
ApexStock.normalize(rows, mapping?)Adapter: objects or [x,o,h,l,c,v] tuples
ApexStock.fromArrays({ open, high, low, close, ... })Adapter: parallel column arrays
ApexStock.fromCSV(text, opts?)Adapter: CSV text
ApexStock.STATE_VERSIONThe current state schema version
ApexStock.migrateState(state)Brings an older snapshot forward

The three adapters all produce the { x, y: [o, h, l, c], v? } shape and resolve column names by case-insensitive alias (date/time to x, o to open, vol to volume). See Data Format.

Core Methods

render ()

Renders the chart and initializes all components. Call once after construction.

apexStock.render()

update (newOptions)

Applies new options/data while preserving active indicators, zoom state, theme, and chart type. This is the full-rebuild path; for live ticks prefer appendData.

apexStock.update({
  series: [{ data: newData }],
  theme: { mode: 'dark' },
})

updateChartOptions (newOptions)

Updates chart options with theme handling.

apexStock.updateChartOptions({
  chart: { height: 800 },
  theme: { mode: 'dark' },
})

destroy ()

Cleans up the chart instance and removes event listeners.

apexStock.destroy()

Data & Streaming

appendData (pointOrPoints, options)

Incrementally append one or more OHLC bars (or replace the forming last bar) without a full rebuild. Refreshes candles, active indicators, the volume pane, and the x-axis in place. Returns the instance. See Real-time Streaming.

// Append a completed bar and ride the right edge
apexStock.appendData({ x: t, y: [o, h, l, c], v }, { view: 'follow' })

// Live ticker with a fixed 500-bar window
apexStock.appendData(bar, { maxPoints: 500 })

// Update the forming candle instead of appending
apexStock.appendData(bar, { updateLast: true })

Indicator Methods

updateIndicator (indicatorKey)

Adds or updates an indicator overlay/pane, preserving zoom state. See Technical Indicators.

apexStock.updateIndicator('rsi')
apexStock.updateIndicator('moving average')

removeIndicator (indicatorKey)

Removes an indicator, preserving zoom state.

apexStock.removeIndicator('rsi')

Theme Methods

updateTheme (newTheme)

Switches between 'light' and 'dark' without rebuilding the chart. See Theming.

apexStock.updateTheme('dark')

getTheme ()

Returns the current theme ('light' or 'dark').

const current = apexStock.getTheme()

Zoom Methods

getCurrentZoomState ()

Returns the visible x-range as { minX, maxX }, or null if the chart is not yet rendered. See Zoom & Pan.

const range = apexStock.getCurrentZoomState()

applyZoomToAllCharts (zoomState)

Applies a saved zoom state to the main chart and all indicator panes.

apexStock.applyZoomToAllCharts(range)

Trading Overlay Methods

Horizontal price lines for order/stop-loss/take-profit/alert levels. See Trading Overlays.

addPriceLine (config) / addOrderLine / addStopLoss / addTakeProfit / addAlert

Add a price line. addPriceLine is the generic form; the others are typed shortcuts. Each returns the line id, or null on invalid input.

const id = apexStock.addOrderLine({ price: 98.5, side: 'buy', label: 'Entry' })
apexStock.addStopLoss({ price: 95 })
apexStock.addTakeProfit({ price: 104 })
apexStock.addAlert({ price: 100, onCross: (e) => notify(e.direction) })

updatePriceLine (id, patch) / removePriceLine (id) / clearPriceLines ()

Patch, remove, or clear price lines. updatePriceLine and removePriceLine return false if no such line exists.

apexStock.updatePriceLine(id, { price: 97 })
apexStock.removePriceLine(id)
apexStock.clearPriceLines()

getPriceLine (id) / getPriceLines ()

Read back copies of one or all line configs.

const line = apexStock.getPriceLine(id)   // config copy, or null
const all = apexStock.getPriceLines()      // array of config copies

Technical Analysis Methods

ApexStock exposes the underlying indicator calculations (calculateRSI, calculateMACD, calculateBollingerBands, calculateIchimoku, and more) so you can compute values as raw arrays without rendering a pane. See Computing Indicator Values for the full list and signatures.

const rsi = apexStock.calculateRSI(series, 14)
const macd = apexStock.calculateMACD(series, 12, 26, 9)
const bb = apexStock.calculateBollingerBands(series, 20, 2)

Methods by feature

The rest of the surface is documented on the page for the feature it belongs to, so each method appears next to the concepts it needs.

FeatureMethodsPage
Range statisticsgetRangeStats, getDrawdownRange Statistics and Drawdown
Pane layoutsetPaneHeightRatio, getPaneHeightRatiosPane heights
MeasurementmeasureRange, getMeasurements, getMeasurement, clearMeasurement, showAnalysisPanel, hideAnalysisPanel, isAnalysisPanelVisibleMeasuring a Region
ComparisonaddComparison, removeComparison, clearComparisons, getComparisons, setComparisonMode, getComparisonMode, setComparisonOptions, getComparisonOptions, setComparisonBenchmark, getComparisonBenchmark, getComparisonStatsComparison Mode
DrawingsaddDrawing, updateDrawing, removeDrawing, clearDrawings, getDrawing, getDrawingsDrawing Tools
Event markersaddEventMarker, updateEventMarker, removeEventMarker, clearEventMarkers, getEventMarker, getEventMarkersEvent Markers
AnnotationsaddAnnotation, updateAnnotation, removeAnnotation, clearAnnotations, getAnnotation, getAnnotationsAnnotations
Data readoutgetDataAt, showLegend, hideLegend, toggleLegend, isLegendVisibleData Legend and Readout
Price scalesetPriceScale, getPriceScalePrice Scale Modes
ToolbaraddToolbarItem, removeToolbarItem, getToolbarItemsToolbar Customization
Theme presetssetThemePreset, getThemePresetTheming
StategetState, setStateState Persistence
Visible rangegetVisibleRange, setVisibleRangeZoom & Pan
Exportexport, exportImage, exportDataExporting
IndicatorsupdateIndicator, setIndicatorParams, removeIndicator, listIndicators, getIndicatorTechnical Indicators

Events

Subscribe with on(name, handler), which returns an unsubscribe function. off, once and emit are also available.

const stop = apexStock.on('crosshairMove', ({ dataPointIndex }) => {})
stop()
EventPayload
crosshairMove{ dataPointIndex, seriesIndex, x, ohlc, volume, nativeEvent }
clickThe same shape as crosshairMove
rangeChange{ min, max, source }, source is 'zoom' | 'pan' | 'reset'. Once per settled gesture
rangeChangingThe same payload with source: 'live', once per animation frame during a gesture
indicatorToggle{ key, active }
priceScaleChange{ mode, base, logBase, indexBase }
rangeMeasured{ id, from, to, selection, stats, source }, source is 'drag' | 'api' | 'coreRuler'
measurementRemoved{ id }
comparisonChange{ reason, mode, benchmark, baseline, instruments, stats, warnings }
comparisonRestoreNeeded{ names }, after a setState that cannot restore instrument data
drawingAdded / drawingUpdated{ id, drawing }
drawingRemoved{ id }
drawingsCleared{}
eventMarkerAdded / eventMarkerUpdated{ id, marker }
eventMarkerRemoved{ id }
eventMarkersCleared{}
eventMarkerHover / eventMarkerClick{ id, marker, nativeEvent }