Feature flags
Altrady Charts exposes a feature-flag system for opting UI features and
behaviors in or out without code changes. Each flag has a documented
default; consumers override per-instance via enabledFeatures and
disabledFeatures in AltradyChartsOptions, or at runtime via
superchart.setFeatureEnabled(flag, enabled).
import { AltradyCharts, type FeatureFlag } from '@altrady/charts'
new AltradyCharts({
// …
enabledFeatures: ['timezone_button'],
disabledFeatures: ['drawing_bar', 'right_click_menu'],
autoSaveDelay: 1500, // companion option (number, not flag)
})
If a flag appears in both arrays, disabledFeatures wins. This also
beats a user override saved from the Preferences tab — a flag the host
disables via disabledFeatures stays disabled regardless.
Runtime API
superchart.isFeatureEnabled('drawing_bar') // → boolean
superchart.setFeatureEnabled('drawing_bar', true)
Inside React components rendered under an Altrady Charts instance:
import { useFeature } from '@altrady/charts'
function MyOverlay() {
if (!useFeature('study_templates')) return null
// …
}
useFeature re-renders the component when the flag is toggled — no chart
remount required.
Editions
Each flag exists from one edition up (src/lib/features/tiers.ts, the
Edition column below). In a lower edition the flag is always off: its
default is dropped, enabledFeatures and setFeatureEnabled(flag, true)
are ignored with one console warning, and the edition's FeatureFlag type
leaves it out, so TypeScript rejects it. See
edition-split-spec.md.
Flag catalog
Toolbars / chrome
| Flag | Default | Edition | Effect |
|---|---|---|---|
drawing_bar | true | Community | Drawing toolbar feature is available. Whether it's currently visible is the orthogonal drawingBarVisible option (defaults to false). |
period_bar | true | Community | Show the top period/symbol toolbar. When false, the chart canvas reclaims the space. |
screenshot_button | true | Community | Show the screenshot button in the period bar. |
fullscreen_button | true | Community | Show the fullscreen button in the period bar. |
header_in_fullscreen_mode | false | Community | Keep the top bar in fullscreen mode (Shift+F). |
side_toolbar_in_fullscreen_mode | false | Community | Keep the drawing bar in fullscreen mode (Shift+F). |
symbol_search | true | Community | Show the symbol-search button + modal. |
market_button | true | Community | Show the market name button. Typing a symbol still opens search. |
compare_symbol | true | Community | Show the Compare or Add Symbol button beside the symbol. |
period_picker | true | Community | Show the period selector in the period bar. |
indicator_picker | true | Community | Show the indicator-modal launcher button. |
structure_indicators | false | Community | List the structure-and-concepts built-ins (the Market Structure, Smart Money and Patterns categories) in the indicator picker. Off by default. Only the listing is gated: a saved layout that already uses one of them restores it with the flag off. |
script_button | true | Enterprise | Show the Script/fx button in the period bar. Button-only: disabling it hides the entry point but leaves the script pipeline (addScriptIndicator() and friends) unaffected, for hosts that ship their own script IDE while keeping scriptProvider set. |
replay | true | Enterprise | Offer SC's own replay UI: the header Replay button, Alt+Shift+P, bar-pick mode and the ReplayBar, plus the Alt+Shift+P row in Settings → Hotkeys and in the ? shortcuts panel. Entry points only — sc.replay (the ReplayEngine) and its events are unaffected, so a host driving replay itself keeps working with the flag off. See docs/replay.md. |
Interaction
| Flag | Default | Edition | Effect |
|---|---|---|---|
keyboard_shortcuts | true | Community | Keyboard shortcuts, type-ahead (digits for an interval, a letter for symbol search) and copy / cut / paste for this chart. When disabled the chart never receives key presses and is never the keyboard target, even as the only or last-mounted chart; setActive() on it is ignored. With several charts mounted only the keyboard target receives keys — see Keyboard target. |
right_click_menu | true | Community | Open the overlay context menu on right-click or long-press. When disabled, the browser context menu is still suppressed but our menu doesn't open — useful when you want to handle right-click via the overlayRightClick event. |
chart_context_menu | true | Community | Open the background context menu (Remove drawings / Remove indicators) on right-click or long-press over empty chart area. When disabled, handle it via the rightClick event. |
crosshair_magnet | true | Community | Offer magnet mode for drawing tools (snap to OHLC values). When disabled the magnet control is removed from the drawing rail; if magnet was active at the time, the mode drops back to normal. |
trade_overlay | false | Pro | Cursor + trade UI over the candle pane — quick/limit order draft, price alerts, R:R handles, and its own right-click trading menu (which supersedes chart_context_menu's generic one while this flag is on; disabling chart_context_menu turns it off too, for a host that draws its own). Display-only until the host wires AltradyChartsOptions.onTradeAction; open positions are pushed in via superchart.setTradePositions(), and free funds via superchart.setTradeBalance() (an order that needs more shows its size unit in red). The order handles are painted on the chart canvas (the tradeHandles overlay), so they move with the candles in the same frame; on touch devices the controls are larger and a long-press opens the trade menu. |
cursor_plus_button | true | Pro | The trade overlay's cursor + beside the crosshair's price on the axis (only while trade_overlay is on). Off, it never shows and the price-scale menu drops its plus-button toggle; the user's own choice (scales.plusButton) is kept for where it is on. For a host with its own way into the same draft, such as a phone's + button. |
price_scale_menu | true | Community | Open the price-scale menu on right-click or long-press over a price axis: reset, auto, lock price to bar ratio, scale price chart only, invert, regular / percent / indexed to 100 / logarithmic, move the scale left or right, label and line toggles, countdown to bar close, and the trade overlay's plus button (only while trade_overlay is on). Candle-pane choices are saved with the chart; indicator-pane choices last for the session. An axis right-click fires none of the rightClick event, the engine's onChartRightClick action or the overlayRightClick event. With priceLabelsInside the pane covers the axis, so the menu is not reachable there. |
price_scale_controls | true | Community | Show the TradingView-style "A" (auto-fit) / "L" (logarithmic) buttons floating over the bottom-right of the price scale. |
chart_nav_controls | false | Community | Show the hover row above the time axis with zoom −/+, scroll ‹ ›, and reset controls. |
chart_legend | true | Community | Show the always-on legend in the chart's top-left corner: symbol · period · exchange, the OHLC and net change of the hovered bar (the last bar when the pointer is away), and one row per main-pane indicator with hover-revealed hide / settings / remove. The engine's own canvas legend keeps drawing each indicator's values at the hovered bar, below this panel. |
bottom_bar_presets | true | Community | Show the bottom-bar history-range presets (1D…All, driven by setVisibleRange) and the price-scale cog menu (scale mode, invert, reset, more settings). |
timezone_launcher | true | Community | Show the bottom-bar clock and its timezone picker. timezone_button is the separate, opt-in copy in the top bar. |
Breaking change:
longpress_menuwas removed from theFeatureFlagunion — it never gated anything at runtime.right_click_menuandchart_context_menualready cover long-press, each on its own flag.
Persistence
| Flag | Default | Edition | Effect |
|---|---|---|---|
auto_save_state | true | Community | Auto-save chart state to the StorageAdapter on every mutation. When disabled, the consumer must call superchart.saveState() explicitly. |
Companion option (numeric, not a flag):
| Option | Type | Default | Effect |
|---|---|---|---|
autoSaveDelay | number | 0 | Debounce window in milliseconds. 0 saves on every mutation (current behavior). >0 collapses rapid mutations into one save after N ms idle. |
autoSaveDelay lives on AltradyChartsOptions directly (not in the flag
union) because flags are strictly boolean. Set them together: turn off
auto_save_state for full manual control, or keep it on with a non-zero
autoSaveDelay to throttle.
On unmount, any pending debounced save is flushed best-effort (last-write-wins) so closing a tab doesn't lose in-flight edits.
Templates / browser (reserved for future tickets)
These flags exist now so consumers can pre-disable them, but the
underlying UIs land in PERSISTENCE_ROADMAP.md
Tickets 4–7. Defaults are true so the UIs appear automatically when
shipped.
| Flag | Default | Edition | Effect (when wired) |
|---|---|---|---|
study_templates | true | Community | "Save / Load template" submenu in indicator settings. |
drawing_templates | true | Community | "Save as default / Apply default" buttons in the floating overlay-style popup. |
chart_templates | true | Enterprise | "Save layout as template / Apply template" entries in the top bar's settings menu. |
multi_chart_browser | true | Enterprise | "Open chart" UX listing all saved layouts. |
multi_chart_layout | false | Enterprise | Top-bar picker for multi-chart layouts and "Sync in layout". AltradyCharts.setLayout() works without it. |
layout_pin | false | Enterprise | Pin control per chart: a lock in the legend and rows in the chart menu to keep the timeframe ('period') or symbol and timeframe ('all') when the host moves the layout to another market. Carried as charts[i].pin in get/setMultiChartState, which works without the flag. A pinned property is left out of "Sync in layout". |
Chart visuals
| Flag | Default | Edition | Effect |
|---|---|---|---|
volume_in_legend | true | Community | Deprecated (ALTD-1915.4), no longer honoured — superseded by preferences.statusLine.volume in the Status Line tab, which replaced it with 11 granular fields. Referencing it logs a one-time migration warning; it is retained for one release. |
last_close_price_line | true | Community | Show the dashed line marking the last close price. |
Development
| Flag | Default | Edition | Effect |
|---|---|---|---|
debug_hit_areas | false | Community | Paint every drawing's click-tolerance halo. Development aid, never on by default. |
debug_overlay_drag | false | Community | Trace overlay drags to the console. Development aid, never on by default. |
Flags vs visibility state — they're complementary
Flags answer "is this feature available?" (developer-controlled). The
drawingBarVisible option answers "is it currently visible?"
(user-toggleable at runtime):
| Concept | Where it lives | Example |
|---|---|---|
| Feature available? | enabledFeatures / disabledFeatures (per-flag boolean) | disabledFeatures: ['drawing_bar'] hides the toolbar AND the top-bar toggle that opens it. |
| Currently visible? | drawingBarVisible (initial state, user-toggleable) | drawingBarVisible: false starts the toolbar collapsed; user can re-open via the top bar's menu (when the flag is on). |
There is no
periodBarVisibleoption. It existed briefly and was removed in9adf04fwhen the feature-flag system superseded it; the top bar is governed by theperiod_barflag alone. This page documented it for a long time after it stopped existing.
Render rule: the drawing toolbar shows only when drawing_bar flag is on
and drawingBarVisible is true. Setting the flag to off hides both
the toolbar and the toggle button — the user has no entry point to a
disabled feature.
Adding a new flag
- Add it to the
FeatureFlagunion insrc/lib/features/types.ts. - Set its default in
src/lib/features/defaults.ts(theRecord<FeatureFlag, boolean>shape enforces this — missing entries are a compile error). - Wire the consuming widget/hook to read it via
useFeature(flag)orstore.isFeatureEnabled(flag). - Give it an edition in
FEATURE_TIER(src/lib/features/tiers.ts; a missing entry is a compile error) and document it in this file with that edition and a one-line description of the effect. - Add it to
FLAG_CATEGORYin.storybook/api-stories/FeatureFlags.stories.tsxso the storybook picks it up automatically.