Skip to main content

Feature Gates

ChartFeatures is the typed product-capability contract for a chart widget. Use it to decide which controls and workflows are available without coupling application code to chart implementation details.

TradeScript toolbar showing symbol, intervals, comparison, storage, search, indicators, chart type, range, timezone, snapshot, and fullscreen controls
Each visible control corresponds to a feature or capability decision. Disabled and hidden states must agree with adapter support and host policy.

Gate by user surface

SurfaceDecision inputsRequired consistency
Symbol and data controlsDatafeed capabilities plus symbol-search, interval, and comparison settingsDo not show options the feed cannot resolve/load
Indicators and drawingsProduct entitlement plus indicator/drawing feature objectsRemove or preserve active objects according to documented lifecycle
Storage and templatesStorage adapter plus storage feature gatesHide actions when no implementation exists
Trading and order flowBroker capabilities plus host permissionNever expose an action the broker will always reject
Accessibility and shortcutsHost policy plus accessibility/shortcut settingsPreserve an alternate path when hiding chrome
sdk.chart.mount({
mount: '#chart',
symbol: 'AAPL',
interval: '1D',
datafeed,
features: {
symbolSearch: {
showLogos: true,
showExchangeLogos: true,
allowArbitraryInput: false,
},
chartTypes: ['candles', 'line', 'area'],
customIntervals: ['1m', '5m', '15m', '1H', '1D'],
comparisons: {
enabled: true,
showSymbolLabels: true,
extendTimeScale: false,
},
drawings: {
enabled: true,
persistenceMode: 'embedded',
},
builtInIndicators: true,
templates: true,
contextMenu: true,
objectTree: true,
userSettings: true,
shortcuts: true,
},
});

Defaults, owners, and runtime changes

Three rules apply to every gate in the matrix below:

  • Default: a gate is enabled unless set to false, except where the Default column says otherwise. Gates with an external dependency are enabled only while that dependency is met.
  • Owner: a gate controls availability only. The state it exposes belongs to the owner listed under Feature Ownership; the gate never becomes a second state store.
  • Runtime mutability: the runtime counterparts that exist are chart.customization().setShortcuts(...), setToolbar(...), and setContextMenu(...), which adjust behavior within an enabled gate.
features is fixed at construction

There is no setFeatures. Turning a gate on or off requires recreating the widget, so decide feature policy before you mount. Plan any product tier that changes a user's available features as a remount, not a live update.

Capability matrix by surface

Symbol and market data

GateDefaultAffected UIDepends on
symbolSearchOnSearch input, filtering, logos, arbitrary-input policy, request behavior
comparisonsOnComparison search, symbol labels, time-scale extension
watchlistOn while supportedWatchlist panel and toolbar entryDatafeed getWatchlist and updateWatchlist
newsOn while supportedNews panelDatafeed getNews
detailsOnInstrument details panel
dataWindowOnData-window panelMarket-data controller attached
marketEventsOnMarket-event markersConfigured event providers
sessionBadgeOnOHLC-row market session badge, variant, popover
sessionsOnSession shading, break lines, extended-hours selector
orderFlowOn while supportedOrder-flow overlays dropdown (footprint, liquidity heatmap)Datafeed depth: getDepth or subscribeDepth
invalidSymbolOnVisible state for unresolved symbols or failed initial history

Chart canvas, indicators, and drawings

GateDefaultAffected UIDepends on
chartTypesOn; array restrictsChart-type selector and available types
customIntervalsOnCustom-interval entry in the interval selector
intervalFamiliesPolicy objectInterval families offered before datafeed/symbol narrowing
drawingsOnDrawing tools, rail visibility, storage mode, sharingPersistence additionally needs a storage adapter with drawing operations
drawingToolsAll toolsRestricts the available drawing-tool idsdrawings enabled
builtInIndicatorsOn; array restrictsBuilt-in indicator catalog, exclusions, disabled states, defaults
customIndicatorsOnRegistered custom indicators and time-scale extensionHost-registered indicator definitions
indicatorInputsOnIndicator input editing and symbol-valued input search
replayOnBar replay controlsReplay controller wired; state persistence needs the storage adapter
offscreenRenderSuspendOnSuspends engine layout/paint while the chart is scrolled off-screen
chartControlsOnFloating quick buttons, pane-header controls, settings-dialog presentation

Toolbars, menus, and input

