ChartnautDocs

Layout and charts

A terminal is a layout of charts and panels. You name each chart with your own id (main, htf) and drive it through terminal.chart(id).

Charts by id

import { Terminal, useTerminal } from "@chartnaut/charts/react";

export function TwoCharts() {
  const terminal = useTerminal();
  return (
    <div style={{ height: 720 }}>
      <Terminal
        ref={terminal.ref}
        layout="2h"
        charts={{
          main: { symbol: "NAS100", timeframe: "5m", type: "candlesticks" },
          htf: { symbol: "NAS100", timeframe: "4h" },
        }}
      />
    </div>
  );
}

Charts are always keyed by id, never a list. Name yours when you want to drive them; charts the user adds get ids of their own (chart-3). useLayout and terminal.layout.charts list every chart's id in layout order.

One chart

import { createTerminal } from "@chartnaut/charts";

const terminal = createTerminal(document.getElementById("terminal")!, {
  charts: { main: { symbol: "NAS100", timeframe: "15m" } },
});
const main = terminal.chart("main");

async function drive() {
  const { affected } = await main.setSymbol("EURUSD"); // resolves when the chart shows it
  console.log("Changed:", affected);
  await main.setTimeframe("1h", { link: false });
  await main.setType("heikin-ashi");
  await main.setVisibleRange("2026-09-15T09:30-04:00", "2026-09-15T16:00-04:00");
  main.on("symbolChange", (e) => console.log("Now", e.data.symbol));
}
drive();

Call

What it does

setSymbol(symbol)

Shows a market. Linked charts follow unless { link: false }; affected names every chart that changed

setTimeframe(tf)

1m, 5m, 15m, 30m, 1h, 2h, 4h, 1d, 1w, 1mo

setType(type)

candlesticks, hollow-candlesticks, bars, line, area, heikin-ashi, volume-footprint, volume-profile, time-price-opportunity, volume-bubbles, liquidity-heatmap

setVisibleRange(from, to), scrollTo(time), zoom(bars), resetView()

The view

focus()

The terminal's focus ring, and the chart commands go to by default. Never takes your page's keyboard

pickSymbol({ apply })

Opens Chartnaut's market search over the terminal and resolves with the choice, or null

pickScript()

Opens Chartnaut's script picker and resolves with the script the person added, or null

get()

Reads the chart again

Calls resolve when the chart shows the change. Pass { wait: "settled" } to wait for the whole history to load, or { wait: "accepted" } to only wait for the terminal to take it. A change that hasn't shown in 10 seconds answers with pending: true.

Times are unix seconds, a Date, or ISO text with an offset (2026-09-15T13:30-04:00). Where a call takes { tz }, local text with a time zone works too. Text with neither is refused, because it could mean any time zone.

Chart events: symbolChange, timeframeChange, typeChange, visibleRangeChange, scaleChange, focus, remove, barClose and resize.

Your own controls over a chart

chart.rect is the chart's box inside the terminal, in CSS pixels, and resize fires when it moves. Float your own UI over a chart with it:

import { createTerminal } from "@chartnaut/charts";

const terminal = createTerminal(document.getElementById("terminal")!, {
  charts: { main: { symbol: "NAS100", timeframe: "15m" } },
});
const badge = document.createElement("div");

terminal.chart("main").on("resize", (e) => {
  badge.style.left = `${e.data.rect.x + e.data.rect.width - 120}px`;
  badge.style.top = `${e.data.rect.y + 8}px`;
});

The layout

import { createTerminal } from "@chartnaut/charts";

const terminal = createTerminal(document.getElementById("terminal")!, {});

async function build() {
  await terminal.layout.set(
    { direction: "row", sizes: [60, 40], children: ["main", { direction: "column", children: ["htf", "book"] }] },
    {
      charts: { main: { symbol: "NAS100", timeframe: "5m" }, htf: { symbol: "NAS100", timeframe: "1h" } },
      panels: { book: { kind: "order-book", settings: { symbol: "NAS100" } } },
    },
  );
  await terminal.layout.addChart({ id: "daily", symbol: "NAS100", timeframe: "1d", nextTo: "htf", side: "bottom" });
  terminal.layout.on("chartRemoved", (e) => console.log("Closed", e.data.chart_id));
}
build();

A layout is a preset or a split tree whose leaves are chart and panel ids, with sizes in percent. Up to 8 charts, and up to 4 panels in a frame. This is how a page gets more charts: a page holds one terminal, and a second one is refused with not_allowed. Past the user's plan, set is refused with plan_limit and the charts the plan allows still show.

Panels: watchlist, order-book, position-manager, economic-calendar, options-levels.

Linking charts

Linked charts follow each other's symbol, timeframe, crosshair or time:

import { createTerminal } from "@chartnaut/charts";

const terminal = createTerminal(document.getElementById("terminal")!, {
  layout: "2h",
  charts: { main: { symbol: "NAS100", timeframe: "5m" }, htf: { symbol: "NAS100", timeframe: "4h" } },
});

terminal.links.set([{ id: "a", charts: ["main", "htf"], link: ["symbol"] }]);

chart.link("a") puts one chart in a group, chart.link(null) takes it out.

The terminal's interface, on or off

interface switches every part around the charts. onlyCharts turns them all off, for when you build your own toolbar:

import { onlyCharts } from "@chartnaut/charts";
import { Terminal, useChart, useTerminal } from "@chartnaut/charts/react";

export function MyTerminal() {
  const terminal = useTerminal();
  const chart = useChart(terminal);

  return (
    <div style={{ display: "flex", flexDirection: "column", height: "100vh" }}>
      <header>
        <button onClick={() => chart.chart.pickSymbol({ apply: true })}>{chart.symbol ?? "Pick a market"}</button>
        {(["5m", "15m", "1h", "4h"] as const).map((tf) => (
          <button key={tf} onClick={() => chart.setTimeframe(tf)}>{tf}</button>
        ))}
      </header>
      <div style={{ flex: 1 }}>
        <Terminal ref={terminal.ref} interface={onlyCharts} layout="2x2" />
      </div>
    </div>
  );
}

The parts you can switch: top_toolbar, chart_toolbar, drawing_rail, drawing_toolbar, context_menu, legend, price_axis, time_axis, chart_tabs, replay_bar, order_bar, account_card, trades_panel, frame (padding, gap, border, transparent background), layout.resizable and keyboard. Most take true or false, and some go deeper: { chart_toolbar: { timeframe: false } }. "Powered by Chartnaut" stays unless your plan removes it (Plans and limits).

Your colours

import { createTerminal } from "@chartnaut/charts";

const terminal = createTerminal(document.getElementById("terminal")!, {
  appearance: { preset: "Carbon", trading: { buy: "#22c55e", sell: "#f43f5e" } },
});

terminal.appearance.presets().then((presets) => console.log(presets.map((p) => p.label)));

appearance takes one of Chartnaut's theme presets plus anything a chartbook can set: theme colours, trading colours, chart and series settings. It applies to this terminal only and is never saved into the user's own Chartnaut. appearance.applyPreset(name) switches preset; appearance.set(null) goes back to the user's own look.