Autoscale and value axis
The value axis is the price column on the right. Two settings control how it behaves:
- Scale mode — linear, logarithmic, or percent.
- Autoscale — automatically zoom the axis to fit visible candles.
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
| Mode | When to use |
|---|---|
lin | Default — normal price steps |
log | Huge 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();
| Event | Use when |
|---|---|
AUTOSCALE | Toggle in your settings panel must stay in sync |
VALUE_AXIS_WIDTH_CHANGE | Layout beside the chart depends on axis width |
Public API summary
| Method | What 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
| Question | Answer |
|---|---|
| Y axis jumped after I changed scale | setValueAxisMode re-enables autoscale |
| Crypto looks flat on linear scale | Try log |
| Need % performance view | setValueAxisMode("%") |
What is next?
- Navigation and viewport — horizontal scroll vs vertical scale
- Custom theme — colors separate from scale
- ChartInstance reference