Skip to main content

Altrady Charts — Developer Guide

Altrady Charts is a professional charting library built on klinecharts. It exposes a class-based, framework-agnostic API with React rendering internals, meaning you can drop it into any JavaScript environment — vanilla JS, React, Vue, Angular — without importing React yourself.

Key Capabilities​

  • Real-time OHLCV charts — candlestick, bar, line, area, and Heikin-Ashi candle types via klinecharts.
  • Built-in indicators — ports of the TradingView built-ins, run in the browser from precompiled WebAssembly shipped in the package; nothing to host.
  • Backend-driven indicators (Enterprise) — an IndicatorProvider feeds pre-calculated values from your backend, rendered as chart indicators.
  • User scripts — an optional ScriptProvider compiles and runs user-written scripts as chart indicators and supplies its own editor. The language and where it executes are the provider's choice; the AltradyScript provider, @altrady/script, is the reference implementation.
  • Events — chart.on('symbolChange', ...), 'periodChange', 'visibleRangeChange' and more for syncing app state with chart changes. on() returns an unsubscribe function.
  • 25+ drawing tools — trend lines, rays, channels, Fibonacci retracements, shapes, wave counts, Gann boxes, annotations, and order lines. Supports extend left/right and per-timeframe visibility rules.
  • Order lines — horizontal price-level overlays used to visualize open orders on the chart.
  • Persistent state — StorageAdapter interface saves and restores indicator subscriptions, overlay drawings, styles, and preferences per symbol.
  • Themes — 'light' and 'dark' built-ins; fine-grained overrides via styleOverrides: DeepPartial<Styles>.
  • i18n — 10 built-in locales; extend with loadLocale().
  • Screenshot — getScreenshotUrl() renders the chart, its legends and a branded footer to a data URL.
  • Symbol search — built-in symbol search modal wired to your Datafeed.searchSymbols.

Installation​

Altrady Charts is not on any package registry. You get it from the Charts page of your Altrady Data account (data.altrady.com):

  1. Accept the licence for your edition: Community is free in one click, Pro is a yearly subscription you can buy there, Enterprise comes through an offer from Altrady.
  2. Download the edition's .tgz (a .zip of the same files is there too).
  3. Commit it to a private repository, for example under vendor/. The licences don't allow publishing the builds.
  4. Check it against the sha256 shown on the Charts page, and add it:
shasum -a 256 vendor/altrady-charts-pro-0.1.5.tgz # compare with the Charts page

pnpm add ./vendor/altrady-charts-0.1.5.tgz # Community → @altrady/charts
pnpm add ./vendor/altrady-charts-pro-0.1.5.tgz # Pro → @altrady/charts-pro
pnpm add ./vendor/altrady-charts-enterprise-0.1.5.tgz # Enterprise → @altrady/charts-enterprise

npm install ./vendor/<file>.tgz and yarn add file:./vendor/<file>.tgz work the same. To upgrade, download the new version, replace the file and run the same command.

Import from your edition's package (the examples below use Community's):

import '@altrady/charts/styles' // compiled CSS, once per app
import { AltradyCharts, createDataLoader } from '@altrady/charts'

React​

Community and Pro bundle their own React: nothing else to install, in any framework. Enterprise uses your app's React (react and react-dom 19.2 or later are peer dependencies), so a component you hand the chart, such as a script editor, renders with the same React:

pnpm add react react-dom # Enterprise only

The script editor UI is not part of this package. A ScriptProvider supplies it via EditorComponent (see scripts.md); the AltradyScript provider (@altrady/script) ships a CodeMirror-based one.

Licences​

Each package carries its licence as LICENSE.md. Community: the Altrady Charts Community License (the watermark stays, and your public website carries one "Charts by Altrady" link). Pro and Enterprise: the Altrady Charts Commercial License (Pro keeps the watermark and is for companies under €5 million in group revenue and investor funding; Enterprise may white-label).


Quick Start (Vanilla JS)​

The following example creates a minimal working chart with no framework. It uses a mock datafeed returning static bars.

import '@altrady/charts/styles'
import { AltradyCharts, createDataLoader } from '@altrady/charts'
import type { Datafeed, DatafeedConfiguration, LibrarySymbolInfo, Bar } from '@altrady/charts'

// 1. Create a minimal Datafeed implementation
const datafeed: Datafeed = {
onReady(callback: (config: DatafeedConfiguration) => void) {
setTimeout(() => callback({ supportedResolutions: ['1', '5', '15', '60', '1D'] }), 0)
},

searchSymbols(_input, _exchange, _type, onResult) {
onResult([])
},

resolveSymbol(symbolName, onResolve, onError) {
if (symbolName === 'BTCUSDT') {
onResolve({
ticker: 'BTCUSDT',
name: 'Bitcoin / USDT',
pricescale: 100,
has_intraday: true,
})
} else {
onError('Symbol not found')
}
},

getBars(_symbolInfo, _resolution, periodParams, onResult) {
// Return mock bars spanning the requested range
const bars: Bar[] = []
const interval = 60_000 // 1-minute bars in ms
const to = periodParams.to * 1000
const from = periodParams.from * 1000
let price = 50_000
for (let t = from; t < to; t += interval) {
const open = price
const close = price + (Math.random() - 0.5) * 200
bars.push({
time: t,
open,
high: Math.max(open, close) + Math.random() * 50,
low: Math.min(open, close) - Math.random() * 50,
close,
volume: Math.floor(Math.random() * 1000),
})
price = close
}
onResult(bars, { noData: false })
},

subscribeBars(_symbolInfo, _resolution, onTick, _uid) {
// Push a fake tick every second
setInterval(() => {
onTick({
time: Date.now(),
open: 50_000,
high: 50_100,
low: 49_900,
close: 50_050,
volume: 10,
})
}, 1000)
},

unsubscribeBars(_uid) {},
}

