Skip to main content

Customization


Stylesheets and fonts​

Import the stylesheet once, anywhere in your app:

import '@altrady/charts/styles'

That single file contains both the chart styles and the design-system layer (tokens, utilities). A @altrady/charts/ui.css entry also exists if you want the design-system layer on its own, but you do not need it alongside /styles.

Icons need nothing from the host​

Every icon is inline SVG from Altrady Charts' own set (src/design-system/icons/): the interface glyphs, the drawing-toolbar art, the trade handles and the indicator legend. There is no icon font to load. Earlier versions asked hosts to load Font Awesome; that is no longer needed and can be removed.

Where an option takes an icon as a string (a settings tab's icon, for example), pass one of the set's names: a short name such as 'gear' or 'bell' (iconAliases.ts) or a full id such as 'navigation/Bell'. Storybook's Design System → Foundations → Icon catalogue lists them all.

The design system also expects Roboto (UI text), Plus Jakarta Sans (headings) and Roboto Mono (numeric/code). Each stack falls back to the platform UI font, so the chart is perfectly usable without them — load them only if you want the intended typography:

import '@fontsource/roboto/400.css'
import '@fontsource/roboto/500.css'
import '@fontsource/plus-jakarta-sans/600.css'
import '@fontsource/roboto-mono/400.css'

Themes​

Altrady Charts ships with 'light' and 'dark' built-in themes. The theme option sets the initial theme; setTheme() changes it at runtime.

// Initial theme
const chart = new AltradyCharts({
theme: 'dark',
// ...
})

// Runtime switch
chart.setTheme('light')
chart.getTheme() // 'light'

Custom theme names are supported. Register a custom theme by calling klinecharts registerStyles with the custom name, then pass the same name as the theme option.


Style Overrides​

For fine-grained control, pass styleOverrides: DeepPartial<PaneProperties> to override specific canvas properties without replacing the entire theme.

PaneProperties extends the klinecharts Styles interface with gradient background fields:

export interface PaneProperties extends Styles {
backgroundType: 'solid' | 'gradient'
background: string
backgroundGradientStartColor: string
backgroundGradientEndColor: string
}

Styles is the full klinecharts style tree. Common sub-trees:

PathDescription
candleCandle body, wick, border colors; Heikin-Ashi variations
candle.barOHLC bar rendering
candle.areaArea chart fill color and line
indicatorColors for built-in klinecharts indicators
crosshairCrosshair line color, style, label
gridGrid line horizontal/vertical color and style
xAxisX-axis label font, color, tick size
yAxisY-axis label font, color, tick size, min/max fractions
separatorPane divider line
overlayOverlay default colors and sizes
const chart = new AltradyCharts({
styleOverrides: {
background: '#0D0D0D',
grid: {
horizontal: { color: '#1A1A1A' },
vertical: { color: '#1A1A1A' },
},
candle: {
upColor: '#00C853',
downColor: '#D50000',
noChangeColor: '#888888',
},
crosshair: {
horizontal: { line: { color: '#666666' } },
vertical: { line: { color: '#666666' } },
},
},
// ...
})

Apply overrides at runtime:

chart.setStyles({
candle: { upColor: '#4CAF50', downColor: '#F44336' },
})

Locale​

Set the UI locale via the locale option (BCP-47 tag). The locale affects all UI labels: toolbar buttons, indicator names, settings modal, period names, drawing tool names.

const chart = new AltradyCharts({
locale: 'zh-CN',
// ...
})

// Change at runtime
chart.setLocale('ja-JP')
chart.getLocale() // 'ja-JP'

Built-in Locales​

CodeLanguage
en-USEnglish (United States) — default
zh-CNChinese (Simplified)
zh-TWChinese (Traditional)
ja-JPJapanese
ko-KRKorean
ar-AEArabic
ru-RURussian
vi-VNVietnamese
ms-MYMalay
es-ESSpanish

Custom Locale​

Register a custom locale with loadLocale():

import { loadLocale } from '@altrady/charts'

loadLocale('de-DE', {
'drawing.trendline': 'Trendlinie',
'drawing.fibonacci': 'Fibonacci',
'indicator.add': 'Indikator hinzufügen',
'period.1m': '1 Min',
'period.1h': '1 Std',
// ...
})

After registering, pass 'de-DE' as the locale option or call setLocale('de-DE').


Timezone​

All timestamps on the x-axis and in tooltips are displayed in the configured timezone.

const chart = new AltradyCharts({
timezone: 'America/New_York',
// ...
})

chart.setTimezone('Europe/London')
chart.getTimezone() // 'Europe/London'

Accepts any IANA timezone identifier (e.g. 'UTC', 'America/Chicago', 'Asia/Tokyo', 'Europe/Berlin'). Default is 'Etc/UTC'.

translateTimezone​

A helper that converts a Charting-Library-style timezone string to an IANA identifier (for use when your Datafeed returns timezone strings in that format):

import { translateTimezone } from '@altrady/charts'

translateTimezone('America/New_York') // 'America/New_York'
translateTimezone('UTC') // 'Etc/UTC'
translateTimezone('Etc/UTC') // 'Etc/UTC'

Periods​

The periods option controls which timeframes appear in the period selector toolbar. Defaults to a standard set of 9 periods.

import { PERIODS } from '@altrady/charts'

const chart = new AltradyCharts({
periods: [
PERIODS['1m'],
PERIODS['5m'],
PERIODS['15m'],
PERIODS['1h'],
PERIODS['4h'],
PERIODS['1D'],
],
// ...
})

You can define completely custom periods:

const chart = new AltradyCharts({
periods: [
{ type: 'minute', span: 2, text: '2m' },
{ type: 'minute', span: 7, text: '7m' },
{ type: 'hour', span: 3, text: '3H' },
{ type: 'day', span: 2, text: '2D' },
],
// ...
})

Watermark​

The watermark option overlays text or a DOM node on the chart canvas. Use it for exchange logos, copyright notices, or branding.

// Simple text
const chart = new AltradyCharts({
watermark: 'EXCHANGE — BTCUSDT',
// ...
})

// HTML string rendered as a node
const chart = new AltradyCharts({
watermark: '<span style="font-size:24px;opacity:0.15">POWERED BY ALTRADY CHARTS</span>',
// ...
})

// DOM element (e.g. an img)
const logo = document.createElement('img')
logo.src = '/logo.svg'
logo.style.opacity = '0.1'
logo.style.width = '200px'

const chart = new AltradyCharts({
watermark: logo,
// ...
})

Period Bar API​

The top bar is extensible with custom buttons and dropdowns. Items are plain HTMLElements — you can set innerHTML, add event listeners, or apply classes freely without touching React.

chart.createButton(options?)​

Adds a button to the toolbar and returns the HTMLElement. The element is pre-styled to match the built-in toolbar buttons.

Altrady Charts styles it for you via the altradycharts-toolbar-btn class, against the design-system tokens the rest of the bar uses — so an injected button follows the active theme and matches its neighbours without you doing anything. Override it by styling that class, or per-element through the returned node (see the last example below). Icons are placed in a 16px slot; supply SVG sized to match, and use fill="currentColor" so the icon follows the button's text colour through hover and theme changes.

// Simple click handler
const alertBtn = chart.createButton({
text: 'Alert',
tooltip: 'Set price alert',
onClick: () => openAlertDialog(),
})

// SVG icon (no text label)
const refreshBtn = chart.createButton({
icon: '<svg viewBox="0 0 20 20" width="16" height="16"><path d="M10 2a8 8 0 100 16A8 8 0 0010 2z" fill="currentColor"/></svg>',
tooltip: 'Refresh data',
onClick: () => reloadData(),
})

// Place on the left side (after period selector)
const leftBtn = chart.createButton({
align: 'left',
text: 'Draw',
onClick: () => activateDrawingMode(),
})

// Returned element can be customised further
const btn = chart.createButton({ text: 'Custom' })
btn.style.color = '#F5A623'
btn.setAttribute('data-testid', 'my-button')

// Opt into compacting: the label hides and the button goes icon-only once
// the bar is too narrow to fit everything at full width.
const shareBtn = chart.createButton({
icon: '<svg>…</svg>',
text: 'Share',
compactPrio: 400,
onClick: () => shareChart(),
})

Options:

FieldTypeDefaultDescription
align'left' | 'right' | 'right-end''right''left' = end of the left section; 'right' = start of the right section, before Layout; 'right-end' = end of the right section, after Altrady Charts' own buttons
textstring—Visible text label
iconstring—SVG markup or HTML rendered before the label
tooltipstring—Tooltip on hover (stored in data-tooltip, not title)
onClick() => void—Click handler
compactPrionumber—Opts into the header's compacting: once the bar is too narrow, the text hides and the button goes icon-only. Higher compacts first, matching TOP_BAR_COMPACT_PRIOS — pick a value between two built-in prios to land in that step. Omit to keep the button unchanged (its width still counts toward the fit)

DOM contract: the button is .altradycharts-toolbar-btn, holding a .altradycharts-toolbar-btn-icon and a .altradycharts-toolbar-btn-text span. Update the label via the text span's textContent and the tooltip via btn.dataset.tooltip — both keep working after compacting toggles .altradycharts-toolbar-btn--compact on the button. btn.remove() is safe; the fit picks up the removal on its own.


chart.createDropdown(options)​

Adds a dropdown trigger button to the toolbar and returns the trigger HTMLElement. The dropdown list is a self-contained pure-DOM widget — no React required.

chart.createDropdown({
text: 'Chart Type',
tooltip: 'Change chart style',
items: [
{
text: 'Candlestick',
icon: '<svg>...</svg>',
onClick: () => chart.getChart()?.setStyles({ candle: { type: 'candle_solid' } }),
},
{
text: 'Line',
onClick: () => chart.getChart()?.setStyles({ candle: { type: 'area' } }),
},
{ type: 'separator' },
{
text: 'Heikin-Ashi',
onClick: () => chart.getChart()?.setStyles({ candle: { type: 'candle_solid' } }),
},
],
})

Options:

FieldTypeDefaultDescription
align'left' | 'right' | 'right-end''right'Same as createButton. No compactPrio support — a dropdown trigger never compacts
textstring—Text label on the trigger
iconstring—SVG/HTML icon on the trigger
tooltipstring—Native tooltip
itemsToolbarDropdownItem[]requiredList of items or separators

ToolbarDropdownItem is a union:

// Regular clickable item
{ type?: 'item'; text: string; icon?: string; onClick: () => void }

// Visual separator line
{ type: 'separator' }

CSS Classes​

Target Altrady Charts DOM elements for custom styling:

ClassElement
.altradychartsRoot wrapper div
.altradycharts-top-barTop toolbar (symbol, timeframes, indicators, settings)
.altradycharts-toolbar-btnA button or dropdown trigger you added via createButton / createDropdown
.altradycharts-toolbar-btn-iconThe icon span inside a createButton button
.altradycharts-toolbar-btn-textThe label span inside a createButton button
.altradycharts-toolbar-btn--compactAdded to a createButton button (with compactPrio set) while the bar has compacted it
.altradycharts-drawing-barDrawing tools sidebar
.altradycharts-widgetCanvas wrapper
.altradycharts-loadingLoading overlay

Only these are a styling contract. Every class is verified against the rendered DOM. Other .altradycharts-* names you may find by inspecting the page belong to individual widgets and are not stable — the UI is being rebuilt on a design system, and a widget that moves to it loses its bespoke class names in the process. If you need a hook that is not in this table, open an issue rather than targeting an internal class.

The OHLCV / indicator tooltip has no CSS hook. It is painted on the canvas, not built from DOM, so no selector can reach it. Style it through setStyles({ candle: { tooltip: … }, indicator: { tooltip: … } }) instead.

Example — custom font for the top bar, and a restyled injected button:

.altradycharts-top-bar {
font-family: 'JetBrains Mono', monospace;
font-size: 12px;
}

/* Your own createButton / createDropdown items */
.altradycharts-top-bar .altradycharts-toolbar-btn {
color: #2196F3;
}

Inside the top bar, prefer the design-system custom properties over literal colours so your additions follow the active theme — var(--color-text-secondary), var(--color-text-primary), var(--color-border-primary), var(--color-button-default-subtle-hover).

Altrady Charts mounts inside container and adds class="altradycharts" to the root element, so all CSS selectors above can be scoped under your container if needed:

#my-chart-container .altradycharts-top-bar { ... }

Screenshot​

Capture the chart as a data URL. It is the same image the screenshot button, download (Ctrl/Cmd + Alt + S) and copy (Ctrl/Cmd + Shift + S) produce:

  • the chart as on screen: candles, indicators, drawings, both scales;
  • the legends where they sit: the market line with OHLC and change, and every indicator row with its values, in every pane;
  • a footer: the brand (logo, name and link) on the left, the market and the capture time in the chart's timezone on the right.

The footer's brand follows the brand option, like the watermark badge: community builds always show the Altrady Charts brand; an enterprise host's own brand shows instead, and brand: false leaves only the market and time. A logo given as a React node can't be drawn into the image, so the footer shows the name alone; give an SVG string or an image URL (served with CORS) for it.

// PNG on the theme's pane background
const pngUrl = chart.getScreenshotUrl('png')

// JPEG with a background of your own
const jpgUrl = chart.getScreenshotUrl('jpeg', '#0D0D0D')

// Download
const link = document.createElement('a')
link.href = pngUrl
link.download = 'chart.png'
link.click()