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").

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)