Skip to main content

Function: attributionNotice()

attributionNotice(container): HTMLElement

Defined in: packages/sdvplot/src/lightweight-charts.ts:101

Puts TradingView's attribution notice on the page, as Lightweight Charts' licence asks: a <p> appended to container, holding TRADINGVIEW_NOTICE (its URL a link, its two lines kept), and returned. Idempotent: called again on the same container it returns the notice already there rather than adding a second. Give it the element around the chart (el.parentElement ?? el for the chart's own el), so the notice sits under the chart. On a server (no document) it does nothing and returns container. withAttribution's example draws a chart with it.

Parameters​

container​

HTMLElement

Returns​

HTMLElement

Example​

import { TRADINGVIEW_NOTICE, attributionNotice } from "@sportsdataverse/sdvplot/lightweight-charts";

const figure = document.body.appendChild(document.createElement("figure"));
const notice = attributionNotice(figure);
// once per container, and exactly TradingView's notice
[attributionNotice(figure) === notice, notice.textContent === TRADINGVIEW_NOTICE];