// 2. Wrap the Datafeed in a DataLoader
const dataLoader = createDataLoader(datafeed)

// 3. Mount the chart
const chart = new AltradyCharts({
container: 'chart', // ID of an existing <div>
symbol: {
ticker: 'BTCUSDT',
name: 'Bitcoin / USDT',
pricePrecision: 2,
volumePrecision: 0,
},
period: { type: 'minute', span: 1, text: '1m' },
dataLoader,
theme: 'dark',
})

// 4. The API is available immediately (synchronous after construction)
chart.setTheme('light')

// 5. Clean up when done
// chart.dispose()

Directory Structure​

src/lib/
├── components/
│ ├── Superchart.ts # Main class (AltradyChartsOptions, AltradyChartsApi)
│ ├── SuperchartComponent.tsx # Internal React root component
│ └── ChartWidget.tsx # klinecharts canvas wrapper
├── datafeed/
│ └── index.ts # createDataLoader(), AltradyChartsDataLoader
├── hooks/
│ ├── useBackendIndicators.ts # Calc-bridge for IndicatorProvider
│ └── useChartState.ts # Restore state from StorageAdapter
├── i18n/
│ ├── index.ts # load(), i18n()
│ └── *.json # 10 locale files
├── store/
│ ├── chartStore.ts # Core state: symbol, period, theme, locale, styles
│ ├── chartStateStore.ts # Persistence via StorageAdapter
│ ├── overlaySettingStore.ts # Overlay popup position/visibility
│ └── keyEventStore.ts # Ctrl/Meta modifier state
├── types/
│ ├── chart.ts # Period, SymbolInfo, PERIODS, formatPeriod
│ ├── datafeed.ts # Datafeed, Bar, PeriodParams, resolutionToPeriod, periodToResolution
│ ├── indicator.ts # IndicatorProvider and all plot/data types
│ ├── overlay.ts # SavedOverlay, BUILT_IN_OVERLAYS, createOrderLine
│ ├── script.ts # ScriptProvider, ScriptEditorProps, BotSubscription
│ └── storage.ts # StorageAdapter, ChartState, createEmptyChartState
├── extension/ # 18 custom overlay templates (Fibonacci, Gann, waves, shapes)
├── features/ # Feature-flag defaults and the useFeature hook
├── storage/ # LocalStorageAdapter, HTTP adapter
├── templates/ # System-shipped indicator + drawing templates
├── component/ # Shared UI primitives (modal, input, select, popup, emoji …)
├── widget/
│ ├── top-bar/ # Top toolbar adapter (was period-bar)
│ ├── drawing-bar/ # Drawing toolbar UI
│ ├── indicator-modal/ # Indicator picker modal
│ └── ... # Other UI widgets
├── ui/
│ └── DsRoot.tsx # Mount wrapper for design-system subtrees (see below)
└── index.ts # Public API surface

The UI is built from src/design-system/ — presentational components generated from Figma, which never import src/lib or klinecharts. Each design-system subtree mounts inside DsRoot, which scopes the CSS reset to that subtree and bridges the two theme mechanisms (data-theme on the chart, .light in the design system). Live wiring lives in a thin adapter under src/lib/widget/<name>/.

This matters to you in one case. Design-system tokens (--color-*) are declared at :root, so they resolve anywhere — but the light values are applied by a .light class or a data-theme="light" attribute. Anything you render inside the chart, including nodes from createButton / createDropdown, sits under .altradycharts and picks up both. Anything you portal to document.body sits under neither, so it will resolve the dark values in both themes. Put such content inside your own element carrying data-theme="light" / "dark", setting it from chart.getTheme() and updating it whenever you call chart.setTheme().


Further Reading​

DocumentDescription
api-reference.mdFull TypeScript signatures for all options, API methods, and types
data-loading.mdDatafeed interface, createDataLoader, setOnBarsLoaded
indicators.mdIndicatorProvider, IndicatorMetadata, plot types, calc-bridge internals
scripts.mdScriptProvider, editor slot, script-drawn primitives, script execution
storage.mdStorageAdapter, ChartState persistence, example adapters
overlays.mdDrawing tools, createOverlay, order lines, SavedOverlay
customization.mdThemes, styles, locale, timezone, periods, watermark
keyboard-shortcuts.mdShortcut registry, the registered keys, undo/redo
replay.mdReplayEngine, playback API, partial candles, integration internals