GateDefaultAffected UIDepends on
contextMenuOnChart, scale, and object context menus
shortcutsOnWidget-root keyboard actions (runtime: setShortcuts)
actionsOnCustom-action registration surface
mobileToolbarOff (opt-in)Mobile toolbar
priceAxisScaleControlsOnPrice-axis scale controls and quick actions
objectTreeOnObject-tree panel visibility and interactions

Storage and workspace

GateDefaultAffected UIDepends on
layoutStorageOn while supportedChart-layout persistence, storage toolbar entry, favoritesStorage adapter chart-layout operations
workspaceTabsOff (opt-in)Named chart-layout tabs, restoration, autosave, tab stripChart-layout storage adapter
workspaceLayoutControlsOn (multi-chart)Native multi-chart split/remove/sync controlsMulti-chart widget
workspaceLegendPer-chart saved settingsMulti-chart legend display policyMulti-chart widget
userSettingsOnUser-setting API and optional persistencePersistence needs storage adapter user-settings operations
templatesOnChart, indicator, and drawing template workflows plus the storage-menu entry (chart / indicator / drawing / toolbar / importExport sub-flags)Template storage via the storage adapter

Trading

GateDefaultAffected UIDepends on
tradingOnOn-chart trading affordances, order ticket, depth ladder, account manager, price-axis order UI, notificationsBroker adapter attached for live actions
alertsOnAlert creation UI and overlays

Boolean and object forms

Many capability groups accept either a boolean or an object. Use the boolean form when only availability matters and the object form when the feature has its own policy.

features: {
drawings: true,
workspaceTabs: {
enabled: true,
restoreActive: true,
autoSave: { delayMs: 1200 },
maxVisible: 8,
},
userSettings: {
enabled: true,
persistence: false,
},
}

Feature ownership

A feature gate controls availability; it does not become a second state store.

  • Chart-layout identity and persistence belong to ChartWorkspaceLayoutController.
  • Chart state belongs to ChartApi and ChartState.
  • Visual values belong to CustomizationState, ChartTheme, and typed style settings.
  • Data capability truth belongs to MarketDataFeed and SymbolInfo.
  • Broker actions belong to TradingBrokerAdapter.
  • Widget and terminal panel arrangement belongs to WidgetLayoutState and its separate widget layout storage boundary, outside chart workspace storage.

Host-owned UI

The SDK intentionally leaves application-shell concerns to the host. Compose navigation, account management, page routing, onboarding, permission prompts, and terminal panel arrangement around the chart. Register chart actions with chart.customization().registerAction(...) when host UI needs to invoke chart behavior.

Why typed features

Typed features provide:

  • editor autocomplete and compile-time validation
  • clear ownership for nested policies
  • stable persistence and inspection
  • explicit defaults
  • direct mapping from product requirements to SDK configuration

Unknown or invalid fields are reported by customization inspection instead of being silently forwarded into the runtime.

Built-in controls

Every control the SDK renders has a public identity, on the same terms as the actions you register yourself. Host-registered actions are ordered and hidden by id through toolbar.groups, toolbar.actionIds, and toolbar.hiddenActionIds; built-in controls carry the same three facts — a stable id, the surface that owns them, and the typed option that gates them.

import {
BUILT_IN_CONTROLS,
getBuiltInControl,
listBuiltInControlsForSurface,
} from '@tradescript/pro/sdk';

listBuiltInControlsForSurface('period-bar').map((control) => control.id);
// ['toolbar', 'toolbar.hints', 'toolbar.quick-search', 'toolbar.interval-selector', ...]

getBuiltInControl('toolbar.screenshot');
// { id, label: 'Screenshot', surface: 'period-bar', group: 'export',
// visibility: { option: 'toolbar', field: 'screenshotButtonVisible' } }

Each entry's visibility names the option that shows or hides it today, so the id and the switch are never out of step:

chart.customization().setToolbar({ screenshotButtonVisible: false });

Surfaces are period-bar, drawing-sidebar, chart-canvas, pane-header and time-scale; CHART_CONTROL_SURFACES lists them. Resolve ids with isBuiltInControlId — exact inventory membership, never an id prefix.

Scope of the control inventory

The inventory supplies identity and gating: every built-in control has a public id, a surface owner, and the typed option that shows or hides it. Ordering those ids alongside your own controls, replacing what one renders, and adding controls of your own build on the same ids — see Toolbar and Settings Extensions.