Skip to main content

Configuration

Exports

NameKindDescription
SelectorWidgetComponentScanner overlay around your chart subtree
SelectorWidgetPropsTypeProps for SelectorWidget

SelectorWidget props

PropTypeRequiredDescription
chartWidgetIChartingLibraryWidget | nullYesLive TradingView widget instance (null until ready).
childrenReactNodeYesYour chart UI (e.g. container + library bootstrap).
widgetKeystringYesiC Candle API key (icc_search_ + 48 hex chars). Used for theme fetch, candle cache, and scanner validation.
submitCallback(iframeSrc: string) => voidYesCalled after a successful scan setup with the plugin iframe URL.
theme"light" | "dark" | "system"NoAffects resolved theme tokens and the plugin URL. "system" follows prefers-color-scheme.

Widget key and remote theming

On mount, the component loads branding colors from iC Candle:

  • URL: https://api.iccandle.ai/corporate-client/v1/widgetStyle/search/user/?service_type=search
  • Header: api-key: <widgetKey>

CSS custom properties (--iccandle-primary, --iccandle-border, etc.) are applied on the widget root so the scanner matches your configured light/dark tokens.

Theme prop vs. API tokens: The theme prop chooses which variant of those tokens to apply and is also forwarded in the plugin iframe URL. "system" tracks prefers-color-scheme so the scanner and plugin stay aligned with the user’s OS preference when you don’t pass an explicit light/dark mode from your app shell.

Behavior summary

  • Subscribes to chart readiness, resolution, symbol changes, and drawing events.
  • Manages a date_range multipoint drawing so the user can adjust the bar window; window size and exported candles drive the scanner.
  • Posts candles to iC Candle’s cache endpoint before opening the plugin URL.
  • Listens for window message events for chart/news integration and can clear persisted news mark selections (localStorage key tv:selected-news-events) when starting a scan.

Optional: timescale marks (news/events)

If your data feed implements getTimescaleMarks, you can surface stored events (e.g. from localStorage under tv:selected-news-events) as marks on the time axis:

getTimescaleMarks: async (
symbolInfo: LibrarySymbolInfo,
from: number,
to: number,
onResult: GetMarksCallback<TimescaleMark>,
) => {
const marks: TimescaleMark[] = [];
try {
const allNewsEvents = JSON.parse(
localStorage.getItem("tv:selected-news-events") || "[]",
) as NewsEventType[];

allNewsEvents?.forEach(({ id, timestamp, event_name, currency }) => {
if (!id || !Number.isFinite(timestamp) || timestamp <= 0) return;
if (marks.some((m) => String(m.id) === String(id))) return;

marks.push({
id,
time: timestamp / 1000,
color: "green",
label: event_name.slice(0, 1) || "N",
tooltip: [event_name],
...(currency ? { imageUrl: `/images/symbols/${currency}.svg` } : {}),
showLabelWhenImageLoaded: true,
});
});
} catch {
/* ignore */
}
onResult(marks);
},

Adjust paths and types to match your app and TradingView typings.

Development (upstream repo)

ScriptCommandPurpose
Dev demonpm run devVite app with local charting library
Library buildnpm run buildEmits dist/ (JS, CJS, bundled CSS injection, declarations)
Lintnpm run lintESLint

prepublishOnly runs build before publish.

License

MIT. TradingView Charting Library is subject to its own license from TradingView.