Skip to main content

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​

FlagDefaultEditionEffect
drawing_bartrueCommunityDrawing toolbar feature is available. Whether it's currently visible is the orthogonal drawingBarVisible option (defaults to false).
period_bartrueCommunityShow the top period/symbol toolbar. When false, the chart canvas reclaims the space.
screenshot_buttontrueCommunityShow the screenshot button in the period bar.
fullscreen_buttontrueCommunityShow the fullscreen button in the period bar.
header_in_fullscreen_modefalseCommunityKeep the top bar in fullscreen mode (Shift+F).
side_toolbar_in_fullscreen_modefalseCommunityKeep the drawing bar in fullscreen mode (Shift+F).
symbol_searchtrueCommunityShow the symbol-search button + modal.
market_buttontrueCommunityShow the market name button. Typing a symbol still opens search.
compare_symboltrueCommunityShow the Compare or Add Symbol button beside the symbol.
period_pickertrueCommunityShow the period selector in the period bar.
indicator_pickertrueCommunityShow the indicator-modal launcher button.
structure_indicatorsfalseCommunityList 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_buttontrueEnterpriseShow 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.
replaytrueEnterpriseOffer 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​

FlagDefaultEditionEffect
keyboard_shortcutstrueCommunityKeyboard 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_menutrueCommunityOpen 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_menutrueCommunityOpen 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_magnettrueCommunityOffer 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_overlayfalseProCursor + 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_buttontrueProThe 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_menutrueCommunityOpen 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_controlstrueCommunityShow the TradingView-style "A" (auto-fit) / "L" (logarithmic) buttons floating over the bottom-right of the price scale.
chart_nav_controlsfalseCommunityShow the hover row above the time axis with zoom −/+, scroll ‹ ›, and reset controls.
chart_legendtrueCommunityShow 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_presetstrueCommunityShow the bottom-bar history-range presets (1D…All, driven by setVisibleRange) and the price-scale cog menu (scale mode, invert, reset, more settings).
timezone_launchertrueCommunityShow the bottom-bar clock and its timezone picker. timezone_button is the separate, opt-in copy in the top bar.

Breaking change: longpress_menu was removed from the FeatureFlag union — it never gated anything at runtime. right_click_menu and chart_context_menu already cover long-press, each on its own flag.

Persistence​

FlagDefaultEditionEffect
auto_save_statetrueCommunityAuto-save chart state to the StorageAdapter on every mutation. When disabled, the consumer must call superchart.saveState() explicitly.

Companion option (numeric, not a flag):

OptionTypeDefaultEffect
autoSaveDelaynumber0Debounce 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.

FlagDefaultEditionEffect (when wired)
study_templatestrueCommunity"Save / Load template" submenu in indicator settings.
drawing_templatestrueCommunity"Save as default / Apply default" buttons in the floating overlay-style popup.
chart_templatestrueEnterprise"Save layout as template / Apply template" entries in the top bar's settings menu.
multi_chart_browsertrueEnterprise"Open chart" UX listing all saved layouts.
multi_chart_layoutfalseEnterpriseTop-bar picker for multi-chart layouts and "Sync in layout". AltradyCharts.setLayout() works without it.
layout_pinfalseEnterprisePin 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​

FlagDefaultEditionEffect
volume_in_legendtrueCommunityDeprecated (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_linetrueCommunityShow the dashed line marking the last close price.

Development​

FlagDefaultEditionEffect
debug_hit_areasfalseCommunityPaint every drawing's click-tolerance halo. Development aid, never on by default.
debug_overlay_dragfalseCommunityTrace 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):

ConceptWhere it livesExample
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 periodBarVisible option. It existed briefly and was removed in 9adf04f when the feature-flag system superseded it; the top bar is governed by the period_bar flag 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​

  1. Add it to the FeatureFlag union in src/lib/features/types.ts.
  2. Set its default in src/lib/features/defaults.ts (the Record<FeatureFlag, boolean> shape enforces this — missing entries are a compile error).
  3. Wire the consuming widget/hook to read it via useFeature(flag) or store.isFeatureEnabled(flag).
  4. 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.
  5. Add it to FLAG_CATEGORY in .storybook/api-stories/FeatureFlags.stories.tsx so the storybook picks it up automatically.