Skip to main content
Skip to main content

Autoscale and value axis

The value axis is the price column on the right. Two settings control how it behaves:

  1. Scale mode — linear, logarithmic, or percent.
  2. Autoscale — automatically zoom the axis to fit visible candles.
Dataset
Draw mode
Public API onlycreateChart • init • setMainSeriesData • setMainDrawMode1000 candles per dataset
Loading chart…

Switch draw modes above with the buttons — the Y axis refits when autoscale is on. Same data, different look and scale behavior.

Conceptual overview: Rendering and scales.


Scale modes

ModeWhen to use
linDefault — normal price steps
logHuge ranges (crypto from cents to thousands)
perc or %“% change from start” instead of absolute price
chart.setValueAxisMode("lin");
chart.setValueAxisMode("log");
chart.setValueAxisMode("%"); // same as "perc"

getValueAxisMode() returns the normalized mode (% becomes perc internally).


Autoscale on / off

When on, the chart adjusts the vertical range so visible bars fill the panel:

chart.setAutoScale(true);

if (chart.getAutoScale()) {
console.log("Axis fits visible candles automatically");
}

When off, the range stays frozen until something else changes it — useful when users manually zoom price.

chart.setAutoScale(false);

Important side effect

Changing scale mode turns autoscale back on:

chart.setAutoScale(false);
chart.setValueAxisMode("log");

console.log(chart.getAutoScale()); // true — autoscale was re-enabled

If your UI has an “autoscale off” toggle, sync it after scale changes.


Measure the axis width

Align external UI (legends, buttons) with the chart edge:

const width = chart.getValueAxisWidth();

Width updates when data loads or label formatting changes.


React to changes in your app

Subscribe when your own controls must mirror the chart:

const autoscaleSub = chart.subscribe("AUTOSCALE", (data) => {
console.log("Autoscale:", data.autoScale);
});

const widthSub = chart.subscribe("VALUE_AXIS_WIDTH_CHANGE", (width) => {
console.log("Axis width:", width);
});

autoscaleSub?.unsubscribe();
widthSub?.unsubscribe();
EventUse when
AUTOSCALEToggle in your settings panel must stay in sync
VALUE_AXIS_WIDTH_CHANGELayout beside the chart depends on axis width

Public API summary

MethodWhat it does
getValueAxisMode() / setValueAxisMode()Read or set lin / log / perc
getAutoScale() / setAutoScale()Read or toggle vertical auto-fit
getValueAxisWidth()Pixel width of price column

These apply to the main panel on the public ChartInstance surface. Per-panel or grid customization requires the runtime layer: Chart runtime access.


Common questions

QuestionAnswer
Y axis jumped after I changed scalesetValueAxisMode re-enables autoscale
Crypto looks flat on linear scaleTry log
Need % performance viewsetValueAxisMode("%")

What is next?