Price Scale Modes

The primary y-axis has four modes:

chart.setPriceScale('logarithmic')
chart.setPriceScale('percent')
chart.setPriceScale('indexed', { indexBase: 100 })
chart.setPriceScale('linear')

Or at construction:

const chart = new ApexStock(el, {
  priceScale: { mode: 'percent' },
  // ...
})
ModeAxis readsOptions
'linear'Price. The default
'logarithmic'Price, on a log axislogBase, default 10
'percent'Percent change from a baselinebase, defaults to the first bar's close
'indexed'An index where the baseline reads indexBaseindexBase, default 100

getPriceScale() returns { mode, base, logBase, indexBase }.

Only one of them changes the data

This is the important distinction. percent and indexed are affine relabelings of the axis: the same numbers are drawn in the same places, with different tick text. Nothing else on the chart has to know about them, so indicators, drawings, annotations and trading price lines stay in true price space and are unaffected. A stop loss at 187.40 is still at 187.40.

logarithmic is the one that genuinely changes the gridline distribution, because that is what a log axis is for.

What persists

The mode survives a theme switch, a chart-type switch, and appendData. Under appendData in percent or indexed mode the baseline is recomputed from the current first bar, so a scrolling window rebases rather than drifting.

It is captured by getState() and fires an event on change:

chart.on('priceScaleChange', ({ mode, base, logBase, indexBase }) => {})

Not the same as comparison mode

Percent-change appears in two places and they are separate systems:

priceScale: { mode: 'percent' }Comparison mode 'percent'
Applies toThe primary y-axis labelThe normalization of several instruments
Baselines onThe series' first bar, or an explicit baseThe comparison baseline policy, 'common' by default
AffectsAxis text onlyWhat each comparison line plots

They can be used together, and they answer different questions: one is how the primary's own axis is labelled, the other is how several instruments are made comparable.

See also