{"owner":"tradingview","repo":"lightweight-charts","hasSkills":true,"totalSkillsCount":56,"totalTokensCount":89954,"categories":["anthropic-skill","plugin-manifest"],"hasMcp":false,"mcpConfig":null,"found":[".github/skills/lightweight-charts-plugin-authoring/SKILL.md",".github/skills/lightweight-charts-plugin-authoring/references/official-plugins.md",".github/skills/lightweight-charts-plugin-authoring/references/package-contract.md",".github/skills/lightweight-charts-plugin-authoring/references/toolkit.md",".github/skills/lightweight-charts/SKILL.md","packages/create-lwc-plugin/README.md","packages/create-lwc-plugin/template-common/README.md","packages/lwc-plugin-accessibility/README.md","packages/lwc-plugin-anchored-text/README.md","packages/lwc-plugin-background-shade-series/README.md","packages/lwc-plugin-box-whisker-series/README.md","packages/lwc-plugin-brushable-area-series/README.md","packages/lwc-plugin-dual-range-histogram-series/README.md","packages/lwc-plugin-grouped-bars-series/README.md","packages/lwc-plugin-heatmap-series/README.md","packages/lwc-plugin-hlc-area-series/README.md","packages/lwc-plugin-image-watermark/README.md","packages/lwc-plugin-lollipop-series/README.md","packages/lwc-plugin-pretty-histogram-series/README.md","packages/lwc-plugin-preview-kit/README.md","packages/lwc-plugin-rounded-candles-series/README.md","packages/lwc-plugin-scatter-series/README.md","packages/lwc-plugin-session-highlighting/README.md","packages/lwc-plugin-stacked-area-series/README.md","packages/lwc-plugin-stacked-bars-series/README.md","packages/lwc-plugin-user-price-lines/README.md","packages/lwc-plugin-vertical-line/README.md","packages/lwc-toolkit/README.md","plugin-examples/src/plugins/accessibility/README.md","plugin-examples/src/plugins/anchored-text/README.md","plugin-examples/src/plugins/background-shade-series/README.md","plugin-examples/src/plugins/box-whisker-series/README.md","plugin-examples/src/plugins/brushable-area-series/README.md","plugin-examples/src/plugins/dual-range-histogram-series/README.md","plugin-examples/src/plugins/grouped-bars-series/README.md","plugin-examples/src/plugins/heatmap-series/README.md","plugin-examples/src/plugins/hlc-area-series/README.md","plugin-examples/src/plugins/image-watermark/README.md","plugin-examples/src/plugins/lollipop-series/README.md","plugin-examples/src/plugins/pretty-histogram-series/README.md","plugin-examples/src/plugins/rounded-candles-series/README.md","plugin-examples/src/plugins/session-highlighting/README.md","plugin-examples/src/plugins/stacked-area-series/README.md","plugin-examples/src/plugins/stacked-bars-series/README.md","plugin-examples/src/plugins/user-price-lines/README.md","plugin-examples/src/plugins/vertical-line/README.md","website/docs/plugins/canvas-rendering-target.md","website/docs/plugins/custom_series.md","website/docs/plugins/intro.md","website/docs/plugins/pane-primitives.md","website/docs/plugins/pixel-perfect-rendering/index.md","website/docs/plugins/pixel-perfect-rendering/widths/candlestick.md","website/docs/plugins/pixel-perfect-rendering/widths/columns.md","website/docs/plugins/pixel-perfect-rendering/widths/crosshair.md","website/docs/plugins/pixel-perfect-rendering/widths/full-bar-width.md","website/plugins/plugin-catalogue/README.md"],"skills":{".github/skills/lightweight-charts-plugin-authoring/SKILL.md":"---\nname: lightweight-charts-plugin-authoring\ndescription: >-\n  Use when creating, extending, debugging or publishing a Lightweight Charts™\n  plugin — a custom series, a series primitive or a pane primitive — or when\n  turning a chart idea (\"I want the chart to show/draw X\") into a working\n  plugin. Covers choosing the plugin type, scaffolding with create-lwc-plugin,\n  building on @tradingview/lwc-toolkit instead of hand-rolled helpers, which of\n  the official plugin packages to read as the reference implementation,\n  where the docs are, and the autoscale, whitespace, visible-range, hit-test\n  and conflation mistakes every plugin author makes once. Reach for it whenever\n  the user mentions a custom series, primitive, renderer, drawing on the chart\n  canvas, lwc-plugin, plugin-examples, the toolkit, or the plugin catalog —\n  even if they never say the word \"plugin\".\n---\n\n# Writing a Lightweight Charts™ plugin\n\nThis skill is about *authoring* plugins. For questions about using the chart\nitself — series, scales, markers, data, wrappers — use the sibling\n`lightweight-charts` skill; the two are designed to be installed together.\n\n## Where you are, and where the sources are\n\nThis skill is used in two places, and the same question has a different\nanswer in each. Detect which before looking anything up:\n\n```sh\n# upstream checkout of lightweight-charts itself?\ntest -f pnpm-workspace.yaml && test -d packages/lwc-toolkit && echo upstream || echo \"a plugin project or other repo\"\n```\n\n**In a plugin project or any other repository** (the common case):\n\n| Looking for | Where |\n| --- | --- |\n| the library's API | `node_modules/lightweight-charts/dist/typings.d.ts`; if it is not installed, the released typings are hosted at `https://tradingview.github.io/lightweight-charts/lightweight-charts.d.ts` |\n| the toolkit's API | `node_modules/@tradingview/lwc-toolkit/dist/<module>.d.ts` — the `.d.ts` carry the doc comments, so they read as documentation |\n| a reference plugin's **source** | not in `node_modules` (packages ship `dist/` only). Fetch it from GitHub: `https://raw.githubusercontent.com/tradingview/lightweight-charts/master/packages/lwc-plugin-<name>/src/<file>`, or clone once and read locally: `git clone --depth 1 https://github.com/tradingview/lightweight-charts /tmp/lightweight-charts` |\n| the docs | every docs page is served as Markdown by appending `.md` to its URL, e.g. `https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series.md`. `https://tradingview.github.io/lightweight-charts/llms.txt` lists every page; `docs_map.md` beside it lists their headings too |\n\n**In the upstream checkout:** `dist/typings.d.ts` (or `src/`) for the library,\n`packages/lwc-toolkit/src/` for the toolkit, `packages/lwc-plugin-*/src/` for\nthe plugins, `website/docs/plugins/*.md` for the docs, `plugin-examples/` for\nthe proof-of-concept examples.\n\n```sh\n# what version is installed, and does the hook I am about to rely on exist in it?\nnode -p \"require('lightweight-charts/package.json').version\"\nrg -n \"hitTest|conflationReducer|isHovered|ICustomSeriesPaneView|IPrimitivePaneRenderer\" node_modules/lightweight-charts/dist/typings.d.ts\n# the toolkit's custom-series surface\nrg -n \"export (declare )?(function|class|interface|type)\" node_modules/@tradingview/lwc-toolkit/dist/custom-series/*.d.ts\n# a reference implementation, without a checkout\ncurl -fsSL https://raw.githubusercontent.com/tradingview/lightweight-charts/master/packages/lwc-plugin-stacked-bars-series/src/renderer.ts\n```\n\nLocal typings win over the docs when they disagree: the docs describe the\ncurrent release, the typings describe what the user actually has. If a file is\nmissing, say what could not be verified. Never invent an option, a hook or a\ntoolkit export — a plugin that compiles against an imagined API fails the\nuser's typecheck, and one that compiles against an option the chart ignores\nfails silently at runtime.\n\n## From idea to plugin type\n\nThe single most consequential decision, and the one to make first. Ask what\nthe idea *is* rather than how it looks:\n\n| The idea is… | Type | Because |\n| --- | --- | --- |\n| a new way to draw a series' own data (bars, bands, stacks, candles) | **custom series** | it needs its own data, autoscale, price line, last value and time-scale integration |\n| a decoration tied to one series (label, marker, band around it, drawing tool on its data) | **series primitive** | it reads that series' coordinates and is clipped to it |\n| a decoration tied to the pane (watermark, legend, title, an overlay for every series) | **pane primitive** | it spans the pane and outlives any one series |\n| a DOM-based accessibility, tooltip or control layer | **pane primitive** with a DOM overlay | the canvas is not the right medium; append to `paneContentElement(pane)` |\n\nDefault to a primitive. A custom series is the heavier construct — it must\nimplement `priceValueBuilder`, `isWhitespace`, `renderer` and `update`, and\nits renderer is called with the series' plot data. Only choose it when the\nidea *is* a series. A drawing tool that needs pointer handling is still a\nprimitive: it draws in a primitive and reacts through `subscribeClick`,\n`subscribeCrosshairMove` and the coordinate-conversion APIs.\n\nKeep hover and interaction in mind when choosing: primitives get a `hitTest`\nso the chart can report them in crosshair and click events; custom series get\na `hitTest` on their renderer only on Lightweight Charts™ 5.2 and later, which\nis what makes the `isHovered` and `hitTestData` arguments of `draw` report a\nhover.\n\n## Working method\n\nBuild in this order. Each step is the cheapest place to find the previous\nstep's mistakes.\n\n1. **Write down the data item and the options** before any code. The data\n   item decides `isWhitespace` (which fields make a point drawable) and the\n   options decide `defaultOptions`. Both go in their own files\n   (`data.ts`, `options.ts`) because the README, the types and the demo all\n   read them.\n2. **Scaffold** (below). Do not start from a blank file.\n3. **Get the renderer drawing with the sample data** the scaffold generates,\n   visible-range only, before touching options or interaction. A renderer that\n   draws everything, or draws nothing, is easier to fix while it is small.\n4. **Wire the options** through `applyOptions`; re-render with\n   `requestUpdate()`. Check every option does something in the demo page.\n5. **Custom series only: autoscale and whitespace.** `priceValueBuilder`\n   drives the price scale and the last-value label; whitespace decides where\n   the line breaks. Both have traps (checklist below).\n6. **Interaction**: `hitTest`, hover, drag. Keep it separate from drawing.\n7. **Tests**, then the README, then the demo and preview pages. The package\n   contract (`references/package-contract.md`) says what each must contain.\n   The preview must use `themeChart` from the preview kit's `preview-theme`\n   and be checked in both the light and the dark theme.\n\n## Scaffold, don't start blank\n\n```sh\nnpm create lwc-plugin@latest\n```\n\nThe wizard is interactive. It first offers to install this skill (say no if it\nis already installed, or the user quit the wizard to hand over to you), then\nasks for the type, a name, a one-sentence description, a package name, a class\nname, author, license, the minimum library version, tags, whether to keep hint\ncomments, and the target folder. Work those answers out with the user before\nanyone runs it — the type decision above is the one that matters — then have\nthe user run the wizard in their terminal, unless your environment gives you a\nTTY to answer the prompts yourself. It writes a Vite project with:\n\n- `src/<entry>.ts` — the plugin class (and, for a custom series, a factory);\n  `src/options.ts`, `src/data.ts`, and a renderer or view file per type\n- `src/example/index.html` + `example.ts` — the dev demo, `pnpm dev` serves it\n- `package.json` with `dev`, `build`, `typecheck` and `check-package` scripts,\n  a `lightweight-charts` peer range, `@tradingview/lwc-toolkit` as a\n  devDependency, and an `lwcPlugin` block for the catalog\n- a README already in the shape the catalog renders\n\nAnswer yes to \"hint comments\": they are `//*` lines that explain each part of\nthe template and are stripped by the wizard otherwise. Read them, then delete\nthe ones you have acted on. Build against the scaffold's own scripts\n(`pnpm typecheck`, `pnpm build`, `pnpm check-package`) — they are what CI and\nthe release tooling run.\n\n## Build on the toolkit\n\n`@tradingview/lwc-toolkit` is what the official plugins are built from,\nextracted from the helpers every example used to copy by hand. Reaching for\nit is not about saving lines; it is that the helpers encode chart behavior\nthat is easy to get subtly wrong — the exact width the built-in candlestick\nuses at a given bar spacing, pixel-perfect line positions at every device\npixel ratio, the dash patterns of `LineStyle`, how conflation changes a bar's\nlogical stride. Import each helper by sub-path:\n\n```ts\nimport { CustomSeriesRendererBase } from '@tradingview/lwc-toolkit/custom-series/renderer-base';\nimport { visibleSegments, extendRange, barCoordinate } from '@tradingview/lwc-toolkit/custom-series/visible-bars';\nimport { PluginBase } from '@tradingview/lwc-toolkit/plugin-base';\n```\n\nProblem → module, for the common cases. `references/toolkit.md` has the rest,\nwith the shape of each API and the official plugin that uses it.\n\n| You need to… | Use |\n| --- | --- |\n| write a custom series renderer without re-doing the data / range guards | `custom-series/renderer-base` — extend `CustomSeriesRendererBase`, implement `drawImpl(scope, args)` |\n| a series or pane primitive with the chart reference and `requestUpdate()` handled | `plugin-base` (`PluginBase`) / `pane-plugin-base` (`PanePluginBase`) |\n| draw only what is on screen, and reach the pane edge with a line | `custom-series/visible-bars` — `forEachVisibleBar`, `mapVisibleBars`, `extendRange`, `barCoordinate` |\n| size a conflated bar to the slots it covers (only with a `conflationReducer`) | `effectiveBarSpacing` (`custom-series/visible-bars`) |\n| implement `hitTest` or `conflationReducer` and still support 5.0 | `custom-series/compat` (types only) — `CustomSeriesHitTestResult`, `ConflationContext` |\n| call a series method newer than 5.0 (`setSeriesOrder`, 5.0.6) and still support 5.0 | `chart/compat` — `supportsSeriesOrder(series)` narrows the series, so the call stays typed |\n| report the bar under the pointer from `hitTest` | `custom-series/hit-test` — `seriesHitTestTolerance`, `nearestVerticalRange` (boxes), `nearestBar` (any shape), `createHitTestDataCache` |\n| break a line at explicit whitespace, not at other series' timestamps | `createWhitespaceSeries` (`custom-series/options-aware-series`) + `visibleSegments` |\n| read options inside `priceValueBuilder` (autoscale that follows options) | `createOptionsAwareSeries` with the option names that affect plot values |\n| stacked values: band edges and autoscale extremes | `custom-series/stacking` — `stackLevels`, `stackedPlotValues` |\n| columns, candles or lines the same width as the built-ins, pixel-aligned | `dimensions/*` — `calculateColumnPositions`, `candlestickWidth`, `positionsLine`, `positionsBox` |\n| rounded rectangles with an inset border | `canvas/round-rect` |\n| polylines, step lines, the area between two lines, a line whose color changes | `custom-series/line-paths` |\n| a label on the price or time axis | `axis-label-view` (`AxisLabelView`) |\n| a DOM overlay inside the pane | `dom/pane-element` (`paneContentElement`) |\n| a small event, or a `Time` as a timestamp or display string | `delegate`, `time` |\n\nWhen the scaffold's template already imports a toolkit helper, keep it; the\ntemplate is the smallest correct plugin of its type.\n\n## Read the reference implementations\n\nThe official packages are the canonical examples: maintained, tested,\npublished, and built exactly the way this skill describes. Read the one\nnearest your idea *before* designing — most questions (\"how do I get the\nhovered item?\", \"how do I autoscale a stack?\") are answered by a file in\none of them. Upstream they are `packages/lwc-plugin-*/src/`. From any other\nrepository the published `@tradingview/lwc-plugin-*` package gives you the\nREADME and the `dist/*.d.ts`, but not the source — fetch that from GitHub\n(raw URL or a shallow clone, see above); each plugin is a handful of files.\n\n| Building… | Read |\n| --- | --- |\n| any custom series | `stacked-bars-series` (the simplest complete one), then `pretty-histogram-series` |\n| a series with several values per point | `stacked-area-series`, `stacked-bars-series`, `grouped-bars-series` (side by side) |\n| a line/area that must break at gaps, or survive conflation | `hlc-area-series`, `brushable-area-series` |\n| a series with its own pointer interaction | `brushable-area-series` (`BrushableAreaInteraction`) |\n| a replacement for a built-in series | `rounded-candles-series` (matches candlestick options and widths) |\n| a chart whose X axis is a number, not time (scatter, bubble) | `scatter-series` (`ScatterHorzScaleBehavior`, `createScatterChart`) |\n| point markers on a series, hovered by their drawn shape | `lollipop-series` (`canvas/markers` dots, `nearestVerticalRange` and `markerDistance` in `hitTest`), `scatter-series` |\n| a shape built from several values per point, on the candle grid | `box-whisker-series` (named fields, per-point colors, part names in `objectId`) |\n| many colored cells per point, an order book or volume profile | `heatmap-series` (fills batched by color, `createColorScale`, a cell-level `hitTest`) |\n| a fixed-pixel-height overlay series | `dual-range-histogram-series` (`scaleMode`, `keepPixelSeriesInView`) |\n| a series primitive with an axis label and dragging | `vertical-line` |\n| a tool the user clicks to add something to a series | `user-price-lines` (pointer events in its own pane, one active instance per pane, a chart option set and put back) |\n| an image or decoration behind a series or pane | `image-watermark` (both a series and a pane primitive) |\n| a background colored from data, outside the price scale | `background-shade-series` (`[NaN]` plot values, `setSeriesOrder(0)`) |\n| a text label anchored to a pane edge or corner | `anchored-text` (the smallest series + pane pair over one core) |\n| a background derived from each bar of a series | `session-highlighting` (per-bar state from `dataUpdated`, visible-range slice) |\n| a DOM layer on a pane, multi-pane lifecycle | `accessibility` |\n\n`references/official-plugins.md` says what each one demonstrates in detail.\n`plugin-examples/src/plugins/` in the repository\n(`https://github.com/tradingview/lightweight-charts/tree/master/plugin-examples`)\nholds a further set of proof-of-concept plugins — tooltips, drawing tools,\na volume profile, … — good for breadth and ideas, but they are\nunpublished starting points, not the standard to match. The graduated\nplugins' folders there are redirects to the packages.\n\n## Read the documentation in this order\n\nFetch pages as Markdown — append `.md` to the URL — rather than scraping the\nHTML: `https://tradingview.github.io/lightweight-charts/docs/plugins/<page>.md`.\n`https://tradingview.github.io/lightweight-charts/llms.txt` is the index of\nevery page, `docs_map.md` the same with headings, and\n`lightweight-charts.d.ts` beside them the released typings.\n\n1. `intro` — the three plugin types and how they attach.\n2. `series-primitives` or `pane-primitives` — the view/renderer/lifecycle\n   contract for your type: `attached` / `detached`, `updateAllViews`,\n   `paneViews`, `priceAxisViews`, `timeAxisViews`, `hitTest`.\n3. `custom_series` — `ICustomSeriesPaneView`: `priceValueBuilder`,\n   `isWhitespace`, `renderer`, `update`, `defaultOptions`, the 5.1 conflation\n   hooks and the 5.2 `hitTest`.\n4. `canvas-rendering-target` — the `CanvasRenderingTarget2D` you draw on and\n   its two coordinate spaces.\n5. `pixel-perfect-rendering` — why widths and positions go through the\n   `dimensions/*` helpers.\n\nFor anything the pages do not cover, read the typings rather than the\ngenerated API reference — they are complete, and the `.d.ts` is what your code\ncompiles against. The docs describe the current release; when your peer range\nstarts earlier, the typings of the installed version are what you actually\nhave.\n\n## Correctness checklist\n\nEach of these has bitten a shipped plugin. The reasons are here so they can\nbe recognized in a new shape, not just avoided in the old one.\n\n### Drawing\n\n- Draw in `useBitmapCoordinateSpace` for anything that must be crisp (lines,\n  bars, borders) and scale widths by `horizontalPixelRatio` /\n  `verticalPixelRatio`; use `useMediaCoordinateSpace` for text and layout in\n  CSS pixels. Mixing them blurs on HiDPI. The `dimensions/*` helpers return\n  bitmap positions for exactly this reason.\n- `CanvasRenderingTarget2D` comes from `fancy-canvas`, not from the library;\n  the toolkit re-exports the type from `custom-series/renderer-base` so a\n  custom series need not depend on it.\n- Restore anything you set on the context (`save`/`restore`, or reset\n  `globalAlpha`, `lineCap`, dash). The next renderer draws on the same\n  context.\n- A `priceToCoordinate` that returns `null` means the price is off the\n  scale. Skip that point or break the line there; drawing to `NaN` loses the\n  whole path.\n\n### Visible range and coordinates\n\n- Draw `data.visibleRange` only; a series can have a million points. For\n  lines and areas widen the range by one bar with `extendRange` so the first\n  and last segments leave the pane instead of stopping at the edge.\n- Bars outside the visible range may carry stale or missing `x`. Rebuild a\n  coordinate from a visible anchor with `barCoordinate(bar, anchor,\n  barSpacing)` — `bar.time` is the *logical index*, and spacing is per index.\n- `bar.time` (logical index) and the array index `i` differ as soon as another\n  series starts earlier or the data has gaps. Per-index option lookups and\n  brush ranges use the logical index.\n\n### Custom series specifics\n\n- `priceValueBuilder` returns the plot values the chart autoscales on and\n  takes the *last* as the current value (price line, last-value label). For\n  a stack report `[min, max, total]` (`stackedPlotValues`); for a band the\n  extremes; for a single value `[value]`.\n- It runs at `setData`, before any render, so a plain view has no options\n  yet — the chart has not called `update` — and `percent`, `base` or\n  `scaleMode` are ignored on the first ingest. `createOptionsAwareSeries`\n  gives the builder a live options getter and re-ingests when a named option\n  changes; this is why the official series ship a `createXSeries` factory as\n  the supported entry point and keep the class exported for composition.\n- The host hands a custom renderer **no whitespace**: bars simply skip the\n  gap, and a jump in logical index may just be another series' timestamps.\n  Break lines only at the series' own whitespace, from its accepted input:\n  `createWhitespaceSeries` provides a `GapCheck`; pass\n  `getConflationFactor(data)` as its `minGap` so a whitespace run narrower\n  than one conflation bucket is absorbed rather than splitting every bucket\n  into a single-point segment.\n- `conflationReducer` and `conflationFactor` exist from 5.1, and the\n  renderer's `hitTest` from 5.2: series hit testing, which reports a custom\n  series hovered through `isHovered` / `hitTestData` (`draw` arguments since\n  5.0), arrived with it. Implement them as optional extras, keep the peer\n  range at `^5.0.0` unless you need them, and say so in the README.\n- `hitTest` must return the same `hitTestData` object while the same item\n  stays hovered: the chart compares it by reference and repaints the pane on\n  every pointer move when it is a new object.\n- `conflationReducer(a, b)` must return a data item of your own type that\n  makes sense as the merge of two: sum for stacks, high/low/last for OHLC,\n  the later value for a rate.\n\n### Primitives specifics\n\n- `requestUpdate()` after any change the chart cannot see (an option, a new\n  time, a decoded image). The chart does not poll your state.\n- `detached()` must undo everything `attached()` did: listeners, DOM nodes,\n  timers, pending image loads. Attach/detach cycles are common (React\n  effects, pane reordering) and leaks show up as ghost drawings and thrown\n  \"disposed\" errors.\n- A pane primitive is drawn only on the pane it is attached to; a pane index\n  given to a constructor is a hint that can be wrong. Resolve the real pane\n  lazily (the first draw's `context.canvas` is inside it) and hold it by\n  identity — indices shift when panes are added, removed or moved.\n- For DOM overlays, append to `paneContentElement(pane)` and keep the\n  overlay's layout independent of the chart's own table cells.\n\n## Testing\n\nThree layers, each catching something the others cannot. The official\npackages have all three under `tests/`; the scaffold sets up the first.\n\n- **Unit** (`tests/unit/*.spec.ts`, `node:test` + `chai`): pure functions —\n  stacking maths, option merging, data padding, gap detection. Fast, run by\n  the repository's `pnpm test`.\n- **Graphics** (`tests/graphics/*.js`): a page that draws one state; CI\n  compares the screenshot against the previous build's. One case per option\n  worth seeing, plus the edge cases: empty visible range, scrolled off, a\n  whitespace run, conflation, inverted scale.\n- **Interactions** (`tests/interactions/*.js`): a page with an async\n  `beforeInteractions(container)` that drives the chart and throws on a\n  wrong outcome — pixel sampling for \"did it paint\", DOM checks, hit tests.\n  This is where whitespace, update, `pop` and pointer behavior are tested.\n\nRun upstream with `pnpm test`, `pnpm e2e:graphics:plugins` and\n`GREP=\"lwc-plugin-<name>/\" pnpm e2e:interactions`, after `pnpm build:prod`\nand `pnpm --filter \"@tradingview/lwc-plugin-*\" build`.\n\n## Publishing and the catalog\n\nA plugin is publishable when `pnpm plugins:validate` passes upstream, or the\nequivalent by hand: an `lwc-plugin-*` name, `publishConfig.access: public`, a\n`lightweight-charts` peer range, the `lightweight-charts-plugin` keyword, a\ncomplete `lwcPlugin` block, a README with `## Installation` (`### npm` and\n`### CDN` tabs) and `## Usage`, and the demo page it declares. The scaffold\nmeets all of it. The docs site's plugin catalog renders the README and\nframes a preview page built from the package; `references/package-contract.md`\nhas the fields, the pages and the first-release changelog convention (short:\nan `Added` list, no `Fixed` — there is nothing to have fixed yet).\n\nWrite documentation and user-facing text (README, CHANGELOG, the package\n`description`, JSDoc on public API) in American English: color, center,\ncatalog, normalize, not colour, centre, catalogue, normalise. Write comments\nin new code the same way, but don't bulk-fix older plugins.\n\n## Answer contract\n\nWhen helping with a plugin:\n\n1. Name the plugin type and say why in one sentence, or explain what the\n   user's idea would lose in the other type.\n2. Point at the toolkit module and the official plugin you are basing the\n   answer on. Read the plugin's file before quoting its pattern.\n3. Verify every library and toolkit name against the local typings; say what\n   you could not verify.\n4. Produce code that the scaffold's own scripts accept: `pnpm typecheck`,\n   `pnpm build`, and `pnpm dev` showing it in the demo page.\n5. When the change touches autoscale, whitespace, the visible range or\n   hover, name the test that would have caught the regression and write it.\n",".github/skills/lightweight-charts-plugin-authoring/references/official-plugins.md":"# The official plugins, and what each one teaches\n\nUpstream: `packages/lwc-plugin-<name>/`. Published: `@tradingview/lwc-plugin-<name>`,\nwhich ships the README and `dist/` (`.js` + `.d.ts`) but not the source. From\na repository that is not the upstream checkout, read the source on GitHub —\n`https://github.com/tradingview/lightweight-charts/tree/master/packages/lwc-plugin-<name>/src`,\nor the raw file URL under `raw.githubusercontent.com/tradingview/lightweight-charts/master/…` —\nor clone once: `git clone --depth 1 https://github.com/tradingview/lightweight-charts /tmp/lightweight-charts`.\n\nEach package has `src/`, a dev demo (`src/example/index.html`), a catalog\npreview (`src/example/preview.html`), `tests/{unit,graphics,interactions}`, a\nREADME in the catalog's shape and a CHANGELOG. Read the whole `src/` of the\nnearest one before designing; they are small.\n\nEvery preview calls `themeChart` from\n`@tradingview/lwc-plugin-preview-kit/preview-theme` and has been checked in\nboth the light and the dark theme. A new package needs the same: open the\nbuilt preview with `?theme=dark` and make sure nothing is left white or\nunreadable on black. For colors that have to change with the theme, see the\npreviews of `session-highlighting`, `image-watermark`,\n`rounded-candles-series` and `box-whisker-series`.\n\nEvery custom series below ships a `create<Name>Series(chart, options?,\npaneIndex?)` factory as the supported entry point and keeps the\n`<Name>Series` class exported for `chart.addCustomSeries` and composition.\nThe factory is where options-aware autoscale and whitespace detection live.\n\n## Custom series\n\n### `stacked-bars-series` — start here for any custom series\n\nStacked columns from a `values: number[]` per point. The shortest complete\ncustom series: `data.ts`, `options.ts`, `stack.ts` (pure maths, unit-tested),\n`renderer.ts` (extends `CustomSeriesRendererBase`), the view, the factory.\nShows `createOptionsAwareSeries` with `['base', 'percent', 'stackOrder']` as\nthe price options; `stackedPlotValues` for autoscale over negatives;\n`calculateColumnPositions` with `time` so columns either side of a gap are\nnot aligned to each other; `hitTest` returning the hovered segment index;\n`conflationReducer` summing bands.\n\n### `pretty-histogram-series` — one value per point, rounded, pixel-aligned\n\nRounded columns with `widthPercent`/`widthMode`, inner corners, a border and\na gradient. Shows `canvas/round-rect` with clamped radii, `base` reported in\n`priceValueBuilder` so bars never clip at the pane edge, `highlightHovered`\ndimming, a `conflationReducer` that keeps the later value, and the guard for\nan empty visible range.\n\n### `lollipop-series` — markers on stems, sized by the bar spacing\n\nA dot at each value on a stem from `base`, drawn with `beginMarker` from\n`canvas/markers`. Read for: sizes that are options but capped by the bar\nspacing, and the dot also by a fixed maximum that keeps it within the price\nscale's margins in a pane at least 100 px tall, since autoscale only knows the\nvalues (`geometry.ts`, unit-tested); a stem kept at least one device pixel\nwide; centering the dot on the stem as it was snapped to the pixel grid; and a\n`hitTest` built on `custom-series/hit-test`: `nearestVerticalRange` for the\nstems and `nearestBar` with `markerDistance` for the dots, so that each dot is\nmeasured as drawn, reporting the dot as a `'point'` and the stem as a\n`'range'`, since the chart prefers any point hit to a range hit whatever the\ndistance. It has no `conflationReducer`, so it sizes against `barSpacing`, not\n`effectiveBarSpacing`. Its `hover-empty-space` interaction test shows the\nlibrary's own fallback: where the renderer's `hitTest` returns `null`, a\npointer inside a bar's slot between its plot values still reports the series\nas hovered, without an `objectId`.\n\n### `grouped-bars-series` — several values per point, side by side\n\nA group of columns per point from `values[]`, with series and per-point\n`colors`, a `base`, and `columnWidthMode`/`widthPercent` named as in\n`stacked-bars-series`. Read for: one column count for the whole series, the\nmost values any point that draws a column has, so a column is as wide in\nevery group, counted once per data change by keying it on the\n`AcceptedInput` revision that `createOptionsAwareSeries` hands the view, and\nread when the renderer draws or hit tests rather than in the view's `update`,\nwhich the chart calls while `setData` is still running, before the revision\nmoves; groups placed with `calculateColumnPositionsInPlace` in `histogram`\nmode and `positionsLine` in `percent` mode, where they are all the same width\nand never wider than the bar spacing covers; splitting each group into\nwhole-pixel columns that tile it exactly (`splitGroup` in `layout.ts`,\nunit-tested), every column keeping at least a pixel and the tallest drawn\nfirst once they share pixels; values equal to `base`, `null` and non-finite\nvalues skipped like whitespace; and a `hitTest` that measures every column\nwithin reach with `nearestBar`, naming the point and the column in\n`objectId`.\n\n### `stacked-area-series` — bands, gaps and conflation together\n\nCumulative bands from `values[]`, negatives folding back to the base,\n`gapHandling: 'break' | 'bridge'`, `percent` mode, per-band and per-point\ncolors, `lineType` simple/step/curved. Shows `createWhitespaceSeries` with\n`['base', 'percent']`; `visibleSegments` with the `GapCheck` and\n`getConflationFactor(data)` as `minGap`; `extendRange` + `barCoordinate` so\nlines reach the pane edge with correct offscreen coordinates; `stackLevels`;\na `hitTest` that ignores whitespace gaps and unpainted extents. Its\ninteraction tests (`shared-timeline`, `whitespace-hit-test`,\n`conflation-holidays`) are the model for testing gap behavior.\n\n### `hlc-area-series` — two lines with a band between\n\nHigh, low and close lines, two-tone fill, gradients, step mode, hover\nmarkers on the bar under the cursor. Shows `line-paths` (`buildLinePath`,\n`buildStepLinePath`, `areaBetween`), skipping points whose prices fall off\nthe scale rather than drawing to `NaN`, `hitTest` by nearest bar, and a\n`conflationReducer` taking highest high / lowest low / last close.\n\n### `brushable-area-series` — a series plus its own interaction primitive\n\nAn area whose `brushRanges` (logical-index ranges) carry their own styles,\nwith `outsideStyle`, `basePrice` and gradient options; and\n`BrushableAreaInteraction`, a series primitive that turns mouse drag,\none-finger drag and two-finger gestures into a range and reports it through\n`activeRange()` as a `Delegate`. Read this for: matching ranges by *logical\nindex* rather than array index (they differ when another series starts\nearlier), `strokeStyledPolyline` for a line whose style changes mid-way, and\nhow a series and a primitive cooperate without the series knowing about\npointers.\n\n### `dual-range-histogram-series` — fixed pixel height, price-scale coexistence\n\nNested up/down columns of fixed pixel height on the zero line, or `scaleMode:\n'price'` to autoscale like a normal series. Shows the problem of a series that\nis *not* part of the autoscale: `keepPixelSeriesInView(chart, series)` reserves\nroom on the price scale and keeps doing so on resize. Also generic horizontal\nscale support, role-keyed `colors`/`borderRadius`, and `normalize`.\n\n### `background-shade-series` — a series that is only a background\n\nFull-height columns behind each bar, colored by where the bar's value sits\nbetween two colors. Read for: a custom series that stays out of the price\nscale (`priceValueBuilder` returns `[NaN]`, so it never changes the autoscale\nrange, has no last value and is never hovered) and sits on an overlay price\nscale of its own, set in `defaultOptions`, since a series at the bottom of the\norder would otherwise set the number format of a shared axis; columns from\n`fullBarWidthAfter`, each starting where the previous one ends, since two\nedges rounded on their own can leave a seam; shades looked up in a table built when the\ncolors change, so no color string is made while drawing; a per-point `color`\nread from `bar.barColor`, since the chart keeps `color` out of\n`originalData` and merges it with the series `color`, which the package\ntherefore leaves empty; parsing a CSS color\nthrough a scratch canvas of its own (never the chart's context, whose\n`fillStyle` a check would change), and spotting an invalid one; mixing colors\nwith premultiplied alpha; a factory that moves the series behind the others\nwith `setSeriesOrder(0)` where the host has it; and `globalAlpha` set inside\n`save`/`restore`. Its `price-format-kept` interaction test compares two\ncharts, since a price axis never narrows once it has grown.\n\n### `box-whisker-series` — a statistical shape on the candle grid\n\nA box plot per point from named fields (`min`, `q1`, `median`, `q3`, `max`)\nand `outliers`, with the five colors overridable on each point. Read for:\nsizing every part from `candlestickWidth` and the grid line width in bitmap\npixels, with the same parity as the whisker so each part is centered on it;\nthe outliers in the autoscale values, so every dot stays in view; malformed\npoints (a non-finite or `null` number) read as whitespace in `isWhitespace`,\nso they never reach the price scale; a factory that is a typed\n`chart.addCustomSeries`, since no option changes the plot values; and a\n`hitTest` on `nearestBar` that names the part and the point under the pointer\n(`'box-<point>'`, `'outlier-<point>-<index>'`, …) in `objectId`, an outlier\nreported as a `'point'` and the rest as `'range'`. It has no\n`conflationReducer`: merging two box plots has no clear meaning.\n\n### `heatmap-series` — many cells per point, filled by color\n\nA column of `{ low, high, amount }` cells per point, colored by a\n`cellShader(amount, range)` option. Read for: drawing many small shapes per\nframe by collecting them per color and filling one path per color, which a\nshader with few colors (`createColorScale` and its `steps`) makes pay off;\nhanding a function option the range of the values in view, worked out over\nthe visible bars, so colors need no maximum fixed in advance; checking a\ncolor a user function returns on a scratch canvas before drawing with it,\nsince the canvas ignores an invalid fill and would reuse the last one;\ncells rounded to pixels edge by edge, so neighbors share an edge, columns\nfrom `fullBarWidthAfter`, and a gap and a border rounded per axis and left out\nof a cell too small for them; rows off the pane skipped; a function-valued\noption, and a factory options type that keeps it a function where the\nlibrary's `DeepPartial` would not; a cell-level `hitTest` limited to the\ncolumn whose slot holds the pointer, so its `objectId` indexes the point\n`param.seriesData` reports, with no `hitTestData` so a pointer moving within a\ncell repaints nothing (its `hover-stable` interaction test counts fills); and\nseeded sample data shared by the demo, the preview and the unit tests.\n\n### `rounded-candles-series` — a drop-in replacement for a built-in\n\nCandlesticks with rounded bodies. Read for how to *match* the built-in:\nthe same color option set and shorthand semantics, `candlestickWidth` for\nthe body, body and wick aligned on one pixel grid at every DPR,\n`upDownMode`, per-point overrides, `conflationFactor` widening candles under\nconflation, and a `radius` that may be a number or a function of bar spacing.\n\n### `scatter-series` — a numeric X axis instead of time\n\nScatter and bubble charts. `createScatterChart` builds the chart on a custom\nhorizontal scale behavior (`ScatterHorzScaleBehavior`) so that the X axis is a\nplain number, and `createScatterSeries` draws the whole data set as one custom\nseries, in named groups with their own colors, marker shapes and connecting\nlines, with bubble sizes driven by a data value. Read for a custom horizontal\nscale, markers drawn and hit tested through `canvas/markers`, and a host API\nfor the tooltip and legend the plugin leaves to the page: `hoveredInfo.objectId`,\n`pointById`, `subscribeHoveredPointChange`. The one official plugin that needs\n`lightweight-charts` 5.2 (`^5.2.0`).\n\n## Series primitives\n\n### `vertical-line` — the model series primitive\n\nA full-height line at a time, with a time-axis label, a badge on the line,\n`snap: 'exact' | 'nearest'`, dragging with an `ew-resize` cursor. Shows\n`PluginBase`, `AxisLabelView` (and the off-screen coordinate when the time is\nnot on the scale), `positionsLine` for a crisp line, `setLineStyle` for dash\npatterns, `Delegate` for `timeChanged()`, hit-testing with a tolerance, and\ndrag ownership — only one line per chart suspends the chart's own scroll and\nscale handling, and restores it exactly once. Its interaction tests cover\ndrag cancel, disabling during a drag, overlapping lines and pointer scope.\n\n### `user-price-lines` — pointer-driven creation on a series\n\nA button at the right edge of the pane that follows the pointer and adds a\nprice line where it is clicked. Read for: driving a tool from\n`subscribeCrosshairMove` and `subscribeClick`, ignoring events from other\npanes with `param.paneIndex` and asking for a repaint only when the button\nchanges; moves with no `sourceEvent` (the chart's own, after\n`setCrosshairPosition`, on data and time scale changes) never bringing the\nbutton up; a click that only counts on the button where it is shown, so a\ntouch tap away from it adds nothing (the chart reports no click after a\ndrag); the pane's width from `chart.paneSize`, since\n`timeScale().width()` is 0 while the time axis is hidden; a geometric\n`hitTest` for the cursor and `hoveredObjectId` (the chart hit tests before it\nreports the move); setting a chart option (`CrosshairMode.Normal`) while\nattached and putting the old value back on detach only if it is still the one\nset, handed over between instances; one active instance per pane, kept in a\nmodule-level `WeakMap` by chart; letting go of the chart once\n`chart.removeSeries` or `chart.remove` has taken its series away (neither\ncalls `detached`); tracking the lines it created by `id`, since\n`series.priceLines()` returns new objects on every call, and removing them on\ndetach; and a deprecated constructor overload kept from the example. Its\ninteraction tests wait out the chart's double-click window between clicks in\none pane: a second click within 500 ms is otherwise swallowed, and a test\nasserting that it added nothing passes for the wrong reason. Its `price-zero`\ntest builds a scale on which a whole pixel row is at exactly 0.\n\n### `image-watermark` — the same idea as both primitive types\n\n`ImageWatermark` (series primitive) and `ImageWatermarkPane` (pane primitive)\nsharing options and a renderer. Read for: drawing nothing until an image has\ndecoded (and reporting failures through `onError` instead of throwing every\nframe), positioning from the *pane's* size rather than the chart element,\n`objectFit`/`position`/`padding` layout, `zOrder`, a decoded-image cache by\nURL, and `detached()` canceling a pending load.\n\n### `anchored-text` — the smallest two-class primitive\n\n`AnchoredText` (series primitive) and `AnchoredTextPane` (pane primitive)\nsharing one core, with no image to load and no interaction: the shape of\n`image-watermark` reduced to its essentials. Read for: laying text out in the\nmedia coordinate space from `measureText` (`layout.ts` is a pure function the\nunit tests cover for all nine anchors), a renderer that returns `null` while\nthere is nothing to draw, `save`/`restore` around context changes, options\nthat accept a deprecated spelling (`'middle'`) on input and never return it,\nand `mergeOptions` where one option (`lineHeight`) treats an explicit\n`undefined` as a value.\n\n### `session-highlighting` — per-bar background from the series' own data\n\n`SessionHighlighting` shades a full-height column behind every bar with the\ncolor a user function returns for its time. Read for: deriving per-bar state\nfrom `series.data()` in `dataUpdated` and patching only the end of it on an\n`'update'` scope. The scope covers more than append and replace: `pop()` and\nan update that turns the last bar into whitespace shrink the data, and a\nhistorical update can remove a bar from the middle or insert one there, so\nthe bar count decides the case: a shrink is only cut back when the kept last\nentry still names the last bar, and a bar is only appended when it comes after\nthe last entry (both compared by the key `timestampOf` stores for each bar: numbers\npass through unchanged, as the time scale keys them, and business days and\ndate strings become the UTC timestamp of their day, so how the time is written\ndoes not matter); otherwise every bar is recolored. Also read for mapping the\nvisible logical range back to data indices by binary search over `timeToIndex`\n(so other series starting earlier do not shift the slice), `fullBarWidth` from\nthe time scale's `barSpacing` for columns as wide as the bar slots (each edge\nrounded on its own, so neighbors can leave a 1 px seam where an edge falls on\na half pixel; `fullBarWidthAfter` rounds a shared edge once), and\n`zOrder: 'bottom'` for a background.\n\n## Pane primitives\n\n### `accessibility` — DOM overlays and multi-pane lifecycle\n\nA pane primitive per pane plus a chart-level `addAccessibilityPlugin(chart,\noptions)` controller. The reference for anything DOM-based: appending a\nsemantic layer to `paneContentElement(pane)`, following the pane by identity\nthrough reordering (the constructor index is only a pre-build hint; the first\ndraw's canvas resolves the real pane), a single shared ARIA-live region,\n`subscribeMediaQuery` for high contrast, message bundles and localization,\nkeyboard handling on the overlay, and a controller that reconciles panes added\nor removed at runtime. Also the largest test suite of the official plugins; its\n`pane-reorder`, `mismatched-pane-index` and `announce-callback-throws`\ninteraction tests show how to assert on DOM state.\n\n## `plugin-examples/` — breadth, not the standard\n\nUpstream `plugin-examples/src/plugins/` holds unpublished proof-of-concept\nplugins: tooltips and delta tooltips, a rectangle drawing tool, trend lines,\nprice alerts, a volume profile, a partial price line,\nand crosshair highlighting. Good for seeing the shape of an\nidea; they predate the toolkit and skip the tests and README the packages\ncarry, so use the official plugins for *how* and these for *what*. The\ngraduated plugins' folders there are redirect stubs to the packages.\n",".github/skills/lightweight-charts-plugin-authoring/references/package-contract.md":"# The plugin package contract\n\nWhat makes a plugin package publishable and catalog-ready. Upstream,\n`pnpm plugins:validate` (`scripts/plugins/validate-metadata.mjs`) enforces all\nof it and fails CI otherwise; a project scaffolded by `create-lwc-plugin`\nalready satisfies every item, so this is mostly a list of what not to break.\nThe catalog on the docs site lists the official packages today; the same\ncontract is what any plugin would need to be listed.\n\nUpstream only: a package under `packages/` also needs its catalog card\nillustration, `website/static/plugin-catalog/assets/previews/<slug>.svg`\n(320×180, TradingView palette colors only). The catalog data README,\n`website/plugins/plugin-catalogue/README.md`, says how to draw it and which\naccent color to pick.\n\n## `package.json`\n\n| Field | Rule | Why |\n| --- | --- | --- |\n| `name` | starts with `lwc-plugin-` (unscoped), or `@tradingview/lwc-plugin-` for an official package | the unscoped remainder is the catalog's URL segment and the entry file name |\n| `version` | valid semver | the release script compares it with npm |\n| `description` | non-empty | shown on the catalog card |\n| `license` | non-empty SPDX id | shown on the detail page |\n| `publishConfig.access` | `\"public\"` | scoped packages default to restricted |\n| `peerDependencies.lightweight-charts` | a valid range, `^5.0.0` unless a 5.1 hook is required | the catalog shows \"works with\"; consumers install the library themselves |\n| `keywords` | includes `lightweight-charts-plugin` | how npm search and the registry find plugins |\n| `files` | `dist` (+ `CHANGELOG.md`, `NOTICE` for official) | ship built output only |\n| `exports` | `.` and `./standalone`, each with `types` + `default` | the standalone build inlines everything but the library, for CDN import maps |\n| `lwcPlugin` | see below | the catalog's curated metadata |\n| `repository.directory` | must equal the package's real path in the repo | the \"source\" link and the catalog read it |\n\n## The `lwcPlugin` block\n\nValidated against `scripts/plugins/lwc-plugin-metadata.schema.json`;\nunknown keys are errors.\n\n| Key | Required | Values |\n| --- | --- | --- |\n| `title` | yes | display name |\n| `category` | yes | `custom-series` \\| `series-primitive` \\| `pane-primitive` |\n| `lifecycle` | yes | `current` \\| `legacy` \\| `deprecated` \\| `experimental` |\n| `origin` | yes | `official` \\| `community` (workspace packages must be `official`) |\n| `demo` | yes | package-relative path of the dev demo page; the file must exist |\n| `author` | no | display name |\n| `preview` | no | package-relative path of the catalog preview page; must exist if declared |\n| `previewHeight` | no | integer ≥ 200, CSS px for the preview frame (default 330); only with `preview` |\n| `tags` | no | search terms |\n\n## Two pages, not one\n\n- **Demo** (`src/example/index.html` + `example.ts`, `lwcPlugin.demo`): the\n  page a developer opens on its own. Put the edge cases here — whitespace\n  runs, negatives, every option as a control. `pnpm dev` serves it; upstream,\n  `pnpm plugins:build-demos` builds it to `/plugin-demos/<slug>/` on the site.\n- **Preview** (`src/example/preview.html` + `preview.ts`, `lwcPlugin.preview`):\n  what the catalog frames next to the README, in a frame ~330 px tall. Show\n  the plugin at its best: clean data, two or three controls, no explanatory\n  text. Official packages build it with the private\n  `@tradingview/lwc-plugin-preview-kit` (layout + `mountControls` /\n  `addRefreshButton`); a standalone project has no preview by default.\n\n  The preview follows the docs site's light or dark theme and switches live\n  when the site theme is toggled. Call `themeChart(chart, onTheme?)` from\n  `@tradingview/lwc-plugin-preview-kit/preview-theme` in the same script run\n  as `createChart`, before anything awaits; it themes the chart's\n  background, text, grid, scales and crosshair labels. Anything the preview\n  colors itself — series and plugin options, a price line color, an image —\n  is your job: recolor it in `onTheme`, which runs right away and again on\n  every switch. Keep a control's current choice in a variable so a theme\n  switch reapplies it, and read `previewTheme()` in the control's handler\n  (see `rounded-candles-series` or `box-whisker-series`). Before you\n  finish, check the built preview in both themes (`?theme=light` and\n  `?theme=dark` on its URL): nothing white or light-only left over, and\n  every line, dot and label readable on black.\n\nNeither page is the plugin's tests. Keep them free of assertions.\n\n## README shape\n\nThe catalog renders the README as the page body (its H1 dropped, since the\npage header shows the title), with the Installation subsections lifted into\nan npm/CDN tab switcher. So:\n\n1. `# <Title>` then a description paragraph.\n2. `## Installation` with `### npm` (install command + import example) and\n   `### CDN` (an import map pointing `lightweight-charts` and the package at\n   their standalone builds, then the same import by name).\n3. `## Usage` with at least one `js`/`ts` code block — the release smoke test\n   compiles the first snippet after `### npm`, so it must be complete and\n   correct.\n4. `## Options`, `## Notes` as needed. Headings become anchors and a table of\n   contents on the site, so keep them descriptive.\n\nIf the series ships a factory, the README's snippets use it, and a line says\nthe plain class draws continuously (no whitespace detection).\n\n## Tests\n\nOfficial packages carry `tests/unit/*.spec.ts` (run by the repo's `pnpm test`),\n`tests/graphics/*.js` (screenshot comparison against the previous build) and\n`tests/interactions/*.js` (async `beforeInteractions(container)` that throws on\na wrong outcome). The e2e runners discover them by folder; a package without\na `tests/<suite>` folder is skipped, never failed.\n\n## CHANGELOG\n\nKeep a Changelog format, one `## <version>` per release. For the **first**\nrelease keep it short: a sentence saying it is the first release (and where\nit came from), an `### Added` list of what the package provides, and\n`### Deprecated` only if it ships a deprecated alias. No `Fixed` or `Changed`\n— nothing has been released to fix or change, and entries written as commit\nsubjects read badly on npm. The release script only checks that an entry for\nthe current version exists.\n\n## Scripts a package is expected to have\n\n`dev` (Vite on the demo page), `build` (`tsc` for declarations, then the\nshared compile producing `dist/<entry>.js` and `dist/<entry>.standalone.js`\nplus bundled `.d.ts`), `typecheck`, and `check-package` (`publint --strict`\nand `@arethetypeswrong/cli`). Upstream adds `plugins:check-compat` (build every\nplugin against the workspace library) and `plugins:smoke` (install the packed\ntarball into a fresh Vite project and compile the README snippet).\n",".github/skills/lightweight-charts-plugin-authoring/references/toolkit.md":"# `@tradingview/lwc-toolkit`, module by module\n\nEvery module is its own sub-path export: `@tradingview/lwc-toolkit/<module>`.\nThere is no root import. This file describes the shape and the reason, not\nevery overload: verify signatures against\n`node_modules/@tradingview/lwc-toolkit/dist/<module>.d.ts`, whose doc comments\nare the module's documentation.\n\n\"Read:\" names the official plugin whose source shows the module used for\nreal. Upstream that is `packages/lwc-plugin-<name>/src/<file>`; from any other\nrepository fetch\n`https://raw.githubusercontent.com/tradingview/lightweight-charts/master/packages/lwc-plugin-<name>/src/<file>`\n(the published package ships `dist/` only).\n\n## Custom series\n\n### `custom-series/renderer-base` — `CustomSeriesRendererBase`, `CustomSeriesDrawArgs`, `CanvasRenderingTarget2D`\n\nBase class for a custom series renderer. `update(data, options)` stores what\nthe chart hands over; `draw(target, priceConverter, isHovered, hitTestData)`\nguards against a missing data set or an empty visible range and then calls\nyour `drawImpl(scope, args)` inside `useBitmapCoordinateSpace`. `args` is\n`{ data, options, priceToCoordinate, from, to, isHovered, hitTestData }`,\nwhere `from`/`to` are the visible range clamped to the bars array.\n\nReach for it because the guards are exactly where a hand-written renderer\nthrows when the whole dataset is scrolled off screen. It also re-exports the\n`CanvasRenderingTarget2D` type so the plugin need not depend on `fancy-canvas`.\n\nIf the renderer also implements `hitTest` (called from 5.2), return the *same*\n`hitTestData` object for as long as the same item stays hovered: the chart\ncompares it by reference and repaints the pane on every pointer move when it\nchanges. Keep the last one, or return a primitive such as the item's index.\n\nRead: `stacked-bars-series/src/renderer.ts` (short), `hlc-area-series/src/renderer.ts`.\n\n### `custom-series/visible-bars` — `forEachVisibleBar`, `mapVisibleBars`, `extendRange`, `visibleSegments`, `whitespaceGapCheck`, `barCoordinate`, `getConflationFactor`, `effectiveBarSpacing`, `GapCheck`, `AcceptedInput`\n\n- `forEachVisibleBar(data, fn)` / `mapVisibleBars(data, fn)` visit only\n  `data.visibleRange`; `fn` receives the bar and its *absolute* index into\n  `data.bars`, which is what per-index option lookups use.\n- `extendRange(range, length, by = 1)` widens a range by `by` bars each side,\n  clamped, so a line's first and last segments leave the pane.\n- `visibleSegments(bars, range, isGap?)` splits a range into runs of\n  increasing logical index, breaking where `isGap(left, right)` says so. A\n  jump in logical index alone is **not** a gap — other series can own those\n  indices — so without a predicate the range is one run.\n- `whitespaceGapCheck(readInput, logicalIndex, isWhitespace)` builds that\n  predicate from the series' accepted input. Its `GapCheck(left, right,\n  minGap = 1)` is true when the *contiguous* whitespace between two drawn\n  bars is at least `minGap` logical indices long. Renderers pass\n  `getConflationFactor(data)` as `minGap`.\n- `barCoordinate(bar, anchor, barSpacing)` reconstructs a media `x` for a bar\n  whose own `x` is stale (it was off screen) from a visible anchor bar.\n- `getConflationFactor(data)` is `data.conflationFactor`, or 1 on hosts\n  before 5.1.\n- `effectiveBarSpacing(data)` is `barSpacing` times that factor: the width a\n  conflated column or candle covers. Use it only in a series with a\n  `conflationReducer`. The chart reports the factor to every custom series\n  but conflates only those with a reducer, so a series without one is still\n  drawn one point per bar and sizes against `barSpacing`.\n\nRead: `stacked-area-series/src/renderer.ts` for all of them together.\n\n### `custom-series/hit-test` — `distanceToRange`, `seriesHitTestTolerance`, `nearestBar`, `nearestVerticalRange`, `createHitTestDataCache`\n\nFor a renderer's `hitTest` (called from 5.2).\n\n- `seriesHitTestTolerance(options)` reads the series' `hitTestTolerance`\n  option, in CSS pixels, with the library's default of 3 for an invalid value.\n- `nearestVerticalRange(data, x, y, halfWidth, tolerance, span)` returns\n  `{ index, distance }` for the visible bar whose box — `halfWidth` either\n  side of its `x`, between the two ends `span(bar, index)` returns — is\n  nearest the pointer and within `tolerance`, or `null`. It finds the bars\n  near `x` by binary search. Return `null` from `span` for a bar with\n  nothing to hit.\n- `nearestBar(data, x, reach, tolerance, distance)` is the same search with\n  your own `distance(bar, index)`, for geometry that is not one box per bar:\n  a dot, a ring, a shape. Only the bars whose `x` is within `reach` of the\n  pointer are measured, so make `reach` the widest the geometry gets from a\n  bar's `x`, plus `tolerance`. Measure to the shape itself; picking the bar by\n  a box around it reports the wrong bar where neighboring shapes touch.\n- `distanceToRange(value, a, b)` is the distance to a range, `0` inside it.\n- `createHitTestDataCache()` returns `get(key, create)`, which hands back the\n  same object while the same key is asked for. Use it for an object\n  `hitTestData`, keyed by the `objectId`: the chart compares `hitTestData` by\n  reference and repaints on every pointer move when it changes.\n\nReturn the result typed as `CustomSeriesHitTestResult` from\n`custom-series/compat`, which also has `ConflationContext` for a\n`conflationReducer`'s arguments. Both are types only: the library exports its\nown from 5.2 and 5.1, and importing them would raise the plugin's floor.\n\nRead: `rounded-candles-series/src/renderer.ts` (boxes), `lollipop-series/src/renderer.ts`\n(a stem and a dot).\n\n### `custom-series/options-aware-series` — `createOptionsAwareSeries`, `createWhitespaceSeries`, `OptionsAwareSeries`\n\nFactories that wrap `chart.addCustomSeries` so a series can do two things a\nplain `ICustomSeriesPaneView` cannot:\n\n- **Read options in `priceValueBuilder`.** The chart calls the builder at\n  `setData`, before any `update(data, options)`, so a plain view has only its\n  defaults there. `createOptionsAwareSeries(chart, createView, defaults,\n  options, priceOptions, paneIndex?)` passes `createView` an options getter\n  bound to the real series, and re-ingests the retained data whenever one of\n  `priceOptions` changes through `applyOptions`. Use it whenever an option\n  changes what a value *means* — a base, percent mode, a scale mode. The\n  getter keeps one copy of the options until `applyOptions`, so a builder can\n  call it for every point; `series.options()` deep-copies on every call, so\n  never call that from a builder or a renderer.\n- **Know its own whitespace.** The wrapper retains a copy of the accepted\n  input (the host's `data()` exposes fulfilled points only) as an\n  `AcceptedInput`: a chronological array plus a `revision`, kept sorted\n  incrementally so a streaming `update` is a binary insert.\n  `createWhitespaceSeries(chart, createView, defaults, options,\n  priceOptions?, paneIndex?)` builds on it and hands `createView` a ready\n  `GapCheck` plus the options getter.\n\nThe returned API keeps its identity in chart events; `setData`, `update`,\n`pop` and `applyOptions` are wrapped, everything else is the host's.\n\nRead: `stacked-area-series/src/stacked-area-series.ts` (both concerns),\n`stacked-bars-series/src/stacked-bars-series.ts` (options only).\n\n### `custom-series/stacking` — `cumulativeSum`, `stackLevels`, `stackedPlotValues`\n\nRunning totals of a values array; the band boundaries of a stack drawn from\na `base` (negative values fold back towards it, so bands never overlap); and\n`[min, max, total]` for `priceValueBuilder`, where min and max are taken over\nthe running totals *and* the base so a stack with negatives stays in view.\n\nRead: `stacked-area-series/src/stacked-area-series.ts`, `stacked-bars-series/src/stack.ts`.\n\n### `custom-series/line-paths` — `buildLinePath`, `buildStepLinePath`, `areaBetween`, `strokeStyledPolyline`\n\n`Path2D` builders in bitmap space: a polyline over a bar range with an\naccessor for `y`, its stepped variant, the closed area between two such\nlines (for bands and stacks), and a polyline whose color changes along its\nlength without a visible seam (adjacent runs share their boundary bar). A run\nof `strokeStyledPolyline` may carry a `dashPattern` (`getDashPattern(style,\nlineWidth)`), stroked with `butt` caps; runs without one keep the context's\nown dash and cap.\n\nRead: `hlc-area-series/src/renderer.ts`, `brushable-area-series/src/renderer.ts`.\n\n## Primitives\n\n### `plugin-base` — `PluginBase`\n\nSeries-primitive base: holds `chart` and `series` from `attached`, exposes\n`requestUpdate()`, and throws if `chart` is read before attach. Subclasses\nthat override `attached`/`detached` call `super`.\n\nRead: `vertical-line/src/vertical-line.ts`, `image-watermark/src/image-watermark.ts`.\n\n### `pane-plugin-base` — `PanePluginBase<T>`\n\nThe same for a pane primitive: `chart` and `requestUpdate()`; there is no\nseries. Read: `accessibility/src/pane-primitive.ts`.\n\n### `axis-label-view` — `AxisLabelView`, `AxisLabelSource`, `OFFSCREEN_LABEL_COORDINATE`\n\nAn `ISeriesPrimitiveAxisView` over a source of callbacks (`coordinate`,\n`text`, `textColor`, `backColor`, `visible`, `tickVisible`). Returns the\noff-screen coordinate when the source has none, so the axis draws nothing\nrather than a stray label at 0.\n\nRead: `vertical-line/src/vertical-line.ts`.\n\n### `dom/pane-element` — `paneContentElement`, `chartTableElement`\n\nThe pane's canvas wrapper cell, to append a DOM overlay to, and the chart's\ntable element. Pane widgets reuse rows when panes move, so hold the pane API\nby identity and re-resolve the element on `updateAllViews`.\n\nRead: `accessibility/src/dom/pane-dom.ts`.\n\n### `dom/media-query` — `subscribeMediaQuery`, `mediaQueryMatches`, `HIGH_CONTRAST_QUERIES`, `REDUCED_MOTION_QUERY`\n\nShared, SSR-safe `matchMedia` subscriptions (no `window` at import time).\nRead: `accessibility/src/high-contrast.ts`.\n\n## Pixel-perfect dimensions\n\nAll return bitmap-space `{ position, length }` (`BitmapPositionLength`, from\n`dimensions/common`), computed the way the chart's own renderers do so a\nplugin lines up with built-in series at every device pixel ratio.\n\n| Module | Export | Use |\n| --- | --- | --- |\n| `dimensions/positions` | `positionsLine(centre, pixelRatio, width)`, `positionsBox(a, b, pixelRatio)` | a crisp line of a given CSS width; a box between two coordinates |\n| `dimensions/columns` | `calculateColumnPositions(items, barSpacing, pixelRatio)`, `…InPlace` | evenly spaced columns with the histogram's gap; items may carry `time` (logical index) so a gap is not bridged |\n| `dimensions/candles` | `candlestickWidth(barSpacing, pixelRatio)` | the body width the built-in candlestick uses |\n| `dimensions/full-width` | `fullBarWidth(x, halfSpacing, pixelRatio)`, `fullBarWidthAfter(previousRight, x, halfSpacing, pixelRatio)` | a bar filling its whole slot; neighboring columns that share an edge, with no seam |\n| `dimensions/crosshair-width` | `gridAndCrosshairMediaWidth`, `gridAndCrosshairBitmapWidth` | line widths matching the grid |\n\nRead: `rounded-candles-series/src/renderer.ts`, `pretty-histogram-series/src/renderer.ts`.\n\n## Canvas and style\n\n### `canvas/round-rect` — `drawRoundRect`, `drawRoundRectWithBorder`, `clampCornerRadius`, `CornerRadii`\n\nRounded rectangles in bitmap space, with per-corner radii, radius clamping\nto the rectangle's size, and an inset border that does not shrink the fill.\nRead: `pretty-histogram-series/src/renderer.ts`, `dual-range-histogram-series/src/renderer.ts`.\n\n### `canvas/markers` — `beginMarker`, `beginMarkerOffset`, `traceMarker`, `traceMarkerOffset`, `markerDistance`, `markerVertices`, `segmentDistance`, `MarkerShape`\n\nPoint markers (`circle`, `square`, `diamond`, `triangleUp`, `triangleDown`),\ntwo ways:\n\n- one marker per path (a different color or opacity per point):\n  `beginMarker(ctx, shape, x, y, radius)` calls `ctx.beginPath()` and traces\n  the marker as the path's only subpath, then fill or stroke. A circle is a\n  bare `arc`, which Chromium draws faster, as an exact oval.\n- many markers per path (one style, one `fill()`): `traceMarker(path, shape,\n  x, y, radius)` adds each to a context or `Path2D` as a subpath of its own,\n  so no line joins them. Begin the path yourself.\n\n`traceMarkerOffset(…, offset)` / `beginMarkerOffset(…, offset)` trace the\noutline `offset` outside the marker, with rounded corners, for a hover ring\nor halo of even width;\n`markerDistance(shape, dx, dy, radius, strokeWidth)` is the distance from a\npoint to the marker as drawn, stroke and rounded corners included, `0` inside,\nfor `hitTest`. All three read the same vertices, so a marker is hit where it is\ndrawn. `segmentDistance` is the building block for hovering a polyline.\nRead: `scatter-series/src/renderer.ts`, `scatter-series/src/hit-test.ts`.\n\n### `line-style` — `setLineStyle`, `getDashPattern`, `LineStyle`\n\nThe chart's own dash patterns for a renderer that receives no drawing utils\n(custom series renderers before 5.1, primitives on some hosts). The `LineStyle`\ntype takes the library's enum as well, so an option passes without a cast.\nStroke a dashed style with `ctx.lineCap = 'butt'`, as the chart does: a round\ncap closes the gaps of a dotted line (`strokeStyledPolyline` does it for a\nrun given a `dashPattern`).\nRead: `vertical-line/src/vertical-line.ts`.\n\n## Chart behavior\n\nLibrary rules a plugin otherwise copies from the library's source. Each\nmodule names the source it mirrors; the interaction flags are pinned to it by\na unit test.\n\n| Module | Export | Use |\n| --- | --- | --- |\n| `chart/compat` | `supportsSeriesOrder(series)` | calling `setSeriesOrder` (5.0.6) from a plugin whose floor is 5.0: the guard narrows the series, so the call compiles against the 5.0 typings and is skipped on a host without the method |\n| `chart/interaction-flags` | `canUserMoveTimeScale(chart.options())`, `TIME_SCALE_MOVE_FLAGS` | whether the user can scroll or zoom the time scale; with none of the flags on, the chart treats both edges as fixed |\n| `chart/lifecycle` | `isChartRemoved(chart)`, `isSeriesAttached(chart, series)` | for a plugin with its own API in front of a series: stop writing to a chart the host removed, or a series it took off with `chart.removeSeries`. Read-only; decide outside the chart's event dispatch what to release |\n| `chart/time-axis-labels` | `timeAxisLabelFont`, `tickMarkPixelsPerCharacter`, `tickMarkMaxLabelWidth`, `tickMarkCharactersForWidth` | the time axis' label font, and `timeScale.tickMarkMaxCharacterLength` to pixels and back |\n| `text/measure` | `textMeasureContext()`, `createTextWidthCache()` | measuring labels before painting (layout, overlap avoidance); `null` without a DOM |\n\nRead: `scatter-series/src/x-axis-controller.ts`, and `scatter-series-api.ts` for\nthe lifecycle checks; `background-shade-series/src/background-shade-series.ts`\nfor `supportsSeriesOrder`.\n\n## General\n\n| Module | Export | Use |\n| --- | --- | --- |\n| `assertions` | `ensureDefined`, `ensureNotNull` | narrow or throw, for state that must exist after attach |\n| `delegate` | `Delegate`, `ISubscription` | a small subscribe/fire event; expose the `ISubscription` half publicly |\n| `time` | `convertTime`, `convertTimeUTC`, `displayTime`, `formattedDateAndTime` | `Time` (string, business day, timestamp) to a number or display string |\n| `closest-index` | `ClosestTimeIndexFinder` | cached binary search for the index at or after a time |\n| `min-max-in-range` | `UpperLowerInRange` | cached extremes over a range, for autoscale providers |\n| `simple-clone` | `cloneReadonly` | deep clone that drops readonly-ness, through JSON (functions and `undefined` are lost) |\n| `options/merge` | `mergeOptions`, `cloneOptions`, `freezeOptions` | `applyOptions` with nested options: a partial nested option changes only its keys (a spread replaces the whole object); arrays and functions replace; unsafe keys are skipped; pass `defaults` to make `null` reset a value |\n| `numbers` | `isFiniteNumber`, `finiteOr`, `nonNegativeOr`, `clampOpacity` | numeric options from JavaScript: the canvas ignores a `NaN` width or opacity silently |\n| `scheduling/coalesced-task` | `createCoalescedTask(run, enqueue?)` | `{ schedule, cancel, pending }`: once per microtask (or frame) for a burst of events, never inside the chart's dispatch; `cancel()` on removal |\n",".github/skills/lightweight-charts/SKILL.md":"---\nname: lightweight-charts\ndescription: >-\n  Use when working with TradingView's lightweight-charts — creating charts,\n  adding series (Line/Area/Bar/Candlestick/Histogram), configuring time and\n  price scales, streaming realtime or historical data, panes, markers,\n  per-bar/per-point colors, tooltips, coordinate conversion, custom plugins or\n  primitives, non-financial horizontal scales, SSR/browser loading, or\n  React/Vue/Web Components wrappers. Covers v5 API conventions and the common\n  time, scale, marker, plugin, and wrapper foot-guns.\n---\n\n# Lightweight Charts skill\n\nWorks the same whether the project is a downstream npm consumer app or an upstream `lightweight-charts` source checkout. Detect which one you are in (below) and resolve every API name from whatever typings are locally available.\n\n## Source lookup order\n\nDo not assume you are inside the upstream source repository.\n\n1. In a consumer app, inspect the installed package first:\n   - `node_modules/lightweight-charts/package.json` for the actual version.\n   - `node_modules/lightweight-charts/dist/typings.d.ts` for the API surface.\n2. In the upstream repo, inspect `dist/typings.d.ts` first, then `src/` if generated output is unavailable.\n3. Use official docs/examples as supporting evidence, but local typings win when they disagree.\n\nVerify before answering (copy-paste):\n\n```sh\nnode -p \"require('./node_modules/lightweight-charts/package.json').version\"\nrg -n \"createSeriesMarkers|addSeries|IPrimitivePaneRenderer|createImageWatermark|createOptionsChart\" node_modules/lightweight-charts/dist/typings.d.ts\n# upstream checkout instead of a consumer app:\nrg -n \"createSeriesMarkers|IPrimitivePaneRenderer|createImageWatermark|createOptionsChart\" dist/typings.d.ts src\n```\n\nIf the relevant file is unavailable, say what could not be verified. Do not invent option names, methods, exports, or wrapper behavior.\n\nIf the user's code imports `from lightweight_charts import ...` (underscore), uses pandas/asyncio, or talks about a Python window wrapper, they are probably using the third-party Python wrapper rather than the TypeScript package. Say that clearly before giving core `lightweight-charts` v5 JavaScript advice.\n\n## Mental model\n\nEight layers, in dependency order. Most bugs come from confusing one for another:\n\n1. **Chart** — `createChart(container, options)` returns an `IChartApi`. One chart per container element.\n2. **Series** — added via `chart.addSeries(SeriesType, options, paneIndex?)`. Each call returns an `ISeriesApi`. v5 requires importing the series type explicitly.\n3. **Scales** — `chart.timeScale()` (`ITimeScaleApi`), `chart.priceScale(id)` (`IPriceScaleApi`). Govern range, ticks, autoscale, visibility.\n4. **Data model** — arrays of `{ time, … }` points. `Time = UTCTimestamp | BusinessDay | string`. `UTCTimestamp` is **seconds**, not milliseconds. Times must be unique and ascending per series.\n5. **Interaction** — `chart.subscribeCrosshairMove`, `chart.subscribeClick`, `timeScale.subscribeVisibleLogicalRangeChange`, etc.\n6. **Layout** — `chart.panes()`, `chart.addPane()`. Adding a series with an out-of-range `paneIndex` auto-creates the pane.\n7. **Extension** — pane primitives, series primitives, custom series, watermarks, custom renderers (canvas via `fancy-canvas`).\n8. **Wrappers** — React/Vue/Web Components/iOS/Android. Lifecycle is the wrapper's responsibility; the core library is framework-agnostic.\n\n## v5 essentials\n\nThe conventions that catch people copying older snippets:\n\n```ts\nimport { createChart, CandlestickSeries, LineSeries } from 'lightweight-charts';\n\nconst chart = createChart(container, { /* ChartOptions */ });\nconst candles = chart.addSeries(CandlestickSeries, { /* options */ });\ncandles.setData([\n    { time: 1700000000, open: 1, high: 2, low: 0.5, close: 1.5 },\n]);\n```\n\nKey v5 changes versus older snippets:\n\n- `chart.addSeries(SeriesType, options, paneIndex?)` replaces `addLineSeries` / `addCandlestickSeries` / …\n- `createSeriesMarkers(series, markers)` replaces `series.setMarkers(...)`. The returned primitive owns `.setMarkers(...)` / `.markers()`.\n- `createTextWatermark(pane, options)` and `createImageWatermark(pane, imageUrl, options)` replace the `watermark` chart option.\n- Series types are tree-shaken — importing them is required for ESM.\n\nIf a snippet calls `addLineSeries` or `series.setMarkers`, it's v4 or older. Confirm the user's version before forwarding it.\n\nWhen the task targets v5, show the v5 API directly — do not hedge by mixing in v4 syntax.\n\n## Triage (problem → API → avoid)\n\n| User asks about | First check | Answer with | Avoid |\n|---|---|---|---|\n| v5 series creation | package version + typings | `chart.addSeries(SeriesType, options)` | `addLineSeries` / `addCandlestickSeries` |\n| markers | `createSeriesMarkers` export | marker primitive + required `color` | `series.setMarkers` |\n| timezone | formatter need vs data semantics | `Intl.DateTimeFormat` in formatters | fake `timeScale.timezone` |\n| realtime updates | last-bar vs full replace | `series.update(point)` | `setData` on every tick |\n| panes | `paneIndex` + `chart.panes()` | v5 pane APIs, `pane.setHeight` | private widget / DOM hacks |\n| per-bar colors | data-point color fields | `color`/`borderColor`/`wickColor` on points | extra series / markers to recolor |\n| plugins | primitive vs custom series | scaffold/examples + public coordinate APIs | invented renderer names |\n\n### v4 → v5 replacement matrix\n\nStale copy-pasted snippets are the most common failure. Map them directly:\n\n| Old or wrong | v5 replacement |\n|---|---|\n| `chart.addLineSeries(options)` | `chart.addSeries(LineSeries, options)` |\n| `chart.addCandlestickSeries(options)` | `chart.addSeries(CandlestickSeries, options)` |\n| `series.setMarkers(markers)` | `createSeriesMarkers(series, markers)` |\n| chart `watermark` option | `createTextWatermark(chart.panes()[0], options)` |\n| `createImageWatermark(pane, options)` | `createImageWatermark(pane, imageUrl, options)` |\n| `IPanePrimitivePaneRenderer` | `IPrimitivePaneRenderer` |\n| `timeScale: { timezone }` | label formatters using `Intl.DateTimeFormat` |\n| `time: Date.now()` (ms) | `time: Math.floor(Date.now() / 1000)` for `UTCTimestamp` |\n\n## Routing map (problem → where to look)\n\nUse local typings first. The repo paths below exist only in the upstream `lightweight-charts` checkout; in a consumer app, translate them to the installed package typings or official docs.\n\n| Task | Canonical sources |\n|---|---|\n| First chart / series | `website/docs/intro.mdx`, `website/tutorials/customization/` |\n| Time / range behavior | `website/docs/time-scale.md`, `website/docs/time-zones.md` |\n| Realtime / history | `website/examples/data/realtime-updates.{mdx,js}`, `website/examples/data/infinite-history.{mdx,js}` |\n| Whitespace / gaps | `website/examples/data/whitespace.{mdx,js}` |\n| Price format / locale | `website/tutorials/customization/price-format.mdx`, `website/examples/styling/custom-locale.{mdx,js}` |\n| Two scales / inverted | `website/examples/price-scales/two-price-scales.{mdx,js}`, `website/examples/price-scales/inverted-price-scale.{mdx,js}` |\n| Panes / price + volume | `website/docs/panes.md`, `website/examples/panes/multiple-panes.{mdx,js}`, `website/examples/price-scales/price-and-volume.{mdx,js}` |\n| Markers / tooltips / legends | `website/examples/markers-and-lines/series-markers.{mdx,js}`, `website/examples/tooltips-and-legends/*-tooltip.{mdx,js}`, `website/examples/tooltips-and-legends/*legend.{mdx,js}` |\n| Crosshair (programmatic) | `website/examples/crosshair/*.{mdx,js}` |\n| Watermarks | `website/examples/styling/*-watermark.{mdx,js}` |\n| Plugins / custom series / primitives | `website/docs/plugins/`, `plugin-examples/src/plugins/` |\n| Coordinate conversion / hit-testing | `dist/typings.d.ts` for `subscribeClick`, `coordinateToPrice`, `timeScale().coordinateToLogical` |\n| Non-time horizontal scales / options chart | `dist/typings.d.ts` for `createOptionsChart`, `createChartEx`, `IHorzScaleBehavior` |\n| Pixel-perfect rendering | `website/docs/plugins/pixel-perfect-rendering/` |\n| React / Vue / Web Components | `website/tutorials/react/`, `website/tutorials/vuejs/`, `website/tutorials/webcomponents/` |\n| SSR / script loading / bundlers | installed package `dist/` files, package `exports`, framework docs for client-only components |\n| iOS / Android wrappers | `website/docs/ios.md`, `website/docs/android.md` |\n| Version migration | `website/docs/migrations/from-v2-to-v3.md`, `from-v3-to-v4.md`, `from-v4-to-v5.md` |\n\nIf these repo paths do not exist in the user's project, do not ask them to create or clone the source tree just to answer a normal usage question. Use `node_modules/lightweight-charts/dist/typings.d.ts` and concise v5 examples.\n\n## Foot-guns (assertions, not categories)\n\n### Time\n\n- **`UTCTimestamp` is in seconds.** Use `Math.floor(Date.now() / 1000)`, never `Date.now()`.\n- **There is no built-in `timeScale.timezone` option.** For display-only timezone conversion, use `timeScale.tickMarkFormatter` for axis labels and `localization.timeFormatter` (or your own tooltip formatter) for crosshair/hover labels. Use `Intl.DateTimeFormat(..., { timeZone })`, Luxon, or date-fns-tz for DST-safe IANA timezone formatting.\n- **Pre-shifting timestamps changes chart semantics.** It can make ticks line up in a chosen timezone, but it also changes where bars sit on the UTC time scale. Prefer formatter-based display unless the user intentionally wants shifted data.\n- **Series data must be strictly ascending by `time`, with unique values.** Duplicates replace silently; out-of-order points are dropped or throw.\n- **One time format per series.** `BusinessDay` (`'YYYY-MM-DD'` string or `{ year, month, day }`) or `UTCTimestamp`, but do not mix within a single series.\n- **Business day strings must be zero-padded `'YYYY-MM-DD'`.** `'2024-1-5'`, `'2024/01/05'` or `'Jan 5 2024'` throw. Pad the string or pass `{ year, month, day }`.\n- **Whitespace points carry `time` only** (no `value` / `open` / …). Use them to create gaps or align overlays; do not set values to `null`.\n- **`setData` replaces the dataset and can reset the visible range. `update(point)` appends if `time > last` and replaces if `time === last`.** `update(point, true)` can update an existing historical point, but it is slower and does not insert missing old points. To prepend older history, build a new array and call `setData` again — there is no prepend method; save and restore the visible logical range to avoid the chart snapping.\n- **`timeScale.setVisibleLogicalRange` is logical (bar indices), not time-based.** Use `setVisibleRange` for time bounds, or `fitContent()` to reset.\n\n### Scales and panes\n\n- **Two visible price scales** requires both assigning series with `priceScaleId: 'right'` / `'left'` and making the left scale visible. Use `chart.applyOptions({ leftPriceScale: { visible: true }, rightPriceScale: { visible: true } })` or `chart.priceScale('left').applyOptions({ visible: true })`.\n- **Overlay series** (`priceScaleId: ''` or any custom id) get an autoscaled, hidden scale by default. Make it visible explicitly if you want axis labels.\n- **`autoscaleInfoProvider` runs on every layout pass.** Keep it cheap; do not allocate per call.\n- **`addSeries(_, _, paneIndex)` creates the pane** if `paneIndex` is one past the current count. Pane order is creation order; sizes are controlled via `chart.panes()[i].setHeight(px)`.\n- **Keep pane references if panes can move.** `const mainPane = chart.panes()[0]` remains the same `IPaneApi`; `mainPane.paneIndex()` gives its current index after `swapPanes` or moves.\n- **Sync separate charts with public time-scale events.** Use `subscribeVisibleLogicalRangeChange` and `setVisibleLogicalRange`; avoid `_private__chartWidget`, `paneWidgets`, or DOM offset hacks.\n- **Price-scale width is readable, not directly settable.** Use `series.priceScale().width()` or `chart.priceScale(id).width()` to measure when aligning adjacent containers.\n\n### Markers and interaction\n\n- **v5 markers are a primitive.** `const m = createSeriesMarkers(series, [...]); m.setMarkers([...])`. `series.setMarkers` does not exist on `ISeriesApi` in v5.\n- **Marker `time` must match an existing data point's `time`** for that series. Misaligned markers are dropped silently.\n- **`subscribeCrosshairMove`** fires with `param.time === undefined` outside the data range. Always null-check before reading.\n- **`param.seriesData.get(series)`** returns `undefined` between bars or before the first bar.\n- **Click/crosshair coordinates need API conversion.** Use `series.coordinateToPrice(y)` / `series.priceToCoordinate(price)` and `chart.timeScale().coordinateToLogical(x)` / `logicalToCoordinate(logical)` / `timeToCoordinate(time)`; do not infer price/time from canvas DOM geometry.\n\n### Plugins and custom rendering\n\n- **Start plugins from the scaffold/examples.** Prefer `npm create lwc-plugin@latest` and `plugin-examples/` before writing a primitive from scratch.\n- **Interactive drawing tools need two parts:** a primitive/custom series for rendering, and chart interaction handlers (`subscribeClick`, `subscribeCrosshairMove`, drag state) that convert coordinates with public APIs.\n- **`CanvasRenderingTarget2D` is imported from `fancy-canvas`,** not from `lightweight-charts`.\n- Use `target.useBitmapCoordinateSpace(scope => …)` for pixel-aligned strokes; use `target.useMediaCoordinateSpace(scope => …)` for CSS-pixel logic. Mixing them causes blur or sub-pixel jitter on HiDPI displays.\n- **`IPanePrimitive` views render across the whole pane; `ISeriesPrimitive` views are clipped to the series.** Pick the right base.\n- **The renderer interface is `IPrimitivePaneRenderer`, not `IPanePrimitivePaneRenderer`.** The view is `IPanePrimitivePaneView` and its `renderer()` returns `IPrimitivePaneRenderer | null` — the names are deliberately asymmetric. There is no `IPanePrimitivePaneRenderer` export; grep `dist/typings.d.ts` if unsure.\n- **`ICustomSeriesPaneView` is heavier than a primitive** — only use it when you need a true series API (data, scales, autoscale). For decorations, use a primitive.\n\n### Wrappers (React/Vue/etc.)\n\n- **Create the chart once** in `useEffect` / `onMounted` and destroy it in cleanup with `chart.remove()`. Recreating on every render duplicates DOM and leaks listeners.\n- **Resize can be automatic in v5** with `autoSize: true` when `ResizeObserver` is available. If you need manual control, subscribe a `ResizeObserver` to the container and call `chart.resize(width, height)` (or `applyOptions({ width, height })`).\n- **Don't drive `setData` from props on every render.** Use `series.update(...)` for incremental changes; only call `setData` when the dataset truly replaces.\n- **`undefined` in `applyOptions` means \"not specified\", not \"reset\".** `{ priceFormatter: custom ? fmt : undefined }` leaves the current formatter in place. To clear a `localization` formatter or `autoscaleInfoProvider`, pass `null`. Other options have no reset value: pass the default explicitly.\n- **Next.js/SSR must be client-only.** Put chart code in a `'use client'` component, create it in `useEffect`, and import that component with `next/dynamic(..., { ssr: false })` from server-rendered pages when needed.\n- **Plain HTML is not npm resolution.** The standalone `.js` build exposes `window.LightweightCharts`; ESM in the browser must import an actual `.mjs` URL or use an import map. `import { createChart } from 'lightweight-charts'` only works when a bundler/runtime resolves the package name.\n\n## Canonical recipes\n\n### Realtime updates\n\n```ts\nimport { createChart, CandlestickSeries } from 'lightweight-charts';\n\nconst chart = createChart(container, {});\nconst series = chart.addSeries(CandlestickSeries, {});\nseries.setData(initialBars); // full history once\n\nws.onmessage = ev => {\n    const bar = JSON.parse(ev.data); // { time, open, high, low, close }\n    series.update(bar); // appends if time > last; replaces if time === last\n};\n```\n\n`update()` only handles the latest bar. To insert in the middle or prepend, rebuild the array and call `setData`.\n\n### Two price scales (left + right)\n\n```ts\nconst right = chart.addSeries(LineSeries, { priceScaleId: 'right' });\nconst left  = chart.addSeries(LineSeries, { priceScaleId: 'left' });\nchart.applyOptions({\n    leftPriceScale: { visible: true },\n    rightPriceScale: { visible: true },\n});\n```\n\n### Volume in its own pane\n\n```ts\nconst price  = chart.addSeries(CandlestickSeries, {}, 0);\nconst volume = chart.addSeries(\n    HistogramSeries,\n    { priceFormat: { type: 'volume' } },\n    1,\n);\nchart.panes()[1].setHeight(120);\n```\n\n### Per-bar / per-point colors\n\nColor individual bars by putting the color on the **data point**, not via a separate API:\n\n```ts\n// Candlesticks: per-point color / borderColor / wickColor override series defaults\ncandles.setData([\n    { time: 1700000000, open: 1, high: 2, low: 0.5, close: 1.5,\n      color: '#26a69a', borderColor: '#26a69a', wickColor: '#26a69a' },\n    { time: 1700003600, open: 1.5, high: 1.8, low: 1.1, close: 1.2,\n      color: '#ef5350', borderColor: '#ef5350', wickColor: '#ef5350' },\n]);\n\n// Histogram (e.g. up/down volume): per-point color\nvolume.setData([\n    { time: 1700000000, value: 100, color: 'rgba(38,166,154,0.5)' },\n    { time: 1700003600, value: 80, color: 'rgba(239,83,80,0.5)' },\n]);\n```\n\nLine/Area points also take a per-point `color`. An omitted point color falls back to the series option. Do not create extra series or use markers to recolor bars.\n\n### Series markers\n\n```ts\nimport { createSeriesMarkers } from 'lightweight-charts';\n\nconst markers = createSeriesMarkers(candles, [\n    { time: 1700000000, position: 'aboveBar', color: '#e53935', shape: 'arrowDown', text: 'Sell' },\n]);\n\nmarkers.setMarkers([\n    { time: 1700003600, position: 'belowBar', color: '#43a047', shape: 'arrowUp', text: 'Buy' },\n]);\n```\n\n`color` is required on every marker (`position`, `shape`, `time` too); `text`, `size`, `id`, `price` are optional. Do not put marker objects into `setData()` points. Do not call `series.setMarkers(...)` in v5.\n\n### Timezone display\n\n```ts\nconst zone = 'America/New_York';\nconst formatTime = (timestamp: number) =>\n    new Intl.DateTimeFormat('en-US', {\n        timeZone: zone,\n        hour: '2-digit',\n        minute: '2-digit',\n        second: '2-digit',\n        hour12: false,\n    }).format(new Date(timestamp * 1000));\n\nchart.applyOptions({\n    timeScale: {\n        timeVisible: true,\n        secondsVisible: true,\n        tickMarkFormatter: (time) =>\n            typeof time === 'number' ? formatTime(time) : String(time),\n    },\n    localization: {\n        timeFormatter: (time) =>\n            typeof time === 'number' ? formatTime(time) : String(time),\n    },\n});\n```\n\nDo not invent `timeScale: { timezone: 'America/New_York' }`. If the user needs exchange-session boundaries to generate in a local timezone, explain the trade-off of shifting source timestamps separately from display formatting.\n\n### Text watermark\n\n```ts\nimport { createTextWatermark } from 'lightweight-charts';\n\ncreateTextWatermark(chart.panes()[0], {\n    horzAlign: 'center',\n    vertAlign: 'center',\n    lines: [{ text: 'DEMO', color: 'rgba(0, 0, 0, 0.25)', fontSize: 48 }],\n});\n```\n\nThe old `watermark` chart option is not the v5 API.\n\n### Whitespace gaps\n\n```ts\nline.setData([\n    { time: '2024-01-01', value: 10 },\n    { time: '2024-01-02' }, // whitespace point: time only\n    { time: '2024-01-03', value: 12 },\n]);\n```\n\nDo not use `value: null`, `undefined`, or `NaN` to create gaps.\n\n### Sync separate charts or panes\n\n```ts\nlet syncing = false;\n\npriceChart.timeScale().subscribeVisibleLogicalRangeChange((range) => {\n    if (!range || syncing) return;\n    syncing = true;\n    indicatorChart.timeScale().setVisibleLogicalRange(range);\n    syncing = false;\n});\n\nindicatorChart.timeScale().subscribeVisibleLogicalRangeChange((range) => {\n    if (!range || syncing) return;\n    syncing = true;\n    priceChart.timeScale().setVisibleLogicalRange(range);\n    syncing = false;\n});\n```\n\nFor v5 panes inside one chart, prefer `chart.addSeries(SeriesType, options, paneIndex)` and `chart.panes()[i].setHeight(px)`. If the original pane can move, keep the `IPaneApi` reference and call `pane.paneIndex()` instead of assuming index `0` forever.\n\n### Coordinate conversion\n\n```ts\nchart.subscribeClick((param) => {\n    if (!param.point || param.time === undefined) return;\n\n    const price = series.coordinateToPrice(param.point.y);\n    const logical = chart.timeScale().coordinateToLogical(param.point.x);\n    if (price === null || logical === null) return;\n\n    // Store { time: param.time, price } or convert logical back later:\n    const x = chart.timeScale().logicalToCoordinate(logical);\n    const y = series.priceToCoordinate(price);\n});\n```\n\nUse the public conversion APIs for drawing tools and annotations. DOM canvas coordinates alone cannot tell you the chart price/time.\n\n### Next.js client-only component\n\n```tsx\n'use client';\n\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport type { ISeriesApi, LineData, Time } from 'lightweight-charts';\nimport { useEffect, useRef } from 'react';\n\nexport function LwcChart({ data }: { data: LineData<Time>[] }) {\n    const ref = useRef<HTMLDivElement | null>(null);\n    const seriesRef = useRef<ISeriesApi<'Line'> | null>(null);\n\n    useEffect(() => {\n        if (!ref.current) return;\n        const chart = createChart(ref.current, { autoSize: true });\n        const series = chart.addSeries(LineSeries);\n        seriesRef.current = series;\n        return () => {\n            seriesRef.current = null;\n            chart.remove();\n        };\n    }, []);\n\n    useEffect(() => {\n        seriesRef.current?.setData(data);\n    }, [data]);\n\n    return <div ref={ref} style={{ width: '100%', height: 320 }} />;\n}\n```\n\nFrom a server-rendered Next.js page, import the component with:\n\n```tsx\nimport dynamic from 'next/dynamic';\n\nconst LwcChart = dynamic(() => import('./LwcChart').then((m) => m.LwcChart), {\n    ssr: false,\n});\n```\n\n### Plain HTML loading\n\nUse the standalone IIFE build when there is no bundler:\n\n```html\n<div id=\"chart\" style=\"width: 600px; height: 300px\"></div>\n<script src=\"https://unpkg.com/lightweight-charts/dist/lightweight-charts.standalone.production.js\"></script>\n<script>\n  const chart = LightweightCharts.createChart(document.getElementById('chart'));\n  const series = chart.addSeries(LightweightCharts.LineSeries);\n</script>\n```\n\nChoose the loading shape by environment:\n\n- **Bundler (Vite/webpack/Next):** bare `import { createChart } from 'lightweight-charts'`. The package `exports` resolve the right ESM/CJS build.\n- **Browser `<script>` (no bundler):** the standalone IIFE build above exposes the `LightweightCharts` global; there is no bare-specifier resolution.\n- **Browser native ESM (`<script type=\"module\">`):** import from a concrete `.mjs` URL (e.g. the standalone `.mjs`) or add an import map; a bare `'lightweight-charts'` specifier will not resolve.\n- **SSR frameworks:** load client-only (see the Next.js recipe above) — never import at module top level in a server component.\n\n### Plugin starter\n\n```sh\nnpm create lwc-plugin@latest\n```\n\nUse the generated project and `plugin-examples/` as the base. Decide the extension type first:\n\n- **Primitive** (`IPanePrimitive` / `ISeriesPrimitive`, attached via `attachPrimitive`) — for drawings, overlays, labels, bands, annotations, hit-testing. This is the default; reach for it unless you need real series behavior.\n- **Custom series** (`ICustomSeriesPaneView`) — only when the extension needs its own data, autoscale, or price/time-scale integration. It is heavier; do not use it for decorations.\n\nFor draggable drawings, attach a primitive with `series.attachPrimitive(...)` or `pane.attachPrimitive(...)`, then manage interaction with `subscribeClick` / `subscribeCrosshairMove` and coordinate conversion APIs. Import renderer-only `CanvasRenderingTarget2D` from `fancy-canvas`. The renderer interface is `IPrimitivePaneRenderer` (not `IPanePrimitivePaneRenderer`).\n\n### Non-financial data\n\n```ts\nimport { createOptionsChart } from 'lightweight-charts';\n\nconst chart = createOptionsChart(container);\n```\n\nDecide first whether the horizontal axis is truly non-time:\n\n- **True custom horizontal scale** (option chains, sensor sweeps by a non-time key): use `createOptionsChart` for a numeric x-axis, or `createChartEx` with a custom `IHorzScaleBehavior` (verify both in local typings).\n- **Just non-financial y units** (temperature, load) on an ordinary time/category axis: keep the normal `createChart` series model and set `priceFormat` / `localization.priceFormatter` so labels match the domain.\n- **Categorical x that is really ordered**: mapping categories to ascending `BusinessDay` strings is simpler than a custom scale — but say that the axis is then date-like, not truly categorical.\n\n### Custom price formatter\n\n```ts\nchart.applyOptions({\n    localization: {\n        priceFormatter: (p: number) => `$${p.toFixed(2)}`,\n    },\n});\n```\n\nFor per-series formatting, set `priceFormat: { type: 'custom', formatter, minMove }` in the series options — the chart-level `priceFormatter` is the fallback.\n\nTo go back to the built-in formatting, pass `null`: `chart.applyOptions({ localization: { priceFormatter: null } })`. Passing `undefined` leaves the current formatter in place.\n\n### Minimal pane primitive\n\n```ts\nimport type {\n    IPanePrimitive,\n    IPanePrimitivePaneView,\n    IPrimitivePaneRenderer,\n    Time,\n} from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D } from 'fancy-canvas';\n\nclass Overlay implements IPanePrimitive<Time> {\n    paneViews(): IPanePrimitivePaneView[] { return [new View()]; }\n}\nclass View implements IPanePrimitivePaneView {\n    renderer(): IPrimitivePaneRenderer { return new Renderer(); }\n}\nclass Renderer implements IPrimitivePaneRenderer {\n    draw(target: CanvasRenderingTarget2D): void {\n        target.useMediaCoordinateSpace(({ context, mediaSize }) => {\n            context.fillStyle = 'rgba(0,0,0,0.05)';\n            context.fillRect(0, 0, mediaSize.width, mediaSize.height);\n        });\n    }\n}\n\nchart.panes()[0].attachPrimitive(new Overlay());\n```\n\nWorking examples live under `plugin-examples/src/plugins/` — copy structure from there before writing one from scratch.\n\n## Worked example\n\n> *\"My chart snaps to the right edge every time new data arrives.\"*\n\n1. **Layers involved:** data model (4) and time scale (3).\n2. **Suspect:** the code calls `series.setData(...)` on every tick instead of `series.update(...)`. `setData` resets the visible range.\n3. **Verify:** ask whether the call path is `setData` or `update`. If `setData`, ask whether the visible logical range is captured before and restored after — the v4-era workaround.\n4. **Fix:** switch to `series.update(bar)` for incremental ticks; reserve `setData` for full-history replacement; only use `chart.timeScale().scrollToRealTime()` if the user explicitly wants follow-the-latest behavior.\n5. **References:** `website/examples/data/realtime-updates.js`, `website/docs/time-scale.md`.\n\n## Code-generation rules\n\n- **Default to v5.** Assume v5 APIs unless the user's installed package or prompt pins an older version. If they're on v4, explain the v5 migration point instead of mixing syntaxes.\n- **Use real option names.** In consumer apps, grep `node_modules/lightweight-charts/dist/typings.d.ts`; in the upstream repo, grep `dist/typings.d.ts` or `src/api/options/`. Many similarly-named options exist across chart/series/scale — confirm which level owns the option.\n- **Minimal snippets.** One feature per code block. Combining markers + watermark + custom pane primitive in one snippet hides which API does what.\n- **Match the user's framework.** A React user wants the `useEffect` lifecycle; a vanilla user does not.\n- **Don't invent.** If an API name does not appear in the installed typings or upstream source, it does not exist.\n\n## Answer contract\n\nWhen answering a lightweight-charts question:\n\n1. Name the relevant v5 API.\n2. Show one minimal snippet, not a mega-demo.\n3. Call out the main foot-gun for that task.\n4. Say what local source was checked (version/typings), or state that it could not be verified.\n","packages/create-lwc-plugin/README.md":"# create-lwc-plugin\n\n**create-lwc-plugin** scaffolds a new plugin project for Lightweight Charts™.\nThe wizard asks a few questions and generates a ready-to-run project from a\ntemplate for one of the three plugin types:\n\n- a series primitive\n- a pane primitive\n- a custom series\n\nThe scaffolded project is ready to publish: its `package.json` follows the\nconventions used by the Lightweight Charts™ plugin catalog, so the plugin can\nbe listed there once it is published to npm.\n\n✨ Need some examples for inspiration? Check out the\n[plugin-examples](https://github.com/tradingview/lightweight-charts/tree/master/plugin-examples)\nfolder in the Lightweight Charts™ repo.\n\n## Scaffold your first Lightweight Charts™ plugin\n\nWith npm:\n\n```bash\nnpm create lwc-plugin@latest\n```\n\nWith Yarn:\n\n```bash\nyarn create lwc-plugin\n```\n\nWith pnpm:\n\n```bash\npnpm create lwc-plugin\n```\n\nThe wizard asks for the plugin's name, description, author, license, the minimum\nversion of Lightweight Charts™ it supports, and the tags to list it under. Those\nanswers populate the generated `package.json`, including the `lwcPlugin` block\nread by the plugin catalog.\n\nBefore any of that, the wizard offers to install the\n[plugin-authoring Agent Skill](https://github.com/tradingview/lightweight-charts/blob/master/.github/skills/lightweight-charts-plugin-authoring/SKILL.md)\nfor AI coding assistants such as Claude Code, Codex, and Cursor. The skill helps\nchoose the plugin type, build on `@tradingview/lwc-toolkit`, and pick the right\nofficial plugin as the reference for your idea. It also points to the docs and\nwarns about the autoscale, whitespace, and hit-test mistakes a first plugin\ntends to make.\n\nSay yes, and you have two ways to continue. Carry on with the wizard: the skill\nis installed into the new project when the wizard finishes. Or quit right\nthere: the skill is installed into the current directory, and you hand the rest\nover to your assistant. The assistant knows how to run this wizard with you.\n\nThe skill is installed with the [`skills` CLI](https://github.com/vercel-labs/skills).\nThe CLI asks which assistants to set it up for. You can also run it yourself at\nany time:\n\n```bash\nnpx skills add tradingview/lightweight-charts --skill lightweight-charts-plugin-authoring\n```\n\n## The generated project\n\n### Run locally\n\n```shell\nnpm install\nnpm run dev\n```\n\nVisit `localhost:5173` in the browser.\n\n### Build the plugin\n\n```shell\nnpm run build\n```\n\nThis writes three files into the `dist` folder: the package entry point\n(`<name>.js`), a standalone build for use over a CDN\n(`<name>.standalone.js`) which inlines every dependency except\nLightweight Charts™ itself, and the bundled type declarations (`<name>.d.ts`).\nPlugins are published as ES modules only.\n\n### Publish to npm\n\nThe `package.json` in the project root is the published manifest. Check its\n`description`, `version`, `license` and `lwcPlugin` fields, then publish from\nthe project root:\n\n```shell\nnpm publish\n```\n\nHint: append `--dry-run` to the end of the publish command to see the results of\nthe publish command without actually uploading the package to npm.\n\n## Scaffold an official in-repo plugin\n\nMaintainers working inside the Lightweight Charts™ repository can scaffold a\nworkspace package instead of a standalone project:\n\n```shell\npnpm create lwc-plugin --workspace\n```\n\nWorkspace mode targets `packages/`, scopes the package name to `@tradingview/`,\ndepends on the library and the shared plugin utilities through `workspace:*`,\nseeds a `CHANGELOG.md`, `LICENSE` and `NOTICE`, and marks the plugin as an\nofficial catalog entry.\n","packages/create-lwc-plugin/template-common/README.md":"# _PLUGINNAME_\n\n_DESCRIPTION_\n\n<!--\nExpand the line above into a short paragraph: what the plugin draws or does, and\nwhen someone would reach for it. This is the first thing a reader sees, both on\nnpm and on the plugin registry page.\n-->\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `_PEERVERSION_` in your\nproject:\n\n```shell\nnpm install _PACKAGENAME_\n```\n\nThen import the plugin and add it to a chart:\n\n```js\n_ATTACH_SNIPPET_\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"_PACKAGENAME_\": \"https://unpkg.com/_PACKAGENAME_/dist/_ENTRYNAME_.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\n_ATTACH_SNIPPET_\n</script>\n```\n\n## Usage\n\n<!-- Describe the plugin's typical usage, and anything a caller has to own. -->\n\n```js\n_USAGE_SNIPPET_\n```\n\n## Options\n\n<!--\nList the options the plugin accepts. Add further tables for any nested option\ngroups. Keep this in sync with the option types in the source.\n-->\n\n| Option | Type | Default | Description |\n| ------ | ---- | ------- | ----------- |\n|        |      |         |             |\n\nThe full typed surface is published with the package — see\n[`dist/_ENTRYNAME_.d.ts`](https://unpkg.com/_PACKAGENAME_/dist/_ENTRYNAME_.d.ts),\nalso browsable from the Code tab on the package's npm page.\n\n## Development\n\nInstall the dependencies and start the example page:\n\n```shell\nnpm install\nnpm run dev\n```\n\nVisit `localhost:5173` in the browser. The example under `src/example/` is the\nplugin's live preview — keep it working, and keep it filling the window so that\nit can be embedded.\n\nBuild the publishable bundles into `dist/`:\n\n```shell\nnpm run build\n```\n\nThis produces the package entry point (`dist/_ENTRYNAME_.js`), the standalone\nbuild used over a CDN (`dist/_ENTRYNAME_.standalone.js`) and the bundled type\ndeclarations (`dist/_ENTRYNAME_.d.ts`).\n\n<!-- EXTERNAL_ONLY -->\n## The plugin toolkit\n\nThis project depends on\n[`@tradingview/lwc-toolkit`](https://www.npmjs.com/package/@tradingview/lwc-toolkit),\na small set of helpers written for plugin authors: pixel-perfect coordinate and\nwidth calculations for candles, columns and full-width bars, crosshair-aligned\nline widths, time conversion, and a `PluginBase` class that keeps the chart and\nseries references wired up for you.\n\nDepending on the starter this project was generated from, the code may already\nuse it — check the imports in `src/`. It is a `devDependency`, bundled into\n`dist/` when the plugin is built, so it never becomes a dependency for anyone\ninstalling the plugin. If none of it is needed, uninstall it; nothing else has\nto change.\n<!-- /EXTERNAL_ONLY -->\n\n<!-- EXTERNAL_ONLY -->\n## Publishing to npm\n\nThe `package.json` in the project root is the published manifest: check the\n`description`, `version`, `license` and `lwcPlugin` fields before releasing.\n\nCheck the packaging before publishing:\n\n```shell\nnpm run check-package\n```\n\nThat runs [publint](https://publint.dev), which checks the manifest, and\n[arethetypeswrong](https://arethetypeswrong.github.io), which resolves every\nentry point the way a consumer's TypeScript would — the check that catches an\n`exports` entry with no `types` alongside it. Two of its rules are ignored\nbecause an ESM-only package is meant to fail them: `node10` predates the\n`exports` field entirely, and `require`-ing an ES module is an error rather\nthan a mistake in the package.\n\nPublish from the project root once the plugin has been built:\n\n```shell\nnpm publish\n```\n\nHint: append `--dry-run` to inspect the result without uploading anything.\n\n## Discoverability\n\nTag the plugin so that others can find it: add the `lightweight-charts-plugin`\ntopic to its GitHub repository, and keep the `lightweight-charts-plugin` keyword\nin `package.json`.\n<!-- /EXTERNAL_ONLY -->\n","packages/lwc-plugin-accessibility/README.md":"# Accessibility\n\nA drop-in accessibility layer for a Lightweight Charts™ chart. The plugin is\nbuilt on\n[pane primitives](https://tradingview.github.io/lightweight-charts/docs/plugins/pane-primitives)\nand helps your application meet\n[WCAG 2.1 Level AA](https://www.w3.org/TR/WCAG21/).\n\nCanvas-based charts are opaque to assistive technology. This plugin packages\nthe techniques from the\n[accessibility tutorial](https://tradingview.github.io/lightweight-charts/tutorials/a11y/intro).\nYou get keyboard navigation, screen-reader announcements, and a visible focus\nindicator without any manual wiring.\n\nUse the chart-level helper for normal integration. It attaches one primitive\nper pane. Each pane gets its own labeled, keyboard-focusable semantic layer.\nThe plugin handles every series in a pane, so multi-series and multi-pane\ncharts work out of the box.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-accessibility\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { addAccessibilityPlugin } from '@tradingview/lwc-plugin-accessibility';\n\nconst chart = createChart(document.getElementById('chart'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(myData);\n\nconst accessibility = addAccessibilityPlugin(chart, {\n    chartTitle: 'Apple daily close',\n});\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-accessibility\": \"https://unpkg.com/@tradingview/lwc-plugin-accessibility/dist/accessibility.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { addAccessibilityPlugin } from '@tradingview/lwc-plugin-accessibility';\n\nconst chart = createChart(document.getElementById('chart'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(myData);\n\nconst accessibility = addAccessibilityPlugin(chart, {\n    chartTitle: 'Apple daily close',\n});\n</script>\n```\n\n## Usage\n\nEnable the plugin for every current pane with one chart-level call:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { addAccessibilityPlugin } from '@tradingview/lwc-plugin-accessibility';\n\nconst chart = createChart(document.getElementById('chart'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(myData);\n\nconst accessibility = addAccessibilityPlugin(chart, {\n    chartTitle: 'Apple daily close',\n});\n```\n\n`chartTitle` is optional; without it every pane is announced with\n`messages.defaultChartTitle` (*\"Interactive financial chart\"*), distinguished by\na *\"Pane 2 of 2\"* suffix. For a multi-pane chart, pass a title resolver instead:\n\n```js\naddAccessibilityPlugin(chart, {\n    chartTitle: paneIndex => paneIndex === 0 ? 'Price' : 'Volume',\n});\n```\n\nTo turn it off again, detach the controller – the plugin restores the DOM to\nthe state it found it in:\n\n```js\naccessibility.detach();\n```\n\nCall `accessibility.refresh()` to attach it again (it re-attaches whatever panes\nthe chart has at that moment). Detach before `chart.remove()` where you can; the\nother order is safe too — `detach()` skips panes that are already gone.\n\nIf you need low-level control, you can still attach `AccessibilityPlugin`\ndirectly as a pane primitive. It takes `AccessibilityPaneOptions` and, as a\nsecond constructor argument, the index of the pane you attach it to (only needed\nfor a pane other than the first):\n\n```js\nimport { AccessibilityPlugin } from '@tradingview/lwc-plugin-accessibility';\n\nchart.panes()[1].attachPrimitive(\n    new AccessibilityPlugin({ chartTitle: 'Volume' }, 1)\n);\n```\n\nThat index is only used to find the pane before the layer exists: the first\ntime the chart draws the primitive it reports the pane it is really attached to,\nand the plugin follows that pane from then on, by identity, through reordering.\nAn index that does not match the pane you attached to therefore costs nothing\nbut a frame.\n\nA directly attached primitive keeps its own polite live region and takes a plain\nboolean `announceDataUpdates`; the chart-level `dataUpdates` settings only exist\non the helper.\n\n## What it does\n\n- **Semantic layer.** Each pane gets a labeled, keyboard-focusable overlay\n  (`role=\"application\"`, `aria-label`, `tabindex=\"0\"`), while the pane's table\n  scaffolding is marked presentational and the visual canvases are hidden from\n  assistive technology with `aria-hidden`. Focusable chart internals such as the\n  attribution link are removed from the tab order and hidden from the\n  accessibility tree.\n- **Keyboard navigation.** Users traverse every data point with the left/right\n  arrows and switch between the series in the pane with the up/down arrows. The\n  focused point is always paged into view, so the whole series is reachable by\n  keyboard even when only part of it is on screen.\n- **ARIA-live announcements.** The focused point, series changes, on-demand\n  summaries, the visible range after a zoom, markers on the focused point and\n  the active series' price lines are announced through a per-pane assertive live\n  region. Background\n  data updates go through a single polite live region shared by the whole chart,\n  so simultaneous updates in different panes never talk over each other\n  (`dataUpdates`, see below).\n- **A text alternative.** `T` renders the active series as a real `<table>` over\n  the pane, on demand (see below).\n- **Visible focus indicator.** The focused pane receives an outline, and an\n  optional focus ring is drawn over the active point. The point ring stays\n  aligned with the canvas as you scroll or zoom, and `syncCrosshair` moves the\n  chart's crosshair with it.\n- **Visible shortcuts & high contrast (opt-in).** With `showShortcuts: true`,\n  sighted keyboard users get a \"Press H\" hint on focus and an `H`-toggled\n  on-screen list of the controls. `highContrast` (default `'auto'`, following the\n  OS) restyles the plugin's own focus ring and overlay, and `onHighContrastChange`\n  lets you restyle the chart itself to match — for users who navigate by keyboard\n  or need higher contrast but don't use a screen reader.\n\n### Keyboard map\n\n| Key | Action |\n| --- | --- |\n| `Tab` | Move focus between panes / out of the chart |\n| `←` / `→` | Move to the previous / next data point |\n| `↑` / `↓` | Switch to the previous / next series in the pane |\n| `Page Up` / `Page Down` | Jump by `pageStep` points (default 10): `Page Up` forward in time, `Page Down` back — following the ARIA slider convention that `Page Up` increases the value |\n| `Home` / `End` | Jump to the first / last point |\n| `+` / `-` | Zoom the chart in / out |\n| `Enter` / `Space` | Announce a summary of the active series |\n| `T` | Show / hide the data as a table (see below) |\n| `Esc` | Close the open panel (table or shortcuts) |\n| `H` | Announce the controls, and — when `showShortcuts` is on — show / hide the visible shortcuts panel |\n\nThe letter keys are matched by physical key as well as by character, so `H` and\n`T` also work on non-Latin keyboard layouts. Remap anything with `keyBindings`:\n\n```js\naddAccessibilityPlugin(chart, {\n    keyBindings: {\n        s: 'summary',   // add a key\n        KeyD: 'viewAsTable', // by physical key\n        h: null,        // remove a built-in binding\n    },\n});\n```\n\n## Options\n\nAll options are optional and have sensible defaults. `addAccessibilityPlugin`\ntakes `AccessibilityOptions`, a single `AccessibilityPlugin` takes\n`AccessibilityPaneOptions`; the two differ only in the rows marked *chart-level*\nbelow.\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `chartTitle` | `string` — *chart-level:* `string \\| (paneIndex) => string` | `messages.defaultChartTitle` | Accessible name of the pane region. |\n| `showFocusIndicator` | `boolean` | `true` | Draw a visible focus ring on the active point. |\n| `focusIndicatorColor` | `string` | `'#2962FF'` | Color of the focus ring. |\n| `focusIndicatorSize` | `number` | `14` | Diameter of the focus ring, in CSS pixels. |\n| `dataUpdates` | *chart-level only:* `{ mode: 'active' \\| 'all' \\| 'none'; panes?: (paneIndex) => boolean; debounceMs?: number }` | `{ mode: 'active' }` | Which panes announce data updates, and how they combine (see below). |\n| `announceDataUpdates` | *pane-level only:* `boolean` | `true` | Whether this pane announces data updates. Set for you from `dataUpdates`. |\n| `updateDebounceMs` | *pane-level only:* `number` | `1000` | Window over which data changes are coalesced before being announced. Use `dataUpdates.debounceMs` at chart level. |\n| `updateMaxSeries` | `number` | `3` | Maximum number of changed series listed in one update announcement. |\n| `pageStep` | `number` | `10` | Points to jump with `Page Up` / `Page Down`. |\n| `zoomStep` | `number` | `0.2` | Fraction the visible range grows / shrinks per `+` / `-` keypress. |\n| `minZoomSpan` | `number` | `2` | Smallest visible span, in bars, that zooming in will produce. |\n| `dataScope` | `'all' \\| 'visible'` | `'visible'` | Whether the on-demand summary and data-update announcements describe the visible range or the full data set (see below). |\n| `priceFormatter` | `(value: number) => string` | chart `localization.priceFormatter`, else the active series price formatter | Formats values for announcements. |\n| `timeFormatter` | `(time: Time) => string` | chart `localization.timeFormatter`, else a locale-aware date | Formats times for announcements (uses the chart's `localization.locale`). |\n| `timeFormat` | `'auto' \\| 'date' \\| 'dateTime' \\| 'seconds' \\| 'time'` | `'auto'` | How much of a time the built-in formatter speaks. `'auto'` follows the chart's `timeScale.timeVisible` / `secondsVisible`, so intraday bars are distinguishable. Ignored when a `timeFormatter` is set. |\n| `valueAccessor` | `(point, series) => number \\| undefined` | `value`, else `close` | Reads the announced value out of a data point — needed for custom series (see below). |\n| `rangeAccessor` | `(point, series) => { high, low, open?, close? } \\| undefined` | the point's own `high` / `low` | Reads a point's high / low band, so a custom series is announced like an OHLC one. |\n| `seriesLabel` | `(series, index) => string` | series `title`, else `Series N` | Accessible label for each series. |\n| `keyBindings` | `Record<string, AccessibilityCommand \\| null>` | — | Key → command overrides, merged onto the built-in map. The key is a `KeyboardEvent.key` or `.code`; `null` removes a binding. |\n| `announceOnFocus` | `boolean` | `false` | Announce the visible range when the pane receives focus (an assertive message can interrupt the accessible name, hence off by default). |\n| `focusOnPointerDown` | `boolean` | `false` | Move the keyboard focus into the pane when the user presses a pointer on it. |\n| `syncCrosshair` | `boolean` | `false` | Move the chart's crosshair to the focused point (`chart.setCrosshairPosition`). |\n| `tableMaxRows` | `number` | `200` | Maximum number of rows rendered by the `T` table; the cap is spoken with the caption. |\n| `markers` | `(series) => readonly SeriesMarker<Time>[]` | — | The markers of a series, announced with the point they sit on. The library does not expose a series' markers, so pass the array you gave `createSeriesMarkers`. |\n| `announcePriceLines` | `boolean` | `true` | Append the active series' `priceLines()` to the `Enter` / `Space` summary. |\n| `onAnnounce` | `(message: string) => void` | — | Called with every string this pane announces — for captions, a transcript, or a test. |\n| `onFocusChange` | `(event: AccessibilityFocusEvent) => void` | — | Called whenever the active point or series changes, with the pane, series, point and value. |\n| `onSonify` | `(note: SonificationNote) => void` | — | Called for every focused point with the data a sonification needs. `createToneSonifier()` is a ready-made handler (see below). |\n| `describeChart` | `(context: DescribeChartContext) => string` | built-in summary | Generates the `Enter` / `Space` summary. The context carries `points` (already narrowed to `dataScope`), `series`, `label` and `scope`. |\n| `messages` | `PartialAccessibilityMessages` | English `defaultMessages` | Overrides for the announced text — translate some or all of it (see Localization). |\n| `lang` | `string` | chart `localization.locale` | BCP-47 `lang` set on the announced regions so screen readers use the right voice. |\n| `showShortcuts` | `boolean` | `false` | Show a visible keyboard-shortcuts overlay (focus hint + `H`-toggled panel) for sighted keyboard users (see below). |\n| `highContrast` | `boolean \\| 'auto'` | `'auto'` | High-contrast styling for the plugin's own focus ring / outline / overlay. `'auto'` follows the OS `prefers-contrast` / `forced-colors`; pass a boolean to drive it from your own setting. |\n| `onHighContrastChange` | `(enabled: boolean) => void` | — | Called when the resolved high-contrast state changes (and once on attach), so you can restyle the chart's own series / grid / font to match. |\n\nOptions can be changed at runtime. Use the controller's\n`accessibility.applyOptions({ ... })` for chart-level changes (`chartTitle`,\n`dataUpdates`, `messages`, `lang`, `highContrast`, …): it updates every pane\n**and** the shared update region together. A single primitive also has its own\n`plugin.applyOptions({ ... })` for per-pane tweaks (e.g. `dataScope`), but that\ndoes not reach the chart-level shared update region — use the controller for\n`dataUpdates` / `messages` / `lang`.\n\n### Scoping announcements to the visible range\n\nKeyboard navigation always covers the whole series – the arrow keys page the\nchart so every point is reachable regardless of this setting. `dataScope` only\ncontrols what the *summaries* describe.\n\nBy default (`dataScope: 'visible'`) the on-demand summary (`Enter` / `Space`) and\nthe background data-update announcements describe only the points within the\ncurrent visible range – for example *\"65 data points in view\"*. This is the\nrecommended setting for charts with large data sets because it keeps those\nsummaries focused on what the user is currently inspecting. The update\nannouncement's *\"Latest\"* value is the one exception: it always reports the\nseries' newest bar – the bar the update actually changed – even when that bar\nis outside the visible range.\n\nUse `dataScope: 'all'` when you want the summary and update announcements to\ndescribe the full data set, even if only part of the history is visible.\n\nPer-point announcements always report the absolute position (*\"Point 247 of\n500\"*) so the user knows where they are in the whole series.\n\n### Announcing data updates\n\nWhen a chart streams live data, several panes can update in the same tick. Each\npane keeps its own assertive region for navigation, but all *data-update*\nannouncements go through **one** polite region shared by the whole chart, so the\nupdates never talk over each other.\n\n`dataUpdates` (on `addAccessibilityPlugin`) chooses which panes speak:\n\n```js\naddAccessibilityPlugin(chart, {\n    dataUpdates: { mode: 'active', debounceMs: 1500 },\n});\n```\n\n- `mode: 'active'` (the default): only the **last-focused** pane announces (pane 0\n  until you focus one). Navigating the volume pane, for example, makes its updates\n  the ones you hear; otherwise you hear the main pane.\n- `mode: 'all'`: every pane announces; simultaneous updates are combined into a\n  single message in pane order (*\"Chart data updated. 3 series changed. …\"*).\n- `mode: 'none'`: no update announcements.\n- `panes: (paneIndex) => boolean`: restricts announcements to the panes the\n  predicate accepts, on top of `mode`.\n- `debounceMs`: how long changes are coalesced before being announced (default\n  `1000`). A live feed can tick far faster than a screen reader can speak.\n\nSwitch this at runtime through the controller —\n`accessibility.applyOptions({ dataUpdates: { mode: 'all' } })` — which\nreconfigures the shared region's mode; a per-pane `plugin.applyOptions` cannot\nchange it.\n\nA directly-attached `AccessibilityPlugin` (without the helper) takes a plain\nboolean `announceDataUpdates` with its own `updateDebounceMs`, and uses its own\npolite region.\n\n## View as table\n\nPressing `T` renders the active series into a real `<table>` over the pane —\nthe text alternative WCAG asks for, and the most requested way to read a chart\nwithout navigating it point by point. The rows follow `dataScope`, are capped at\n`tableMaxRows` (the cap is announced), and use OHLC columns whenever the points\ncarry a high / low band. `Esc` (or `T` again) closes it. The table is built only\nwhile it is open, so a 50,000-bar series costs nothing until it is asked for.\nIts column headers and caption come from the `messages` bundle\n(`tableColumns`, `tableCaption`, `tableTruncated`, `tableClose`).\n\n## Custom series\n\nA custom series' data shape is only known to its author, so the plugin cannot\nguess where the value is. Without help every point of a custom series announces\n*\"no value\"* and the focus ring has nowhere to go. Point the plugin at the right\nfield:\n\n```js\naddAccessibilityPlugin(chart, {\n    valueAccessor: point => (point.high + point.low) / 2,\n    // Optional: announce it like an OHLC series and report true extremes.\n    rangeAccessor: point => ({ high: point.high, low: point.low }),\n});\n```\n\nBoth are called for every series in the pane; return `undefined` to fall back to\nthe built-in extraction (`value`, then `close`), so a chart mixing built-in and\ncustom series needs only the custom branch.\n\n## Following along: crosshair, captions and sound\n\n- `syncCrosshair: true` moves the chart's crosshair with the keyboard, so a\n  sighted user can follow a screen-reader user point by point.\n- `onAnnounce` receives every string this pane speaks, in order — mirror it into\n  captions, a transcript, or an assertion in a test.\n- `onFocusChange` reports the pane, series, point index and value whenever the\n  focus moves, for your own status bar or analytics.\n- `onSonify` receives each focused point with its position in the series' value\n  range. `createToneSonifier()` is a ready-made handler that plays a short tone\n  whose pitch follows the value, so holding `→` plays the series:\n\n```js\nimport { addAccessibilityPlugin, createToneSonifier } from '@tradingview/lwc-plugin-accessibility';\n\nconst sonifier = createToneSonifier();\naddAccessibilityPlugin(chart, { onSonify: sonifier });\n// sonifier.dispose() releases the AudioContext.\n```\n\nThe `AudioContext` is created on the first note (after a key press, so the\nbrowser's autoplay policy is satisfied) and reused afterwards.\n\n## Localization\n\nOut of the box the announcements are English, but **numbers and dates follow the\nchart's locale** and **every spoken string is translatable**.\n\n**Numbers and dates** come from the chart's\n[`localization`](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/LocalizationOptions):\ndates use `localization.locale`, the summary's percentage uses it via\n`Intl.NumberFormat`, and if you set `localization.priceFormatter` /\n`localization.timeFormatter` the announcements use those too. So a chart you have\nalready localized (see the\n[Custom locale](https://tradingview.github.io/lightweight-charts/tutorials/demos/custom-locale)\nand [Price format](https://tradingview.github.io/lightweight-charts/tutorials/customization/price-format)\ntutorials) gets localized announcements for free. You can still override per\nplugin with `priceFormatter` / `timeFormatter`.\n\n**Strings** are supplied through the `messages` bundle. Every announced sentence\nis a formatter function (so a translation controls word order and pluralization);\natomic words are plain strings. Pass a partial override — anything you leave out\nstays English:\n\n```js\nimport { addAccessibilityPlugin } from '@tradingview/lwc-plugin-accessibility';\n\naddAccessibilityPlugin(chart, {\n    chartTitle: 'Gráfico de precios',\n    lang: 'es',\n    messages: {\n        ohlc: { close: 'cierre' }, // only some keys — the rest stay English\n        point: ({ position, total, time, label, values }) =>\n            `${label} ${values}, ${time}. Punto ${position} de ${total}.`,\n        help: ({ multiSeries }) =>\n            `Controles de teclado. Las flechas izquierda y derecha se mueven entre los puntos de datos. ${multiSeries ? 'Las flechas arriba y abajo cambian de serie. ' : ''}Intro o Espacio lee un resumen de la serie.`,\n    },\n});\n```\n\n`lang` sets the BCP-47 `lang` attribute on the announced regions so a screen\nreader pronounces them with the right voice; it defaults to\n`localization.locale`. `messages`/`lang` are uniform across panes. To switch\nlanguage at runtime, call `accessibility.applyOptions({ messages, lang })` on the\ncontroller — it updates every pane and the shared update region together.\n\nA complete Spanish bundle ships with the package as `esMessages`, both as a\nready-made translation and as a template for your own:\n\n```js\nimport { addAccessibilityPlugin, esMessages } from '@tradingview/lwc-plugin-accessibility';\n\naddAccessibilityPlugin(chart, { messages: esMessages, lang: 'es' });\n```\n\n`defaultMessages` is the English bundle. It is **frozen and read-only** — write a\ntranslation by passing your own entries through `messages` (they are merged onto\n`defaultMessages`), never by mutating it. `paneLabel` receives `paneIndex` and\n`paneCount` alongside the title, so a translation can keep multi-pane titles\ndistinguishable, and `defaultChartTitle` is the fallback used when `chartTitle`\nis unset.\n\nThe precedence for the overridable pieces:\n\n- **value:** `priceFormatter` → chart `localization.priceFormatter` → series formatter\n- **time:** `timeFormatter` → chart `localization.timeFormatter` → locale-aware date\n- **summary:** `describeChart` (full override) → `messages.summary`\n- **strings:** your `messages` entry → English `defaultMessages`\n\n## Visible shortcuts and high contrast\n\nThese help users who navigate by keyboard, or need higher contrast, but don't use\na screen reader.\n\n**Shortcuts overlay** — set `showShortcuts: true`. While the pane is focused a\nsmall *\"Press H for keyboard shortcuts\"* hint is shown; `H` toggles an on-screen\npanel listing the controls. It is `aria-hidden` (screen-reader\nusers already get the spoken `H` help) and its text comes from the `messages`\nbundle (`shortcutsHint`, `shortcutsTitle`, `shortcuts`), so it localizes with the\nrest. The overlay text is sized in `rem`, so it scales with the page/browser font.\n\n**High contrast** — `highContrast` (`boolean | 'auto'`, default `'auto'`) controls\nthe plugin's *own* visuals (focus ring, focus outline, the overlay). `'auto'`\nfollows the OS `prefers-contrast` / `forced-colors` and updates live; to wire it\nto your own app setting, pass a boolean and keep it in step with\n`accessibility.applyOptions({ highContrast })`.\n\nThe plugin deliberately does **not** restyle the chart's series, grid or font —\nthat's the chart theme's job (see the\n[Readability](https://tradingview.github.io/lightweight-charts/tutorials/a11y/readability)\ntutorial). Instead it calls `onHighContrastChange(enabled)` whenever the state\nchanges (and once on attach) so you can apply your own high-contrast chart theme\nin one place:\n\n```js\naddAccessibilityPlugin(chart, {\n    showShortcuts: true,\n    onHighContrastChange: enabled => {\n        chart.applyOptions({ layout: { textColor: enabled ? '#000' : '#222' } });\n        series.applyOptions({ lineWidth: enabled ? 4 : 2 });\n    },\n});\n```\n\nThe example wires both of these up (the \"Enable high contrast\" and \"Large font\"\nbuttons).\n\n## Performance\n\nThe plugin uses an **active-point-only** strategy: it never mirrors every data\npoint into the DOM. Regardless of whether a series holds 500 or 50,000 bars each\npane adds only a small fixed set of nodes (a semantic overlay, a visually-hidden\ndescription, an assertive live region, a focus ring and — when `showShortcuts` is\non — the shortcuts hint and panel), plus one polite live region shared across the\nwhole chart for data-update announcements.\n\nData stays in sync through one `subscribeDataChanged` listener per series.\nScrolling and zooming reposition the focus ring with coordinate lookups; they\ndo not copy series data. Data-change events invalidate a shared snapshot because\nthey do not distinguish a tail tick from a historical correction or `pop()`.\n\nAn unfocused pane reads data only when its debounced announcement is prepared.\nWith update announcements disabled, it defers the read until keyboard focus\nreturns. Focused navigation refreshes immediately after a data change and shares\nthat snapshot with announcement statistics. Each refresh is proportional to the\nseries length; visible-point counts use binary searches within the snapshot, so\nwhitespace and gaps supplied by other series do not inflate the count.\n\n## CSS class hooks\n\nEvery element the plugin injects carries a stable class name, so you can restyle\nthe layer from your own stylesheet. These names are part of the public API and\nwill not change without a major version:\n\n| Class | Element |\n| --- | --- |\n| `lw-chart-a11y-layer` | The focusable semantic overlay per pane (`role=\"application\"`). |\n| `lw-chart-a11y-description` | Visually hidden pane description (`aria-describedby` target). |\n| `lw-chart-a11y-live-region` | Per-pane assertive region for navigation announcements. |\n| `lw-chart-a11y-status-region` | Per-pane polite region, only present on a directly attached primitive. |\n| `lw-chart-a11y-shared-status-region` | The single chart-level polite region created by `addAccessibilityPlugin`. |\n| `lw-chart-a11y-focus-ring` | The visible focus ring drawn over the active point. |\n| `lw-chart-a11y-shortcuts-hint` | The \"Press H\" hint (`showShortcuts`). |\n| `lw-chart-a11y-shortcuts-panel` | The `H`-toggled shortcuts panel (`showShortcuts`). |\n| `lw-chart-a11y-data-table` | The `T`-toggled table panel. |\n\nThe plugin sets its own geometry and colors inline, so an inline style wins over\na plain rule — use `!important`, or restyle through the options where one exists\n(`focusIndicatorColor`, `focusIndicatorSize`, `highContrast`).\n\n## Notes & limitations\n\n- Built-in series work out of the box: OHLC series announce their open / high /\n  low / close, value series announce their value. A **custom series** needs\n  `valueAccessor` (and optionally `rangeAccessor`), because only its author knows\n  where its value lives.\n- Series **and panes** added or removed at runtime are picked up automatically:\n  the controller reconciles its layers with `chart.panes()` on the next redraw\n  and attaches or detaches only the difference, so the focus of the panes that\n  were already there is never disturbed. `controller.refresh()` forces that check\n  immediately and is rarely needed.\n- The library forces `direction: ltr` on the chart element, so the plugin reads\n  the writing direction from the element you created the chart in: on a\n  right-to-left page its panels sit on the leading (right) side.\n- Series in a pane do not need to share timestamps. Navigation is aligned by\n  *time* on the chart's shared time scale: switching series with the up / down\n  arrows keeps the focused time (the nearest point in the new series is\n  selected and paged into view), and the visible-range scoping follows each\n  series' own data.\n- The plugin provides the semantic layer and keyboard model. Visual contrast and\n  font-scaling (covered in the\n  [Readability](https://tradingview.github.io/lightweight-charts/tutorials/a11y/readability)\n  part of the tutorial) remain the responsibility of your chart theme.\n- The API is typed for a `Time`-based chart (`IChartApi`), not the generic\n  `IChartApiBase<HorzScaleItem>`. The announcements format UTC timestamps and\n  business days and the navigation maps points through the `Time` scale, so every\n  internal path assumes `Time`; a custom horizontal scale is not supported.\n- Always validate with real assistive technology (VoiceOver, NVDA) as part of\n  your own accessibility testing before shipping.\n","packages/lwc-plugin-anchored-text/README.md":"# Anchored text\n\nA single line of text anchored to an edge, a corner or the center of a pane,\nas a [series primitive](https://tradingview.github.io/lightweight-charts/docs/plugins/series-primitives)\n(`AnchoredText`) or as a\n[pane primitive](https://tradingview.github.io/lightweight-charts/docs/plugins/pane-primitives)\n(`AnchoredTextPane`). The text keeps its place while the chart scrolls and\nzooms, inset from the pane edges by a margin you choose. The text, its anchor,\nmargins, font, color, layer and visibility can all be changed after the\nprimitive has been attached.\n\nThe series primitive belongs to the series it is attached to: it lives in that\nseries' pane and is removed together with the series. The pane primitive needs\nno series at all.\n\nUse it for a chart title, a symbol or interval label, a data-source credit, or\na \"preview\" or \"draft\" stamp.\n\n> **Lightweight Charts™ 5 also ships a built-in text watermark.**\n> [`createTextWatermark(pane, options)`](https://tradingview.github.io/lightweight-charts/docs/api/functions/createTextWatermark)\n> is a pane primitive which draws one or more lines of text, centered by default\n> and scaled down to fit the pane. If that is all you need, the built-in\n> function is the right choice. Use this package for text tied to a specific\n> series rather than to a pane, or for what the built-in does not offer:\n> margins from the pane edge, a CSS `font` shorthand, `zOrder` and\n> `setText`.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-anchored-text\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { AnchoredText } from '@tradingview/lwc-plugin-anchored-text';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(data);\n\nseries.attachPrimitive(new AnchoredText({ text: 'BTC/USD · 1D' }));\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-anchored-text\": \"https://unpkg.com/@tradingview/lwc-plugin-anchored-text/dist/anchored-text.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { AnchoredText } from '@tradingview/lwc-plugin-anchored-text';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(data);\n\nseries.attachPrimitive(new AnchoredText({ text: 'BTC/USD · 1D' }));\n</script>\n```\n\n## Usage\n\n### On a series\n\nCreate the text, then attach it to the series whose pane it should sit in:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { AnchoredText } from '@tradingview/lwc-plugin-anchored-text';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(data);\n\nconst title = new AnchoredText({\n    text: 'BTC/USD · 1D',\n    horzAlign: 'right',\n    vertAlign: 'top',\n    font: 'bold 16px sans-serif',\n    color: '#2962FF',\n});\nseries.attachPrimitive(title);\n```\n\nTo remove the text, detach it from the series:\n\n```js\nseries.detachPrimitive(title);\n```\n\n### On a pane\n\n`AnchoredTextPane` takes the same options and is attached to a pane instead\nof a series. Use it when the text should stay put while series are added and\nremoved:\n\n```js\nimport { AnchoredTextPane } from '@tradingview/lwc-plugin-anchored-text';\n\nconst title = new AnchoredTextPane({ text: 'Volume', vertAlign: 'bottom' });\nchart.panes()[1].attachPrimitive(title);\n\n// later\nchart.panes()[1].detachPrimitive(title);\n```\n\n### Changing the text\n\nBoth classes have the same methods:\n\n```js\ntitle.applyOptions({ horzAlign: 'center', color: '#787B86' });\ntitle.setText('ETH/USD · 1D'); // same as applyOptions({ text })\ntitle.options(); // the current options, with the defaults filled in\n```\n\n`applyOptions` merges: an option which is not passed, or is passed as\n`undefined`, is left unchanged. The one exception is `lineHeight`: passing\n`lineHeight: undefined` goes back to measuring the height from the font.\n\n## Options\n\nOptions are passed as the constructor argument, which is optional, as is every\noption in it. The type is `AnchoredTextOptions`, and the defaults are exported\nas `defaultOptions`.\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `text` | `string` | `''` | The line of text. An empty string draws nothing. |\n| `horzAlign` | `'left' \\| 'center' \\| 'right'` | `'left'` | Which side of the pane the text is anchored to, or centered. |\n| `vertAlign` | `'top' \\| 'center' \\| 'bottom'` | `'top'` | Which edge of the pane the text is anchored to, or centered. |\n| `horzMargin` | `number` | `20` | Distance from the left or right pane edge, in CSS pixels. Not used when `horzAlign` is `'center'`. |\n| `vertMargin` | `number` | `10` | Distance from the top or bottom pane edge, in CSS pixels. Not used when `vertAlign` is `'center'`. |\n| `font` | `string` | `bold 14px` system sans-serif | Font, as a CSS `font` shorthand. |\n| `lineHeight` | `number` | — (measured) | Height of the text, in CSS pixels. Measured from the font when not set. |\n| `color` | `string` | `'#131722'` | Text color. |\n| `visible` | `boolean` | `true` | Whether the text is drawn at all. |\n| `zOrder` | `'bottom' \\| 'normal' \\| 'top'` | `'normal'` | Layer the text is drawn in. `'normal'` draws it with the series, under the crosshair; `'top'` puts it over everything in the pane, the crosshair included; `'bottom'` puts it behind the series. |\n\n### Alignment and margins\n\nThe text is placed against the anchored edge of its pane, `horzMargin` and\n`vertMargin` away from it. A centered axis ignores its margin. With a\n`lineHeight` the text's baseline sits at the bottom of that height, as it did\nin the `plugin-examples` version; without one the height is that of the font,\nso it does not change with the text, and the baseline sits at the font's\nascent.\n\n## Notes\n\n- The text is drawn on one line, as given. It is neither wrapped nor scaled:\n  text wider than the pane is clipped at the pane edge. The built-in\n  `createTextWatermark` scales its text down to fit, if that is what you need.\n- The text appears only in the pane it belongs to. It never covers the price\n  scales or the time scale, and a visible left price scale or a second pane\n  does not move it.\n- Sizes are in CSS pixels; the text is drawn in the media coordinate space, so\n  it stays sharp at any device pixel ratio.\n- `'middle'` is still accepted as a value of `horzAlign` and `vertAlign`, the\n  spelling used in the `plugin-examples` collection, and is read as `'center'`.\n  It is kept for compatibility and will be removed in a future major version.\n","packages/lwc-plugin-background-shade-series/README.md":"# Background shade series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series)\nthat shades the full height of the pane behind each bar. The shade is mixed\nfrom two colors by where the bar's value sits between a low and a high value,\nso the background follows an indicator while the price series stays readable\non top of it.\n\nUse it to show a regime or a reading behind the price: an oscillator, the\nshare of up days, volatility, a sentiment score, or a session's volume\nrelative to normal.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-background-shade-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { createBackgroundShadeSeries } from '@tradingview/lwc-plugin-background-shade-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst line = chart.addSeries(LineSeries);\nline.setData([\n    { time: '2024-04-22', value: 101.2 },\n    { time: '2024-04-23', value: 102.8 },\n    { time: '2024-04-24', value: 100.9 },\n]);\n\nconst shade = createBackgroundShadeSeries(chart, {\n    lowColor: '#F23645',\n    highColor: '#089981',\n    opacity: 0.25,\n});\nshade.setData([\n    { time: '2024-04-22', value: 35 },\n    { time: '2024-04-23', value: 70 },\n    { time: '2024-04-24', value: 20 },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-background-shade-series\": \"https://unpkg.com/@tradingview/lwc-plugin-background-shade-series/dist/background-shade-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { createBackgroundShadeSeries } from '@tradingview/lwc-plugin-background-shade-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst line = chart.addSeries(LineSeries);\nline.setData([\n    { time: '2024-04-22', value: 101.2 },\n    { time: '2024-04-23', value: 102.8 },\n    { time: '2024-04-24', value: 100.9 },\n]);\n\nconst shade = createBackgroundShadeSeries(chart, {\n    lowColor: '#F23645',\n    highColor: '#089981',\n    opacity: 0.25,\n});\nshade.setData([\n    { time: '2024-04-22', value: 35 },\n    { time: '2024-04-23', value: 70 },\n    { time: '2024-04-24', value: 20 },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `createBackgroundShadeSeries`, then set data with a\n`value` per bar:\n\n```js\nconst shade = createBackgroundShadeSeries(chart, {\n    lowColor: 'rgb(50, 50, 255)',\n    highColor: 'rgb(255, 50, 50)',\n    lowValue: 0,\n    highValue: 100,\n    opacity: 0.8,\n});\n\nshade.setData([\n    { time: '2024-04-22', value: 35 },\n    { time: '2024-04-23', value: 120 },\n    { time: '2024-04-24' },\n    { time: '2024-04-25', value: 50, color: '#131722' },\n]);\n```\n\nEach data point is `{ time, value }`:\n\n- A value of `lowValue` gets `lowColor`, a value of `highValue` gets\n  `highColor`, and a value in between a mix of the two. Values beyond the\n  range get the color of the nearer end. `lowValue` may be the larger of the\n  two. With `lowValue` equal to `highValue` the shading becomes a two-color\n  threshold: values below it get `lowColor` and the rest `highColor`.\n- A point without a finite `value`, `null` and `NaN` included, is whitespace\n  and leaves its slot unshaded.\n- A `color` on a point shades that bar with it, whatever its value. A color\n  the canvas does not accept is ignored, and the bar is shaded from its value.\n  The series' own `color` option is not drawn; it is empty by default, and a\n  point whose `color` equals it is shaded from its value.\n\n`lowColor` and `highColor` can be hex, `rgb()`, `rgba()`, `hsl()` or named\ncolors. They are mixed with premultiplied alpha, as CSS gradients are, so a\ntransparent end, `'transparent'` included, fades the other color out. A color\nthat cannot be parsed, or one in another color space such as `oklch()`, falls\nback to the default for that end.\n\nThe series shades the full height of its pane and takes no part in the price\nscale. It sits on a price scale of its own, `'background-shade'`, an overlay\nscale with nothing drawn on it, so it never sets the number format of the\nprice axis; its values never change any autoscale range; and it has no price\nline or last value label. It still draws when it is the only series in the\nchart. It is never reported as hovered, so it does not get in the way of the\nseries on top of it.\n\n## Creating a series\n\nUse `createBackgroundShadeSeries(chart, options?, paneIndex?)`. It adds the\nseries and moves it behind every other series in its pane with\n`series.setSeriesOrder(0)`, so it reads as a background whatever order the\nseries are added in. `setSeriesOrder` arrived in `lightweight-charts` 5.0.6;\non older versions the series keeps the order it was added in, so add it\nbefore the others.\n\nMoving the series to another pane, with `series.moveToPane`, puts it on top\nof that pane's series, as for any series; call `series.setSeriesOrder(0)`\nagain afterwards.\n\nThe `BackgroundShadeSeries` class remains available for\n`chart.addCustomSeries(new BackgroundShadeSeries(), options)`. Added that way,\nit gets the same options, its own price scale included, but is drawn in the\norder it was added: added after the main series, an opaque shade covers it.\nAdd it first, or call `series.setSeriesOrder(0)`.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `lowColor` | `string` | `'rgb(50, 50, 255)'` | Shade of a bar whose value is `lowValue`, or beyond it. |\n| `highColor` | `string` | `'rgb(255, 50, 50)'` | Shade of a bar whose value is `highValue`, or beyond it. |\n| `lowValue` | `number` | `0` | Value shaded with `lowColor`. |\n| `highValue` | `number` | `100` | Value shaded with `highColor`. |\n| `opacity` | `number` | `0.8` | Opacity of the whole shading, `0`–`1`, on top of any alpha in the colors. |\n\n`priceLineVisible` and `lastValueVisible` default to `false`, since the series\nhas no value on the price scale, and `priceScaleId` to `'background-shade'`.\nSetting `priceScaleId` to `'right'` or `'left'` puts the shade on a visible\nscale, where, being the bottom series, it would set that scale's number\nformat; it still never changes the scale's range.\n\n## Notes\n\n- Each bar is shaded across one bar spacing centered on it, in whole device\n  pixels, so the slots of consecutive bars abut with no seam and no overlap at\n  every zoom level and device pixel ratio. Time points that only other series\n  have stay unshaded: daily values over hourly candles, say, shade one slot a\n  day. On `lightweight-charts` 5.1 and later, while the chart conflates data, a\n  conflated bar's column is as wide as the slots it stands for, centered where\n  the chart places the bar, and it keeps the later of the two values it\n  merges.\n- Only the bars on screen are drawn. Their shades come from 256 steps between\n  the two end colors, worked out when the colors change, so no color is\n  mixed while drawing.\n- The shading covers its own pane only. To shade another pane, add a second\n  series to it with the `paneIndex` argument.\n","packages/lwc-plugin-box-whisker-series/README.md":"# Box and whisker series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series)\nthat draws a box plot per time point: a box from the first to the third\nquartile split at the median, whiskers out to the `min` and `max` you give,\nand a dot for each outlier you list beyond them. Where the whiskers end is\nyours to decide, such as 1.5 times the interquartile range or the 5th and\n95th percentiles, and the values past them are the outliers.\n\nUse it to show how a distribution changes over time rather than a single\nvalue: intraday price distribution per day, latency percentiles per hour,\nor the spread of forecasts per period.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-box-whisker-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createBoxWhiskerSeries } from '@tradingview/lwc-plugin-box-whisker-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createBoxWhiskerSeries(chart);\n\nseries.setData([\n    { time: '2024-04-22', min: 55, q1: 70, median: 80, q3: 85, max: 95 },\n    { time: '2024-04-23', min: 50, q1: 70, median: 78, q3: 83, max: 90, outliers: [40] },\n    { time: '2024-04-24', min: 58, q1: 68, median: 75, q3: 85, max: 90 },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-box-whisker-series\": \"https://unpkg.com/@tradingview/lwc-plugin-box-whisker-series/dist/box-whisker-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createBoxWhiskerSeries } from '@tradingview/lwc-plugin-box-whisker-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createBoxWhiskerSeries(chart);\n\nseries.setData([\n    { time: '2024-04-22', min: 55, q1: 70, median: 80, q3: 85, max: 95 },\n    { time: '2024-04-23', min: 50, q1: 70, median: 78, q3: 83, max: 90, outliers: [40] },\n    { time: '2024-04-24', min: 58, q1: 68, median: 75, q3: 85, max: 90 },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `createBoxWhiskerSeries`, then set data with five\nnumbers per point:\n\n```js\nconst series = createBoxWhiskerSeries(chart, {\n    whiskerColor: '#131722',\n    lowerBoxColor: '#90BFF9',\n    upperBoxColor: '#2962FF',\n    medianColor: '#FFFFFF',\n    outlierColor: '#F23645',\n});\n\nseries.setData([\n    { time: '2024-04-22', min: 55, q1: 70, median: 80, q3: 85, max: 95 },\n    { time: '2024-04-23', min: 50, q1: 70, median: 78, q3: 83, max: 90, outliers: [40, 100] },\n    { time: '2024-04-24' },\n    { time: '2024-04-25', min: 58, q1: 68, median: 75, q3: 85, max: 90, upperBoxColor: '#F23645' },\n]);\n```\n\nEach data point is `{ time, min, q1, median, q3, max, outliers? }`:\n\n- The whiskers run from `min` to `q1` and from `q3` to `max`, and the box from\n  `q1` to `q3`, split at the `median` into a lower and an upper half.\n- `outliers` holds the values beyond the whiskers, each drawn as a dot. `null`\n  means none, and an outlier which is not a finite number is not drawn.\n- A point without five finite numbers, a missing or `null` one included, is\n  whitespace: it keeps its place on the time scale, is not drawn, and takes\n  no part in the price scale.\n- `whiskerColor`, `lowerBoxColor`, `upperBoxColor`, `medianColor` and\n  `outlierColor` on a point override the series options of the same names\n  for that point.\n\nThe autoscale range covers the lowest and the highest of the five numbers and\nthe outliers, so every dot is in view, and a point whose numbers are not in\norder still fits on the scale.\n\nThe series' price line and last value label follow the median of the last\npoint. Options can be changed at runtime with `series.applyOptions({ ... })`.\n\nIn the `plugin-examples` collection this series was `WhiskerBoxSeries`, with a\n`quartiles` array instead of the five named numbers and `lowerQuartileFill` /\n`upperQuartileFill` for the box colors. The package was never published under\nthose names, so it does not keep them.\n\n## Creating a series\n\nUse `createBoxWhiskerSeries(chart, options?, paneIndex?)`. It adds a\n`BoxWhiskerSeries` with `chart.addCustomSeries` and returns the normal series\nAPI, typed `BoxWhiskerSeriesApi`, with the plugin's data and options types\npreserved. The `BoxWhiskerSeries` class remains available for\n`chart.addCustomSeries(new BoxWhiskerSeries(), options)` too; no option\nchanges the plot values, so both behave the same.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `whiskerColor` | `string` | `'rgba(106, 27, 154, 1)'` | Color of the whiskers and their end caps. |\n| `lowerBoxColor` | `string` | `'rgba(103, 58, 183, 1)'` | Fill of the lower half of the box, from `q1` to the median. |\n| `upperBoxColor` | `string` | `'rgba(233, 30, 99, 1)'` | Fill of the upper half of the box, from the median to `q3`. |\n| `medianColor` | `string` | `'rgba(106, 27, 154, 1)'` | Color of the median line across the box. |\n| `outlierColor` | `string` | `'rgba(149, 152, 161, 1)'` | Color of the outlier dots. |\n\nThe standard `color` option is not used for the box plots; it colors the\nseries' price line.\n\n## Notes\n\n- The box is as wide as a candlestick body at the same bar spacing, and every\n  part is centered on the whisker line in whole device pixels, the way the\n  built-in candlestick centers its body on the wick. The median line spans\n  the slot, each whisker cap is as wide as a candlestick body at half the bar\n  spacing, and outlier dots shrink with the box down to a 1.5 px radius, so\n  they stay visible when the chart is zoomed out.\n- Only the points on screen are drawn. The series is never conflated: with\n  `timeScale.enableConflation` on, the chart still draws every point.\n- On `lightweight-charts` 5.2 and later the series reports the part under the\n  pointer through `hitTest`, within the series' `hitTestTolerance` (3 px by\n  default). The crosshair event's `hoveredInfo.objectId` is `'box-<point>'`,\n  `'median-<point>'`, `'whisker-<point>'` or `'outlier-<point>-<index>'`,\n  where `<point>` is the point's position in `series.data()` and `<index>`\n  the index into its `outliers`. Elsewhere in a point's slot, between its\n  lowest and highest value, the chart's own fallback still reports the series\n  as hovered, without an `objectId`, so check `objectId` before reading it.\n  The median line, drawn over the box, is reported on its own row of pixels.\n  An outlier dot is reported as a point and the box and the lines as ranges,\n  so a candle body the pointer is inside wins over a whisker it is only near.\n  Older versions never call `hitTest`.\n","packages/lwc-plugin-brushable-area-series/README.md":"# Brushable area series\n\nAn area series that can style parts of the data differently. You set a base\nstyle for the whole series and any number of *brush ranges*. A brush range is\na span of data points with its own line and fill colors.\n\nThe series itself only draws the styles. Attach the optional\n`BrushableAreaInteraction` primitive, or add your own pointer handling, to turn\nit into a brush selection: the user drags across the chart, the brush range for\nthe selected span is set, and the rest of the series keeps the base style.\nGive `outsideStyle` a semi-transparent style to get the classic effect where\nthe selection stays vivid and the rest looks faded.\n\nUse it for range selection on a sparkline or an overview chart. It also fits\nhighlighting a period, such as a trading session, an event window, or a\nbacktest sample, and comparing segments of one series visually.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-brushable-area-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createBrushableAreaSeries } from '@tradingview/lwc-plugin-brushable-area-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createBrushableAreaSeries(chart, {\n    lineColor: 'rgb(41, 98, 255)',\n    topColor: 'rgba(41, 98, 255, 0.4)',\n    bottomColor: 'rgba(41, 98, 255, 0)',\n    priceLineVisible: false,\n});\nseries.setData(data); // [{ time, value }, ...]\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-brushable-area-series\": \"https://unpkg.com/@tradingview/lwc-plugin-brushable-area-series/dist/brushable-area-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createBrushableAreaSeries } from '@tradingview/lwc-plugin-brushable-area-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createBrushableAreaSeries(chart, {\n    lineColor: 'rgb(41, 98, 255)',\n    topColor: 'rgba(41, 98, 255, 0.4)',\n    bottomColor: 'rgba(41, 98, 255, 0)',\n    priceLineVisible: false,\n});\nseries.setData(data); // [{ time, value }, ...]\n</script>\n```\n\n## Usage\n\nAdd the [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series) with `createBrushableAreaSeries`, set single-value data, then set\n`brushRanges` whenever the selection changes:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createBrushableAreaSeries } from '@tradingview/lwc-plugin-brushable-area-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createBrushableAreaSeries(chart, {\n    lineColor: 'rgb(41, 98, 255)',\n    topColor: 'rgba(41, 98, 255, 0.4)',\n    bottomColor: 'rgba(41, 98, 255, 0)',\n    priceLineVisible: false,\n});\nseries.setData(data); // [{ time, value }, ...]\n\n// Highlight points 40–80 in green and fade everything else.\nseries.applyOptions({\n    brushRanges: [\n        {\n            range: { from: 40, to: 80 },\n            style: {\n                lineColor: '#089981',\n                topColor: 'rgba(8, 153, 129, 0.4)',\n                bottomColor: 'rgba(8, 153, 129, 0)',\n                lineWidth: 3,\n            },\n        },\n    ],\n    outsideStyle: {\n        lineColor: 'rgba(41, 98, 255, 0.2)',\n        topColor: 'rgba(41, 98, 255, 0.05)',\n    },\n});\n\n// Clear the selection: the whole series goes back to the base style.\nseries.applyOptions({ brushRanges: [] });\n```\n\nA range's `style` and `outsideStyle` are both partial: every property left out\nfalls back to the base style set on the series.\n\nRanges are expressed in **logical indices** of the time scale (the position on\nthe chart's own index, shared by every series), not in time and not in the\nseries' own array positions. To turn a pointer position into a logical index,\nuse `chart.timeScale().coordinateToLogical(x)`, where `x` is the pointer's\nhorizontal position within the plot area.\n\nEach data point is `{ time, value }`. Points without a `value` are treated as\nwhitespace, and the line breaks at the gap rather than bridging it.\n\n### Brush selection\n\n`BrushableAreaInteraction` is an optional\n[series primitive](https://tradingview.github.io/lightweight-charts/docs/plugins/series-primitives)\nthat turns a mouse drag, a one-finger drag or a two-finger gesture into a brush\nrange, so the pointer handling does not have to be written again in every\napplication:\n\n```js\nimport {\n    BrushableAreaInteraction,\n} from '@tradingview/lwc-plugin-brushable-area-series';\n\nconst brush = new BrushableAreaInteraction({\n    style: { lineColor: '#089981', topColor: 'rgba(8, 153, 129, 0.4)' },\n    outsideStyle: { lineColor: 'rgba(41, 98, 255, 0.2)' },\n});\nseries.attachPrimitive(brush);\n\nbrush.activeRange().subscribe(range => {\n    // null once the selection is cleared by a click without a drag\n    if (range !== null) {\n        console.log(range.from, range.to, range.fromTime, range.toTime);\n    }\n});\n```\n\n| Interaction option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `style` | `Partial<style>` | green | Style applied to the brushed range. |\n| `outsideStyle` | `Partial<style>` | faded blue | Style applied outside the brushed range. |\n| `applyToSeries` | `boolean` | `true` | Set the series' `brushRanges` as the user drags. Turn it off to only receive `activeRange` events. |\n| `minimumRangeWidth` | `number` | `1` | Smallest drag, in logical indices, that counts as a range. |\n\nThe defaults are exported as `defaultInteractionOptions`. The range reported by\n`activeRange()` carries `from` / `to` as logical indices and `fromTime` /\n`toTime` as the times of the data points at those indices (`null` where the\nseries has no point there). `brush.clear()` removes the selection, and\n`brush.range()` returns the current one.\n\nThe chart's own drag gesture competes with brushing, so a chart using this\nprimitive normally sets `handleScroll: false` and `handleScale: false`.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `lineColor` | `string` | `'rgb(40,98,255)'` | Base line color, used outside brush ranges. |\n| `topColor` | `string` | `'rgba(40,98,255, 0.4)'` | Base fill color at the line (top of the gradient). |\n| `bottomColor` | `string` | `'rgba(40,98,255, 0)'` | Base fill color at the base price (bottom of the gradient). |\n| `lineWidth` | `1 \\| 2 \\| 3 \\| 4` | `2` | Base line width, in CSS pixels. |\n| `lineStyle` | `LineStyle` | `LineStyle.Solid` | Base dash pattern of the line. |\n| `lineVisible` | `boolean` | `true` | Draw the line itself. Set it to `false` for the fill only. |\n| `lineType` | `LineType` | `LineType.Simple` | Shape of the line between two points: straight, stepped or curved. The fill follows the same shape. |\n| `relativeGradient` | `boolean` | `false` | Anchor the far end of the fill gradient to the outermost point in view rather than to the edge of the pane, as `AreaSeries` does. |\n| `invertFilledArea` | `boolean` | `false` | Fill the area above the line, up to the top of the pane, instead of down to `basePrice`. |\n| `basePrice` | `number` | `0` | Price the area is filled down to. |\n| `brushRanges` | `{ range: { from: number; to: number }; style: Partial<style> }[]` | `[]` | Ranges of logical indices rendered in their own style. `from` is inclusive, `to` is exclusive. Set an empty array to clear. |\n| `outsideStyle` | `Partial<style>` | — | Style of the points outside every brush range. Used only while at least one range is set. |\n\n`style` is `{ lineColor, topColor, bottomColor, lineWidth, lineStyle }` — the\nsame five properties as the base style, and each one optional.\n\n## Notes\n\n- A point inside a brush range is drawn with that range's style; if ranges\n  overlap, the **last** matching range wins, so a new selection covers the ones\n  it is dragged over.\n- Each drawn segment takes the style of its right-hand point, and consecutive\n  points sharing a style are drawn as one path, so no seam shows inside a run.\n- The fill is a vertical gradient from `bottomColor` at `basePrice` to\n  `topColor` at the edge of the pane the fill extends towards (or at the\n  outermost point in view with `relativeGradient`). When `basePrice` falls\n  outside the visible price range, the fill reaches the edge of the pane.\n- The line and the fill are drawn one bar past each edge of the visible range,\n  so they leave the pane rather than stopping at the last visible point while\n  the chart is panned.\n- Points whose value falls outside the current price scale, and gaps in the\n  data, break the line rather than being drawn to an invalid coordinate.\n- The examples disable chart scrolling and scaling (`handleScroll`,\n  `handleScale`) so that dragging brushes instead of panning; decide which\n  gesture your chart should own.\n\n### Explicit whitespace\n\nUse `createBrushableAreaSeries` to retain whitespace passed through `setData` and\n`update`, including historical corrections. Other series' timestamps do not\nbreak the area. The low-level `BrushableAreaSeries` view remains available, but\nwithout the factory's gap predicate it draws continuously: the host does not\nprovide whitespace to custom renderers.\n\nUnder time-scale conflation the area is drawn from buckets of several bars, and\na whitespace run narrower than one bucket cannot be resolved at that bar\nspacing: it is absorbed into the bucket rather than breaking the area at every\nbar. Zooming in past the conflation threshold shows the gap again.\n","packages/lwc-plugin-dual-range-histogram-series/README.md":"# Dual range histogram series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series) that draws columns above and below a zero line. At each time\npoint it can show up to two nested columns in each direction: an outer range\nin a lighter color and an inner range in a darker color.\n\nBy default the columns are not sized in price units. The series has a fixed\nheight in pixels: the largest value gets the full height, and the other columns\nare scaled relative to it. This makes the series a compact overlay. It sits on\nthe zero line of another series' price scale and does not disturb that scale.\nSet `scaleMode: 'price'` to have the values read as prices and autoscale like\nany other series instead.\n\nUse it to show paired values around a center line. Typical examples: buy and\nsell volume with an inner share of \"aggressive\" orders, bid and ask depth, or\ninflows and outflows with a highlighted component. Any positive and negative\npair with a nested subset fits.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-dual-range-histogram-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createDualRangeHistogramSeries } from '@tradingview/lwc-plugin-dual-range-histogram-series';\n\nconst chart = createChart(document.getElementById('container'));\n\nconst histogram = createDualRangeHistogramSeries(chart, {\n    priceLineVisible: false,\n    lastValueVisible: false,\n});\nhistogram.setData([\n    { time: '2024-04-22', values: [120, 45, -80, -30] },\n    { time: '2024-04-23', values: [90, 60, -110, -20] },\n    { time: '2024-04-24', values: [140, 35, -60, -40] },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-dual-range-histogram-series\": \"https://unpkg.com/@tradingview/lwc-plugin-dual-range-histogram-series/dist/dual-range-histogram-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createDualRangeHistogramSeries } from '@tradingview/lwc-plugin-dual-range-histogram-series';\n\nconst chart = createChart(document.getElementById('container'));\n\nconst histogram = createDualRangeHistogramSeries(chart, {\n    priceLineVisible: false,\n    lastValueVisible: false,\n});\nhistogram.setData([\n    { time: '2024-04-22', values: [120, 45, -80, -30] },\n    { time: '2024-04-23', values: [90, 60, -110, -20] },\n    { time: '2024-04-24', values: [140, 35, -60, -40] },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `addCustomSeries`, then set data with a `values` array per\npoint — positive values draw upward, negative values downward. The array is\n`[upOuter, upInner, downOuter, downInner]`, which is also how the styling\noptions name their columns:\n\n```js\nimport { createChart, BaselineSeries } from 'lightweight-charts';\nimport { createDualRangeHistogramSeries } from '@tradingview/lwc-plugin-dual-range-histogram-series';\n\nconst chart = createChart(document.getElementById('container'), {\n    timeScale: { barSpacing: 21, minBarSpacing: 4 },\n});\n\nconst histogram = createDualRangeHistogramSeries(chart, {\n    priceLineVisible: false,\n    lastValueVisible: false,\n});\nhistogram.setData([\n    { time: '2024-04-22', values: [120, 45, -80, -30] },\n    { time: '2024-04-23', values: [90, 60, -110, -20] },\n    { time: '2024-04-24', values: [140, 35, -60, -40] },\n]);\n\n// A main series sharing the price scale; the histogram sits on its zero line.\nconst baseline = chart.addSeries(BaselineSeries, {\n    baseValue: { type: 'price', price: 0 },\n});\nbaseline.setData(mainData);\n```\n\nEach data point is `{ time, values: number[], colors? }`. Points with an empty\nor missing `values` array are treated as whitespace. A `colors` entry overrides\nthe series color for the column at the same position; an `undefined` entry\nkeeps the series color.\n\nColors and corner radii are set per column:\n\n```js\nhistogram.applyOptions({\n    colors: {\n        upOuter: '#BBDEFB',\n        upInner: '#1565C0',\n        downOuter: '#FFE0B2',\n        downInner: '#EF6C00',\n    },\n    borderRadius: { upOuter: 8, upInner: 4, downOuter: 8, downInner: 4 },\n    borderColor: '#131722',\n    borderWidth: 1,\n});\n```\n\n### Keeping the histogram in view\n\nIn the default `pixels` scale mode the histogram is `maxHeight` pixels tall and\ncentered on `baseValue`. It does not report its values to the price scale, so\nit never distorts the scaling of the main series — but if the base line is\nclose to the top or bottom of the pane, the columns are clipped. Reserve room\nwith `keepPixelSeriesInView`, which sets the price scale's margins and keeps\nthem correct while the chart is resized:\n\n```js\nimport { keepPixelSeriesInView } from '@tradingview/lwc-plugin-dual-range-histogram-series';\n\nconst stop = keepPixelSeriesInView(chart, histogram);\n// … later, before removing the chart:\nstop();\n```\n\nThe helper follows the series' current pane, including pane resizing and moves.\nIt uses a sizing primitive attached to the series; call `stop()` before removing\nthe chart. Calling `stop()` more than once is safe.\n\nPass a height as the third argument to reserve room for something other than\nthe series' own `maxHeight`.\n\n### Scale modes\n\n`scaleMode: 'price'` treats the values as prices measured from `baseValue`, so\nthe columns are autoscaled by the price scale like any other series;\n`maxHeight` and `normalize` are then ignored and no margins need reserving.\n\n`createDualRangeHistogramSeries` keeps the plot values synchronized with\n`scaleMode` and `baseValue`, including changes made through `applyOptions`.\n\nIn `pixels` mode, `normalize` chooses what the heights are scaled against:\n`'visible'` (the default) rescales the columns as you pan, `'all'` keeps their\nrelative heights across the whole data set, and a number fixes the value which\nfills half of `maxHeight`.\n\nOptions can be changed at runtime with `series.applyOptions({ ... })`.\n\n## Creating a series\n\nUse `createDualRangeHistogramSeries(chart, options?, paneIndex?)`. It returns the\nnormal series API, with the plugin's data and options types preserved. The helper\nmakes scaling options available before the first `setData` and rebuilds plot\nvalues automatically when those options change through `series.applyOptions`.\nThis keeps autoscaling, last-value labels and crosshair values consistent. The\nhelper retains a shallow copy of the input data, including whitespace, and\nre-ingests it only when a scaling option changes. Streaming updates remain\nincremental.\n\nThe low-level `DualRangeHistogramSeries` pane view remains available for integrations\nthat supply their own options getter to its constructor. Passing scaling options\nonly to `chart.addCustomSeries(new DualRangeHistogramSeries(), options)` cannot make\nthem available before data ingestion on LWC 5.0; use the creation helper instead.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `colors` | `{ upOuter, upInner, downOuter, downInner }` of `string` | `{ upOuter: '#ACE5DC', upInner: '#42BDA8', downOuter: '#FCCACD', downInner: '#F77C80' }` | Fill color of each column. A per-point `colors` entry overrides it. |\n| `borderRadius` | `{ upOuter, upInner, downOuter, downInner }` of `number` | `{ upOuter: 2, upInner: 0, downOuter: 2, downInner: 0 }` | Corner radius of each column, in CSS pixels, applied to the column's outer end. |\n| `borderColor` | `string \\| null` | `null` | Border color of the columns. `null` for no border. |\n| `borderWidth` | `number` | `1` | Border width in CSS pixels. Only drawn when `borderColor` is set. |\n| `maxHeight` | `number` | `130` | Total height of the histogram in CSS pixels; the largest value reaches half of it above or below the base line. `pixels` scale mode only. |\n| `scaleMode` | `'pixels' \\| 'price'` | `'pixels'` | Whether the column heights are a fixed number of pixels or prices measured from `baseValue`. See [Scale modes](#scale-modes). |\n| `normalize` | `'visible' \\| 'all' \\| number` | `'visible'` | What the heights are scaled against in `pixels` mode: the largest value in the visible range, in the whole data set, or a fixed value. |\n| `gap` | `number` | `0` | Gap between the upward and the downward half, in CSS pixels. |\n| `widthPercent` | `number` | `100` | Column width as a percentage of the bar spacing, `0`–`100`. |\n| `baseValue` | `number` | `0` | Price the columns are centered on. |\n| `highlightHovered` | `boolean` | `false` | Whether hovering the series fades every point except the one under the cursor. Requires Lightweight Charts 5.2 or later. |\n\n## Notes\n\n- Columns are matched to `colors` and `borderRadius` by their **position** in\n  `values`, not by their sign: a negative value in the `upOuter` slot points\n  downwards but is still drawn in the `upOuter` color.\n- Columns for the same point share one width and position; values are drawn in\n  array order, so later (inner) values paint over earlier (outer) ones. Keep\n  inner values smaller than outer ones for the nested look.\n- A point may carry more than four values; the four columns then repeat, so\n  `values[4]` is styled as `upOuter` again.\n- Column widths follow the same pixel grid as the built-in histogram series,\n  and the alignment is not carried across a gap of whitespace.\n- Values which are not finite are skipped, and nothing is drawn when there is\n  no value to scale the columns against (an all-zero data set, say).\n- `hitTest`, which reports the hovered point through the crosshair as\n  `bar-<index>`, is used by Lightweight Charts 5.2 and later, and\n  `conflationReducer` from 5.1. Older versions simply never call them, and\n  `highlightHovered` has no effect before 5.2.\n","packages/lwc-plugin-grouped-bars-series/README.md":"# Grouped bars series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series)\nthat draws several values per time point as columns side by side, one group\nof columns per point.\n\nUse it to compare a few quantities period by period, when a stack would hide\nthe smaller ones: revenue by region per quarter, buy and sell volume per day,\nor a forecast next to the actual value.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-grouped-bars-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createGroupedBarsSeries } from '@tradingview/lwc-plugin-grouped-bars-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createGroupedBarsSeries(chart, {\n    colors: ['#2962FF', '#F23645', '#FF9800'],\n});\n\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    { time: '2024-04-23', values: [14, 7, 6] },\n    { time: '2024-04-24', values: [11, 9, 4] },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-grouped-bars-series\": \"https://unpkg.com/@tradingview/lwc-plugin-grouped-bars-series/dist/grouped-bars-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createGroupedBarsSeries } from '@tradingview/lwc-plugin-grouped-bars-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createGroupedBarsSeries(chart, {\n    colors: ['#2962FF', '#F23645', '#FF9800'],\n});\n\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    { time: '2024-04-23', values: [14, 7, 6] },\n    { time: '2024-04-24', values: [11, 9, 4] },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `createGroupedBarsSeries`, then set data with a `values`\narray per point. The array order is the column order: `values[0]` is the\nleftmost column of the group.\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createGroupedBarsSeries } from '@tradingview/lwc-plugin-grouped-bars-series';\n\nconst chart = createChart(document.getElementById('container'), {\n    timeScale: { barSpacing: 18, minBarSpacing: 6 },\n});\nconst series = createGroupedBarsSeries(chart, {\n    colors: ['#2962FF', '#F23645', '#FF9800'],\n    widthPercent: 80,\n});\n\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    { time: '2024-04-23', values: [14, -7, 6] },\n    { time: '2024-04-24' },\n    { time: '2024-04-25', values: [11, 9, 4], colors: [undefined, '#131722'] },\n]);\n```\n\nEach data point is `{ time, values: (number | null)[] }`. A point with an empty or\nmissing `values` array is whitespace: it keeps its place on the time scale and\ndraws nothing. Columns grow from `base` (`0` by default), up for values above\nit and down for values below it. A `null` value, a number which is not finite,\nand a value equal to `base`, which would draw a column of no height, leave\ntheir column empty and stay out of the autoscale range, and the other columns\nkeep their places; use `null` for a missing value coming from JSON, which has\nno `NaN`. A point none of whose values draws a column is whitespace.\n\nEvery group is split into as many columns as the longest point has values, so\na column is as wide in every group; a point with fewer values leaves its last\ncolumns empty.\n\nA point may override the series colors for its own columns with a `colors`\narray. A missing or `undefined` entry keeps the series color for that column.\n\nThe series' price line and last value label follow the last value of the last\npoint that draws a column. Options can be changed at runtime with\n`series.applyOptions({ ... })`.\n\n## Creating a series\n\nUse `createGroupedBarsSeries(chart, options?, paneIndex?)`. It returns the\nnormal series API, with the plugin's data and options types preserved. It\nmakes `base` available to the series before the first `setData`, so the base\nline is part of the autoscale range from the start, and changing `base`\nthrough `series.applyOptions` rescales the series without setting the data\nagain. The helper keeps a shallow copy of the input data for that purpose,\nand counts the columns once per data change: a streamed `update()` recounts\nthem over all the points once, on the next redraw.\n\nThe `GroupedBarsSeries` class remains available for\n`chart.addCustomSeries(new GroupedBarsSeries(), options)`. Added that way, the\nseries only learns its options at the first render, so the data set before\nthen is read as if `base` were `0` until the data is set again: values around\n100 with `base: 50` are stretched down to 0, and a value of `0`, equal to that\nassumed base, draws nothing. It also counts the columns over all its points\non every redraw, after a scroll, a zoom or a data change.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `colors` | `string[]` | `['#2962FF', '#E1575A', '#F28E2C', 'rgb(164, 89, 209)', 'rgb(27, 156, 133)']` | Fill color of each column, in the order of `values`. If there are more values than colors, the colors repeat. An empty array falls back to this default. |\n| `base` | `number` | `0` | Price the columns are drawn from. It is part of the autoscale range, so the base line always stays in view. |\n| `columnWidthMode` | `'percent' \\| 'histogram'` | `'percent'` | How wide a group is: a share of the bar spacing, given by `widthPercent`, or as wide as the built-in histogram's columns, the whole bar spacing but a one pixel gap. |\n| `widthPercent` | `number` | `80` | Share of the bar spacing that each group fills in `percent` mode, `0`–`100`. The rest is the gap between neighboring groups; at `100` they touch, or are a device pixel apart where the bar spacing covers a fractional number of them. |\n\nPer-point overrides, on the data item:\n\n| Field | Type | Description |\n| --- | --- | --- |\n| `colors` | `(string \\| undefined)[]` | Fill color of each column of this point. A missing or `undefined` entry falls back to the series color for that column. |\n\n`values` is typed `(number | null)[]`.\n\nThe standard `color` option is not used for the columns; it colors the\nseries' price line and last value label.\n\n## Notes\n\n- In `percent` mode every group is the same whole number of device pixels\n  wide. In `histogram` mode groups can differ by a pixel, as the built-in\n  histogram's columns do, to keep the gap between them even. Each group's\n  width is split among its columns so that they abut with no seam and no\n  overlap and differ by at most one pixel, as long as every column gets at\n  least one device pixel. Set `timeScale.minBarSpacing` to keep that when the\n  user zooms out. Below it, every column still gets a pixel and columns share\n  pixels: the tallest are drawn first so that the shorter ones stay visible.\n- Only the points on screen are drawn. The series is never conflated: with\n  `timeScale.enableConflation` on, the chart still draws every point.\n- On `lightweight-charts` 5.2 and later the series reports the column nearest\n  the pointer through `hitTest`, within the series' `hitTestTolerance` (3 px\n  by default): the crosshair event's `hoveredInfo.objectId` is\n  `'column-<point>-<index>'`, where `<point>` is the point's position in\n  `series.data()` and `<index>` the column's index in its `values`. The\n  nearest column can belong to the next point, so read the point from\n  `<point>` rather than from the crosshair's time. Elsewhere in a point's slot,\n  between its lowest and highest value or the base, the chart's own fallback\n  still reports the series as hovered, without an `objectId`. Older versions\n  never call `hitTest`.\n","packages/lwc-plugin-heatmap-series/README.md":"# Heatmap series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series)\nthat draws a column of cells per time point, each cell covering a price range\nand colored by an amount.\n\nUse it to show how something is spread over prices through time: the size\nresting at each level of an order book, the volume traded at each price, the\ndensity of a forecast, or any value bucketed by price.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-heatmap-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createColorScale, createHeatmapSeries } from '@tradingview/lwc-plugin-heatmap-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createHeatmapSeries(chart, {\n    cellShader: createColorScale({ stops: ['rgba(41, 98, 255, 0.1)', '#2962FF', '#F23645'] }),\n});\n\nseries.setData([\n    { time: '2024-04-22', cells: [{ low: 100, high: 101, amount: 20 }, { low: 101, high: 102, amount: 80 }] },\n    { time: '2024-04-23', cells: [{ low: 100, high: 101, amount: 60 }, { low: 101, high: 102, amount: 40 }] },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-heatmap-series\": \"https://unpkg.com/@tradingview/lwc-plugin-heatmap-series/dist/heatmap-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createColorScale, createHeatmapSeries } from '@tradingview/lwc-plugin-heatmap-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createHeatmapSeries(chart, {\n    cellShader: createColorScale({ stops: ['rgba(41, 98, 255, 0.1)', '#2962FF', '#F23645'] }),\n});\n\nseries.setData([\n    { time: '2024-04-22', cells: [{ low: 100, high: 101, amount: 20 }, { low: 101, high: 102, amount: 80 }] },\n    { time: '2024-04-23', cells: [{ low: 100, high: 101, amount: 60 }, { low: 101, high: 102, amount: 40 }] },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `createHeatmapSeries`, then set data with a `cells`\narray per point:\n\n```js\nconst series = createHeatmapSeries(chart, {\n    cellShader: (amount, range) => (amount > (range.min + range.max) / 2 ? '#F23645' : '#2962FF'),\n    cellGap: 1,\n});\n\nseries.setData([\n    {\n        time: '2024-04-22',\n        cells: [\n            { low: 100, high: 101, amount: 20 },\n            { low: 101, high: 102, amount: 80 },\n        ],\n    },\n    { time: '2024-04-23' },\n]);\n```\n\nEach data point is `{ time, cells }`, and each cell `{ low, high, amount }`:\n\n- A cell is drawn from `low` to `high` across the point's whole slot, in the\n  color `cellShader(amount, range)` returns. The edges may come in either\n  order, and the cells of a column in any order. Cells are not expected to\n  overlap: cells of the same color are filled together, so where two\n  overlap, which one shows depends on their colors, not on their order.\n- A cell whose `low`, `high` or `amount` is not a finite number is skipped,\n  and so is a `null` cell, as a JSON feed may send.\n- A point with no cell to draw is whitespace, `cells` that is missing or\n  `null` included.\n\nCells whose price edges meet share a pixel edge, and so do neighboring\ncolumns, so with no gap they abut with no seam and no overlap at every zoom\nlevel and device pixel ratio.\n\nThe series autoscales to the lowest and highest cell edge of the points on\nscreen. The price line and the last value label, off by default, show the\nmiddle of a column's lowest and highest edge. Options can be changed at\nruntime with `series.applyOptions({ ... })`.\n\nIn the `plugin-examples` collection the types were spelled `HeatMapSeries`,\n`HeatMapData`, `HeatMapSeriesOptions` and `HeatMapCellShader`; the package\nspells them `HeatmapSeries`, `HeatmapData`, `HeatmapSeriesOptions` and\n`HeatmapCellShader`. `HeatmapCell` is unchanged.\n\n## Colors\n\nThe shader is called with the cell's amount and the range of the amounts in\nview, `{ min, max }`: the lowest and the highest amount among the cells of\nthe points on screen. A shader can spread its colors over that range rather\nthan over a maximum worked out in advance, so the colors keep their spread as\nthe chart scrolls.\n\n`createColorScale({ stops, domain?, steps? })` builds such a shader from a\nlist of colors:\n\n```js\nconst shader = createColorScale({\n    // Spread evenly from the low end to the high end.\n    stops: ['rgba(41, 98, 255, 0.1)', '#2962FF', '#F7A600', '#F23645'],\n    // The amounts that take the first and the last stop. Without it, the\n    // range of the amounts in view.\n    domain: [0, 100],\n    // How many colors the scale holds, 2 to 1024. Defaults to 32.\n    steps: 16,\n});\n```\n\nThe stops can be any CSS color the canvas accepts, and are mixed with\npremultiplied alpha, as CSS gradients are. A stop the canvas cannot parse, or\none in a color space other than sRGB such as `oklch()`, is left out; without a\nDOM, as in server-side rendering, only `#rrggbb`, `rgb()` and `rgba()` stops\ncan be read. An amount\nbeyond the domain takes the color at that end; a domain given high end first\nreverses the scale, and one whose ends are not both finite numbers is ignored.\nThe colors are worked out once, so the shader builds no color string while\ndrawing, and the fewer steps there are, the more cells share a fill.\n\nA shader of your own is called for every cell on screen on every paint, so\nkeep it cheap, and return a limited set of colors: cells are filled together\nby color, once per color per paint. A cell whose color the canvas cannot\nparse is not drawn.\n\n## Creating a series\n\nUse `createHeatmapSeries(chart, options?, paneIndex?)`. It adds the series and\nreturns the normal series API, with the plugin's data and options types\nfilled in. Its options type keeps `cellShader` a function, here and in\n`applyOptions`, so an inline shader gets its parameters typed; the library's\n`DeepPartial`, which `chart.addCustomSeries` uses, turns a function option\ninto an object type.\n\nThe `HeatmapSeries` class remains available for\n`chart.addCustomSeries(new HeatmapSeries(), options)`.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `cellShader` | `(amount: number, range: { min: number; max: number }) => string` | green, from faint at `0` to opaque at `100` | Turns a cell's amount into its fill color, given the range of the amounts in view. A value that is not a function falls back to the default. |\n| `cellGap` | `number` | `1` | Space between neighboring cells, in CSS pixels, both between the columns and between the cells of a column. Left out along a side where the cell is not more than three times as long. `0` for none. |\n| `cellBorderWidth` | `number` | `0` | Width of the border drawn inside the edge of every cell, in CSS pixels. Left out along a side where the cell, less the gap, is not more than three times as long. `0` for none. |\n| `cellBorderColor` | `string` | `'rgba(255, 255, 255, 1)'` | Color of the cell border. A color the canvas cannot parse draws no border. |\n\nThe gap and the border are rounded to whole device pixels along each axis.\nWhether a cell is long enough for them is decided before its edges are\nrounded, so cells of one size all get them or all go without.\nA negative width counts as `0`, and one that is not a number as the default.\n`lastValueVisible` and `priceLineVisible` default to `false`.\n\n## Notes\n\n- Only the points on screen are drawn, and of their cells only those on the\n  pane. A cell whose two edges round to the same device pixel is not drawn,\n  which can happen to one under a pixel tall.\n- The series has no `conflationReducer`, so the chart never merges its\n  points: zoomed out to a bar spacing under a device pixel, every column is\n  still worked out, and those that round to no width are skipped.\n- On `lightweight-charts` 5.2 and later the series reports the cell under the\n  pointer through `hitTest`, in the column whose slot holds the pointer and\n  within the series' `hitTestTolerance` (3 px by default) above or below the\n  cell: the crosshair's `hoveredInfo.objectId` is `'cell-<index>'`, the index\n  into that point's `cells`, and `param.seriesData` holds the point to read\n  the cell from. Between a column's lowest and highest edge, holes\n  included, the chart's own fallback reports the series as hovered without\n  an `objectId`, so check `objectId` before reading a cell. Hovering changes\n  nothing in how the series is drawn.\n- On 5.2 and later the chart also draws the hovered series above the others\n  by default. A heatmap is hovered anywhere over the span of its columns, so\n  it then covers a price series drawn on top of it. Create the chart with\n  `hoveredSeriesOnTop: false` to keep the other series on top.\n","packages/lwc-plugin-hlc-area-series/README.md":"# HLC area series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series) for high-low-close data. It draws the high, low, and close\nvalues as three lines. The band between the lines is filled with two colors:\none between high and close, another between close and low. The result reads\nlike a candlestick's range without the visual weight of individual candles.\n\nUse it to show a value together with its range over time. Typical examples: a\ndaily close between its high and low, a forecast with its confidence band, the\nminimum, average, and maximum of a metric, or a mid price between bid and ask.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-hlc-area-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createHLCAreaSeries } from '@tradingview/lwc-plugin-hlc-area-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createHLCAreaSeries(chart, {\n    highLineColor: '#089981',\n    lowLineColor: '#F23645',\n    closeLineColor: '#787B86',\n});\n\nseries.setData([\n    { time: '2024-04-22', high: 104.2, low: 98.7, close: 101.3 },\n    { time: '2024-04-23', high: 105.0, low: 100.1, close: 104.6 },\n    { time: '2024-04-24', high: 106.8, low: 103.2, close: 103.9 },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-hlc-area-series\": \"https://unpkg.com/@tradingview/lwc-plugin-hlc-area-series/dist/hlc-area-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createHLCAreaSeries } from '@tradingview/lwc-plugin-hlc-area-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createHLCAreaSeries(chart, {\n    highLineColor: '#089981',\n    lowLineColor: '#F23645',\n    closeLineColor: '#787B86',\n});\n\nseries.setData([\n    { time: '2024-04-22', high: 104.2, low: 98.7, close: 101.3 },\n    { time: '2024-04-23', high: 105.0, low: 100.1, close: 104.6 },\n    { time: '2024-04-24', high: 106.8, low: 103.2, close: 103.9 },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `createHLCAreaSeries`, then set data with `high`, `low`, and\n`close` values:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createHLCAreaSeries } from '@tradingview/lwc-plugin-hlc-area-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createHLCAreaSeries(chart, {\n    highLineColor: '#089981',\n    lowLineColor: '#F23645',\n    closeLineColor: '#787B86',\n});\n\nseries.setData([\n    { time: '2024-04-22', high: 104.2, low: 98.7, close: 101.3 },\n    { time: '2024-04-23', high: 105.0, low: 100.1, close: 104.6 },\n    { time: '2024-04-24', high: 106.8, low: 103.2, close: 103.9 },\n]);\n```\n\nEach data point is `{ time, high, low, close }`. Points missing any of the three\nvalues are treated as whitespace, and leave a gap. The series' price line and last-value label follow the\n`close` value.\n\nOptions can be changed at runtime with `series.applyOptions({ ... })`.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `highLineColor` | `string` | `'#049981'` | Color of the high line. |\n| `lowLineColor` | `string` | `'#F23645'` | Color of the low line. |\n| `closeLineColor` | `string` | `'#878993'` | Color of the close line. |\n| `highAreaColor` | `string` | `'rgba(4, 153, 129, 0.2)'` | Fill color between the high line and the close line. |\n| `lowAreaColor` | `string` | `'rgba(242, 54, 69, 0.2)'` | Fill color between the close line and the low line. |\n| `highLineWidth` | `LineWidth` | `2` | Width of the high line, in CSS pixels (`1`–`4`). |\n| `lowLineWidth` | `LineWidth` | `2` | Width of the low line, in CSS pixels (`1`–`4`). |\n| `closeLineWidth` | `LineWidth` | `2` | Width of the close line, in CSS pixels (`1`–`4`). |\n| `highLineStyle` | `LineStyle` | `LineStyle.Solid` | Dash pattern of the high line. |\n| `lowLineStyle` | `LineStyle` | `LineStyle.Solid` | Dash pattern of the low line. |\n| `closeLineStyle` | `LineStyle` | `LineStyle.Solid` | Dash pattern of the close line. |\n| `highLineVisible` | `boolean` | `true` | Whether the high line is drawn. |\n| `lowLineVisible` | `boolean` | `true` | Whether the low line is drawn. |\n| `closeLineVisible` | `boolean` | `true` | Whether the close line is drawn. |\n| `areaVisible` | `boolean` | `true` | Whether the two fills between the lines are drawn. |\n| `lineType` | `'simple' \\| 'step'` | `'simple'` | How the lines and the fills get from one point to the next. `'step'` matches the built-in `LineType.WithSteps`. |\n| `highAreaTopColor` | `string` | `''` | Upper stop of a vertical gradient filling the high–close band. |\n| `highAreaBottomColor` | `string` | `''` | Lower stop of the high–close band gradient. |\n| `lowAreaTopColor` | `string` | `''` | Upper stop of a vertical gradient filling the close–low band. |\n| `lowAreaBottomColor` | `string` | `''` | Lower stop of the close–low band gradient. |\n| `hoverPointRadius` | `number` | `4` | Radius, in CSS pixels, of the dots drawn on the high, low and close of the bar under the cursor while the series is hovered. `0` turns the highlight off. |\n\n`areaTopColor` and `areaBottomColor` are deprecated aliases of `highAreaColor`\nand `lowAreaColor`. They still work, and take precedence when both are set.\n\nA band is filled with a gradient only when both stops of its pair are set; while\neither is an empty string the flat `highAreaColor` / `lowAreaColor` is used. The\ngradient runs down the whole pane, like the built-in Area series' `topColor` and\n`bottomColor` without `relativeGradient`.\n\n## Notes\n\n- The price scale autoscales to the full `low`–`high` range, so the band is\n  never clipped.\n- Points missing any of `high`, `low` and `close` are whitespace. The lines and\n  the fills break at a run of whitespace instead of bridging it, and a point\n  whose price falls off the scale is skipped rather than turned into a NaN\n  coordinate.\n- The lines and the fills continue past the first and the last visible point, so\n  they reach the edges of the pane while panning.\n- Line widths follow the library's `LineWidth` type, so `0` is not one of them.\n  Use `highLineVisible` / `lowLineVisible` / `closeLineVisible` to hide a line\n  and `areaVisible` to hide both fills.\n- On Lightweight Charts™ 5.2 and later the series reports the bar under the\n  cursor through `hitTest` and highlights its three values, and from 5.1\n  conflated points are merged as the highest high, the lowest low and the\n  last close.\n\n### Explicit whitespace\n\nUse `createHLCAreaSeries` to retain whitespace passed through `setData` and\n`update`, including historical corrections. Other series' timestamps do not\nbreak the area. The low-level `HLCAreaSeries` view remains available, but\nwithout the factory's gap predicate it draws continuously: the host does not\nprovide whitespace to custom renderers.\n\nUnder time-scale conflation the area is drawn from buckets of several bars, and\na whitespace run narrower than one bucket cannot be resolved at that bar\nspacing: it is absorbed into the bucket rather than breaking the area at every\nbar. Zooming in past the conflation threshold shows the gap again.\n","packages/lwc-plugin-image-watermark/README.md":"# Image watermark\n\nAn image drawn behind the chart content, as a\n[series primitive](https://tradingview.github.io/lightweight-charts/docs/plugins/series-primitives)\n(`ImageWatermark`) or as a\n[pane primitive](https://tradingview.github.io/lightweight-charts/docs/plugins/pane-primitives)\n(`ImageWatermarkPane`). The image is placed within the pane — centered by\ndefault, or anchored to a corner — and scaled to fit, to fill, or not at all.\nPosition, size limits, padding, opacity and visibility can all be changed after\nthe watermark has been attached.\n\nThe series primitive belongs to the series it is attached to: it lives in that\nseries' pane and is removed together with the series. The pane primitive needs\nno series at all.\n\nUse it to brand a chart with a logo, or to mark a chart as a preview or draft,\nwithout touching the chart's own rendering.\n\n> **Lightweight Charts™ 5 also ships a built-in image watermark.**\n> [`createImageWatermark(pane, url, options)`](https://tradingview.github.io/lightweight-charts/docs/api/functions/createImageWatermark)\n> is a pane primitive which centers an image and scales it to fit. If that is\n> all you need, the built-in function is the right choice. Use this package for\n> a watermark tied to a specific series rather than to a pane, or for anything\n> the built-in does not offer: corner and fractional positions, `objectFit`,\n> `crossOrigin`, `visible`, `zOrder`, `applyOptions` / `setImage` and an\n> `onError` callback.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-image-watermark\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { ImageWatermark } from '@tradingview/lwc-plugin-image-watermark';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(data);\n\nseries.attachPrimitive(new ImageWatermark('/logo.svg', { alpha: 0.4 }));\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-image-watermark\": \"https://unpkg.com/@tradingview/lwc-plugin-image-watermark/dist/image-watermark.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { ImageWatermark } from '@tradingview/lwc-plugin-image-watermark';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(data);\n\nseries.attachPrimitive(new ImageWatermark('/logo.svg', { alpha: 0.4 }));\n</script>\n```\n\n## Usage\n\n### Behind a series\n\nCreate the watermark with the image URL, then attach it to the series it\nshould follow:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { ImageWatermark } from '@tradingview/lwc-plugin-image-watermark';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(data);\n\nconst watermark = new ImageWatermark('/logo.svg', {\n    maxHeight: 400,\n    maxWidth: 400,\n    padding: 50,\n    alpha: 0.4,\n});\nseries.attachPrimitive(watermark);\n```\n\nTo remove the watermark, detach it from the series:\n\n```js\nseries.detachPrimitive(watermark);\n```\n\n### Behind a pane\n\n`ImageWatermarkPane` takes the same image URL and the same options, and is\nattached to a pane instead of a series. Use it when the watermark should stay\nput while series are added and removed:\n\n```js\nimport { ImageWatermarkPane } from '@tradingview/lwc-plugin-image-watermark';\n\nconst watermark = new ImageWatermarkPane('/logo.svg', { alpha: 0.4 });\nchart.panes()[0].attachPrimitive(watermark);\n\n// later\nchart.panes()[0].detachPrimitive(watermark);\n```\n\n### Changing the watermark\n\nBoth classes have the same methods:\n\n```js\nwatermark.applyOptions({ position: 'bottom-right', alpha: 0.2 });\nwatermark.setImage('/other-logo.svg'); // same as applyOptions({ imageUrl })\nwatermark.options(); // the current options, with the defaults filled in\n```\n\n`applyOptions` merges: an option which is not passed, or is passed as\n`undefined`, is left unchanged.\n\nThe image is loaded when the primitive is attached and drawn once it has\ndecoded; until then nothing is rendered. A new image passed to `setImage` or\n`applyOptions` replaces the current one once it has decoded, so the watermark\ndoes not blink out in between. Any URL the browser can load into an\n`<img>` element works, including SVG and data URLs. Decoded images are cached\nby URL, so detaching and re-attaching a watermark — or using the same image\ntwice — never loads it again.\n\n## Options\n\nOptions are passed as the second constructor argument, which is optional, as\nis every option in it. The type is `ImageWatermarkPluginOptions`, and the\ndefaults are exported as `defaultOptions`.\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `imageUrl` | `string` | `''` | URL of the image. The first constructor argument sets the same option. |\n| `position` | `WatermarkPosition` | `'center'` | Where the image sits in the pane: `'center'`, `'top-left'`, `'top-right'`, `'bottom-left'`, `'bottom-right'`, or `{ x, y }`. |\n| `objectFit` | `WatermarkObjectFit` | `'contain'` | `'contain'` scales the image to fit, `'cover'` scales it to fill and crops the overflow, `'none'` draws it at its natural size. |\n| `maxWidth` | `number` | — (pane width) | Maximum width of the drawing area, in CSS pixels. |\n| `maxHeight` | `number` | — (pane height) | Maximum height of the drawing area, in CSS pixels. |\n| `padding` | `number` | `0` | Minimum distance between the drawing area and the edges of the pane, in CSS pixels. |\n| `alpha` | `number` | `1` | Opacity of the image, from `0` (invisible) to `1` (opaque). |\n| `visible` | `boolean` | `true` | Whether the watermark is drawn at all. |\n| `zOrder` | `'bottom' \\| 'normal' \\| 'top'` | `'bottom'` | Layer the watermark is drawn in. `'bottom'` puts it behind the grid and the series. |\n| `crossOrigin` | `'anonymous' \\| 'use-credentials'` | — | `crossOrigin` attribute of the underlying `<img>` element. |\n| `onError` | `(error, imageUrl) => void` | — | Called when the image cannot be loaded. Nothing else reports the failure. |\n\n### Position and size\n\nThe drawing area is the pane inset by `padding` and limited to `maxWidth` /\n`maxHeight`. `position` places that area within the pane and the image within\nthat area:\n\n- a named anchor — `'center'` or one of the four corners;\n- `{ x, y }`, fractions of the free space from `0` to `1`. `{ x: 0, y: 0 }` is\n  the top-left corner, `{ x: 1, y: 1 }` the bottom-right one, `{ x: 0.5, y: 0 }`\n  the middle of the top edge. Values outside `0`…`1` are clamped.\n\n`objectFit` then decides the scale. With `'contain'` (the default) the image is\nscaled up or down to fit, keeping its aspect ratio; set `maxWidth` /\n`maxHeight` to its natural size if it should never be enlarged. With `'cover'`\nit is scaled to fill the drawing area and the overflow is cropped, and with\n`'none'` it is drawn at its natural size. Nothing is ever drawn outside the\ndrawing area, so `padding` always holds.\n\n## Notes\n\n- The watermark is drawn behind the chart content by default: the grid, the\n  series, and other primitives all appear on top of it. Only the pane\n  background is below it. Pass `zOrder: 'top'` to draw it over everything\n  instead.\n- The image appears only in the pane it belongs to, where the series is drawn.\n  It never covers the price scales or the time scale, and a visible left price\n  scale or a second pane does not move it.\n- A watermark whose image cannot be loaded draws nothing and throws nothing.\n  Pass `onError` to be told about it; the plugin logs nothing itself.\n- `ImageWatermarkOptions` is still exported, as a deprecated alias of\n  `ImageWatermarkPluginOptions`. The plugin option type was renamed because\n  the library exports an `ImageWatermarkOptions` of its own, for the built-in\n  `createImageWatermark`. The alias is kept for compatibility and will be\n  removed in a future major version.\n- The image can be loaded from any origin. However, an image served without\n  CORS headers marks the canvas as \"tainted\", and\n  [`takeScreenshot`](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/IChartApi#takescreenshot)\n  fails on a tainted canvas. If you plan to export the chart as an image, serve\n  the watermark image with CORS headers and set `crossOrigin: 'anonymous'`.\n","packages/lwc-plugin-lollipop-series/README.md":"# Lollipop series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series)\nthat draws each value as a dot at the end of a stem. The stem runs from a\nbase line, `0` by default, up to a value above it or down to a value below it.\n\nUse it where a histogram would put too much ink on the chart: values that\nswing around a reference, such as daily returns, net flows or a difference\nfrom a target, where the dot marks the value and the stem shows how far it is\nfrom the base.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-lollipop-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createLollipopSeries } from '@tradingview/lwc-plugin-lollipop-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createLollipopSeries(chart, { color: '#2962FF' });\n\nseries.setData([\n    { time: '2024-04-22', value: 4.2 },\n    { time: '2024-04-23', value: -1.8 },\n    { time: '2024-04-24', value: 2.6 },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-lollipop-series\": \"https://unpkg.com/@tradingview/lwc-plugin-lollipop-series/dist/lollipop-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createLollipopSeries } from '@tradingview/lwc-plugin-lollipop-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createLollipopSeries(chart, { color: '#2962FF' });\n\nseries.setData([\n    { time: '2024-04-22', value: 4.2 },\n    { time: '2024-04-23', value: -1.8 },\n    { time: '2024-04-24', value: 2.6 },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `createLollipopSeries`, then set data with a `value` per\npoint:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createLollipopSeries } from '@tradingview/lwc-plugin-lollipop-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createLollipopSeries(chart, {\n    base: 0,\n    lineWidth: 2,\n    markerSize: 8,\n});\n\nseries.setData([\n    { time: '2024-04-22', value: 4.2 },\n    { time: '2024-04-23', value: -1.8, color: '#F23645' },\n    { time: '2024-04-24' },\n    { time: '2024-04-25', value: 2.6 },\n]);\n```\n\nEach data point is `{ time, value }`. A point without a finite `value`,\n`null` included, as JSON sends a missing one, is whitespace: it keeps its\nplace on the time scale and draws nothing. A `color` on a point\noverrides the series `color` for that point's stem and dot.\n\nThe series' price line and last value label follow the last value. Options can\nbe changed at runtime with `series.applyOptions({ ... })`.\n\n## Creating a series\n\nUse `createLollipopSeries(chart, options?, paneIndex?)`. It returns the normal\nseries API, with the plugin's data and options types preserved. It makes `base`\navailable to the series before the first `setData`, so the base line is part\nof the autoscale range from the start, and changing `base` through\n`series.applyOptions` rescales the series without setting the data again. The\nhelper keeps a shallow copy of the input data for that purpose; streaming\nupdates stay incremental.\n\nThe `LollipopSeries` class remains available for\n`chart.addCustomSeries(new LollipopSeries(), options)`. Added that way, the\nseries only learns its options at the first render, so the data set before\nthen is scaled as if `base` were `0`: values around 100 with `base: 100` are\nstretched down to 0 until the data is set again.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`color`, `priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `base` | `number` | `0` | Price the stems are drawn from. It is part of the autoscale range, so the base line always stays in view. |\n| `lineWidth` | `number` | `2` | Width of the stem, in CSS pixels, at most half the bar spacing and at least one device pixel. |\n| `markerSize` | `number` | `8` | Diameter of the dot at the value, in CSS pixels, at most 20 and at most the bar spacing. `0` draws no dots. |\n\nThe standard `color` option colors the stems, the dots and the price line.\n\n## Notes\n\n- Stems and dots shrink with the bar spacing when the chart is zoomed out: a\n  stem is at most half the bar spacing wide, down to one device pixel, and a\n  dot at most as wide as the bar spacing, so neighboring dots can touch but\n  stay apart from the next stem. At a bar spacing of one device pixel the\n  one-pixel stems fill every pixel. Set `timeScale.minBarSpacing` to keep\n  lollipops from getting that small.\n- Autoscale covers the values and the base, not the dots around them, so a\n  dot at the highest or lowest value sticks out by its radius. The 20 px cap\n  on `markerSize` keeps it within the price scale's default margins in a pane\n  at least 100 px tall.\n- Only the points on screen are drawn. The series is never conflated: with\n  `timeScale.enableConflation` on, the chart still draws every point.\n- On `lightweight-charts` 5.2 and later the series reports the lollipop under\n  the pointer through `hitTest`, within the series' `hitTestTolerance` (3 px\n  by default): the crosshair event's `hoveredInfo.objectId` is `bar-<index>`,\n  where `<index>` is the point's position in `series.data()`. The dot is\n  reported as a point and the stem as a range, like a column, so a candle body\n  the pointer is inside wins over a stem the pointer is only near. Elsewhere\n  in a point's slot, between the base and the value, the chart's own fallback\n  still reports the series as hovered, without an `objectId`. Older versions\n  never call `hitTest`.\n","packages/lwc-plugin-pretty-histogram-series/README.md":"# Pretty histogram series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series) that draws a histogram with rounded bars. Unlike the built-in\nhistogram series, it can round the outer corners of each bar, control the bar\nwidth as a share of the bar spacing, color bars by their sign, draw a border\nand fade the fill into a second color. The result is a softer look that fits\ndashboards and marketing-style charts.\n\nUse it for volume panes, single-value indicators, or any bar chart where the\ndefault square bars look too heavy.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-pretty-histogram-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createPrettyHistogramSeries } from '@tradingview/lwc-plugin-pretty-histogram-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createPrettyHistogramSeries(chart, {\n    color: '#2962FF',\n    widthPercent: 60,\n    radius: 6,\n});\n\nseries.setData([\n    { time: '2024-04-22', value: 12.5 },\n    { time: '2024-04-23', value: -4.1 },\n    { time: '2024-04-24', value: 8.3, color: '#F23645' },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-pretty-histogram-series\": \"https://unpkg.com/@tradingview/lwc-plugin-pretty-histogram-series/dist/pretty-histogram-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createPrettyHistogramSeries } from '@tradingview/lwc-plugin-pretty-histogram-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createPrettyHistogramSeries(chart, {\n    color: '#2962FF',\n    widthPercent: 60,\n    radius: 6,\n});\n\nseries.setData([\n    { time: '2024-04-22', value: 12.5 },\n    { time: '2024-04-23', value: -4.1 },\n    { time: '2024-04-24', value: 8.3, color: '#F23645' },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `addCustomSeries`, then set histogram data:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createPrettyHistogramSeries } from '@tradingview/lwc-plugin-pretty-histogram-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createPrettyHistogramSeries(chart, {\n    color: '#2962FF',\n    widthPercent: 60,\n    radius: 6,\n});\n\nseries.setData([\n    { time: '2024-04-22', value: 12.5 },\n    { time: '2024-04-23', value: -4.1 },\n    { time: '2024-04-24', value: 8.3, color: '#F23645' },\n]);\n```\n\nEach data point is `{ time, value, color? }` — the same shape as the built-in\nhistogram series. A per-point `color` overrides the series `color` for that\nbar. Points without a `value` are treated as whitespace.\n\nOptions can be changed at runtime with `series.applyOptions({ ... })`.\n\n### Two-tone bars\n\nSet `upColor` and `downColor` to color each bar by its sign relative to\n`base`, the way a volume pane usually does:\n\n```js\nseries.applyOptions({\n    base: 0,\n    upColor: '#089981',\n    downColor: '#F23645',\n});\n```\n\nA per-point `color` still wins over both.\n\n### The base line\n\nBars grow from `base` (`0` by default), and the base is always reported to the\nautoscale alongside the values, exactly as the built-in histogram series does.\nBars are therefore never cut off at the edge of the pane, and no custom\n`autoscaleInfoProvider` is needed.\n\n`base` is read when the data is set, so change it before or together with\n`setData` if you also rely on the autoscale following it.\n\n## Creating a series\n\nUse `createPrettyHistogramSeries(chart, options?, paneIndex?)`. It returns the\nnormal series API, with the plugin's data and options types preserved. The helper\nmakes scaling options available before the first `setData` and rebuilds plot\nvalues automatically when those options change through `series.applyOptions`.\nThis keeps autoscaling, last-value labels and crosshair values consistent. The\nhelper retains a shallow copy of the input data, including whitespace, and\nre-ingests it only when a scaling option changes. Streaming updates remain\nincremental.\n\nThe low-level `PrettyHistogramSeries` pane view remains available for integrations\nthat supply their own options getter to its constructor. Passing scaling options\nonly to `chart.addCustomSeries(new PrettyHistogramSeries(), options)` cannot make\nthem available before data ingestion on LWC 5.0; use the creation helper instead.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `color` | `string` | `'#D63864'` | Fill color of the bars, used whenever no more specific color applies. A per-point `color` in the data overrides it. |\n| `upColor` | `string \\| null` | `null` | Fill color of bars at or above `base`. `null` falls back to `color`. |\n| `downColor` | `string \\| null` | `null` | Fill color of bars below `base`. `null` falls back to `color`. |\n| `base` | `number` | `0` | Price the bars grow from. Always included in the autoscale. |\n| `widthPercent` | `number` | `50` | Bar width as a percentage of the bar spacing, `0`–`100`. Ignored when `widthMode` is `'histogram'`. |\n| `widthMode` | `'percent' \\| 'histogram'` | `'percent'` | `'percent'` sizes each bar from `widthPercent`. `'histogram'` uses the full slot with a one-pixel gap, exactly as the built-in histogram series does. |\n| `minColumnWidth` | `number` | `1` | Lower bound for the bar width, in CSS pixels. |\n| `radius` | `number` | `4` | Corner radius of the bar's outer end, in CSS pixels. Positive bars are rounded at the top, negative bars at the bottom. The radius is capped at half the bar width and at the bar height. |\n| `roundInnerCorners` | `boolean` | `false` | Whether the corners at the `base` end are rounded with the same radius. |\n| `borderColor` | `string \\| null` | `null` | Border color of the bars. `null` for no border. |\n| `borderWidth` | `number` | `1` | Border width in CSS pixels. Only drawn when `borderColor` is set. |\n| `gradientColor` | `string \\| null` | `null` | Color the fill fades into at the outer end of each bar. `null` for a flat fill. |\n| `highlightHovered` | `boolean` | `false` | Whether hovering the series fades every bar except the one under the cursor. Requires Lightweight Charts 5.2 or later. |\n\n## Notes\n\n- Bars are anchored at `base` and the base is always part of the autoscale, so\n  the series behaves like the built-in histogram; see\n  [The base line](#the-base-line).\n- Bar widths reproduce the built-in histogram exactly in `'histogram'` width\n  mode and at `widthPercent: 100`: the same pixel grid, the same one-pixel gap,\n  and no alignment carried across a whitespace gap.\n- Flat, borderless bars are drawn in batches: consecutive bars of the same\n  color are filled in one canvas operation. Setting `borderColor`,\n  `gradientColor` or `highlightHovered` paints bar by bar instead.\n- `hitTest`, which reports the hovered bar through the crosshair as\n  `bar-<index>`, is used by Lightweight Charts 5.2 and later, and\n  `conflationReducer` from 5.1. Older versions simply never call them, and\n  `highlightHovered` has no effect before 5.2.\n","packages/lwc-plugin-preview-kit/README.md":"# Preview kit\n\nPrivate, never published. Shared layout and controls for the catalog preview\npages of the plugin packages: `src/example/preview.html` and `preview.ts` of\nevery `packages/lwc-plugin-*`, declared as `lwcPlugin.preview` and built to\n`/plugin-previews/<slug>/` by `pnpm plugins:build-demos`.\n\nA preview page is not the plugin's demo. The demo (`lwcPlugin.demo`) is the\npage a developer opens on its own: it carries edge cases, whitespace runs,\nnegative values and every option the plugin has. A preview is what the\ncatalog frames next to the README, so it shows the plugin at its best in a\nshort frame and nothing else.\n\nThree entry points:\n\n- `@tradingview/lwc-plugin-preview-kit/preview.css` — the whole layout. One\n  compact `#controls` row above a `#chart` that fills the rest of the frame.\n  Light and dark, keyed on the root element's `data-theme`. Nothing is\n  restyled after load, so the chart is created at its final size and does not\n  jump.\n- `@tradingview/lwc-plugin-preview-kit/preview-theme` — follows the theme of\n  the docs page that frames the preview, live: toggling the site theme\n  restyles the running preview without reloading it. `?theme=light|dark` in\n  the page URL pins a theme instead (a page opened on its own is light).\n  `themeChart(chart, onTheme?)` themes the chart's background, text, grid,\n  scale borders and crosshair labels now and on every switch; `onTheme` is\n  where a preview recolours anything of its own that would not read on the\n  other background.\n- `@tradingview/lwc-plugin-preview-kit/preview-controls` — `mountControls(defs)`\n  builds the control row from `select`, `checkbox` and `button` declarations,\n  and `addRefreshButton(onRefresh)` adds a \"New data\" button for the previews\n  whose sample data is random. Plain DOM, no framework.\n\nA preview page is therefore two elements and a script:\n\n```html\n<div id=\"controls\"></div>\n<div id=\"chart\"></div>\n<script type=\"module\" src=\"./preview.ts\"></script>\n```\n\nThe page script is a module and can run after the first paint, so\n`src/theme-boot.js` sets the theme before it: `pnpm plugins:build-demos`\ninlines it straight after `<meta charset>` of every built preview page (the\nbuild fails without one), which is why a preview page needs no script of its\nown in its HTML. It applies the same rules as `preview-theme`; change them in\nboth places.\n\nAdd the kit to a package with `@tradingview/lwc-plugin-preview-kit: workspace:*` in\n`devDependencies` — `create-lwc-plugin --workspace` does this for you — and\ndeclare `lwcPlugin.preview` (and `previewHeight`, when 330 px is not enough).\n","packages/lwc-plugin-rounded-candles-series/README.md":"# Rounded candles series\n\nA [custom candlestick series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series) with rounded candle bodies. It renders the same\nopen-high-low-close data as the built-in candlestick series. Each body is\ndrawn as a rounded rectangle. The corner radius adapts to the bar spacing:\nsharp when zoomed out, soft when zoomed in.\n\nUse it as a drop-in replacement for the built-in candlesticks wherever a\nsofter visual style fits, such as dashboards, embedded widgets, or marketing\npages.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-rounded-candles-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { RoundedCandleSeries } from '@tradingview/lwc-plugin-rounded-candles-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addCustomSeries(new RoundedCandleSeries(), {\n    upColor: '#089981',\n    downColor: '#F23645',\n    wickUpColor: '#089981',\n    wickDownColor: '#F23645',\n});\n\nseries.setData([\n    { time: '2024-04-22', open: 100.2, high: 104.6, low: 99.1, close: 103.8 },\n    { time: '2024-04-23', open: 103.8, high: 105.0, low: 101.4, close: 102.0 },\n    { time: '2024-04-24', open: 102.0, high: 106.1, low: 101.7, close: 105.4 },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-rounded-candles-series\": \"https://unpkg.com/@tradingview/lwc-plugin-rounded-candles-series/dist/rounded-candles-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { RoundedCandleSeries } from '@tradingview/lwc-plugin-rounded-candles-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addCustomSeries(new RoundedCandleSeries(), {\n    upColor: '#089981',\n    downColor: '#F23645',\n    wickUpColor: '#089981',\n    wickDownColor: '#F23645',\n});\n\nseries.setData([\n    { time: '2024-04-22', open: 100.2, high: 104.6, low: 99.1, close: 103.8 },\n    { time: '2024-04-23', open: 103.8, high: 105.0, low: 101.4, close: 102.0 },\n    { time: '2024-04-24', open: 102.0, high: 106.1, low: 101.7, close: 105.4 },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `addCustomSeries`, then set candlestick data:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { RoundedCandleSeries } from '@tradingview/lwc-plugin-rounded-candles-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addCustomSeries(new RoundedCandleSeries(), {\n    upColor: '#089981',\n    downColor: '#F23645',\n    wickUpColor: '#089981',\n    wickDownColor: '#F23645',\n});\n\nseries.setData([\n    { time: '2024-04-22', open: 100.2, high: 104.6, low: 99.1, close: 103.8 },\n    { time: '2024-04-23', open: 103.8, high: 105.0, low: 101.4, close: 102.0 },\n    { time: '2024-04-24', open: 102.0, high: 106.1, low: 101.7, close: 105.4 },\n]);\n```\n\nEach data point is `{ time, open, high, low, close }` — the same shape as the\nbuilt-in candlestick series. Points missing any of the four values are treated\nas whitespace, and leave a gap.\n\nA constant `radius` fixes the corner rounding regardless of zoom:\n\n```js\nseries.applyOptions({ radius: 6 });\n```\n\nOptions can be changed at runtime with `series.applyOptions({ ... })`.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `upColor` | `string` | `'#26a69a'` | Body color of rising candles. |\n| `downColor` | `string` | `'#ef5350'` | Body color of falling candles. |\n| `borderVisible` | `boolean` | `true` | Whether a border is drawn around the body. |\n| `borderUpColor` | `string` | `'#26a69a'` | Border color of rising candles. |\n| `borderDownColor` | `string` | `'#ef5350'` | Border color of falling candles. |\n| `borderColor` | `string` | — | Border color of both directions. Wins over `borderUpColor` / `borderDownColor` while it is set to a non-empty string. |\n| `wickVisible` | `boolean` | `true` | Whether wicks are drawn. |\n| `wickUpColor` | `string` | `'#26a69a'` | Wick color of rising candles. |\n| `wickDownColor` | `string` | `'#ef5350'` | Wick color of falling candles. |\n| `wickColor` | `string` | — | Wick color of both directions. Wins over `wickUpColor` / `wickDownColor` while it is set to a non-empty string. |\n| `wickLineCap` | `'butt' \\| 'round'` | `'butt'` | Shape of the two wick ends. |\n| `radius` | `number \\| ((barSpacing: number) => number)` | `bs => bs < 4 ? 0 : bs / 3` | Corner radius of the candle body, in CSS pixels. Either a constant, or a function of the current bar spacing. Use `0` for square candles. |\n| `upDownMode` | `'openClose' \\| 'previousClose'` | `'openClose'` | How a candle is decided to be rising or falling. `'openClose'` compares `open <= close`, exactly as the built-in candlestick series does. `'previousClose'` compares the close with the previous candle's close and treats the first candle as rising. |\n| `hoverDimOpacity` | `number` | `1` | Opacity of the candles other than the hovered one while the series is hovered. `1` leaves the series unchanged. |\n\nEach data point may also carry `color`, `borderColor` and `wickColor`, which\noverride the corresponding options for that candle only — the same per-item\noverrides the built-in candlestick series supports.\n\n## Notes\n\n- A candle counts as *rising* when `open <= close`, exactly as the built-in\n  candlestick series decides it. `upDownMode: 'previousClose'` restores the\n  behavior this plugin had while it was an example (close compared with the\n  previous close, the first candle always rising).\n- `borderColor` and `wickColor` are resolved at draw time, so clearing them\n  (setting them to an empty string) brings the up/down pair back. The built-in\n  series copies them into the pair once, in `applyOptions`, and cannot be\n  reverted that way.\n- Wicks are drawn above and below the body rather than as one bar behind it, so\n  a translucent body does not show its own wick through itself.\n- On Lightweight Charts™ 5.2 and later the series reports the candle under the\n  cursor through `hitTest`, and from 5.1 conflated candles are merged\n  open-first, close-last with the extremes of both.\n- Rounded corners use `CanvasRenderingContext2D.roundRect`, which every browser\n  the library supports provides.\n","packages/lwc-plugin-scatter-series/README.md":"# Scatter series\n\nA scatter and bubble chart for Lightweight Charts™: points placed by two\nnumbers on a numeric X axis, in named groups with their own colors and marker\nshapes, sized by a data value, optionally connected by lines, with baselines\nand accent borders around the plot.\n\nUse it to show how two measures relate across many items, where time is not\nthe horizontal axis: trades by maximum adverse excursion and result, bonds by\nmaturity and yield with the issue size as the bubble, or sectors on a relative\nrotation graph with their recent path as a tail. The plugin draws the chart\ncontent only: titles, legends and tooltips stay with your page, and the series\ntells it which point is hovered and where it is drawn.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.2.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-scatter-series\n```\n\nThen create a scatter chart and add the series to it:\n\n```js\nimport { createScatterChart, createScatterSeries } from '@tradingview/lwc-plugin-scatter-series';\n\nconst chart = createScatterChart(document.getElementById('container'), { autoSize: true });\n\nconst series = createScatterSeries(chart, {\n    groups: [\n        { id: 'win', name: 'Win trades', color: '#089981' },\n        { id: 'loss', name: 'Loss trades', color: '#F23645' },\n    ],\n    baselines: [{ axis: 'y', value: 0 }],\n});\n\nseries.setData([\n    { x: 12, y: 540000, group: 'win', sizeValue: 14 },\n    { x: 31, y: -320000, group: 'loss', sizeValue: 3 },\n    { x: 18, y: 120000, group: 'win', sizeValue: 40 },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-scatter-series\": \"https://unpkg.com/@tradingview/lwc-plugin-scatter-series/dist/scatter-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createScatterChart, createScatterSeries } from '@tradingview/lwc-plugin-scatter-series';\n\nconst series = createScatterSeries(createScatterChart(document.getElementById('container'), { autoSize: true }));\nseries.setData([{ x: 1, y: 2 }, { x: 3, y: 5 }, { x: 4, y: 1 }]);\n</script>\n```\n\n## Usage\n\n`createScatterChart(container, options?)` creates a chart whose horizontal\nscale is a numeric X axis (see [The scatter chart](#the-scatter-chart)), and\n`createScatterSeries(chart, options?, paneIndex?)` adds the series, which\nholds the whole dataset, every group included. Fields of your own travel with\nthe points; give the series their type:\n\n```ts\nimport { createScatterChart, createScatterSeries, type ScatterPoint } from '@tradingview/lwc-plugin-scatter-series';\n\ninterface Bond extends ScatterPoint {\n    title: string;\n}\n\nconst chart = createScatterChart(document.getElementById('container')!, { autoSize: true });\nconst series = createScatterSeries<Bond>(chart, {\n    groups: [\n        { id: 'aaa', name: 'AAA-AA', color: '#089981' },\n        { id: 'hy', name: 'High yield', color: '#FF9800' },\n    ],\n    xRange: { min: 0, max: 30 },\n    xFormatter: (x: number) => `${x}Y`,\n    priceFormat: { type: 'custom', minMove: 0.01, formatter: (y: number) => `${y.toFixed(2)}%` },\n});\n\nseries.setData([\n    { id: 'PEMX1', x: 4.5, y: 3.2, group: 'aaa', sizeValue: 120, title: 'PEMX1' },\n    { id: 'PEMX3', x: 21.7, y: 9.4, group: 'hy', sizeValue: 75, title: 'PEMX3' },\n]);\n```\n\nChange options with `series.applyOptions({ ... })` and replace the points with\n`series.setData(points)`; the chart applies both on its next frame. Every\noption and method is documented in the package's type declarations.\n\n### Points\n\n| Field | Type | Description |\n| --- | --- | --- |\n| `x`, `y` | `number` | Position, in X axis and price scale units. Required. A point is drawn only when both are finite and `x` is within the X range. |\n| `id` | `string` | Reported as the `objectId` when the point is hovered; defaults to its index. Keep it unique. |\n| `group` | `string` | Identifier of the point's group. |\n| `sizeValue` | `number` | A value mapped to the point's size (see [Dynamic size](#dynamic-size)). |\n| `size` | `number` | Size in CSS pixels, stroke included. Overrides `sizeValue`. |\n| `color`, `opacity`, `shape`, `strokeColor`, `strokeWidth`, `hollow` | | Overrides of the group's style (see [Point styles](#point-styles)). |\n\nPoints need no ordering, and may share an X value. Any other field is kept\nand handed back with the point by the hover API.\n\n### Groups\n\nA group is a named set of points sharing a style — what a user calls a\n\"series\" of the scatter chart. Declare groups in `groups`, in drawing order; a\ngroup a point names without it being declared comes after them. `groups` is\nreplaced as a whole by `applyOptions`.\n\n| Field | Default | Description |\n| --- | --- | --- |\n| `id` | — | Identifier points refer to. Required. |\n| `name` | `id` | Display name, for your legend. |\n| `color` | the `palette` entry | Fill color. |\n| `opacity`, `shape`, `pointSize`, `strokeColor`, `strokeWidth`, `hollow` | the series option | Style of the group's points; `opacity` is `1` with `lineVisible`. |\n| `visible` | `true` | Whether the group is drawn, hovered and autoscaled. |\n| `lineVisible` | `false` | Connect the group's points in data order, as a tail. |\n| `lineWidth`, `lineColor`, `lineStyle` | `1`, the group color, solid | The connecting line. |\n\nA hidden group still counts for the automatic X range and size domain, so\nswitching it moves neither; `series.setGroupVisible(id, visible)` switches one\nwithout passing every group again. A connecting line is cut at the plot edge.\n\n### Point styles\n\nA point's style beats its group's, which beats the series options; its size\nis its `size`, else its mapped `sizeValue`, else the `pointSize` of its group,\nelse of the series. Every point has a thin ring, `strokeWidth` wide but at\nmost a quarter of its size, to show where points overlap; a `hollow` point is\nan outline at least 1 px wide and no fill. The ring color is automatic by\ndefault: the chart's background, following theme changes, or the point's own\ncolor when it is hollow.\n\n`strokeColor` is the only style that also takes `null`, on a group or a point,\nand `null` is not the same as leaving it out: left out, the color comes from\nthe group, then the series; `null` asks for the automatic color even when the\ngroup or the series sets one.\n\n```js\nseries.applyOptions({\n    strokeColor: '#131722',\n    groups: [\n        { id: 'aaa', hollow: true, strokeWidth: 2, strokeColor: null }, // outlined in its own color\n        { id: 'bbb', strokeWidth: 2 }, // ringed in #131722\n    ],\n});\n```\n\n### Dynamic size\n\n`sizeValue` is mapped onto `sizeRange` (5–25 px by default): `sizeDomain.min`\nto the smallest size, `sizeDomain.max` to the largest, and values beyond the\ndomain to its ends. An open end of the domain (`null`, the default) is taken\nfrom the points of every group, hidden ones included. When every value is the\nsame, the points are drawn at the middle of the range. When every value lies\npast the one given end, the domain is that end alone and the points take its\nsize: the smallest below a given `min`, the largest above a given `max`.\n`sizeScale: 'area'` grows the area\nrather than the diameter, which is what the eye compares in a bubble chart.\n\n```js\nseries.applyOptions({ sizeRange: { min: 5, max: 50 }, sizeDomain: { min: 0, max: null }, sizeScale: 'area' });\n```\n\nEvery size, stroke included, is clamped to `pointSizeLimits`: 5–50 px by\ndefault (`defaultOptions.pointSizeLimits`), each end within 1–500 px.\n`series.sizeMapping()` returns the mapping as drawn — `domain`, `range`,\n`scale` and `sizeFor(value)` — for a bubble-size legend.\n\n### Baselines and border\n\n`baselines` are reference lines under the points: `{ axis: 'y', value: 0 }`\nis horizontal at a Y value, `axis: 'x'` vertical at an X value, each with an\noptional `color`, `width` and `style`. The price scale and the automatic X\nrange include them. `plotBorder` draws an accent border inside the edges of\nthe plot, on the sides you choose: `{ visible: true, top: false, right: false }`.\n\n### The X axis\n\nThe X axis spans `xRange`. An open end (`null`, the default) is taken from\nevery point and rounded outwards to a nice tick — 1, 2 or 5 × 10ⁿ, about ten\nintervals across; a given end off the axis grid (slots a tenth or a twentieth\nof a tick apart) is moved outwards to it. `series.xDomain()` returns the range\nin use. The labels are evenly spaced nice values, thinned out on narrow charts\nso that none overlap, and formatted with `xFormatter`.\n\nThe ends of the range sit on the plot edges, so a bubble there is cut in half;\n`xMargins` keeps room for it, in pixels. A fixed edge allows no such room, so\nwhile `xMargins` is above 0 the series frees the chart's fixed edges, and fixes\nthem again when the margins return to 0 or the series is removed. An edge the\nhost fixes meanwhile is kept fixed then; one it frees meanwhile cannot be told\nfrom the freed one, so free it again once the margins are 0. For dates, pass\ntimestamps and format them: the ticks are nice numbers of the unit, not\ncalendar boundaries, and next to large offsets such as epoch milliseconds the\nslots stay coarse enough to be distinct numbers. X values beyond ±1e300 cannot\nbe laid out: those points are not drawn, and the series warns once; nor can a\nspan below 1e-98, which is widened, with a warning. Data spanning only a few\nfloating-point steps of its own magnitude, such as `[1e15, 1e15 + 1]`, gets\nan axis of very few slots, since finer ones would not be distinct numbers;\nthe chart keeps neighboring slots at most half the plot width apart (its\ndefault `timeScale.maxBarSpacing`), so such data spans about half the plot.\n\n```js\nseries.applyOptions({\n    xFormatter: x => new Date(x).toLocaleDateString('en-GB', { day: 'numeric', month: 'short', timeZone: 'UTC' }),\n    xMargins: 12,\n});\nseries.setData(trades.map(trade => ({ id: trade.id, x: trade.closedAt, y: trade.pnl }))); // epoch milliseconds\n```\n\n### The Y axis\n\nThe Y axis is the series' price scale: format it with `priceFormat`, and pin\neither end with `yRange` (an open end autoscales, with room for the largest\npoint; ends in the wrong order are swapped, as in `xRange`). Its modes apply as they are — `PriceScaleMode.Logarithmic`, or\n`invertScale` — and the points, hit tests and `pointById` follow; the\npercentage and indexed-to-100 modes mean nothing here, and the series warns\nonce when either is set. For the scale on the left, give the chart\n`leftPriceScale: { visible: true }` and `rightPriceScale: { visible: false }`,\nand the series `priceScaleId: 'left'`.\n\n## The scatter chart\n\n`createScatterChart` is `createChartEx` with a numeric horizontal scale\nbehavior (`ScatterHorzScaleBehavior`) and these defaults\n(`scatterChartDefaults`), which the options you pass override:\n\n- scrolling and zooming off, flag by flag: `handleScroll`'s `mouseWheel`,\n  `pressedMouseMove`, `horzTouchDrag` and `vertTouchDrag`, and `handleScale`'s\n  `mouseWheel`, `pinch`, and `axisPressedMouseMove` and `axisDoubleClickReset`\n  for both axes, so that the X axis spans its range edge to edge;\n- `crosshair.mode: CrosshairMode.Hidden`; hover and the crosshair events keep\n  working;\n- dotted grid lines, and no time or price scale borders;\n- on the time scale: `allowBoldLabels: false`, `uniformDistribution: true`,\n  `lockVisibleTimeRangeOnResize: true`, `shiftVisibleRangeOnNewBar: false`,\n  `rightOffset: 0`, `minBarSpacing: 0.001`, `fixLeftEdge: true` and\n  `fixRightEdge: true`;\n- price `scaleMargins` of 0.05 at the top and the bottom, on both price\n  scales; the series adds room for its largest point.\n\n`scatterChartDefaults` is frozen. A `handleScroll` or `handleScale` object you\npass switches on just the flags it sets; `true` switches them all on. To build\nthe chart yourself, give `createChartEx` both type arguments, which it cannot\ninfer:\n`createChartEx<number, ScatterHorzScaleBehavior>(container, new ScatterHorzScaleBehavior(), scatterChartDefaults)`.\n\nThe series manages the chart's `timeScale.tickMarkMaxCharacterLength`, and\ngives the chart its own value back on `remove()`. A crosshair you show\n(`CrosshairMode.Normal`) snaps its vertical line to the slots of the X axis,\nnot to the points; its magnet modes snap to the extremes of a slot.\n\n### Scrolling and zooming\n\nWith scrolling or zooming switched on (`handleScroll`, `handleScale`), the\nseries keeps the user's zoom through data refreshes, option changes and\nresizes, and labels the part of the axis in view. A new X range is fitted\nagain, as `series.fitXDomain()` does. Zoomed out to the span of the fit or\nfurther, wherever the range sat, the user is back at the fit: a pan at that\nzoom springs back to it, as does the chart's double-click reset of the time\naxis. Keep the fixed edges: they keep the user within the X range, and only at\na fixed edge does the chart move an end label inside the plot. At a free edge\nit centers the label on its value, so the series keeps that end of the range\nfar enough inside for it. To let the user pan past the range, set `xMargins`.\nZoom from code with `chart.timeScale().setVisibleLogicalRange(...)`: a zoom\nset through the `timeScale.barSpacing` and `rightOffset` options looks like the\nchart's double-click reset, so the series fits the range again.\n\n## Hover, tooltips and legends\n\n`subscribeHoveredPointChange(handler)` is the one subscription a tooltip\nneeds. After the chart has painted, at most once a frame, it hands the handler\nthe hovered point — under the pointer, else the one set with\n`setHoveredPoint` — whenever anything about it changes (another point, new\ndata or options, a resize, a rescaled axis), and `null` when there is none any\nmore, the removal of the series included.\n\n```js\nconst tooltip = document.getElementById('tooltip'); // absolutely positioned in the chart container\n\nseries.subscribeHoveredPointChange(info => {\n    if (info === null) {\n        tooltip.style.display = 'none';\n        return;\n    }\n    // Pane coordinates: the plot starts after the left price scale, if it is shown.\n    const left = chart.priceScale('left').width() + info.x;\n    tooltip.textContent = `${info.point.title}: ${info.point.x}, ${info.point.y}`;\n    tooltip.style.display = 'block';\n    tooltip.style.transform = `translate(${left}px, ${info.y - info.radius}px) translate(-50%, -100%)`;\n});\n```\n\nIt gets what `series.pointById(objectId)` returns: your point, its `index`\nand `groupId`, its center `x` and `y` in pane coordinates (CSS pixels from the\ntop-left corner of the plot), its `radius` as drawn, and its resolved style.\nThe chart's crosshair and click events carry the hovered `objectId` in\n`param.hoveredInfo` (with `hoveredInfo.series === series.series()`), but come\nwith pointer moves, and when the series lays the X axis out again, and never\nreport a point set with `setHoveredPoint`: prefer the subscription. To highlight a point from outside\nthe chart, a table row say, call `series.setHoveredPoint(objectId)`, and\n`null` to clear it.\n\nBuild a legend from `series.groups()`, the groups as drawn, with their palette\ncolor, shape, ring and `pointCount` resolved, and switch them with\n`setGroupVisible`:\n\n```js\nfunction renderLegend() {\n    legend.replaceChildren(...series.groups().map(group => {\n        const item = document.createElement('button');\n        item.textContent = `${group.name} (${group.pointCount})`;\n        item.style.cssText = `color: ${group.color}; opacity: ${group.visible ? 1 : 0.4}`;\n        item.onclick = () => { series.setGroupVisible(group.id, !group.visible); renderLegend(); };\n        return item;\n    }));\n}\nrenderLegend();\n```\n\nThe hovered point is drawn on top at `hoveredOpacity`, and can grow\n(`hoveredSizeIncrease`) and get a ring (`hoveredRingWidth`). Of overlapping\npoints the topmost is hovered; over no point, the pointer hovers one within\n`hitTestTolerance` pixels.\n\n## Draw your own overlays\n\nFor anything else — a shaded region, a band, an annotation — attach a\n[series primitive](https://tradingview.github.io/lightweight-charts/docs/plugins/series-primitives)\nto `series.series()`, placed with `series.xToCoordinate(x)` and\n`series.series().priceToCoordinate(y)` in its `updateAllViews`, which the\nchart calls before every paint. This one shades rectangles given in data\nunits under the grid and the points — the quadrants of a relative rotation\ngraph, say:\n\n```ts\nimport type { IPrimitivePaneView, ISeriesPrimitive } from 'lightweight-charts';\nimport type { ScatterSeriesApi } from '@tradingview/lwc-plugin-scatter-series';\n\n/** A rectangle in data units. An open end (`null`) runs to the edge of the pane. */\ninterface ShadedRegion {\n    xMin: number | null;\n    xMax: number | null;\n    yMin: number | null;\n    yMax: number | null;\n    color: string;\n}\n\nfunction regionShading(scatter: ScatterSeriesApi, regions: readonly ShadedRegion[]): ISeriesPrimitive<number> {\n    let boxes: { left: number; right: number; top: number; bottom: number; color: string }[] = [];\n    const view: IPrimitivePaneView = {\n        zOrder: () => 'bottom',\n        renderer: () => ({\n            // Whole device pixels within the pane, so that the edges stay sharp.\n            draw: target => target.useBitmapCoordinateSpace(({ context, bitmapSize, horizontalPixelRatio: h, verticalPixelRatio: v }) => {\n                for (const box of boxes) {\n                    const left = Math.max(0, Math.round(box.left * h));\n                    const right = Math.min(bitmapSize.width, Math.round(box.right * h));\n                    const top = Math.max(0, Math.round(box.top * v));\n                    const bottom = Math.min(bitmapSize.height, Math.round(box.bottom * v));\n                    if (right > left && bottom > top) {\n                        context.fillStyle = box.color;\n                        context.fillRect(left, top, right - left, bottom - top);\n                    }\n                }\n            }),\n        }),\n    };\n    return {\n        attached: ({ requestUpdate }) => requestUpdate(), // attaching does not repaint the chart\n        paneViews: () => [view],\n        updateAllViews: () => {\n            const series = scatter.series();\n            boxes = [];\n            if (!series.options().visible) {\n                return; // the chart draws the primitives of a hidden series too\n            }\n            // An open Y end runs to the top of the pane, or to the bottom of an inverted scale.\n            const up = series.priceScale().options().invertScale ? Infinity : -Infinity;\n            const x = (value: number | null, open: number) => (value === null ? open : scatter.xToCoordinate(value));\n            const y = (value: number | null, open: number) => (value === null ? open : series.priceToCoordinate(value));\n            for (const region of regions) {\n                const left = x(region.xMin, -Infinity);\n                const right = x(region.xMax, Infinity);\n                const low = y(region.yMin, -up);\n                const high = y(region.yMax, up);\n                if (left !== null && right !== null && low !== null && high !== null) {\n                    boxes.push({ left, right, top: Math.min(low, high), bottom: Math.max(low, high), color: region.color });\n                }\n            }\n        },\n    };\n}\n\nseries.series().attachPrimitive(regionShading(series, [\n    { xMin: 100, xMax: null, yMin: 100, yMax: null, color: 'rgba(8, 153, 129, 0.1)' }, // leading\n    { xMin: 100, xMax: null, yMin: null, yMax: 100, color: 'rgba(251, 192, 45, 0.12)' }, // weakening\n    { xMin: null, xMax: 100, yMin: null, yMax: 100, color: 'rgba(242, 54, 69, 0.08)' }, // lagging\n    { xMin: null, xMax: 100, yMin: 100, yMax: null, color: 'rgba(41, 98, 255, 0.08)' }, // improving\n]));\n```\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceFormat`, `priceScaleId`, `visible`, `autoscaleInfoProvider`, …):\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `color` | `'#2962FF'` | Fill color of points with no group, and of groups when `palette` is empty. |\n| `opacity` | `0.65` | Opacity of the points, `0`–`1`. |\n| `pointSize` | `9` | Size of the points in CSS pixels, stroke included. |\n| `pointSizeLimits` | `{ min: 5, max: 50 }` | Smallest and largest size of any point. |\n| `shape` | `'circle'` | `'circle'`, `'square'`, `'diamond'`, `'triangleUp'` or `'triangleDown'`. |\n| `strokeColor`, `strokeWidth` | `null`, `1` | Color (`null`: automatic) and width in CSS pixels (`0`: none) of the ring around every point. |\n| `hollow` | `false` | Draw points as open markers. |\n| `palette` | `DEFAULT_SCATTER_PALETTE` | Colors of the groups which set none, in group order: ten by default. |\n| `groups` | `[]` | The groups, in drawing order. |\n| `sizeRange` | `{ min: 5, max: 25 }` | Sizes `sizeValue` is mapped onto, in CSS pixels. |\n| `sizeDomain` | `{ min: null, max: null }` | Values mapped to the ends of `sizeRange`; `null` takes the end from the data. |\n| `sizeScale` | `'linear'` | Whether the diameter (`'linear'`) or the area (`'area'`) grows with `sizeValue`. |\n| `xRange` | `{ min: null, max: null }` | The X axis range; `null` takes the end from the data. |\n| `xMargins` | `0` | Room between each end of the X range and the plot edge, in CSS pixels. |\n| `xFormatter` | `null` | Formats the X labels; `null` prints the number. |\n| `yRange` | `{ min: null, max: null }` | Pins the ends of the Y axis; `null` autoscales. |\n| `baselines` | `[]` | Reference lines under the points. |\n| `plotBorder` | `visible: false`, `'#9598A1'`, 1 px, solid, every side | Accent border along the edges of the plot (`visible`, `color`, `width`, `style`, `top`, `right`, `bottom`, `left`). |\n| `hoveredOpacity` | `1` | Opacity of the hovered point, drawn on top. |\n| `hoveredSizeIncrease` | `0` | Pixels added to the size of the hovered point. |\n| `hoveredRingWidth`, `hoveredRingGap`, `hoveredRingColor` | `0`, `1`, `null` | Width (`0`: none), distance and color (`null`: the point's) of a ring around the hovered point. |\n| `hitTestTolerance` | `3` | How many pixels outside a point the pointer may be and still hover it. |\n\n`applyOptions` merges nested objects; `groups`, `baselines`, `palette` and\n`xFormatter` are replaced whole. `null` sets an option back to its default: an\nend of a range to automatic, or (from JavaScript) a whole option. An\n`applyOptions` or `setData` call that throws — an `xFormatter` that throws,\nsay — changes nothing. Set `visible` through the scatter series. Keep the\nprice line and last-value label off: the underlying values are X axis slots.\n\n## API\n\n`createScatterSeries` returns a `ScatterSeriesApi`:\n\n| Method | Description |\n| --- | --- |\n| `setData(points)` / `data()` | Replaces / reads the points. The array is copied, the points are not. |\n| `applyOptions(options)` / `options()` | Changes / reads (a copy of) the options. |\n| `series()` | The underlying custom series, for its price scale and Y conversions. |\n| `groups()` | The groups as drawn, resolved, with their point counts, for a legend. |\n| `setGroupVisible(groupId, visible)` | Shows or hides a group, keeping its color and the X axis. |\n| `xDomain()` / `fitXDomain()` | The X axis range in use and its tick step / fits it to the plot again. |\n| `xToCoordinate(x)` / `coordinateToX(coordinate)` | An X value to a horizontal pane coordinate and back, as the points are drawn, or `null`. |\n| `sizeMapping()` | How `sizeValue` maps to sizes, or `null` when no point uses it. |\n| `pointById(objectId)` / `hitTest(x, y)` | Where a point is drawn / the point at a pane coordinate, or `null`. |\n| `hoveredPoint()` / `setHoveredPoint(objectId \\| null)` | Reads / sets the hovered point. |\n| `subscribeHoveredPointChange(handler)` / `unsubscribeHoveredPointChange(handler)` | Follows the hovered point: which point, and where it is drawn. |\n| `remove()` | Removes the series, and gives the chart back the options the series manages. Safe to call twice, or after `chart.remove()`. |\n\n## Notes\n\n- Requires `lightweight-charts` 5.2 or later, for the custom series hit test\n  and the `hoveredInfo` of chart events.\n- One scatter series per chart: it holds every group, and creating a second\n  throws until the first is removed. Other series on a scatter chart are not\n  supported, as their time points break the even spacing of the X axis: use\n  `baselines`, a group's `lineVisible`, or a\n  [primitive](#draw-your-own-overlays).\n- Take the series off with `series.remove()`; one taken off with\n  `chart.removeSeries(series.series())` releases itself right after the next\n  chart event or API call. After `chart.remove()` the API returns `null`.\n- `series.series()` serves the price scale and Y conversions, not data or\n  scatter options: its data is the slot grid of the X axis, and its own\n  `options().hitTestTolerance` is `-Infinity`, which turns the chart's hit test\n  of the slots off (the scatter tolerance is in `series.options()`).\n- A chart and a series from different copies of the package (the standalone\n  build and the main entry point, say) do not mix: `createScatterSeries`\n  throws.\n","packages/lwc-plugin-session-highlighting/README.md":"# Session highlighting\n\nA [series primitive](https://tradingview.github.io/lightweight-charts/docs/plugins/series-primitives)\nthat shades the background behind each bar of a series. You give it a\nfunction from a bar's time to a color, and every bar of the attached series\ngets a full-height column in that color, as wide as the bar itself. The\ncolumns follow the series as the chart scrolls and zooms.\n\nUse it to show where one trading session ends and the next begins, to tint\npre-market and after-hours bars, to mark weekends or holidays, or to shade any\nother time-based condition behind the data.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-session-highlighting\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart, CandlestickSeries } from 'lightweight-charts';\nimport { SessionHighlighting } from '@tradingview/lwc-plugin-session-highlighting';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(CandlestickSeries);\nseries.setData(data);\n\nseries.attachPrimitive(new SessionHighlighting(time => {\n    const day = new Date(time * 1000).getUTCDay();\n    return day === 0 || day === 6 ? 'rgba(255, 152, 1, 0.2)' : '';\n}));\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-session-highlighting\": \"https://unpkg.com/@tradingview/lwc-plugin-session-highlighting/dist/session-highlighting.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart, CandlestickSeries } from 'lightweight-charts';\nimport { SessionHighlighting } from '@tradingview/lwc-plugin-session-highlighting';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(CandlestickSeries);\nseries.setData(data);\n\nseries.attachPrimitive(new SessionHighlighting(time => {\n    const day = new Date(time * 1000).getUTCDay();\n    return day === 0 || day === 6 ? 'rgba(255, 152, 1, 0.2)' : '';\n}));\n</script>\n```\n\n## Usage\n\n### The highlighter\n\nThe first constructor argument is the highlighter: a function which receives\na bar's time and returns a CSS color. Return an empty string for a bar that\nshould not be shaded. The time comes in whatever form your data uses, so for\nbusiness-day data check for an object:\n\n```js\nimport { isBusinessDay } from 'lightweight-charts';\n\nfunction toDate(time) {\n    if (isBusinessDay(time)) {\n        return new Date(Date.UTC(time.year, time.month - 1, time.day));\n    }\n    return typeof time === 'number' ? new Date(time * 1000) : new Date(time);\n}\n\nconst highlighter = time => {\n    const hour = toDate(time).getUTCHours();\n    if (hour < 9 || hour >= 16) {\n        return 'rgba(120, 123, 134, 0.15)'; // outside the main session\n    }\n    return '';\n};\n\nconst highlighting = new SessionHighlighting(highlighter);\nseries.attachPrimitive(highlighting);\n```\n\nThe highlighter is called once per bar when the series data is set, and once\nfor the last bar when `series.update()` appends or replaces it, so it can do\nreal work per call; `series.pop()` drops the popped bars without calling it.\nKeep it a function of the time alone: a historical update, which is\n`series.update(bar, true)`, re-asks it for the last bar rather than for the\nbar it changed, and one that turns a bar into whitespace, or whitespace into a\nbar, re-asks it for every bar. Translucent colors let the grid and the series show through; the shading\nis drawn behind both by default.\n\nTo remove the shading, detach it from the series:\n\n```js\nseries.detachPrimitive(highlighting);\n```\n\n### Changing the shading\n\n```js\nhighlighting.applyOptions({ zOrder: 'top', visible: false });\nhighlighting.setHighlighter(time => '#F0F3FA'); // recolors every bar\nhighlighting.options(); // the current options, with the defaults filled in\n```\n\n`applyOptions` merges: an option which is not passed, or is passed as\n`undefined`, is left unchanged.\n\n## Options\n\nOptions are passed as the second constructor argument, which is optional, as\nis every option in it. The type is `SessionHighlightingOptions`, and the\ndefaults are exported as `defaultOptions`.\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `visible` | `boolean` | `true` | Whether the shading is drawn at all. |\n| `zOrder` | `'bottom' \\| 'normal' \\| 'top'` | `'bottom'` | Layer the shading is drawn in. `'bottom'` puts it behind the grid and the series. |\n\n## Notes\n\n- Each column is exactly one bar wide, taken from the time scale's bar\n  spacing, so neighboring columns abut with no seams and no overlap at any\n  zoom level or device pixel ratio.\n- Only bars of the attached series are shaded. Whitespace items and gaps in\n  the data get no column, even where another series has a bar at that time.\n- The shading appears only in the pane the series is drawn in, never under\n  the price scales or the time scale. To shade a second pane, attach another\n  `SessionHighlighting` to a series in that pane.\n- Only the bars on screen are drawn, so the cost of a paint is bounded by the\n  width of the chart, not by the length of the history. An incremental\n  `series.update()` or `series.pop()` does read the series data once to find\n  out what changed, which is proportional to the number of bars.\n","packages/lwc-plugin-stacked-area-series/README.md":"# Stacked area series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series) that stacks several values per\ntime point into cumulative\nbands. Each value is drawn as an area on top of the previous one, with a line\nalong its upper edge. The top edge of the stack shows the total.\n\nUse it to show composition over time, when the parts and the whole matter at\nthe same time. Typical examples: portfolio allocation, revenue by segment,\ntraffic by source, or volume by venue.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-stacked-area-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createStackedAreaSeries } from '@tradingview/lwc-plugin-stacked-area-series';\n\nconst chart = createChart(document.getElementById('container'), {\n    rightPriceScale: { scaleMargins: { top: 0.05, bottom: 0.05 } },\n});\nconst series = createStackedAreaSeries(chart, {\n    colors: [\n        { line: '#2962FF', area: 'rgba(41, 98, 255, 0.2)' },\n        { line: '#F23645', area: 'rgba(242, 54, 69, 0.2)' },\n        { line: '#FF9800', area: 'rgba(255, 152, 0, 0.2)' },\n    ],\n    lineWidth: 2,\n});\n\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    { time: '2024-04-23', values: [14, 7, 6] },\n    { time: '2024-04-24', values: [11, 9, 4] },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-stacked-area-series\": \"https://unpkg.com/@tradingview/lwc-plugin-stacked-area-series/dist/stacked-area-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createStackedAreaSeries } from '@tradingview/lwc-plugin-stacked-area-series';\n\nconst chart = createChart(document.getElementById('container'), {\n    rightPriceScale: { scaleMargins: { top: 0.05, bottom: 0.05 } },\n});\nconst series = createStackedAreaSeries(chart, {\n    colors: [\n        { line: '#2962FF', area: 'rgba(41, 98, 255, 0.2)' },\n        { line: '#F23645', area: 'rgba(242, 54, 69, 0.2)' },\n        { line: '#FF9800', area: 'rgba(255, 152, 0, 0.2)' },\n    ],\n    lineWidth: 2,\n});\n\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    { time: '2024-04-23', values: [14, 7, 6] },\n    { time: '2024-04-24', values: [11, 9, 4] },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `createStackedAreaSeries`, then set data with a `values` array per\npoint. The array order is the stacking order: `values[0]` is the bottom band.\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createStackedAreaSeries } from '@tradingview/lwc-plugin-stacked-area-series';\n\nconst chart = createChart(document.getElementById('container'), {\n    rightPriceScale: { scaleMargins: { top: 0.05, bottom: 0.05 } },\n});\nconst series = createStackedAreaSeries(chart, {\n    colors: [\n        { line: '#2962FF', area: 'rgba(41, 98, 255, 0.2)' },\n        { line: '#F23645', area: 'rgba(242, 54, 69, 0.2)' },\n        { line: '#FF9800', area: 'rgba(255, 152, 0, 0.2)' },\n    ],\n    lineWidth: 2,\n});\n\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    { time: '2024-04-23', values: [14, 7, 6] },\n    { time: '2024-04-24', values: [11, 9, 4] },\n]);\n```\n\nEach data point is `{ time, values: number[] }`. Points do not have to carry\nthe same number of values: a point with fewer values is padded with zeroes, so\nits missing bands collapse onto the one below them. Points with an empty or\nmissing `values` array are treated as whitespace. The series' price line and\nlast-value label follow the stack total.\n\nValues are stacked from `base` (`0` by default): a positive value continues\naway from the base, a negative one comes back towards it and past it, so each\nband is a single ribbon between two lines and never folds over itself.\n\nA point may override the colors of its own bands:\n\n```js\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    {\n        time: '2024-04-23',\n        values: [14, 7, 6],\n        colors: [{ line: '#000000', area: 'rgba(0, 0, 0, 0.2)' }],\n    },\n]);\n```\n\nAn override applies to the piece of the band which starts at that point.\n\nOptions can be changed at runtime with `series.applyOptions({ ... })`.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `colors` | `StackedAreaColor[]` | five preset pairs (blue, red, orange, purple, teal); in each pair the area is the line color at 20% opacity | Appearance of each band, in stacking order. If there are more values than entries, the entries repeat. An empty array falls back to this default. |\n| `lineWidth` | `LineWidth` | `2` | Width of the band lines, in CSS pixels (`1`–`4`). |\n| `lineStyle` | `LineStyle` | `LineStyle.Solid` | Style of the band lines. |\n| `lineVisible` | `boolean` | `true` | Whether the band lines are drawn. |\n| `areaVisible` | `boolean` | `true` | Whether the bands are filled. |\n| `base` | `number` | `0` | Price the bands are stacked from. |\n| `lineType` | `'simple' \\| 'step' \\| 'curved'` | `'simple'` | How the points of a band are joined: straight lines, a value held until the next point, or a smooth curve. |\n| `gapHandling` | `'break' \\| 'bridge'` | `'break'` | Whether the bands stop at a whitespace gap and start again after it, or are drawn straight across it. |\n| `percent` | `boolean` | `false` | Scale every point so that its bands total 100 in absolute terms, giving a 100% stacked chart. |\n\nEach entry of `colors` is a `StackedAreaColor`, which may also override the\nseries-wide line options for that band:\n\n| Field | Type | Description |\n| --- | --- | --- |\n| `line` | `string` | Color of the line along the top of the band. |\n| `area` | `string` | Fill color of the band, or the top of its gradient when `areaBottom` is set. |\n| `areaBottom` | `string` (optional) | Bottom color of the band's gradient. |\n| `lineWidth` | `LineWidth` (optional) | Width of this band's line. |\n| `lineStyle` | `LineStyle` (optional) | Style of this band's line. |\n| `lineVisible` | `boolean` (optional) | Whether this band's line is drawn. |\n| `areaVisible` | `boolean` (optional) | Whether this band is filled. |\n\nPer-point overrides, on the data item:\n\n| Field | Type | Description |\n| --- | --- | --- |\n| `colors` | `StackedAreaPointColor[]` | `line`, `area` and `areaBottom` for each band at this point. Anything missing falls back to the series color. |\n\n## Notes\n\n- The price scale autoscales over the whole run of the stack, not just its\n  total, so a point containing negative values stays fully in view. The\n  outermost line sits exactly on the edge of the range; add a small\n  `scaleMargins` on the price scale (as in the example above) if you want\n  breathing room around it.\n- Autoscaling follows `percent` and `base`, so a 100% stack scales to\n  `base`…`base + 100` and not to the raw totals, and changing either option\n  rescales the series. This needs the current options at the moment the library\n  asks for the plot values, which only `createStackedAreaSeries` can provide: a\n  bare `new StackedAreaSeries()` added with `chart.addCustomSeries` autoscales\n  from the raw `values` measured from zero, and needs an\n  `autoscaleInfoProvider` of its own for `percent` or a non-zero `base`.\n- The factory retains explicit whitespace, and `gapHandling` decides whether\n  to break or bridge it. Timestamps from other series do not create gaps.\n- On `lightweight-charts` 5.2 and later the series reports the hovered band\n  through `hitTest` (the `objectId` is the index of the band) and dims the\n  other bands while one is hovered, and from 5.1 conflated points are merged\n  by summing each band. Older versions simply never call those hooks.\n\n### Explicit whitespace\n\nUse `createStackedAreaSeries` to retain whitespace passed through `setData` and\n`update`, including historical corrections. Other series' timestamps do not\nbreak the area. The low-level `StackedAreaSeries` view remains available, but\nwithout the factory's gap predicate it draws continuously: the host does not\nprovide whitespace to custom renderers.\n\nUnder time-scale conflation the area is drawn from buckets of several bars, and\na whitespace run narrower than one bucket cannot be resolved at that bar\nspacing: it is absorbed into the bucket rather than breaking the area at every\nbar. Zooming in past the conflation threshold shows the gap again.\n","packages/lwc-plugin-stacked-bars-series/README.md":"# Stacked bars series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series) that stacks several values per\ntime point into one column.\nEach value is a segment drawn on top of the previous one. The column height\nshows the total, and the segments show its composition.\n\nUse it to show composition over time in discrete periods, when a bar reads\nbetter than an area. Typical examples: volume by venue, revenue by product\nline, or trades by side.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-stacked-bars-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createStackedBarsSeries } from '@tradingview/lwc-plugin-stacked-bars-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createStackedBarsSeries(chart, {\n    colors: ['#2962FF', '#F23645', '#FF9800'],\n});\n\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    { time: '2024-04-23', values: [14, 7, 6] },\n    { time: '2024-04-24', values: [11, 9, 4] },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-stacked-bars-series\": \"https://unpkg.com/@tradingview/lwc-plugin-stacked-bars-series/dist/stacked-bars-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createStackedBarsSeries } from '@tradingview/lwc-plugin-stacked-bars-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createStackedBarsSeries(chart, {\n    colors: ['#2962FF', '#F23645', '#FF9800'],\n});\n\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    { time: '2024-04-23', values: [14, 7, 6] },\n    { time: '2024-04-24', values: [11, 9, 4] },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `addCustomSeries`, then set data with a `values` array per\npoint. The array order is the stacking order: `values[0]` is the bottom\nsegment.\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createStackedBarsSeries } from '@tradingview/lwc-plugin-stacked-bars-series';\n\nconst chart = createChart(document.getElementById('container'), {\n    timeScale: { minBarSpacing: 3 },\n});\nconst series = createStackedBarsSeries(chart, {\n    colors: ['#2962FF', '#F23645', '#FF9800'],\n});\n\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    { time: '2024-04-23', values: [14, 7, 6] },\n    { time: '2024-04-24', values: [11, 9, 4] },\n]);\n```\n\nEach data point is `{ time, values: number[] }`. Points with an empty or\nmissing `values` array are treated as whitespace. The series' price line and\nlast-value label follow the column total.\n\nValues are stacked from `base` (`0` by default): a positive value continues\naway from the base, a negative one comes back towards it and past it, so a\nmixed point stays contiguous and never overlaps. Values which are not finite\nare skipped without shifting the segments above them.\n\nA point may override the series colors for its own segments:\n\n```js\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    { time: '2024-04-23', values: [14, 7, 6], colors: ['#000000', undefined, '#BBBBBB'] },\n]);\n```\n\nOptions can be changed at runtime with `series.applyOptions({ ... })`.\n\n## Creating a series\n\nUse `createStackedBarsSeries(chart, options?, paneIndex?)`. It returns the\nnormal series API, with the plugin's data and options types preserved. The helper\nmakes scaling options available before the first `setData` and rebuilds plot\nvalues automatically when those options change through `series.applyOptions`.\nThis keeps autoscaling, last-value labels and crosshair values consistent. The\nhelper retains a shallow copy of the input data, including whitespace, and\nre-ingests it only when a scaling option changes. Streaming updates remain\nincremental.\n\nThe low-level `StackedBarsSeries` pane view remains available for integrations\nthat supply their own options getter to its constructor. Passing scaling options\nonly to `chart.addCustomSeries(new StackedBarsSeries(), options)` cannot make\nthem available before data ingestion on LWC 5.0; use the creation helper instead.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `colors` | `string[]` | `['#2962FF', '#E1575A', '#F28E2C', 'rgb(164, 89, 209)', 'rgb(27, 156, 133)']` | Fill color of each segment, in stacking order. If there are more values than colors, the colors repeat. An empty array falls back to this default. |\n| `base` | `number` | `0` | Price the columns are stacked from. |\n| `columnWidthMode` | `'histogram' \\| 'percent'` | `'histogram'` | `histogram` uses the width the built-in histogram series uses (as wide as the bar spacing allows, with a one pixel gap); `percent` uses a share of the bar spacing, given by `widthPercent`. |\n| `widthPercent` | `number` | `80` | Column width as a percentage of the bar spacing, `0`–`100`. Only used when `columnWidthMode` is `percent`. |\n| `segmentBorderColor` | `string` | `'#FFFFFF'` | Color of the border drawn inside the edge of every segment. |\n| `segmentBorderWidth` | `number` | `0` | Width of the segment border in pixels. `0` draws no border. |\n| `radius` | `number` | `0` | Corner radius of the two ends of a column, in pixels. |\n| `stackOrder` | `'normal' \\| 'reverse'` | `'normal'` | `normal` puts `values[0]` closest to the base; `reverse` puts the last value there. Colors stay with their value. |\n| `percent` | `boolean` | `false` | Scale every point so that its segments total 100 in absolute terms, giving a 100% stacked chart. |\n\nPer-point overrides, on the data item:\n\n| Field | Type | Description |\n| --- | --- | --- |\n| `colors` | `(string \\| undefined)[]` | Fill color of each segment of this point. A missing or `undefined` entry falls back to the series color for that segment. |\n\nThe standard `color` option is not used for the segments; it colors the\nseries' price line.\n\n## Notes\n\n- Column width follows the bar spacing by default, with a small gap between\n  columns. Set `timeScale.minBarSpacing` (as in the example above) to keep\n  columns from collapsing when the user zooms out, or switch to\n  `columnWidthMode: 'percent'` for a fixed share of the slot.\n- The price scale autoscales over the whole run of the stack, not just its\n  total, so a column containing negative values stays fully in view.\n- `createStackedBarsSeries` measures the same ordered, normalized, and offset\n  bands that are drawn. `percent`, nonzero `base`, and `stackOrder: 'reverse'`\n  therefore autoscale without a custom range provider.\n\n- On `lightweight-charts` 5.2 and later the series reports the hovered segment\n  through `hitTest` (the `objectId` is the index of the value within the point)\n  and dims the other segments while one is hovered, and from 5.1 conflated\n  points are merged by summing each band. Older versions simply never call\n  those hooks.\n","packages/lwc-plugin-user-price-lines/README.md":"# User price lines\n\nA [series primitive](https://tradingview.github.io/lightweight-charts/docs/plugins/series-primitives)\nthat lets the user add price lines to a series. When the pointer comes near\nthe right edge of the pane, a small button with a plus follows it up and down;\nclicking the button adds a price line at that price.\n\nUse it for levels the user marks by hand: support and resistance, entry and\nexit prices, or the price an alert should fire at.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-user-price-lines\n```\n\nThen import the plugin and attach it to a series:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { UserPriceLines } from '@tradingview/lwc-plugin-user-price-lines';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData([\n    { time: '2024-04-22', value: 101.2 },\n    { time: '2024-04-23', value: 102.8 },\n    { time: '2024-04-24', value: 100.9 },\n]);\n\nseries.attachPrimitive(new UserPriceLines({ lineColor: '#F23645' }));\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-user-price-lines\": \"https://unpkg.com/@tradingview/lwc-plugin-user-price-lines/dist/user-price-lines.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { UserPriceLines } from '@tradingview/lwc-plugin-user-price-lines';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData([\n    { time: '2024-04-22', value: 101.2 },\n    { time: '2024-04-23', value: 102.8 },\n    { time: '2024-04-24', value: 100.9 },\n]);\n\nseries.attachPrimitive(new UserPriceLines({ lineColor: '#F23645' }));\n</script>\n```\n\n## Usage\n\nAttach the plugin to the series the lines belong to. The button shows near\nthe right edge of that series' pane, wherever the series has a price, and a\nclick on it adds a price line to the series at the price under the pointer:\n\n```js\nconst lines = new UserPriceLines({ maxLines: 3 });\nseries.attachPrimitive(lines);\n\n// Lines can be added and removed from code as well.\nconst line = lines.addLine(102.5);\nlines.lineAdded().subscribe(added => console.log('added', added.options().price));\nlines.lineRemoved().subscribe(removed => console.log('removed', removed.options().price));\nlines.removeLine(line);\nlines.removeAll();\n```\n\n- `addLine(price)` adds a line with the line options and returns its\n  `IPriceLine`. A click on the button does the same. At `maxLines`, the\n  oldest line is removed first. It throws unless the plugin is attached to a\n  series that is on a chart.\n- `removeLine(line)` removes a line the plugin added and returns `true`; a\n  line it did not add, or one already removed, is left alone and gives\n  `false`. `removeAll()` removes every line the plugin added.\n- `lines()` lists the lines the plugin added that are still on the series,\n  oldest first. A line removed with `series.removePriceLine` is left out.\n- `lineAdded()` and `lineRemoved()` fire with each line the plugin adds and\n  removes. Lines are removed by `removeLine` and `removeAll`, to stay within\n  `maxLines`, and when the plugin is detached.\n\nDetaching the plugin, `series.detachPrimitive(lines)`, stops it listening to\nthe pointer, removes the lines it added and puts the crosshair mode back.\nAttaching it to another series while it is attached moves it there: it is\ndetached from the first series, which removes its lines there.\n`chart.removeSeries` takes the lines away with the series, and the plugin\nlets go of the chart on the next pointer event.\n\n### Crosshair mode\n\nThe button follows the pointer, so the plugin sets the chart's crosshair to\n`CrosshairMode.Normal` while it is attached: in the `Magnet` modes the\ncrosshair would jump between the series' values instead. The mode the chart\nhad is put back when the plugin is detached, unless something changed it\nfrom `Normal` in the meantime, in which case it is left as it is. Pass\n`setCrosshairMode: false` to leave the crosshair mode alone.\n\n### Several instances\n\nWithin a pane, only the instance attached last shows its button and adds\nlines, so a click never adds a line to two series at once. When it is\ndetached, the one attached before it takes over.\n\n## Options\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `lineColor` | `string` | `'#000000'` | Color of the price lines the plugin adds. |\n| `lineWidth` | `LineWidth` | `1` | Width of the price lines, in CSS pixels. |\n| `lineStyle` | `LineStyle` | `LineStyle.Dashed` | Style of the price lines. |\n| `axisLabelVisible` | `boolean` | `true` | Whether the price lines show their price on the price scale. |\n| `buttonColor` | `string` | `''` | Background of the add button. An empty string uses the background of the crosshair's horizontal line label. |\n| `hoverColor` | `string` | `'#777777'` | Background of the add button while the pointer is over it. |\n| `maxLines` | `number` | `Infinity` | The most lines the plugin keeps; adding one more removes the oldest. Rounded down and at least `1`; a value that is not a number means no limit. |\n| `setCrosshairMode` | `boolean` | `true` | Whether the plugin sets the crosshair to `Normal` mode while attached. |\n\nChange them with `lines.applyOptions({ ... })`; `lines.options()` returns\nthem all. The line options apply to the lines added afterwards. Lowering\n`maxLines` removes the oldest lines over the new limit.\n\n## Notes\n\n- The button is reported to the chart's hit test, so the cursor becomes a\n  pointer over it and pointer events report `ADD_BUTTON_ID` as the hovered\n  object (`param.hoveredObjectId`).\n- The button only comes up for the pointer. A crosshair placed with\n  `chart.setCrosshairPosition`, as charts kept in sync do, never shows it.\n- A tap on a touch screen moves no crosshair, so no button is shown and a tap\n  at the edge adds nothing; after a long press has brought the button up,\n  only a tap on the button adds a line. The chart reports no click after a\n  drag, so a drag that starts on the button adds nothing either.\n- The button always sits at the right edge of the pane, which is where the\n  pointer leaves the pane for the right price scale. Clicking a line to remove\n  it, placing the button by the left price scale and rounding prices to the\n  series' price step are not part of this release.\n\n## Migrating from `plugin-examples`\n\nIn the `plugin-examples` collection the plugin was created with\n`new UserPriceLines(chart, series, options)` and taken off with `remove()`.\nBoth still work and are deprecated: pass the options only and attach the\nplugin with `series.attachPrimitive`, and detach it with\n`series.detachPrimitive`. `remove()` now removes the lines the plugin added,\nas detaching does, and does not throw once the chart or the series is gone.\n\nThe options are renamed: `color`, the color of the lines, is `lineColor`, and\n`limitToOne`, which was never read, is `maxLines` (`maxLines: 1` keeps one\nline). The lines can now be removed, and the plugin no longer adds lines for\nclicks in other panes or for two instances at once.\n","packages/lwc-plugin-vertical-line/README.md":"# Vertical line\n\nA [series primitive](https://tradingview.github.io/lightweight-charts/docs/plugins/series-primitives)\nthat draws a full-height vertical line at a given time, with an optional label\non the time axis. You attach the line to a series. The line then follows that\nseries' time scale as the user scrolls and zooms.\n\nUse it to mark a moment in time that matters on your chart:\n\n- an event, such as earnings, a news release, or a dividend date;\n- a trade, such as entry and exit points, with a label like `Buy` or `Sell`;\n- a boundary, such as a session open or close, the start of a backtest, or\n  the current bar.\n\nBecause each line is a separate primitive, you can place as many as you need\non the same series, each with its own color, width, and label.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-vertical-line\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { VerticalLine } from '@tradingview/lwc-plugin-vertical-line';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(data);\n\nseries.attachPrimitive(new VerticalLine('2024-04-25'));\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-vertical-line\": \"https://unpkg.com/@tradingview/lwc-plugin-vertical-line/dist/vertical-line.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { VerticalLine } from '@tradingview/lwc-plugin-vertical-line';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(data);\n\nseries.attachPrimitive(new VerticalLine('2024-04-25'));\n</script>\n```\n\n## Usage\n\nCreate a line for a time that exists in your series data, then attach it to that series:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { VerticalLine } from '@tradingview/lwc-plugin-vertical-line';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(data);\n\nconst earningsLine = new VerticalLine('2024-04-25', {\n    color: '#2962FF',\n    width: 2,\n    showLabel: true,\n    labelText: 'Earnings',\n    labelBackgroundColor: '#2962FF',\n    labelTextColor: '#FFFFFF',\n});\nseries.attachPrimitive(earningsLine);\n```\n\nTo remove a line, detach it from the series:\n\n```js\nseries.detachPrimitive(earningsLine);\n```\n\nThe `time` argument accepts any [`Time`](https://tradingview.github.io/lightweight-charts/docs/api/type-aliases/Time)\nvalue supported by the chart (a business day string, a `BusinessDay` object,\nor a UTC timestamp) — use the same format as your series data.\n\nChange a line after it has been created with `applyOptions` and `setTime`:\n\n```js\nearningsLine.applyOptions({ color: '#F23645', labelText: 'Moved' });\nearningsLine.setTime('2024-05-02');\n```\n\n## Options\n\nAll options are optional. Pass them as the second constructor argument.\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `color` | `string` | `'green'` | Color of the line. |\n| `width` | `number` | `3` | Width of the line, in CSS pixels. |\n| `lineStyle` | `LineStyle` | `LineStyle.Solid` | Dash pattern of the line. |\n| `lineVisible` | `boolean` | `true` | Draw the line itself. Set it to `false` for a time-axis label with no line. |\n| `showLabel` | `boolean` | `false` | Show a label at the line's position on the time axis. |\n| `tickVisible` | `boolean` | `true` | Draw the tick mark of the time-axis label. |\n| `labelText` | `string` | `''` | Text of the time-axis label. Overrides `labelFormatter` when set. |\n| `labelFormatter` | `(time) => string` | — | Builds the label text from the line's time. Used only while `labelText` is empty; the default formats the time the way the chart's own time axis does. |\n| `labelBackgroundColor` | `string` | `'green'` | Background color of the label. |\n| `labelTextColor` | `string` | `'white'` | Text color of the label. |\n| `zOrder` | `'bottom' \\| 'normal' \\| 'top'` | `'normal'` | Layer the line is drawn in. |\n| `snap` | `'exact' \\| 'nearest'` | `'exact'` | `'exact'` draws the line only at a time which is a bar of the chart; `'nearest'` places it on the closest bar instead. |\n| `draggable` | `boolean` | `false` | Lets the user drag the line along the time scale. |\n| `hitTestTolerance` | `number` | `4` | Distance from the line, in CSS pixels, still counted as a hit. |\n| `id` | `string` | `'vertical-line'` | Reported as `externalId` for a hit on this line. |\n| `badge` | `Partial<VerticalLineBadgeOptions> & { text }` | — | Text badge drawn on the line. Omit it for no badge. |\n\nThe defaults are exported as `defaultOptions`.\n\n### Badge\n\nA badge is a short caption drawn on the line itself, for text that should stay\nnext to the line rather than sit on the time axis:\n\n```js\nseries.attachPrimitive(new VerticalLine('2024-04-25', {\n    badge: { text: 'Earnings', backgroundColor: '#2962FF' },\n}));\n```\n\n| Badge option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `text` | `string` | `''` | Text of the badge. An empty string hides it. |\n| `color` | `string` | `'white'` | Text color. |\n| `backgroundColor` | `string` | `'green'` | Background color. |\n| `borderColor` | `string` | — | Border color. Leave it out for no border. |\n| `borderWidth` | `number` | `0` | Border width, in CSS pixels. |\n| `borderRadius` | `number` | `4` | Corner radius of the background, in CSS pixels. |\n| `font` | `string` | system sans-serif, 12px | Font, as a CSS `font` shorthand. |\n| `padding` | `number` | `4` | Space between the text and the edge of the background. |\n| `margin` | `number` | `4` | Distance from the line and from the pane edge. |\n| `verticalAlign` | `'top' \\| 'middle' \\| 'bottom'` | `'top'` | Where along the line the badge sits. |\n| `horizontalAlign` | `'left' \\| 'right'` | `'right'` | Which side of the line the badge sits on. |\n\nThe badge defaults are exported as `defaultBadgeOptions`.\n\n### Dragging\n\nWith `draggable: true` the line can be moved along the time scale with the\npointer, and `timeChanged()` reports every new time:\n\n```js\nconst line = new VerticalLine('2024-04-25', { draggable: true });\nseries.attachPrimitive(line);\nline.timeChanged().subscribe(time => console.log(time));\n```\n\nDragging suspends the chart's own scroll and scale handling for the duration of\nthe gesture, so the chart does not pan under the pointer. Only one line per\nchart holds that suspension at a time: where two draggable lines overlap, the\none attached first takes the gesture and the other ignores it, so the chart's\noptions are restored exactly once. Ownership is tracked per loaded copy of this\nmodule, so two bundles of the plugin on the same page each track their own\nowner; load it once per page if you attach overlapping draggable lines.\n\n## Notes\n\n- With the default `snap: 'exact'` the line is drawn only when its time is a\n  bar of the chart's time scale; a time between bars or outside the data draws\n  nothing, and its time-axis label is hidden with it. Use `snap: 'nearest'` to\n  place the line on the closest bar instead.\n- The line spans the full height of the pane the series belongs to. To mark a\n  time across several panes, attach a line to a series in each pane.\n- The label is rendered by the chart's time axis, so it inherits the axis font\n  and is hidden together with the axis if `timeScale.visible` is `false`.\n- `VertLine` and `VertLineOptions` are still exported, as deprecated aliases of\n  `VerticalLine` and `VerticalLineOptions`, and the old\n  `new VertLine(chart, series, time, options)` form of the constructor still\n  works: the chart and the series arguments are ignored. Both are kept for\n  compatibility and will be removed in a future major version.\n","packages/lwc-toolkit/README.md":"# @tradingview/lwc-toolkit\n\nHelpers for authoring [Lightweight Charts™](https://www.tradingview.com/lightweight-charts/)\nplugins — the pixel-arithmetic, subscription and base-class pieces that every\nplugin ends up needing, so they do not have to be copied into each project.\n\nRequires `lightweight-charts` 5.0 or later as a peer dependency.\n\n```shell\nnpm install --save-dev @tradingview/lwc-toolkit\n```\n\nA dev dependency is usually the right choice: a plugin bundles the handful of\nhelpers it uses into its own output, so the people installing that plugin never\nneed this package themselves. See [Bundling](#bundling) below.\n\n## Usage\n\nEvery helper is imported from its own sub-path. There is no barrel entry point,\nso `@tradingview/lwc-toolkit` on its own does not resolve — import the module\nyou want:\n\n```js\nimport { PluginBase } from '@tradingview/lwc-toolkit/plugin-base';\nimport { positionsBox, positionsLine } from '@tradingview/lwc-toolkit/dimensions/positions';\n```\n\nSub-path exports need a modern module resolver. Set `moduleResolution` to\n`\"bundler\"`, `\"node16\"` or `\"nodenext\"` in `tsconfig.json`; the legacy `\"node\"`\nsetting ignores the `exports` field and will report the imports as unresolved.\n\n## Modules\n\n| Sub-path | Provides |\n| --- | --- |\n| `assertions` | `ensureDefined`, `ensureNotNull` — narrow a value or throw |\n| `axis-label-view` | `AxisLabelView`, `AxisLabelSource` — a price- or time-axis label over a source that may have no coordinate yet |\n| `canvas/markers` | `beginMarker`, `beginMarkerOffset`, `traceMarker`, `traceMarkerOffset`, `markerDistance`, `markerVertices`, `segmentDistance`, `MarkerShape` — circle, square, diamond and triangle markers, one per path (`begin*`, which start the path) or many to a path (`trace*`), the ring around them, and the distance to them as drawn, for hit testing, all from the same vertices |\n| `canvas/round-rect` | `drawRoundRect`, `drawRoundRectWithBorder`, `clampCornerRadius`, `CornerRadii` — rounded rectangles with an inset border |\n| `chart/compat` | `supportsSeriesOrder` — runtime checks for series methods newer than 5.0 (`setSeriesOrder`, 5.0.6) that narrow the series, so that a plugin calls them where the host has them and still supports 5.0 |\n| `chart/interaction-flags` | `canUserMoveTimeScale`, `TIME_SCALE_MOVE_FLAGS` — whether `handleScroll` / `handleScale` let the user scroll or zoom the time scale, by the library's own rule |\n| `chart/lifecycle` | `isChartRemoved`, `isSeriesAttached` — side-effect-free checks for a removed chart and a series taken off the chart |\n| `chart/time-axis-labels` | `timeAxisLabelFont`, `tickMarkPixelsPerCharacter`, `tickMarkMaxLabelWidth`, `tickMarkCharactersForWidth` — the time axis' label font, and `tickMarkMaxCharacterLength` to pixels and back |\n| `closest-index` | `ClosestTimeIndexFinder` — cached binary search for the first index at or after (or last at or before) a time |\n| `custom-series/compat` | `CustomSeriesHitTestResult`, `ConflationContext` — types only: the library's hit test result (5.2) and conflation context (5.1), so a plugin can implement `hitTest` and `conflationReducer` and still support 5.0 |\n| `custom-series/hit-test` | `distanceToRange`, `seriesHitTestTolerance`, `nearestBar`, `nearestVerticalRange`, `createHitTestDataCache` — a renderer's `hitTest`: the series' tolerance, the visible bar nearest the pointer within it by any distance or, for bars that span a vertical range, by the distance to their box, and one `hitTestData` object per hovered item |\n| `custom-series/line-paths` | `buildLinePath`, `buildStepLinePath`, `areaBetween`, `strokeStyledPolyline` — polylines (straight or stepped), the band between two lines, and a line whose style, dash pattern included, changes along its length |\n| `custom-series/options-aware-series` | `createOptionsAwareSeries`, `createWhitespaceSeries`, `OptionsAwareSeries` — retain accepted input, bind price-value builders to current options and refresh stored values when scaling options change |\n| `custom-series/renderer-base` | `CustomSeriesRendererBase`, `CustomSeriesDrawArgs` — a custom series renderer with the data and visible-range guards done, leaving `drawImpl`. A renderer's `hitTest` must return the same `hitTestData` object while the same item stays hovered |\n| `custom-series/stacking` | `cumulativeSum`, `stackLevels`, `stackedPlotValues` — running totals, the band boundaries of a stack drawn from a base, and the autoscale values of a stack that may contain negatives |\n| `custom-series/visible-bars` | `forEachVisibleBar`, `mapVisibleBars`, `extendRange`, `visibleSegments`, `whitespaceGapCheck`, `AcceptedInput`, `barCoordinate`, `getConflationFactor`, `effectiveBarSpacing` — iterate the visible bars only, reach the pane edge, split at whitespace gaps wide enough to see at the current bar spacing, size a conflated bar to the slots it covers |\n| `delegate` | `Delegate`, `ISubscription` — a small subscribe/fire event primitive |\n| `dimensions/candles` | `candlestickWidth` — the body width the chart itself would use at a given bar spacing |\n| `dimensions/columns` | `calculateColumnPositions`, `calculateColumnPositionsInPlace` — evenly spaced column bars with consistent gaps |\n| `dimensions/common` | `BitmapPositionLength` — the `{ position, length }` pair the other dimension helpers return |\n| `dimensions/crosshair-width` | `gridAndCrosshairMediaWidth`, `gridAndCrosshairBitmapWidth` — line widths matching the grid and crosshair |\n| `dimensions/full-width` | `fullBarWidth`, `fullBarWidthAfter` — a bar spanning the whole slot, and one starting where its neighbor ended, so neighbors share an edge |\n| `dimensions/positions` | `positionsBox`, `positionsLine` — pixel-perfect boxes and lines from two coordinates |\n| `dom/media-query` | `subscribeMediaQuery`, `mediaQueryMatches`, `HIGH_CONTRAST_QUERIES`, `REDUCED_MOTION_QUERY` — shared, SSR-safe media query subscriptions |\n| `dom/pane-element` | `paneContentElement`, `chartTableElement` — the pane's canvas wrapper to append DOM overlays to, and the chart table |\n| `line-style` | `setLineStyle`, `getDashPattern`, `LineStyle` — the chart's dash patterns for renderers that receive no drawing utils; takes the library's `LineStyle` too |\n| `min-max-in-range` | `UpperLowerInRange` — cached upper/lower bounds over a range, for autoscaling |\n| `numbers` | `isFiniteNumber`, `finiteOr`, `nonNegativeOr`, `clampOpacity` — checks for numeric options, which the canvas otherwise ignores silently when they are `NaN` |\n| `options/merge` | `mergeOptions`, `cloneOptions`, `freezeOptions`, `isPlainObject`, `isUnsafeKey` — deep merge of partial options (a `null` reset to the default is opt-in), a copy that keeps functions, and frozen defaults |\n| `pane-plugin-base` | `PanePluginBase` — the pane-primitive counterpart of `PluginBase`: chart reference and `requestUpdate` hook |\n| `plugin-base` | `PluginBase` — a series-primitive base class holding the chart and series references and a `requestUpdate` hook |\n| `scheduling/coalesced-task` | `createCoalescedTask`, `CoalescedTask` — work run at most once per microtask (or frame), with `cancel()` for disposal |\n| `simple-clone` | `cloneReadonly` — deep clone that drops readonly-ness, through JSON: functions and `undefined` are dropped (`cloneOptions` in `options/merge` keeps them) |\n| `text/measure` | `textMeasureContext`, `createTextWidthCache` — a shared offscreen context to measure text with, and a bounded cache of widths |\n| `time` | `convertTime`, `convertTimeUTC`, `displayTime`, `formattedDateAndTime` — `Time` to local or UTC timestamps and display strings |\n\nThe dimension helpers exist because canvas drawing has to land on whole device\npixels to look sharp at every device pixel ratio. See\n[Pixel Perfect Rendering](https://tradingview.github.io/lightweight-charts/docs/plugins/pixel-perfect-rendering)\nfor the reasoning.\n\n## Bundling\n\nThe package is ESM only, ships no side effects (`\"sideEffects\": false`) and\nkeeps one module per file, so a bundler drops whatever a plugin does not\nreference. Since each plugin inlines only the helpers it actually uses — a few\nhundred bytes, typically — the usual arrangement is to keep this as a\n`devDependency` and let it disappear into the plugin's own bundle, rather than\nmaking every consumer of the plugin install it.\n\n`lightweight-charts` is a peer dependency and must stay external: the chart and\nseries objects are compared by identity, so a second copy of the library is a\nbug rather than an inefficiency.\n\n## Contributing\n\nThe sources live in the\n[Lightweight Charts™ repository](https://github.com/tradingview/lightweight-charts/tree/master/packages/lwc-toolkit).\n\n```shell\npnpm --filter @tradingview/lwc-toolkit build\n```\n\nOn a fresh checkout, build the library first (`pnpm build:prod` in the\nrepository root) — this package compiles against the `lightweight-charts`\ntypings from the root `dist/`.\n\nConsumers inside the repository use the compiled `dist/` output, so re-run the\nbuild after editing a helper. The `plugin-examples` scripts do this\nautomatically before building.\n\n## License\n\nApache-2.0. See [LICENSE](./LICENSE) and [NOTICE](./NOTICE).\n","plugin-examples/src/plugins/accessibility/README.md":"# Accessibility\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-accessibility`](https://www.npmjs.com/package/@tradingview/lwc-plugin-accessibility).\nIts source lives in [`packages/lwc-plugin-accessibility`](../../../../packages/lwc-plugin-accessibility),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/accessibility/` and `/plugin-previews/accessibility/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","plugin-examples/src/plugins/anchored-text/README.md":"# Anchored text\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-anchored-text`](https://www.npmjs.com/package/@tradingview/lwc-plugin-anchored-text).\nIts source lives in [`packages/lwc-plugin-anchored-text`](../../../../packages/lwc-plugin-anchored-text),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/anchored-text/` and `/plugin-previews/anchored-text/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","plugin-examples/src/plugins/background-shade-series/README.md":"# Background shade series\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-background-shade-series`](https://www.npmjs.com/package/@tradingview/lwc-plugin-background-shade-series).\nIts source lives in [`packages/lwc-plugin-background-shade-series`](../../../../packages/lwc-plugin-background-shade-series),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/background-shade-series/` and `/plugin-previews/background-shade-series/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","plugin-examples/src/plugins/box-whisker-series/README.md":"# Box and whisker series\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-box-whisker-series`](https://www.npmjs.com/package/@tradingview/lwc-plugin-box-whisker-series).\nIts source lives in [`packages/lwc-plugin-box-whisker-series`](../../../../packages/lwc-plugin-box-whisker-series),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/box-whisker-series/` and `/plugin-previews/box-whisker-series/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","plugin-examples/src/plugins/brushable-area-series/README.md":"# Brushable area series\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-brushable-area-series`](https://www.npmjs.com/package/@tradingview/lwc-plugin-brushable-area-series).\nIts source lives in [`packages/lwc-plugin-brushable-area-series`](../../../../packages/lwc-plugin-brushable-area-series),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/brushable-area-series/` and `/plugin-previews/brushable-area-series/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","plugin-examples/src/plugins/dual-range-histogram-series/README.md":"# Dual range histogram series\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-dual-range-histogram-series`](https://www.npmjs.com/package/@tradingview/lwc-plugin-dual-range-histogram-series).\nIts source lives in [`packages/lwc-plugin-dual-range-histogram-series`](../../../../packages/lwc-plugin-dual-range-histogram-series),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/dual-range-histogram-series/` and `/plugin-previews/dual-range-histogram-series/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","plugin-examples/src/plugins/grouped-bars-series/README.md":"# Grouped bars series\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-grouped-bars-series`](https://www.npmjs.com/package/@tradingview/lwc-plugin-grouped-bars-series).\nIts source lives in [`packages/lwc-plugin-grouped-bars-series`](../../../../packages/lwc-plugin-grouped-bars-series),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/grouped-bars-series/` and `/plugin-previews/grouped-bars-series/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","plugin-examples/src/plugins/heatmap-series/README.md":"# Heatmap series\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-heatmap-series`](https://www.npmjs.com/package/@tradingview/lwc-plugin-heatmap-series).\nIts source lives in [`packages/lwc-plugin-heatmap-series`](../../../../packages/lwc-plugin-heatmap-series),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/heatmap-series/` and `/plugin-previews/heatmap-series/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working. `example/example2.html`, the old\nsecond example, redirects to the same demo, which now holds both data sets.\n","plugin-examples/src/plugins/hlc-area-series/README.md":"# HLC area series\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-hlc-area-series`](https://www.npmjs.com/package/@tradingview/lwc-plugin-hlc-area-series).\nIts source lives in [`packages/lwc-plugin-hlc-area-series`](../../../../packages/lwc-plugin-hlc-area-series),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/hlc-area-series/` and `/plugin-previews/hlc-area-series/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","plugin-examples/src/plugins/image-watermark/README.md":"# Image watermark\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-image-watermark`](https://www.npmjs.com/package/@tradingview/lwc-plugin-image-watermark).\nIts source lives in [`packages/lwc-plugin-image-watermark`](../../../../packages/lwc-plugin-image-watermark),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/image-watermark/` and `/plugin-previews/image-watermark/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","plugin-examples/src/plugins/lollipop-series/README.md":"# Lollipop series\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-lollipop-series`](https://www.npmjs.com/package/@tradingview/lwc-plugin-lollipop-series).\nIts source lives in [`packages/lwc-plugin-lollipop-series`](../../../../packages/lwc-plugin-lollipop-series),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/lollipop-series/` and `/plugin-previews/lollipop-series/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","plugin-examples/src/plugins/pretty-histogram-series/README.md":"# Pretty histogram series\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-pretty-histogram-series`](https://www.npmjs.com/package/@tradingview/lwc-plugin-pretty-histogram-series).\nIts source lives in [`packages/lwc-plugin-pretty-histogram-series`](../../../../packages/lwc-plugin-pretty-histogram-series),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/pretty-histogram-series/` and `/plugin-previews/pretty-histogram-series/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","plugin-examples/src/plugins/rounded-candles-series/README.md":"# Rounded candles series\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-rounded-candles-series`](https://www.npmjs.com/package/@tradingview/lwc-plugin-rounded-candles-series).\nIts source lives in [`packages/lwc-plugin-rounded-candles-series`](../../../../packages/lwc-plugin-rounded-candles-series),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/rounded-candles-series/` and `/plugin-previews/rounded-candles-series/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","plugin-examples/src/plugins/session-highlighting/README.md":"<!-- Skill available on-demand via /api/skills/tradingview/lightweight-charts?path=plugin-examples%2Fsrc%2Fplugins%2Fsession-highlighting%2FREADME.md -->","plugin-examples/src/plugins/stacked-area-series/README.md":"<!-- Skill available on-demand via /api/skills/tradingview/lightweight-charts?path=plugin-examples%2Fsrc%2Fplugins%2Fstacked-area-series%2FREADME.md -->","plugin-examples/src/plugins/stacked-bars-series/README.md":"<!-- Skill available on-demand via /api/skills/tradingview/lightweight-charts?path=plugin-examples%2Fsrc%2Fplugins%2Fstacked-bars-series%2FREADME.md -->","plugin-examples/src/plugins/user-price-lines/README.md":"<!-- Skill available on-demand via /api/skills/tradingview/lightweight-charts?path=plugin-examples%2Fsrc%2Fplugins%2Fuser-price-lines%2FREADME.md -->","plugin-examples/src/plugins/vertical-line/README.md":"<!-- Skill available on-demand via /api/skills/tradingview/lightweight-charts?path=plugin-examples%2Fsrc%2Fplugins%2Fvertical-line%2FREADME.md -->","website/docs/plugins/canvas-rendering-target.md":"---\nsidebar_label: Canvas rendering target\ntitle: Canvas rendering target\nsidebar_position: 4\n---\n\nThe renderer functions of a plugin — whether it is a custom series or a\nprimitive — receive a `CanvasRenderingTarget2D` target to execute their\ndrawing logic on, using the browser's\n[2D Canvas API](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D).\n`CanvasRenderingTarget2D` comes from the\n[Fancy Canvas](https://github.com/tradingview/fancy-canvas) library; its\ndefinition can be viewed in\n[canvas-rendering-target.d.ts](https://unpkg.com/fancy-canvas/canvas-rendering-target.d.ts)\nwithin the published\n[TypeScript declarations](https://www.npmjs.com/package/fancy-canvas?activeTab=code).\n\n## Using CanvasRenderingTarget2D\n\n`CanvasRenderingTarget2D` provides two rendering scopes which you can use:\n\n- `useMediaCoordinateSpace`\n- `useBitmapCoordinateSpace`\n\n## Difference between bitmap and media\n\nBitmap sizing represents the actual physical pixels on the device's screen,\nwhile media sizing represents the size of a pixel as seen by the operating\nsystem and the browser. The number of physical pixels used to render one media\npixel is referred to as the device pixel ratio.\n\nBitmap sizing gives you more control over the drawn image and lets you keep\nthe graphics crisp and pixel perfect; the cost is that the code multiplies\ncoordinates by the pixel ratio throughout. When you don't need that precision,\nmedia sizing is easier: you don't have to think about the device pixel ratio\nat all.\n\n### Bitmap coordinate space\n\nUse `useBitmapCoordinateSpace` to draw with the actual device pixels as the\ncoordinate sizing. The provided scope (of type\n`BitmapCoordinatesRenderingScope`) contains readonly values for the following:\n\n- `context`\n  ([CanvasRenderingContext2D](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D)).\n  Context which can be used for rendering.\n- `horizontalPixelRatio` (number)\n- `verticalPixelRatio` (number)\n- `bitmapSize` (Size). Height and width of the canvas in bitmap dimensions.\n- `mediaSize` (Size). Height and width of the canvas in media dimensions.\n\n#### Bitmap coordinate space usage\n\n```js title='javascript'\n// target is an instance of CanvasRenderingTarget2D\ntarget.useBitmapCoordinateSpace(scope => {\n    // scope is an instance of BitmapCoordinatesRenderingScope\n\n    // example of drawing a filled rectangle which fills the canvas\n    scope.context.beginPath();\n    scope.context.rect(0, 0, scope.bitmapSize.width, scope.bitmapSize.height);\n    scope.context.fillStyle = 'rgba(100, 200, 50, 0.5)';\n    scope.context.fill();\n});\n```\n\n### Media coordinate space\n\nUse `useMediaCoordinateSpace` to draw with the media dimensions as the\ncoordinate sizing. The provided scope (of type\n`MediaCoordinatesRenderingScope`) contains readonly values for the following:\n\n- `context`\n  ([CanvasRenderingContext2D](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D)).\n  Context which can be used for rendering.\n- `mediaSize` (Size). Height and width of the canvas in media dimensions.\n\n#### Media coordinate space usage\n\n```js title='javascript'\n// target is an instance of CanvasRenderingTarget2D\ntarget.useMediaCoordinateSpace(scope => {\n    // scope is an instance of MediaCoordinatesRenderingScope\n\n    // example of drawing a filled rectangle which fills the canvas\n    scope.context.beginPath();\n    scope.context.rect(0, 0, scope.mediaSize.width, scope.mediaSize.height);\n    scope.context.fillStyle = 'rgba(100, 200, 50, 0.5)';\n    scope.context.fill();\n});\n```\n\n## General tips\n\nIt is recommended that rendering functions save and restore the canvas context\nbefore and after all their rendering logic, so the canvas state is the same as\nwhen the function was called. Wrap the logic in a `try…finally` block so the\ncontext is restored even when an error interrupts the drawing.\n\n**Note** that `useBitmapCoordinateSpace` and `useMediaCoordinateSpace`\nautomatically save and restore the canvas context for the logic defined within\nthem. This tip applies to your additional rendering functions called inside\n`use*CoordinateSpace`.\n\n```js title='javascript'\nfunction myRenderingFunction(scope) {\n    const ctx = scope.context;\n\n    // save the current state of the context to the stack\n    ctx.save();\n\n    try {\n        // example code\n        scope.context.beginPath();\n        scope.context.rect(0, 0, scope.mediaSize.width, scope.mediaSize.height);\n        scope.context.fillStyle = 'rgba(100, 200, 50, 0.5)';\n        scope.context.fill();\n    } finally {\n        // restore the saved context from the stack\n        ctx.restore();\n    }\n}\n\ntarget.useMediaCoordinateSpace(scope => {\n    myRenderingFunction(scope);\n    myOtherRenderingFunction(scope);\n    /* ... */\n});\n```\n","website/docs/plugins/custom_series.md":"---\nsidebar_label: Custom series\ntitle: Custom series\nsidebar_position: 3\n---\n\n**Custom series** let you define new types of series with your own data\nstructures and rendering logic. A custom series mirrors the API of the\nbuilt-in series: you add it to the chart once, then manage it with the same\nmethods you already use, such as\n[`setData`](../api/interfaces/ISeriesApi.md#setdata) and\n[`applyOptions`](../api/interfaces/ISeriesApi.md#applyoptions). For primitives\nthat decorate an existing series rather than define a new one, see\n[Series primitives](./series-primitives.mdx).\n\n## Adding a custom series\n\nA custom series is defined by a class implementing the\n[`ICustomSeriesPaneView`](../api/interfaces/ICustomSeriesPaneView.md)\ninterface. Pass an instance of it to the\n[`addCustomSeries`](../api/interfaces/IChartApi.md#addcustomseries) method,\nthen work with the returned series as with any other:\n\n```javascript title='javascript'\nclass MyCustomSeries {\n    /* Class implementing the ICustomSeriesPaneView interface */\n}\n\n// Create an instantiated custom series\nconst customSeriesInstance = new MyCustomSeries();\n\nconst chart = createChart(document.getElementById('container'));\nconst myCustomSeries = chart.addCustomSeries(customSeriesInstance, {\n    // Options for MyCustomSeries\n    customOption: 10,\n});\n\nconst data = [\n    { time: 1642425322, value: 123, customValue: 456 },\n    /* ... more data */\n];\n\nmyCustomSeries.setData(data);\n```\n\nTo remove a custom series, use the standard\n[`removeSeries`](../api/interfaces/IChartApi.md#removeseries) method:\n\n```javascript title='javascript'\nchart.removeSeries(myCustomSeries);\n```\n\nThese series are expected to have a uniform width for each data point, which\nensures that the chart maintains a consistent look and feel across all series\ntypes. The only restriction on the data structure is that it should extend the\n[`CustomData`](../api/interfaces/CustomData.md) interface (have a valid time\nproperty for each data point).\n\n## Defining a custom series\n\nThe [`ICustomSeriesPaneView`](../api/interfaces/ICustomSeriesPaneView.md)\ninterface defines the functionality and structure required of a custom series.\nIt includes the following methods and properties:\n\n### Renderer\n\nThe [`renderer`](../api/interfaces/ICustomSeriesPaneView.md#renderer) method\nreturns the renderer that draws the series data on the main chart pane. The\nrenderer must implement the\n[`ICustomSeriesPaneRenderer`](../api/interfaces/ICustomSeriesPaneRenderer.md)\ninterface.\n\nThe library calls the renderer's\n[`draw`](../api/interfaces/ICustomSeriesPaneRenderer.md#draw) method whenever\nthe chart needs to draw the series.\n\nThe [`PriceToCoordinateConverter`](../api/type-aliases/PriceToCoordinateConverter.md)\nprovided as the 2nd argument to the draw method is a convenience function for\nchanging prices into vertical coordinate values. It is provided since the\nseries' original data will most likely be defined in price values, and the\nrenderer needs to draw with coordinates. The values returned by the converter\nare in media coordinates (unscaled by `devicePixelRatio`).\nSee the [Canvas rendering target](./canvas-rendering-target.md) page for more\ndetails on the `CanvasRenderingTarget2D` provided to the `draw` method.\n\n### Update\n\nThe [`update`](../api/interfaces/ICustomSeriesPaneView.md#update) method is\ncalled with the latest data for the renderer to use during the next paint. It\nreceives two parameters: `data` (described below) and `seriesOptions`, a\nreference to the currently applied options for the series.\n\nThe [`PaneRendererCustomData`](../api/interfaces/PaneRendererCustomData.md)\ninterface provides the data that can be used within the renderer for drawing the\nseries data. It includes the following properties:\n\n- `bars`: list of all the series' items and their x coordinates. See\n  [`CustomBarItemData`](../api/interfaces/CustomBarItemData.md) for more details\n- `barSpacing`: spacing between consecutive bars.\n- `visibleRange`: the current visible range of items on the chart.\n\n### Hit testing\n\nThe renderer can implement the optional\n[`hitTest`](../api/interfaces/ICustomSeriesPaneRenderer.md#hittest) method to\nparticipate directly in hover and click resolution.\n\nReturn `null` when the cursor misses the custom geometry. Return a\n[`CustomSeriesHitTestResult`](../api/interfaces/CustomSeriesHitTestResult.md)\nwhen the cursor hits a custom object. The result can provide:\n\n- `distance`: geometric distance from the cursor to the hit\n- `type`: optional geometric classification such as `point`, `line`, `range`, or `custom`\n- `objectId`: optional object identifier that becomes `hoveredObjectId`\n- `cursorStyle`: optional cursor override\n- `hitTestData`: optional renderer-defined hover data passed back into `draw`\n\nThis hook lets the custom series participate in the same geometry-first\narbitration model as built-in series.\n\nThe `type` field is used for hover arbitration only. Public mouse events still\nreport `hoveredInfo.type` as `custom` for custom-series hits. Use `objectId`\nand `hoveredInfo.objectKind` to distinguish custom sub-objects.\n\n### Price value builder\n\nThe\n[`priceValueBuilder`](../api/interfaces/ICustomSeriesPaneView.md#pricevaluebuilder)\nmethod interprets a data item and returns an array of numbers: the equivalent\nhighest, lowest, and current price values for that item.\n\nThese price values are used by the chart to determine the auto-scaling (to\nensure the items are in view) and the crosshair and price line positions. The\nlargest and smallest values in the array will be used to specify the visible\nrange of the painted item, and the last value will be used for the crosshair and\nprice line position.\n\n### Whitespace\n\nThe\n[`isWhitespace`](../api/interfaces/ICustomSeriesPaneView.md#iswhitespace)\nmethod tells the library which data points should be treated as whitespace:\nreturn `true` for a whitespace item. Whitespace data points are not passed to\nthe renderer or to the `priceValueBuilder`.\n\n### Default options\n\nThe\n[`defaultOptions`](../api/interfaces/ICustomSeriesPaneView.md#defaultoptions)\nproperty provides the default options for the series. The user can override\nthem with the options argument of\n[`addCustomSeries`](../api/interfaces/IChartApi.md#addcustomseries), or later\nvia the [`applyOptions`](../api/interfaces/ISeriesApi.md#applyoptions) method\non the series.\n\n### Destroy\n\nThe [`destroy`](../api/interfaces/ICustomSeriesPaneView.md#destroy) method is\ncalled when the series is removed from the chart. Use it to clean up\neverything that could outlive the series and cause memory leaks: event\nlisteners, timers, and references to other objects.\n","website/docs/plugins/intro.md":"---\nsidebar_label: Overview\nsidebar_position: 0\n---\n\n# Plugin development\n\n**Plugins** let you extend Lightweight Charts™ with your own functionality: new\nseries types, drawing tools, indicators, watermarks, and other custom elements\nrendered as part of the chart. This section explains how plugins work and how\nto build your own.\n\n:::tip\n\nLooking for a ready-made plugin instead of building one? Browse the\n[plugin catalog](/plugins).\n\n:::\n\n## Choosing a plugin type\n\n| You want to build | Plugin type | Attach with |\n| --- | --- | --- |\n| A drawing tool, annotation, or overlay tied to a series and its scales | [Series primitive](./series-primitives.mdx) | [`ISeriesApi.attachPrimitive`](../api/interfaces/ISeriesApi.md#attachprimitive) |\n| A pane-wide element independent of any series, such as a watermark | [Pane primitive](./pane-primitives.md) | [`IPaneApi.attachPrimitive`](../api/interfaces/IPaneApi.md#attachprimitive) |\n| A new way to draw data: a series with its own data structure and rendering | [Custom series](./custom_series.md) | [`addCustomSeries`](../api/interfaces/IChartApi.md#addcustomseries) |\n\n:::tip\n\nIf your element visualizes its own data, build a custom series;\nif it decorates a series or reacts to its scales, build a series primitive;\nif it belongs to the pane as a whole, build a pane primitive.\nSeries primitives can also render on the price and time scales; pane primitives cannot.\n\n:::\n\n## Development workflow\n\n1. **Scaffold a project.** Run `npm create lwc-plugin@latest` — the\n   [create-lwc-plugin](https://www.npmjs.com/package/create-lwc-plugin)\n   package generates a ready-to-run project for the plugin type you choose.\n   The wizard also offers to install the plugin-authoring\n   [Agent Skill](../ai.md#ai-coding-assistants), which teaches AI coding\n   assistants how to write Lightweight Charts™ plugins.\n2. **Implement the plugin interface.** Follow the article for your plugin type\n   from the table above.\n3. **Render on the canvas.** Draw in the right coordinate space with\n   [Canvas rendering target](./canvas-rendering-target.md), and keep lines\n   crisp with the [Pixel perfect rendering](./pixel-perfect-rendering/index.md)\n   techniques.\n4. **Learn from working code.** The\n   [Plugin examples demo](https://tradingview.github.io/lightweight-charts/plugin-examples)\n   hosts interactive examples of heatmaps, alerts, watermarks, and tooltips;\n   their sources live in the\n   [`plugin-examples`](https://github.com/tradingview/lightweight-charts/tree/master/plugin-examples)\n   folder of the repository.\n","website/docs/plugins/pane-primitives.md":"---\nsidebar_label: Pane primitives\ntitle: Pane primitives\nsidebar_position: 2\n---\n\n**Pane primitives** are primitives attached to a chart pane rather than to a specific series.\nUse pane primitives for chart-wide elements that are not tied to any series' data, such as watermarks.\nThe library's built-in text and image watermarks are implemented this way.\nFor series-bound primitives, see [Series primitives](./series-primitives.mdx).\n\n## Attaching a primitive\n\nA pane primitive is a class implementing the\n[`IPanePrimitive`](../api/type-aliases/IPanePrimitive.md) interface.\nCreate an instance of your primitive and attach it to a pane with the\n[`attachPrimitive`](../api/interfaces/IPaneApi.md#attachprimitive) method:\n\n```javascript\nclass MyCustomPanePrimitive {\n    /* Class implementing the IPanePrimitive interface */\n}\n\n// Create an instantiated pane primitive\nconst myCustomPanePrimitive = new MyCustomPanePrimitive();\n\nconst chart = createChart(document.getElementById('container'));\n// Get the main pane\nconst mainPane = chart.panes()[0];\n\n// Attach the primitive to the pane\nmainPane.attachPrimitive(myCustomPanePrimitive);\n```\n\nTo remove the primitive from the pane, use the\n[`detachPrimitive`](../api/interfaces/IPaneApi.md#detachprimitive) method:\n\n```javascript\nmainPane.detachPrimitive(myCustomPanePrimitive);\n```\n\n## Key differences from series primitives\n\nPane primitives follow the same model as\n[series primitives](./series-primitives.mdx) — views that return renderers,\nthe `attached` / `detached` lifecycle, `updateAllViews`, and hit testing —\nwith four differences:\n\n- A pane primitive is attached to a pane, so\n  [`paneViews`](../api/interfaces/IPanePrimitiveBase.md#paneviews) is its only\n  view getter: it cannot draw on the price or time scales, or define axis\n  labels.\n- The `attached` method receives\n  [`{ chart, requestUpdate }`](../api/interfaces/PaneAttachedParameter.md)\n  without a series reference.\n- There is no `autoscaleInfo`: a pane primitive is not tied to a price scale.\n- Within each `zOrder` layer, pane primitives are drawn before the series and their primitives, so a pane primitive on `'normal'` sits under the series. Use `'top'` to draw it above the series.\n\n## Implementing a pane primitive\n\nThe `paneViews` method returns the views that draw on the pane. Each view must\nprovide a `renderer()` method returning the renderer that draws on the canvas:\n\n```javascript\nclass MyCustomPanePrimitive {\n    paneViews() {\n        return [\n            {\n                renderer: () => ({\n                    draw: target => {\n                        // Custom drawing logic here\n                    },\n                }),\n            },\n        ];\n    }\n\n    // Other methods as needed...\n}\n```\n","website/docs/plugins/pixel-perfect-rendering/index.md":"---\nsidebar_position: 0\nsidebar_label: Pixel perfect rendering\npagination_title: Pixel perfect rendering\ntitle: Best practices for pixel perfect rendering in canvas drawings\ndescription: Best practices for pixel perfect rendering in canvas drawings when creating plugins for Lightweight Charts\nkeywords:\n  - plugins\n  - extensions\n  - rendering\n  - canvas\n  - bitmap\n  - media\n  - pixels\npagination_prev: null\n---\n\nTo achieve crisp pixel perfect rendering for your plugins, it is recommended that the canvas drawings are created using bitmap coordinates. The difference between media and bitmap coordinate spaces is discussed on the [Canvas rendering target](../canvas-rendering-target.md) page. **Essentially, all drawing actions should use integer positions and dimensions when on the bitmap coordinate space.**\n\nTo ensure consistency between your plugins and the library's built-in logic for rendering points on the chart, use the following calculation functions.\n\n:::info\n\nVariable names containing `media` refer to positions / dimensions specified using the media coordinate space (such as the x and y coordinates provided by the library to the renderers), and names containing `bitmap` refer to positions / dimensions on the bitmap coordinate space (actual device screen pixels).\n\n:::\n\n## Centered shapes\n\nIf you need to draw a shape which is centered on a position (for example a price or x coordinate) and has a desired width then you could use the `positionsLine` function presented below. This can be used for drawing a horizontal line at a specific price, or a vertical line aligned with the center of a series point.\n\n```typescript\ninterface BitmapPositionLength {\n    /** coordinate for use with a bitmap rendering scope */\n    position: number;\n    /** length for use with a bitmap rendering scope */\n    length: number;\n}\n\nfunction centreOffset(lineBitmapWidth: number): number {\n    return Math.floor(lineBitmapWidth * 0.5);\n}\n\n/**\n * Calculates the bitmap position for an item with a desired length (height or width), and centered according to\n * a position coordinate defined in media sizing.\n * @param positionMedia - position coordinate for the bar (in media coordinates)\n * @param pixelRatio - pixel ratio. Either horizontal for x positions, or vertical for y positions\n * @param desiredWidthMedia - desired width (in media coordinates)\n * @returns Position of the start point and length dimension.\n */\nexport function positionsLine(\n    positionMedia: number,\n    pixelRatio: number,\n    desiredWidthMedia: number = 1,\n    widthIsBitmap?: boolean\n): BitmapPositionLength {\n    const scaledPosition = Math.round(pixelRatio * positionMedia);\n    const lineBitmapWidth = widthIsBitmap\n        ? desiredWidthMedia\n        : Math.round(desiredWidthMedia * pixelRatio);\n    const offset = centreOffset(lineBitmapWidth);\n    const position = scaledPosition - offset;\n    return { position, length: lineBitmapWidth };\n}\n```\n\n## Dual point shapes\n\nIf you need to draw a shape between two coordinates (for example, y coordinates for a high and low price) then you can use the `positionsBox` function as presented below.\n\n```typescript\n/**\n * Determines the bitmap position and length for a dimension of a shape to be drawn.\n * @param position1Media - media coordinate for the first point\n * @param position2Media - media coordinate for the second point\n * @param pixelRatio - pixel ratio for the corresponding axis (vertical or horizontal)\n * @returns Position of the start point and length dimension.\n */\nexport function positionsBox(\n    position1Media: number,\n    position2Media: number,\n    pixelRatio: number\n): BitmapPositionLength {\n    const scaledPosition1 = Math.round(pixelRatio * position1Media);\n    const scaledPosition2 = Math.round(pixelRatio * position2Media);\n    return {\n        position: Math.min(scaledPosition1, scaledPosition2),\n        length: Math.abs(scaledPosition2 - scaledPosition1) + 1,\n    };\n}\n```\n\n## Default widths\n\nRefer to the following pages for functions defining the default widths of shapes drawn by the library:\n\n- [Crosshair and grid lines](./widths/crosshair.md)\n- [Candlesticks](./widths/candlestick.md)\n- [Columns (histogram)](./widths/columns.md)\n- [Full bar width](./widths/full-bar-width.md)\n","website/docs/plugins/pixel-perfect-rendering/widths/candlestick.md":"---\nsidebar_position: 0\nsidebar_label: Candlesticks\npagination_title: Candlestick Widths\ntitle: Candlestick width calculations\ndescription: Describes the calculation for candlestick body widths\nkeywords:\n  - plugins\n  - extensions\n  - rendering\n  - canvas\n  - bitmap\n  - media\n  - pixels\n  - candlestick\n  - width\n---\n\n:::tip\n\nIt is recommend that you first read the [Pixel Perfect Rendering](../index.md) page.\n\n:::\n\nThe following functions can be used to get the calculated width that the library would use for a candlestick at a specific bar spacing and device pixel ratio.\n\nBelow a bar spacing of 4, the library will attempt to use as large a width as possible without the possibility of overlapping, while above 4 then the width will start to trend towards an 80% width of the available space.\n\n:::warning\n\nIt is expected that candles can overlap slightly at smaller bar spacings (more pronounced on lower resolution devices). This produces a more readable chart. If you need to ensure that bars can never overlap then rather use the widths for [Columns](./columns.md) or the [full bar width](./full-bar-width.md) calculation.\n\n:::\n\n```typescript\nfunction optimalCandlestickWidth(\n    barSpacing: number,\n    pixelRatio: number\n): number {\n    const barSpacingSpecialCaseFrom = 2.5;\n    const barSpacingSpecialCaseTo = 4;\n    const barSpacingSpecialCaseCoeff = 3;\n    if (barSpacing >= barSpacingSpecialCaseFrom && barSpacing <= barSpacingSpecialCaseTo) {\n        return Math.floor(barSpacingSpecialCaseCoeff * pixelRatio);\n    }\n    // coeff should be 1 on small barspacing and go to 0.8 while bar spacing grows\n    const barSpacingReducingCoeff = 0.2;\n    const coeff =\n        1 -\n        (barSpacingReducingCoeff *\n            Math.atan(\n                Math.max(barSpacingSpecialCaseTo, barSpacing) - barSpacingSpecialCaseTo\n            )) /\n            (Math.PI * 0.5);\n    const res = Math.floor(barSpacing * coeff * pixelRatio);\n    const scaledBarSpacing = Math.floor(barSpacing * pixelRatio);\n    const optimal = Math.min(res, scaledBarSpacing);\n    return Math.max(Math.floor(pixelRatio), optimal);\n}\n\n/**\n * Calculates the candlestick width that the library would use for the current\n * bar spacing.\n * @param barSpacing - bar spacing in media coordinates\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @returns The width (in bitmap coordinates) that the chart would use to draw a candle body\n */\nexport function candlestickWidth(\n    barSpacing: number,\n    horizontalPixelRatio: number\n): number {\n    let width = optimalCandlestickWidth(barSpacing, horizontalPixelRatio);\n    if (width >= 2) {\n        const wickWidth = Math.floor(horizontalPixelRatio);\n        if (wickWidth % 2 !== width % 2) {\n            width--;\n        }\n    }\n    return width;\n}\n```\n","website/docs/plugins/pixel-perfect-rendering/widths/columns.md":"---\nsidebar_position: 0\nsidebar_label: Columns\npagination_title: Histogram Column Widths\ntitle: Histogram column width calculations\ndescription: Describes the calculation for histogram column widths\nkeywords:\n  - plugins\n  - extensions\n  - rendering\n  - canvas\n  - bitmap\n  - media\n  - pixels\n  - histogram\n  - column\n  - width\n---\n\n:::tip\n\nIt is recommend that you first read the [Pixel Perfect Rendering](../index.md) page.\n\n:::\n\nThe following functions can be used to get the calculated width that the library would use for a histogram column at a specific bar spacing and device pixel ratio.\n\nYou can use the `calculateColumnPositionsInPlace` function instead of the `calculateColumnPositions` function to perform the calculation on an existing array of items without needing to create additional arrays (which is more efficient). It is recommended that you memoize the majority of the calculations below to improve the rendering performance.\n\n```typescript\nconst alignToMinimalWidthLimit = 4;\nconst showSpacingMinimalBarWidth = 1;\n\n/**\n * Spacing gap between columns.\n * @param barSpacingMedia - spacing between bars (media coordinate)\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @returns Spacing gap between columns (in Bitmap coordinates)\n */\nfunction columnSpacing(barSpacingMedia: number, horizontalPixelRatio: number) {\n    return Math.ceil(barSpacingMedia * horizontalPixelRatio) <=\n        showSpacingMinimalBarWidth\n        ? 0\n        : Math.max(1, Math.floor(horizontalPixelRatio));\n}\n\n/**\n * Desired width for columns. This may not be the final width because\n * it may be adjusted later to ensure all columns on screen have a\n * consistent width and gap.\n * @param barSpacingMedia - spacing between bars (media coordinate)\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @param spacing - Spacing gap between columns (in Bitmap coordinates). (optional, provide if you have already calculated it)\n * @returns Desired width for column bars (in Bitmap coordinates)\n */\nfunction desiredColumnWidth(\n    barSpacingMedia: number,\n    horizontalPixelRatio: number,\n    spacing?: number\n) {\n    return (\n        Math.round(barSpacingMedia * horizontalPixelRatio) -\n        (spacing ?? columnSpacing(barSpacingMedia, horizontalPixelRatio))\n    );\n}\n\ninterface ColumnCommon {\n    /** Spacing gap between columns */\n    spacing: number;\n    /** Shift columns left by one pixel */\n    shiftLeft: boolean;\n    /** Half width of a column */\n    columnHalfWidthBitmap: number;\n    /** horizontal pixel ratio */\n    horizontalPixelRatio: number;\n}\n\n/**\n * Calculated values which are common to all the columns on the screen, and\n * are required to calculate the individual positions.\n * @param barSpacingMedia - spacing between bars (media coordinate)\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @returns calculated values for subsequent column calculations\n */\nfunction columnCommon(\n    barSpacingMedia: number,\n    horizontalPixelRatio: number\n): ColumnCommon {\n    const spacing = columnSpacing(barSpacingMedia, horizontalPixelRatio);\n    const columnWidthBitmap = desiredColumnWidth(\n        barSpacingMedia,\n        horizontalPixelRatio,\n        spacing\n    );\n    const shiftLeft = columnWidthBitmap % 2 === 0;\n    const columnHalfWidthBitmap = (columnWidthBitmap - (shiftLeft ? 0 : 1)) / 2;\n    return {\n        spacing,\n        shiftLeft,\n        columnHalfWidthBitmap,\n        horizontalPixelRatio,\n    };\n}\n\ninterface ColumnPosition {\n    left: number;\n    right: number;\n    shiftLeft: boolean;\n}\n\n/**\n * Calculate the position for a column. These values can be later adjusted\n * by a second pass which corrects widths, and shifts columns.\n * @param xMedia - column x position (center) in media coordinates\n * @param columnData - precalculated common values (returned by `columnCommon`)\n * @param previousPosition - result from this function for the previous bar.\n * @returns initial column position\n */\nfunction calculateColumnPosition(\n    xMedia: number,\n    columnData: ColumnCommon,\n    previousPosition: ColumnPosition | undefined\n): ColumnPosition {\n    const xBitmapUnRounded = xMedia * columnData.horizontalPixelRatio;\n    const xBitmap = Math.round(xBitmapUnRounded);\n    const xPositions: ColumnPosition = {\n        left: xBitmap - columnData.columnHalfWidthBitmap,\n        right:\n            xBitmap +\n            columnData.columnHalfWidthBitmap -\n            (columnData.shiftLeft ? 1 : 0),\n        shiftLeft: xBitmap > xBitmapUnRounded,\n    };\n    const expectedAlignmentShift = columnData.spacing + 1;\n    if (previousPosition) {\n        if (xPositions.left - previousPosition.right !== expectedAlignmentShift) {\n            // need to adjust alignment\n            if (previousPosition.shiftLeft) {\n                previousPosition.right = xPositions.left - expectedAlignmentShift;\n            } else {\n                xPositions.left = previousPosition.right + expectedAlignmentShift;\n            }\n        }\n    }\n    return xPositions;\n}\n\nfunction fixPositionsAndReturnSmallestWidth(\n    positions: ColumnPosition[],\n    initialMinWidth: number\n): number {\n    return positions.reduce((smallest: number, position: ColumnPosition) => {\n        if (position.right < position.left) {\n            position.right = position.left;\n        }\n        const width = position.right - position.left + 1;\n        return Math.min(smallest, width);\n    }, initialMinWidth);\n}\n\nfunction fixAlignmentForNarrowColumns(\n    positions: ColumnPosition[],\n    minColumnWidth: number\n) {\n    return positions.map((position: ColumnPosition) => {\n        const width = position.right - position.left + 1;\n        if (width <= minColumnWidth) return position;\n        if (position.shiftLeft) {\n            position.right -= 1;\n        } else {\n            position.left += 1;\n        }\n        return position;\n    });\n}\n\n/**\n * Calculates the column positions and widths for the x positions.\n * This function creates a new array. You may get faster performance using the\n * `calculateColumnPositionsInPlace` function instead\n * @param xMediaPositions - x positions for the bars in media coordinates\n * @param barSpacingMedia - spacing between bars in media coordinates\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @returns Positions for the columns\n */\nexport function calculateColumnPositions(\n    xMediaPositions: number[],\n    barSpacingMedia: number,\n    horizontalPixelRatio: number\n): ColumnPosition[] {\n    const common = columnCommon(barSpacingMedia, horizontalPixelRatio);\n    const positions = new Array<ColumnPosition>(xMediaPositions.length);\n    let previous: ColumnPosition | undefined = undefined;\n    for (let i = 0; i < xMediaPositions.length; i++) {\n        positions[i] = calculateColumnPosition(\n            xMediaPositions[i],\n            common,\n            previous\n        );\n        previous = positions[i];\n    }\n    const initialMinWidth = Math.ceil(barSpacingMedia * horizontalPixelRatio);\n    const minColumnWidth = fixPositionsAndReturnSmallestWidth(\n        positions,\n        initialMinWidth\n    );\n    if (common.spacing > 0 && minColumnWidth < alignToMinimalWidthLimit) {\n        return fixAlignmentForNarrowColumns(positions, minColumnWidth);\n    }\n    return positions;\n}\n\nexport interface ColumnPositionItem {\n    x: number;\n    column?: ColumnPosition;\n}\n\n/**\n * Calculates the column positions and widths for bars using the existing\n * array of items.\n * @param items - bar items which include an `x` property, and will be mutated to contain a column property\n * @param barSpacingMedia - bar spacing in media coordinates\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @param startIndex - start index for visible bars within the items array\n * @param endIndex - end index for visible bars within the items array\n */\nexport function calculateColumnPositionsInPlace(\n    items: ColumnPositionItem[],\n    barSpacingMedia: number,\n    horizontalPixelRatio: number,\n    startIndex: number,\n    endIndex: number\n): void {\n    const common = columnCommon(barSpacingMedia, horizontalPixelRatio);\n    let previous: ColumnPosition | undefined = undefined;\n    for (let i = startIndex; i < Math.min(endIndex, items.length); i++) {\n        items[i].column = calculateColumnPosition(items[i].x, common, previous);\n        previous = items[i].column;\n    }\n    const minColumnWidth = (items as ColumnPositionItem[]).reduce(\n        (smallest: number, item: ColumnPositionItem, index: number) => {\n            if (!item.column || index < startIndex || index > endIndex)\n                return smallest;\n            if (item.column.right < item.column.left) {\n                item.column.right = item.column.left;\n            }\n            const width = item.column.right - item.column.left + 1;\n            return Math.min(smallest, width);\n        },\n        Math.ceil(barSpacingMedia * horizontalPixelRatio)\n    );\n    if (common.spacing > 0 && minColumnWidth < alignToMinimalWidthLimit) {\n        (items as ColumnPositionItem[]).forEach(\n            (item: ColumnPositionItem, index: number) => {\n                if (!item.column || index < startIndex || index > endIndex) return;\n                const width = item.column.right - item.column.left + 1;\n                if (width <= minColumnWidth) return item;\n                if (item.column.shiftLeft) {\n                    item.column.right -= 1;\n                } else {\n                    item.column.left += 1;\n                }\n                return item.column;\n            }\n        );\n    }\n}\n\n```\n","website/docs/plugins/pixel-perfect-rendering/widths/crosshair.md":"---\nsidebar_position: 0\nsidebar_label: Crosshair\npagination_title: Crosshair Widths\ntitle: Crosshair and grid line width calculations\ndescription: Describes the calculation for the crosshair line and grid line widths\nkeywords:\n  - plugins\n  - extensions\n  - rendering\n  - canvas\n  - bitmap\n  - media\n  - pixels\n  - crosshair\n  - grid\n  - line\n  - width\n---\n\n:::tip\n\nIt is recommend that you first read the [Pixel Perfect Rendering](../index.md) page.\n\n:::\n\nThe following functions can be used to get the calculated width that the library would use for a crosshair or grid line at a specific device pixel ratio.\n\n```typescript\n/**\n * Default grid / crosshair line width in Bitmap sizing\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @returns default grid / crosshair line width in Bitmap sizing\n */\nexport function gridAndCrosshairBitmapWidth(\n    horizontalPixelRatio: number\n): number {\n    return Math.max(1, Math.floor(horizontalPixelRatio));\n}\n\n/**\n * Default grid / crosshair line width in Media sizing\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @returns default grid / crosshair line width in Media sizing\n */\nexport function gridAndCrosshairMediaWidth(\n    horizontalPixelRatio: number\n): number {\n    return (\n        gridAndCrosshairBitmapWidth(horizontalPixelRatio) / horizontalPixelRatio\n    );\n}\n\n```\n","website/docs/plugins/pixel-perfect-rendering/widths/full-bar-width.md":"---\nsidebar_position: 0\nsidebar_label: Full bar width\npagination_title: Full Bar Width\ntitle: Full bar width calculations\ndescription: Describes the calculation for full bar widths\nkeywords:\n  - plugins\n  - extensions\n  - rendering\n  - canvas\n  - bitmap\n  - media\n  - pixels\n  - histogram\n  - column\n  - width\n---\n\n:::tip\n\nIt is recommend that you first read the [Pixel Perfect Rendering](../index.md) page.\n\n:::\n\nThe following functions can be used to get the calculated width that the library would use for the full width of a bar (data point) at a specific bar spacing and device pixel ratio. This can be used when you would like to use the full width available for each data point on the x axis, and don't want any gaps to be visible.\n\n```typescript\ninterface BitmapPositionLength {\n    /** coordinate for use with a bitmap rendering scope */\n    position: number;\n    /** length for use with a bitmap rendering scope */\n    length: number;\n}\n\n/**\n * Calculates the position and width which will completely full the space for the bar.\n * Useful if you want to draw something that will not have any gaps between surrounding bars.\n * @param xMedia - x coordinate of the bar defined in media sizing\n * @param halfBarSpacingMedia - half the width of the current barSpacing (un-rounded)\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @returns position and width which will completely full the space for the bar\n */\nexport function fullBarWidth(\n    xMedia: number,\n    halfBarSpacingMedia: number,\n    horizontalPixelRatio: number\n): BitmapPositionLength {\n    const fullWidthLeftMedia = xMedia - halfBarSpacingMedia;\n    const fullWidthRightMedia = xMedia + halfBarSpacingMedia;\n    const fullWidthLeftBitmap = Math.round(\n        fullWidthLeftMedia * horizontalPixelRatio\n    );\n    const fullWidthRightBitmap = Math.round(\n        fullWidthRightMedia * horizontalPixelRatio\n    );\n    const fullWidthBitmap = fullWidthRightBitmap - fullWidthLeftBitmap;\n    return {\n        position: fullWidthLeftBitmap,\n        length: fullWidthBitmap,\n    };\n}\n```\n","website/plugins/plugin-catalogue/README.md":"<!-- Skill available on-demand via /api/skills/tradingview/lightweight-charts?path=website%2Fplugins%2Fplugin-catalogue%2FREADME.md -->"},"files":{".github/skills/lightweight-charts-plugin-authoring/SKILL.md":"---\nname: lightweight-charts-plugin-authoring\ndescription: >-\n  Use when creating, extending, debugging or publishing a Lightweight Charts™\n  plugin — a custom series, a series primitive or a pane primitive — or when\n  turning a chart idea (\"I want the chart to show/draw X\") into a working\n  plugin. Covers choosing the plugin type, scaffolding with create-lwc-plugin,\n  building on @tradingview/lwc-toolkit instead of hand-rolled helpers, which of\n  the official plugin packages to read as the reference implementation,\n  where the docs are, and the autoscale, whitespace, visible-range, hit-test\n  and conflation mistakes every plugin author makes once. Reach for it whenever\n  the user mentions a custom series, primitive, renderer, drawing on the chart\n  canvas, lwc-plugin, plugin-examples, the toolkit, or the plugin catalog —\n  even if they never say the word \"plugin\".\n---\n\n# Writing a Lightweight Charts™ plugin\n\nThis skill is about *authoring* plugins. For questions about using the chart\nitself — series, scales, markers, data, wrappers — use the sibling\n`lightweight-charts` skill; the two are designed to be installed together.\n\n## Where you are, and where the sources are\n\nThis skill is used in two places, and the same question has a different\nanswer in each. Detect which before looking anything up:\n\n```sh\n# upstream checkout of lightweight-charts itself?\ntest -f pnpm-workspace.yaml && test -d packages/lwc-toolkit && echo upstream || echo \"a plugin project or other repo\"\n```\n\n**In a plugin project or any other repository** (the common case):\n\n| Looking for | Where |\n| --- | --- |\n| the library's API | `node_modules/lightweight-charts/dist/typings.d.ts`; if it is not installed, the released typings are hosted at `https://tradingview.github.io/lightweight-charts/lightweight-charts.d.ts` |\n| the toolkit's API | `node_modules/@tradingview/lwc-toolkit/dist/<module>.d.ts` — the `.d.ts` carry the doc comments, so they read as documentation |\n| a reference plugin's **source** | not in `node_modules` (packages ship `dist/` only). Fetch it from GitHub: `https://raw.githubusercontent.com/tradingview/lightweight-charts/master/packages/lwc-plugin-<name>/src/<file>`, or clone once and read locally: `git clone --depth 1 https://github.com/tradingview/lightweight-charts /tmp/lightweight-charts` |\n| the docs | every docs page is served as Markdown by appending `.md` to its URL, e.g. `https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series.md`. `https://tradingview.github.io/lightweight-charts/llms.txt` lists every page; `docs_map.md` beside it lists their headings too |\n\n**In the upstream checkout:** `dist/typings.d.ts` (or `src/`) for the library,\n`packages/lwc-toolkit/src/` for the toolkit, `packages/lwc-plugin-*/src/` for\nthe plugins, `website/docs/plugins/*.md` for the docs, `plugin-examples/` for\nthe proof-of-concept examples.\n\n```sh\n# what version is installed, and does the hook I am about to rely on exist in it?\nnode -p \"require('lightweight-charts/package.json').version\"\nrg -n \"hitTest|conflationReducer|isHovered|ICustomSeriesPaneView|IPrimitivePaneRenderer\" node_modules/lightweight-charts/dist/typings.d.ts\n# the toolkit's custom-series surface\nrg -n \"export (declare )?(function|class|interface|type)\" node_modules/@tradingview/lwc-toolkit/dist/custom-series/*.d.ts\n# a reference implementation, without a checkout\ncurl -fsSL https://raw.githubusercontent.com/tradingview/lightweight-charts/master/packages/lwc-plugin-stacked-bars-series/src/renderer.ts\n```\n\nLocal typings win over the docs when they disagree: the docs describe the\ncurrent release, the typings describe what the user actually has. If a file is\nmissing, say what could not be verified. Never invent an option, a hook or a\ntoolkit export — a plugin that compiles against an imagined API fails the\nuser's typecheck, and one that compiles against an option the chart ignores\nfails silently at runtime.\n\n## From idea to plugin type\n\nThe single most consequential decision, and the one to make first. Ask what\nthe idea *is* rather than how it looks:\n\n| The idea is… | Type | Because |\n| --- | --- | --- |\n| a new way to draw a series' own data (bars, bands, stacks, candles) | **custom series** | it needs its own data, autoscale, price line, last value and time-scale integration |\n| a decoration tied to one series (label, marker, band around it, drawing tool on its data) | **series primitive** | it reads that series' coordinates and is clipped to it |\n| a decoration tied to the pane (watermark, legend, title, an overlay for every series) | **pane primitive** | it spans the pane and outlives any one series |\n| a DOM-based accessibility, tooltip or control layer | **pane primitive** with a DOM overlay | the canvas is not the right medium; append to `paneContentElement(pane)` |\n\nDefault to a primitive. A custom series is the heavier construct — it must\nimplement `priceValueBuilder`, `isWhitespace`, `renderer` and `update`, and\nits renderer is called with the series' plot data. Only choose it when the\nidea *is* a series. A drawing tool that needs pointer handling is still a\nprimitive: it draws in a primitive and reacts through `subscribeClick`,\n`subscribeCrosshairMove` and the coordinate-conversion APIs.\n\nKeep hover and interaction in mind when choosing: primitives get a `hitTest`\nso the chart can report them in crosshair and click events; custom series get\na `hitTest` on their renderer only on Lightweight Charts™ 5.2 and later, which\nis what makes the `isHovered` and `hitTestData` arguments of `draw` report a\nhover.\n\n## Working method\n\nBuild in this order. Each step is the cheapest place to find the previous\nstep's mistakes.\n\n1. **Write down the data item and the options** before any code. The data\n   item decides `isWhitespace` (which fields make a point drawable) and the\n   options decide `defaultOptions`. Both go in their own files\n   (`data.ts`, `options.ts`) because the README, the types and the demo all\n   read them.\n2. **Scaffold** (below). Do not start from a blank file.\n3. **Get the renderer drawing with the sample data** the scaffold generates,\n   visible-range only, before touching options or interaction. A renderer that\n   draws everything, or draws nothing, is easier to fix while it is small.\n4. **Wire the options** through `applyOptions`; re-render with\n   `requestUpdate()`. Check every option does something in the demo page.\n5. **Custom series only: autoscale and whitespace.** `priceValueBuilder`\n   drives the price scale and the last-value label; whitespace decides where\n   the line breaks. Both have traps (checklist below).\n6. **Interaction**: `hitTest`, hover, drag. Keep it separate from drawing.\n7. **Tests**, then the README, then the demo and preview pages. The package\n   contract (`references/package-contract.md`) says what each must contain.\n   The preview must use `themeChart` from the preview kit's `preview-theme`\n   and be checked in both the light and the dark theme.\n\n## Scaffold, don't start blank\n\n```sh\nnpm create lwc-plugin@latest\n```\n\nThe wizard is interactive. It first offers to install this skill (say no if it\nis already installed, or the user quit the wizard to hand over to you), then\nasks for the type, a name, a one-sentence description, a package name, a class\nname, author, license, the minimum library version, tags, whether to keep hint\ncomments, and the target folder. Work those answers out with the user before\nanyone runs it — the type decision above is the one that matters — then have\nthe user run the wizard in their terminal, unless your environment gives you a\nTTY to answer the prompts yourself. It writes a Vite project with:\n\n- `src/<entry>.ts` — the plugin class (and, for a custom series, a factory);\n  `src/options.ts`, `src/data.ts`, and a renderer or view file per type\n- `src/example/index.html` + `example.ts` — the dev demo, `pnpm dev` serves it\n- `package.json` with `dev`, `build`, `typecheck` and `check-package` scripts,\n  a `lightweight-charts` peer range, `@tradingview/lwc-toolkit` as a\n  devDependency, and an `lwcPlugin` block for the catalog\n- a README already in the shape the catalog renders\n\nAnswer yes to \"hint comments\": they are `//*` lines that explain each part of\nthe template and are stripped by the wizard otherwise. Read them, then delete\nthe ones you have acted on. Build against the scaffold's own scripts\n(`pnpm typecheck`, `pnpm build`, `pnpm check-package`) — they are what CI and\nthe release tooling run.\n\n## Build on the toolkit\n\n`@tradingview/lwc-toolkit` is what the official plugins are built from,\nextracted from the helpers every example used to copy by hand. Reaching for\nit is not about saving lines; it is that the helpers encode chart behavior\nthat is easy to get subtly wrong — the exact width the built-in candlestick\nuses at a given bar spacing, pixel-perfect line positions at every device\npixel ratio, the dash patterns of `LineStyle`, how conflation changes a bar's\nlogical stride. Import each helper by sub-path:\n\n```ts\nimport { CustomSeriesRendererBase } from '@tradingview/lwc-toolkit/custom-series/renderer-base';\nimport { visibleSegments, extendRange, barCoordinate } from '@tradingview/lwc-toolkit/custom-series/visible-bars';\nimport { PluginBase } from '@tradingview/lwc-toolkit/plugin-base';\n```\n\nProblem → module, for the common cases. `references/toolkit.md` has the rest,\nwith the shape of each API and the official plugin that uses it.\n\n| You need to… | Use |\n| --- | --- |\n| write a custom series renderer without re-doing the data / range guards | `custom-series/renderer-base` — extend `CustomSeriesRendererBase`, implement `drawImpl(scope, args)` |\n| a series or pane primitive with the chart reference and `requestUpdate()` handled | `plugin-base` (`PluginBase`) / `pane-plugin-base` (`PanePluginBase`) |\n| draw only what is on screen, and reach the pane edge with a line | `custom-series/visible-bars` — `forEachVisibleBar`, `mapVisibleBars`, `extendRange`, `barCoordinate` |\n| size a conflated bar to the slots it covers (only with a `conflationReducer`) | `effectiveBarSpacing` (`custom-series/visible-bars`) |\n| implement `hitTest` or `conflationReducer` and still support 5.0 | `custom-series/compat` (types only) — `CustomSeriesHitTestResult`, `ConflationContext` |\n| call a series method newer than 5.0 (`setSeriesOrder`, 5.0.6) and still support 5.0 | `chart/compat` — `supportsSeriesOrder(series)` narrows the series, so the call stays typed |\n| report the bar under the pointer from `hitTest` | `custom-series/hit-test` — `seriesHitTestTolerance`, `nearestVerticalRange` (boxes), `nearestBar` (any shape), `createHitTestDataCache` |\n| break a line at explicit whitespace, not at other series' timestamps | `createWhitespaceSeries` (`custom-series/options-aware-series`) + `visibleSegments` |\n| read options inside `priceValueBuilder` (autoscale that follows options) | `createOptionsAwareSeries` with the option names that affect plot values |\n| stacked values: band edges and autoscale extremes | `custom-series/stacking` — `stackLevels`, `stackedPlotValues` |\n| columns, candles or lines the same width as the built-ins, pixel-aligned | `dimensions/*` — `calculateColumnPositions`, `candlestickWidth`, `positionsLine`, `positionsBox` |\n| rounded rectangles with an inset border | `canvas/round-rect` |\n| polylines, step lines, the area between two lines, a line whose color changes | `custom-series/line-paths` |\n| a label on the price or time axis | `axis-label-view` (`AxisLabelView`) |\n| a DOM overlay inside the pane | `dom/pane-element` (`paneContentElement`) |\n| a small event, or a `Time` as a timestamp or display string | `delegate`, `time` |\n\nWhen the scaffold's template already imports a toolkit helper, keep it; the\ntemplate is the smallest correct plugin of its type.\n\n## Read the reference implementations\n\nThe official packages are the canonical examples: maintained, tested,\npublished, and built exactly the way this skill describes. Read the one\nnearest your idea *before* designing — most questions (\"how do I get the\nhovered item?\", \"how do I autoscale a stack?\") are answered by a file in\none of them. Upstream they are `packages/lwc-plugin-*/src/`. From any other\nrepository the published `@tradingview/lwc-plugin-*` package gives you the\nREADME and the `dist/*.d.ts`, but not the source — fetch that from GitHub\n(raw URL or a shallow clone, see above); each plugin is a handful of files.\n\n| Building… | Read |\n| --- | --- |\n| any custom series | `stacked-bars-series` (the simplest complete one), then `pretty-histogram-series` |\n| a series with several values per point | `stacked-area-series`, `stacked-bars-series`, `grouped-bars-series` (side by side) |\n| a line/area that must break at gaps, or survive conflation | `hlc-area-series`, `brushable-area-series` |\n| a series with its own pointer interaction | `brushable-area-series` (`BrushableAreaInteraction`) |\n| a replacement for a built-in series | `rounded-candles-series` (matches candlestick options and widths) |\n| a chart whose X axis is a number, not time (scatter, bubble) | `scatter-series` (`ScatterHorzScaleBehavior`, `createScatterChart`) |\n| point markers on a series, hovered by their drawn shape | `lollipop-series` (`canvas/markers` dots, `nearestVerticalRange` and `markerDistance` in `hitTest`), `scatter-series` |\n| a shape built from several values per point, on the candle grid | `box-whisker-series` (named fields, per-point colors, part names in `objectId`) |\n| many colored cells per point, an order book or volume profile | `heatmap-series` (fills batched by color, `createColorScale`, a cell-level `hitTest`) |\n| a fixed-pixel-height overlay series | `dual-range-histogram-series` (`scaleMode`, `keepPixelSeriesInView`) |\n| a series primitive with an axis label and dragging | `vertical-line` |\n| a tool the user clicks to add something to a series | `user-price-lines` (pointer events in its own pane, one active instance per pane, a chart option set and put back) |\n| an image or decoration behind a series or pane | `image-watermark` (both a series and a pane primitive) |\n| a background colored from data, outside the price scale | `background-shade-series` (`[NaN]` plot values, `setSeriesOrder(0)`) |\n| a text label anchored to a pane edge or corner | `anchored-text` (the smallest series + pane pair over one core) |\n| a background derived from each bar of a series | `session-highlighting` (per-bar state from `dataUpdated`, visible-range slice) |\n| a DOM layer on a pane, multi-pane lifecycle | `accessibility` |\n\n`references/official-plugins.md` says what each one demonstrates in detail.\n`plugin-examples/src/plugins/` in the repository\n(`https://github.com/tradingview/lightweight-charts/tree/master/plugin-examples`)\nholds a further set of proof-of-concept plugins — tooltips, drawing tools,\na volume profile, … — good for breadth and ideas, but they are\nunpublished starting points, not the standard to match. The graduated\nplugins' folders there are redirects to the packages.\n\n## Read the documentation in this order\n\nFetch pages as Markdown — append `.md` to the URL — rather than scraping the\nHTML: `https://tradingview.github.io/lightweight-charts/docs/plugins/<page>.md`.\n`https://tradingview.github.io/lightweight-charts/llms.txt` is the index of\nevery page, `docs_map.md` the same with headings, and\n`lightweight-charts.d.ts` beside them the released typings.\n\n1. `intro` — the three plugin types and how they attach.\n2. `series-primitives` or `pane-primitives` — the view/renderer/lifecycle\n   contract for your type: `attached` / `detached`, `updateAllViews`,\n   `paneViews`, `priceAxisViews`, `timeAxisViews`, `hitTest`.\n3. `custom_series` — `ICustomSeriesPaneView`: `priceValueBuilder`,\n   `isWhitespace`, `renderer`, `update`, `defaultOptions`, the 5.1 conflation\n   hooks and the 5.2 `hitTest`.\n4. `canvas-rendering-target` — the `CanvasRenderingTarget2D` you draw on and\n   its two coordinate spaces.\n5. `pixel-perfect-rendering` — why widths and positions go through the\n   `dimensions/*` helpers.\n\nFor anything the pages do not cover, read the typings rather than the\ngenerated API reference — they are complete, and the `.d.ts` is what your code\ncompiles against. The docs describe the current release; when your peer range\nstarts earlier, the typings of the installed version are what you actually\nhave.\n\n## Correctness checklist\n\nEach of these has bitten a shipped plugin. The reasons are here so they can\nbe recognized in a new shape, not just avoided in the old one.\n\n### Drawing\n\n- Draw in `useBitmapCoordinateSpace` for anything that must be crisp (lines,\n  bars, borders) and scale widths by `horizontalPixelRatio` /\n  `verticalPixelRatio`; use `useMediaCoordinateSpace` for text and layout in\n  CSS pixels. Mixing them blurs on HiDPI. The `dimensions/*` helpers return\n  bitmap positions for exactly this reason.\n- `CanvasRenderingTarget2D` comes from `fancy-canvas`, not from the library;\n  the toolkit re-exports the type from `custom-series/renderer-base` so a\n  custom series need not depend on it.\n- Restore anything you set on the context (`save`/`restore`, or reset\n  `globalAlpha`, `lineCap`, dash). The next renderer draws on the same\n  context.\n- A `priceToCoordinate` that returns `null` means the price is off the\n  scale. Skip that point or break the line there; drawing to `NaN` loses the\n  whole path.\n\n### Visible range and coordinates\n\n- Draw `data.visibleRange` only; a series can have a million points. For\n  lines and areas widen the range by one bar with `extendRange` so the first\n  and last segments leave the pane instead of stopping at the edge.\n- Bars outside the visible range may carry stale or missing `x`. Rebuild a\n  coordinate from a visible anchor with `barCoordinate(bar, anchor,\n  barSpacing)` — `bar.time` is the *logical index*, and spacing is per index.\n- `bar.time` (logical index) and the array index `i` differ as soon as another\n  series starts earlier or the data has gaps. Per-index option lookups and\n  brush ranges use the logical index.\n\n### Custom series specifics\n\n- `priceValueBuilder` returns the plot values the chart autoscales on and\n  takes the *last* as the current value (price line, last-value label). For\n  a stack report `[min, max, total]` (`stackedPlotValues`); for a band the\n  extremes; for a single value `[value]`.\n- It runs at `setData`, before any render, so a plain view has no options\n  yet — the chart has not called `update` — and `percent`, `base` or\n  `scaleMode` are ignored on the first ingest. `createOptionsAwareSeries`\n  gives the builder a live options getter and re-ingests when a named option\n  changes; this is why the official series ship a `createXSeries` factory as\n  the supported entry point and keep the class exported for composition.\n- The host hands a custom renderer **no whitespace**: bars simply skip the\n  gap, and a jump in logical index may just be another series' timestamps.\n  Break lines only at the series' own whitespace, from its accepted input:\n  `createWhitespaceSeries` provides a `GapCheck`; pass\n  `getConflationFactor(data)` as its `minGap` so a whitespace run narrower\n  than one conflation bucket is absorbed rather than splitting every bucket\n  into a single-point segment.\n- `conflationReducer` and `conflationFactor` exist from 5.1, and the\n  renderer's `hitTest` from 5.2: series hit testing, which reports a custom\n  series hovered through `isHovered` / `hitTestData` (`draw` arguments since\n  5.0), arrived with it. Implement them as optional extras, keep the peer\n  range at `^5.0.0` unless you need them, and say so in the README.\n- `hitTest` must return the same `hitTestData` object while the same item\n  stays hovered: the chart compares it by reference and repaints the pane on\n  every pointer move when it is a new object.\n- `conflationReducer(a, b)` must return a data item of your own type that\n  makes sense as the merge of two: sum for stacks, high/low/last for OHLC,\n  the later value for a rate.\n\n### Primitives specifics\n\n- `requestUpdate()` after any change the chart cannot see (an option, a new\n  time, a decoded image). The chart does not poll your state.\n- `detached()` must undo everything `attached()` did: listeners, DOM nodes,\n  timers, pending image loads. Attach/detach cycles are common (React\n  effects, pane reordering) and leaks show up as ghost drawings and thrown\n  \"disposed\" errors.\n- A pane primitive is drawn only on the pane it is attached to; a pane index\n  given to a constructor is a hint that can be wrong. Resolve the real pane\n  lazily (the first draw's `context.canvas` is inside it) and hold it by\n  identity — indices shift when panes are added, removed or moved.\n- For DOM overlays, append to `paneContentElement(pane)` and keep the\n  overlay's layout independent of the chart's own table cells.\n\n## Testing\n\nThree layers, each catching something the others cannot. The official\npackages have all three under `tests/`; the scaffold sets up the first.\n\n- **Unit** (`tests/unit/*.spec.ts`, `node:test` + `chai`): pure functions —\n  stacking maths, option merging, data padding, gap detection. Fast, run by\n  the repository's `pnpm test`.\n- **Graphics** (`tests/graphics/*.js`): a page that draws one state; CI\n  compares the screenshot against the previous build's. One case per option\n  worth seeing, plus the edge cases: empty visible range, scrolled off, a\n  whitespace run, conflation, inverted scale.\n- **Interactions** (`tests/interactions/*.js`): a page with an async\n  `beforeInteractions(container)` that drives the chart and throws on a\n  wrong outcome — pixel sampling for \"did it paint\", DOM checks, hit tests.\n  This is where whitespace, update, `pop` and pointer behavior are tested.\n\nRun upstream with `pnpm test`, `pnpm e2e:graphics:plugins` and\n`GREP=\"lwc-plugin-<name>/\" pnpm e2e:interactions`, after `pnpm build:prod`\nand `pnpm --filter \"@tradingview/lwc-plugin-*\" build`.\n\n## Publishing and the catalog\n\nA plugin is publishable when `pnpm plugins:validate` passes upstream, or the\nequivalent by hand: an `lwc-plugin-*` name, `publishConfig.access: public`, a\n`lightweight-charts` peer range, the `lightweight-charts-plugin` keyword, a\ncomplete `lwcPlugin` block, a README with `## Installation` (`### npm` and\n`### CDN` tabs) and `## Usage`, and the demo page it declares. The scaffold\nmeets all of it. The docs site's plugin catalog renders the README and\nframes a preview page built from the package; `references/package-contract.md`\nhas the fields, the pages and the first-release changelog convention (short:\nan `Added` list, no `Fixed` — there is nothing to have fixed yet).\n\nWrite documentation and user-facing text (README, CHANGELOG, the package\n`description`, JSDoc on public API) in American English: color, center,\ncatalog, normalize, not colour, centre, catalogue, normalise. Write comments\nin new code the same way, but don't bulk-fix older plugins.\n\n## Answer contract\n\nWhen helping with a plugin:\n\n1. Name the plugin type and say why in one sentence, or explain what the\n   user's idea would lose in the other type.\n2. Point at the toolkit module and the official plugin you are basing the\n   answer on. Read the plugin's file before quoting its pattern.\n3. Verify every library and toolkit name against the local typings; say what\n   you could not verify.\n4. Produce code that the scaffold's own scripts accept: `pnpm typecheck`,\n   `pnpm build`, and `pnpm dev` showing it in the demo page.\n5. When the change touches autoscale, whitespace, the visible range or\n   hover, name the test that would have caught the regression and write it.\n",".github/skills/lightweight-charts-plugin-authoring/references/official-plugins.md":"# The official plugins, and what each one teaches\n\nUpstream: `packages/lwc-plugin-<name>/`. Published: `@tradingview/lwc-plugin-<name>`,\nwhich ships the README and `dist/` (`.js` + `.d.ts`) but not the source. From\na repository that is not the upstream checkout, read the source on GitHub —\n`https://github.com/tradingview/lightweight-charts/tree/master/packages/lwc-plugin-<name>/src`,\nor the raw file URL under `raw.githubusercontent.com/tradingview/lightweight-charts/master/…` —\nor clone once: `git clone --depth 1 https://github.com/tradingview/lightweight-charts /tmp/lightweight-charts`.\n\nEach package has `src/`, a dev demo (`src/example/index.html`), a catalog\npreview (`src/example/preview.html`), `tests/{unit,graphics,interactions}`, a\nREADME in the catalog's shape and a CHANGELOG. Read the whole `src/` of the\nnearest one before designing; they are small.\n\nEvery preview calls `themeChart` from\n`@tradingview/lwc-plugin-preview-kit/preview-theme` and has been checked in\nboth the light and the dark theme. A new package needs the same: open the\nbuilt preview with `?theme=dark` and make sure nothing is left white or\nunreadable on black. For colors that have to change with the theme, see the\npreviews of `session-highlighting`, `image-watermark`,\n`rounded-candles-series` and `box-whisker-series`.\n\nEvery custom series below ships a `create<Name>Series(chart, options?,\npaneIndex?)` factory as the supported entry point and keeps the\n`<Name>Series` class exported for `chart.addCustomSeries` and composition.\nThe factory is where options-aware autoscale and whitespace detection live.\n\n## Custom series\n\n### `stacked-bars-series` — start here for any custom series\n\nStacked columns from a `values: number[]` per point. The shortest complete\ncustom series: `data.ts`, `options.ts`, `stack.ts` (pure maths, unit-tested),\n`renderer.ts` (extends `CustomSeriesRendererBase`), the view, the factory.\nShows `createOptionsAwareSeries` with `['base', 'percent', 'stackOrder']` as\nthe price options; `stackedPlotValues` for autoscale over negatives;\n`calculateColumnPositions` with `time` so columns either side of a gap are\nnot aligned to each other; `hitTest` returning the hovered segment index;\n`conflationReducer` summing bands.\n\n### `pretty-histogram-series` — one value per point, rounded, pixel-aligned\n\nRounded columns with `widthPercent`/`widthMode`, inner corners, a border and\na gradient. Shows `canvas/round-rect` with clamped radii, `base` reported in\n`priceValueBuilder` so bars never clip at the pane edge, `highlightHovered`\ndimming, a `conflationReducer` that keeps the later value, and the guard for\nan empty visible range.\n\n### `lollipop-series` — markers on stems, sized by the bar spacing\n\nA dot at each value on a stem from `base`, drawn with `beginMarker` from\n`canvas/markers`. Read for: sizes that are options but capped by the bar\nspacing, and the dot also by a fixed maximum that keeps it within the price\nscale's margins in a pane at least 100 px tall, since autoscale only knows the\nvalues (`geometry.ts`, unit-tested); a stem kept at least one device pixel\nwide; centering the dot on the stem as it was snapped to the pixel grid; and a\n`hitTest` built on `custom-series/hit-test`: `nearestVerticalRange` for the\nstems and `nearestBar` with `markerDistance` for the dots, so that each dot is\nmeasured as drawn, reporting the dot as a `'point'` and the stem as a\n`'range'`, since the chart prefers any point hit to a range hit whatever the\ndistance. It has no `conflationReducer`, so it sizes against `barSpacing`, not\n`effectiveBarSpacing`. Its `hover-empty-space` interaction test shows the\nlibrary's own fallback: where the renderer's `hitTest` returns `null`, a\npointer inside a bar's slot between its plot values still reports the series\nas hovered, without an `objectId`.\n\n### `grouped-bars-series` — several values per point, side by side\n\nA group of columns per point from `values[]`, with series and per-point\n`colors`, a `base`, and `columnWidthMode`/`widthPercent` named as in\n`stacked-bars-series`. Read for: one column count for the whole series, the\nmost values any point that draws a column has, so a column is as wide in\nevery group, counted once per data change by keying it on the\n`AcceptedInput` revision that `createOptionsAwareSeries` hands the view, and\nread when the renderer draws or hit tests rather than in the view's `update`,\nwhich the chart calls while `setData` is still running, before the revision\nmoves; groups placed with `calculateColumnPositionsInPlace` in `histogram`\nmode and `positionsLine` in `percent` mode, where they are all the same width\nand never wider than the bar spacing covers; splitting each group into\nwhole-pixel columns that tile it exactly (`splitGroup` in `layout.ts`,\nunit-tested), every column keeping at least a pixel and the tallest drawn\nfirst once they share pixels; values equal to `base`, `null` and non-finite\nvalues skipped like whitespace; and a `hitTest` that measures every column\nwithin reach with `nearestBar`, naming the point and the column in\n`objectId`.\n\n### `stacked-area-series` — bands, gaps and conflation together\n\nCumulative bands from `values[]`, negatives folding back to the base,\n`gapHandling: 'break' | 'bridge'`, `percent` mode, per-band and per-point\ncolors, `lineType` simple/step/curved. Shows `createWhitespaceSeries` with\n`['base', 'percent']`; `visibleSegments` with the `GapCheck` and\n`getConflationFactor(data)` as `minGap`; `extendRange` + `barCoordinate` so\nlines reach the pane edge with correct offscreen coordinates; `stackLevels`;\na `hitTest` that ignores whitespace gaps and unpainted extents. Its\ninteraction tests (`shared-timeline`, `whitespace-hit-test`,\n`conflation-holidays`) are the model for testing gap behavior.\n\n### `hlc-area-series` — two lines with a band between\n\nHigh, low and close lines, two-tone fill, gradients, step mode, hover\nmarkers on the bar under the cursor. Shows `line-paths` (`buildLinePath`,\n`buildStepLinePath`, `areaBetween`), skipping points whose prices fall off\nthe scale rather than drawing to `NaN`, `hitTest` by nearest bar, and a\n`conflationReducer` taking highest high / lowest low / last close.\n\n### `brushable-area-series` — a series plus its own interaction primitive\n\nAn area whose `brushRanges` (logical-index ranges) carry their own styles,\nwith `outsideStyle`, `basePrice` and gradient options; and\n`BrushableAreaInteraction`, a series primitive that turns mouse drag,\none-finger drag and two-finger gestures into a range and reports it through\n`activeRange()` as a `Delegate`. Read this for: matching ranges by *logical\nindex* rather than array index (they differ when another series starts\nearlier), `strokeStyledPolyline` for a line whose style changes mid-way, and\nhow a series and a primitive cooperate without the series knowing about\npointers.\n\n### `dual-range-histogram-series` — fixed pixel height, price-scale coexistence\n\nNested up/down columns of fixed pixel height on the zero line, or `scaleMode:\n'price'` to autoscale like a normal series. Shows the problem of a series that\nis *not* part of the autoscale: `keepPixelSeriesInView(chart, series)` reserves\nroom on the price scale and keeps doing so on resize. Also generic horizontal\nscale support, role-keyed `colors`/`borderRadius`, and `normalize`.\n\n### `background-shade-series` — a series that is only a background\n\nFull-height columns behind each bar, colored by where the bar's value sits\nbetween two colors. Read for: a custom series that stays out of the price\nscale (`priceValueBuilder` returns `[NaN]`, so it never changes the autoscale\nrange, has no last value and is never hovered) and sits on an overlay price\nscale of its own, set in `defaultOptions`, since a series at the bottom of the\norder would otherwise set the number format of a shared axis; columns from\n`fullBarWidthAfter`, each starting where the previous one ends, since two\nedges rounded on their own can leave a seam; shades looked up in a table built when the\ncolors change, so no color string is made while drawing; a per-point `color`\nread from `bar.barColor`, since the chart keeps `color` out of\n`originalData` and merges it with the series `color`, which the package\ntherefore leaves empty; parsing a CSS color\nthrough a scratch canvas of its own (never the chart's context, whose\n`fillStyle` a check would change), and spotting an invalid one; mixing colors\nwith premultiplied alpha; a factory that moves the series behind the others\nwith `setSeriesOrder(0)` where the host has it; and `globalAlpha` set inside\n`save`/`restore`. Its `price-format-kept` interaction test compares two\ncharts, since a price axis never narrows once it has grown.\n\n### `box-whisker-series` — a statistical shape on the candle grid\n\nA box plot per point from named fields (`min`, `q1`, `median`, `q3`, `max`)\nand `outliers`, with the five colors overridable on each point. Read for:\nsizing every part from `candlestickWidth` and the grid line width in bitmap\npixels, with the same parity as the whisker so each part is centered on it;\nthe outliers in the autoscale values, so every dot stays in view; malformed\npoints (a non-finite or `null` number) read as whitespace in `isWhitespace`,\nso they never reach the price scale; a factory that is a typed\n`chart.addCustomSeries`, since no option changes the plot values; and a\n`hitTest` on `nearestBar` that names the part and the point under the pointer\n(`'box-<point>'`, `'outlier-<point>-<index>'`, …) in `objectId`, an outlier\nreported as a `'point'` and the rest as `'range'`. It has no\n`conflationReducer`: merging two box plots has no clear meaning.\n\n### `heatmap-series` — many cells per point, filled by color\n\nA column of `{ low, high, amount }` cells per point, colored by a\n`cellShader(amount, range)` option. Read for: drawing many small shapes per\nframe by collecting them per color and filling one path per color, which a\nshader with few colors (`createColorScale` and its `steps`) makes pay off;\nhanding a function option the range of the values in view, worked out over\nthe visible bars, so colors need no maximum fixed in advance; checking a\ncolor a user function returns on a scratch canvas before drawing with it,\nsince the canvas ignores an invalid fill and would reuse the last one;\ncells rounded to pixels edge by edge, so neighbors share an edge, columns\nfrom `fullBarWidthAfter`, and a gap and a border rounded per axis and left out\nof a cell too small for them; rows off the pane skipped; a function-valued\noption, and a factory options type that keeps it a function where the\nlibrary's `DeepPartial` would not; a cell-level `hitTest` limited to the\ncolumn whose slot holds the pointer, so its `objectId` indexes the point\n`param.seriesData` reports, with no `hitTestData` so a pointer moving within a\ncell repaints nothing (its `hover-stable` interaction test counts fills); and\nseeded sample data shared by the demo, the preview and the unit tests.\n\n### `rounded-candles-series` — a drop-in replacement for a built-in\n\nCandlesticks with rounded bodies. Read for how to *match* the built-in:\nthe same color option set and shorthand semantics, `candlestickWidth` for\nthe body, body and wick aligned on one pixel grid at every DPR,\n`upDownMode`, per-point overrides, `conflationFactor` widening candles under\nconflation, and a `radius` that may be a number or a function of bar spacing.\n\n### `scatter-series` — a numeric X axis instead of time\n\nScatter and bubble charts. `createScatterChart` builds the chart on a custom\nhorizontal scale behavior (`ScatterHorzScaleBehavior`) so that the X axis is a\nplain number, and `createScatterSeries` draws the whole data set as one custom\nseries, in named groups with their own colors, marker shapes and connecting\nlines, with bubble sizes driven by a data value. Read for a custom horizontal\nscale, markers drawn and hit tested through `canvas/markers`, and a host API\nfor the tooltip and legend the plugin leaves to the page: `hoveredInfo.objectId`,\n`pointById`, `subscribeHoveredPointChange`. The one official plugin that needs\n`lightweight-charts` 5.2 (`^5.2.0`).\n\n## Series primitives\n\n### `vertical-line` — the model series primitive\n\nA full-height line at a time, with a time-axis label, a badge on the line,\n`snap: 'exact' | 'nearest'`, dragging with an `ew-resize` cursor. Shows\n`PluginBase`, `AxisLabelView` (and the off-screen coordinate when the time is\nnot on the scale), `positionsLine` for a crisp line, `setLineStyle` for dash\npatterns, `Delegate` for `timeChanged()`, hit-testing with a tolerance, and\ndrag ownership — only one line per chart suspends the chart's own scroll and\nscale handling, and restores it exactly once. Its interaction tests cover\ndrag cancel, disabling during a drag, overlapping lines and pointer scope.\n\n### `user-price-lines` — pointer-driven creation on a series\n\nA button at the right edge of the pane that follows the pointer and adds a\nprice line where it is clicked. Read for: driving a tool from\n`subscribeCrosshairMove` and `subscribeClick`, ignoring events from other\npanes with `param.paneIndex` and asking for a repaint only when the button\nchanges; moves with no `sourceEvent` (the chart's own, after\n`setCrosshairPosition`, on data and time scale changes) never bringing the\nbutton up; a click that only counts on the button where it is shown, so a\ntouch tap away from it adds nothing (the chart reports no click after a\ndrag); the pane's width from `chart.paneSize`, since\n`timeScale().width()` is 0 while the time axis is hidden; a geometric\n`hitTest` for the cursor and `hoveredObjectId` (the chart hit tests before it\nreports the move); setting a chart option (`CrosshairMode.Normal`) while\nattached and putting the old value back on detach only if it is still the one\nset, handed over between instances; one active instance per pane, kept in a\nmodule-level `WeakMap` by chart; letting go of the chart once\n`chart.removeSeries` or `chart.remove` has taken its series away (neither\ncalls `detached`); tracking the lines it created by `id`, since\n`series.priceLines()` returns new objects on every call, and removing them on\ndetach; and a deprecated constructor overload kept from the example. Its\ninteraction tests wait out the chart's double-click window between clicks in\none pane: a second click within 500 ms is otherwise swallowed, and a test\nasserting that it added nothing passes for the wrong reason. Its `price-zero`\ntest builds a scale on which a whole pixel row is at exactly 0.\n\n### `image-watermark` — the same idea as both primitive types\n\n`ImageWatermark` (series primitive) and `ImageWatermarkPane` (pane primitive)\nsharing options and a renderer. Read for: drawing nothing until an image has\ndecoded (and reporting failures through `onError` instead of throwing every\nframe), positioning from the *pane's* size rather than the chart element,\n`objectFit`/`position`/`padding` layout, `zOrder`, a decoded-image cache by\nURL, and `detached()` canceling a pending load.\n\n### `anchored-text` — the smallest two-class primitive\n\n`AnchoredText` (series primitive) and `AnchoredTextPane` (pane primitive)\nsharing one core, with no image to load and no interaction: the shape of\n`image-watermark` reduced to its essentials. Read for: laying text out in the\nmedia coordinate space from `measureText` (`layout.ts` is a pure function the\nunit tests cover for all nine anchors), a renderer that returns `null` while\nthere is nothing to draw, `save`/`restore` around context changes, options\nthat accept a deprecated spelling (`'middle'`) on input and never return it,\nand `mergeOptions` where one option (`lineHeight`) treats an explicit\n`undefined` as a value.\n\n### `session-highlighting` — per-bar background from the series' own data\n\n`SessionHighlighting` shades a full-height column behind every bar with the\ncolor a user function returns for its time. Read for: deriving per-bar state\nfrom `series.data()` in `dataUpdated` and patching only the end of it on an\n`'update'` scope. The scope covers more than append and replace: `pop()` and\nan update that turns the last bar into whitespace shrink the data, and a\nhistorical update can remove a bar from the middle or insert one there, so\nthe bar count decides the case: a shrink is only cut back when the kept last\nentry still names the last bar, and a bar is only appended when it comes after\nthe last entry (both compared by the key `timestampOf` stores for each bar: numbers\npass through unchanged, as the time scale keys them, and business days and\ndate strings become the UTC timestamp of their day, so how the time is written\ndoes not matter); otherwise every bar is recolored. Also read for mapping the\nvisible logical range back to data indices by binary search over `timeToIndex`\n(so other series starting earlier do not shift the slice), `fullBarWidth` from\nthe time scale's `barSpacing` for columns as wide as the bar slots (each edge\nrounded on its own, so neighbors can leave a 1 px seam where an edge falls on\na half pixel; `fullBarWidthAfter` rounds a shared edge once), and\n`zOrder: 'bottom'` for a background.\n\n## Pane primitives\n\n### `accessibility` — DOM overlays and multi-pane lifecycle\n\nA pane primitive per pane plus a chart-level `addAccessibilityPlugin(chart,\noptions)` controller. The reference for anything DOM-based: appending a\nsemantic layer to `paneContentElement(pane)`, following the pane by identity\nthrough reordering (the constructor index is only a pre-build hint; the first\ndraw's canvas resolves the real pane), a single shared ARIA-live region,\n`subscribeMediaQuery` for high contrast, message bundles and localization,\nkeyboard handling on the overlay, and a controller that reconciles panes added\nor removed at runtime. Also the largest test suite of the official plugins; its\n`pane-reorder`, `mismatched-pane-index` and `announce-callback-throws`\ninteraction tests show how to assert on DOM state.\n\n## `plugin-examples/` — breadth, not the standard\n\nUpstream `plugin-examples/src/plugins/` holds unpublished proof-of-concept\nplugins: tooltips and delta tooltips, a rectangle drawing tool, trend lines,\nprice alerts, a volume profile, a partial price line,\nand crosshair highlighting. Good for seeing the shape of an\nidea; they predate the toolkit and skip the tests and README the packages\ncarry, so use the official plugins for *how* and these for *what*. The\ngraduated plugins' folders there are redirect stubs to the packages.\n",".github/skills/lightweight-charts-plugin-authoring/references/package-contract.md":"# The plugin package contract\n\nWhat makes a plugin package publishable and catalog-ready. Upstream,\n`pnpm plugins:validate` (`scripts/plugins/validate-metadata.mjs`) enforces all\nof it and fails CI otherwise; a project scaffolded by `create-lwc-plugin`\nalready satisfies every item, so this is mostly a list of what not to break.\nThe catalog on the docs site lists the official packages today; the same\ncontract is what any plugin would need to be listed.\n\nUpstream only: a package under `packages/` also needs its catalog card\nillustration, `website/static/plugin-catalog/assets/previews/<slug>.svg`\n(320×180, TradingView palette colors only). The catalog data README,\n`website/plugins/plugin-catalogue/README.md`, says how to draw it and which\naccent color to pick.\n\n## `package.json`\n\n| Field | Rule | Why |\n| --- | --- | --- |\n| `name` | starts with `lwc-plugin-` (unscoped), or `@tradingview/lwc-plugin-` for an official package | the unscoped remainder is the catalog's URL segment and the entry file name |\n| `version` | valid semver | the release script compares it with npm |\n| `description` | non-empty | shown on the catalog card |\n| `license` | non-empty SPDX id | shown on the detail page |\n| `publishConfig.access` | `\"public\"` | scoped packages default to restricted |\n| `peerDependencies.lightweight-charts` | a valid range, `^5.0.0` unless a 5.1 hook is required | the catalog shows \"works with\"; consumers install the library themselves |\n| `keywords` | includes `lightweight-charts-plugin` | how npm search and the registry find plugins |\n| `files` | `dist` (+ `CHANGELOG.md`, `NOTICE` for official) | ship built output only |\n| `exports` | `.` and `./standalone`, each with `types` + `default` | the standalone build inlines everything but the library, for CDN import maps |\n| `lwcPlugin` | see below | the catalog's curated metadata |\n| `repository.directory` | must equal the package's real path in the repo | the \"source\" link and the catalog read it |\n\n## The `lwcPlugin` block\n\nValidated against `scripts/plugins/lwc-plugin-metadata.schema.json`;\nunknown keys are errors.\n\n| Key | Required | Values |\n| --- | --- | --- |\n| `title` | yes | display name |\n| `category` | yes | `custom-series` \\| `series-primitive` \\| `pane-primitive` |\n| `lifecycle` | yes | `current` \\| `legacy` \\| `deprecated` \\| `experimental` |\n| `origin` | yes | `official` \\| `community` (workspace packages must be `official`) |\n| `demo` | yes | package-relative path of the dev demo page; the file must exist |\n| `author` | no | display name |\n| `preview` | no | package-relative path of the catalog preview page; must exist if declared |\n| `previewHeight` | no | integer ≥ 200, CSS px for the preview frame (default 330); only with `preview` |\n| `tags` | no | search terms |\n\n## Two pages, not one\n\n- **Demo** (`src/example/index.html` + `example.ts`, `lwcPlugin.demo`): the\n  page a developer opens on its own. Put the edge cases here — whitespace\n  runs, negatives, every option as a control. `pnpm dev` serves it; upstream,\n  `pnpm plugins:build-demos` builds it to `/plugin-demos/<slug>/` on the site.\n- **Preview** (`src/example/preview.html` + `preview.ts`, `lwcPlugin.preview`):\n  what the catalog frames next to the README, in a frame ~330 px tall. Show\n  the plugin at its best: clean data, two or three controls, no explanatory\n  text. Official packages build it with the private\n  `@tradingview/lwc-plugin-preview-kit` (layout + `mountControls` /\n  `addRefreshButton`); a standalone project has no preview by default.\n\n  The preview follows the docs site's light or dark theme and switches live\n  when the site theme is toggled. Call `themeChart(chart, onTheme?)` from\n  `@tradingview/lwc-plugin-preview-kit/preview-theme` in the same script run\n  as `createChart`, before anything awaits; it themes the chart's\n  background, text, grid, scales and crosshair labels. Anything the preview\n  colors itself — series and plugin options, a price line color, an image —\n  is your job: recolor it in `onTheme`, which runs right away and again on\n  every switch. Keep a control's current choice in a variable so a theme\n  switch reapplies it, and read `previewTheme()` in the control's handler\n  (see `rounded-candles-series` or `box-whisker-series`). Before you\n  finish, check the built preview in both themes (`?theme=light` and\n  `?theme=dark` on its URL): nothing white or light-only left over, and\n  every line, dot and label readable on black.\n\nNeither page is the plugin's tests. Keep them free of assertions.\n\n## README shape\n\nThe catalog renders the README as the page body (its H1 dropped, since the\npage header shows the title), with the Installation subsections lifted into\nan npm/CDN tab switcher. So:\n\n1. `# <Title>` then a description paragraph.\n2. `## Installation` with `### npm` (install command + import example) and\n   `### CDN` (an import map pointing `lightweight-charts` and the package at\n   their standalone builds, then the same import by name).\n3. `## Usage` with at least one `js`/`ts` code block — the release smoke test\n   compiles the first snippet after `### npm`, so it must be complete and\n   correct.\n4. `## Options`, `## Notes` as needed. Headings become anchors and a table of\n   contents on the site, so keep them descriptive.\n\nIf the series ships a factory, the README's snippets use it, and a line says\nthe plain class draws continuously (no whitespace detection).\n\n## Tests\n\nOfficial packages carry `tests/unit/*.spec.ts` (run by the repo's `pnpm test`),\n`tests/graphics/*.js` (screenshot comparison against the previous build) and\n`tests/interactions/*.js` (async `beforeInteractions(container)` that throws on\na wrong outcome). The e2e runners discover them by folder; a package without\na `tests/<suite>` folder is skipped, never failed.\n\n## CHANGELOG\n\nKeep a Changelog format, one `## <version>` per release. For the **first**\nrelease keep it short: a sentence saying it is the first release (and where\nit came from), an `### Added` list of what the package provides, and\n`### Deprecated` only if it ships a deprecated alias. No `Fixed` or `Changed`\n— nothing has been released to fix or change, and entries written as commit\nsubjects read badly on npm. The release script only checks that an entry for\nthe current version exists.\n\n## Scripts a package is expected to have\n\n`dev` (Vite on the demo page), `build` (`tsc` for declarations, then the\nshared compile producing `dist/<entry>.js` and `dist/<entry>.standalone.js`\nplus bundled `.d.ts`), `typecheck`, and `check-package` (`publint --strict`\nand `@arethetypeswrong/cli`). Upstream adds `plugins:check-compat` (build every\nplugin against the workspace library) and `plugins:smoke` (install the packed\ntarball into a fresh Vite project and compile the README snippet).\n",".github/skills/lightweight-charts-plugin-authoring/references/toolkit.md":"# `@tradingview/lwc-toolkit`, module by module\n\nEvery module is its own sub-path export: `@tradingview/lwc-toolkit/<module>`.\nThere is no root import. This file describes the shape and the reason, not\nevery overload: verify signatures against\n`node_modules/@tradingview/lwc-toolkit/dist/<module>.d.ts`, whose doc comments\nare the module's documentation.\n\n\"Read:\" names the official plugin whose source shows the module used for\nreal. Upstream that is `packages/lwc-plugin-<name>/src/<file>`; from any other\nrepository fetch\n`https://raw.githubusercontent.com/tradingview/lightweight-charts/master/packages/lwc-plugin-<name>/src/<file>`\n(the published package ships `dist/` only).\n\n## Custom series\n\n### `custom-series/renderer-base` — `CustomSeriesRendererBase`, `CustomSeriesDrawArgs`, `CanvasRenderingTarget2D`\n\nBase class for a custom series renderer. `update(data, options)` stores what\nthe chart hands over; `draw(target, priceConverter, isHovered, hitTestData)`\nguards against a missing data set or an empty visible range and then calls\nyour `drawImpl(scope, args)` inside `useBitmapCoordinateSpace`. `args` is\n`{ data, options, priceToCoordinate, from, to, isHovered, hitTestData }`,\nwhere `from`/`to` are the visible range clamped to the bars array.\n\nReach for it because the guards are exactly where a hand-written renderer\nthrows when the whole dataset is scrolled off screen. It also re-exports the\n`CanvasRenderingTarget2D` type so the plugin need not depend on `fancy-canvas`.\n\nIf the renderer also implements `hitTest` (called from 5.2), return the *same*\n`hitTestData` object for as long as the same item stays hovered: the chart\ncompares it by reference and repaints the pane on every pointer move when it\nchanges. Keep the last one, or return a primitive such as the item's index.\n\nRead: `stacked-bars-series/src/renderer.ts` (short), `hlc-area-series/src/renderer.ts`.\n\n### `custom-series/visible-bars` — `forEachVisibleBar`, `mapVisibleBars`, `extendRange`, `visibleSegments`, `whitespaceGapCheck`, `barCoordinate`, `getConflationFactor`, `effectiveBarSpacing`, `GapCheck`, `AcceptedInput`\n\n- `forEachVisibleBar(data, fn)` / `mapVisibleBars(data, fn)` visit only\n  `data.visibleRange`; `fn` receives the bar and its *absolute* index into\n  `data.bars`, which is what per-index option lookups use.\n- `extendRange(range, length, by = 1)` widens a range by `by` bars each side,\n  clamped, so a line's first and last segments leave the pane.\n- `visibleSegments(bars, range, isGap?)` splits a range into runs of\n  increasing logical index, breaking where `isGap(left, right)` says so. A\n  jump in logical index alone is **not** a gap — other series can own those\n  indices — so without a predicate the range is one run.\n- `whitespaceGapCheck(readInput, logicalIndex, isWhitespace)` builds that\n  predicate from the series' accepted input. Its `GapCheck(left, right,\n  minGap = 1)` is true when the *contiguous* whitespace between two drawn\n  bars is at least `minGap` logical indices long. Renderers pass\n  `getConflationFactor(data)` as `minGap`.\n- `barCoordinate(bar, anchor, barSpacing)` reconstructs a media `x` for a bar\n  whose own `x` is stale (it was off screen) from a visible anchor bar.\n- `getConflationFactor(data)` is `data.conflationFactor`, or 1 on hosts\n  before 5.1.\n- `effectiveBarSpacing(data)` is `barSpacing` times that factor: the width a\n  conflated column or candle covers. Use it only in a series with a\n  `conflationReducer`. The chart reports the factor to every custom series\n  but conflates only those with a reducer, so a series without one is still\n  drawn one point per bar and sizes against `barSpacing`.\n\nRead: `stacked-area-series/src/renderer.ts` for all of them together.\n\n### `custom-series/hit-test` — `distanceToRange`, `seriesHitTestTolerance`, `nearestBar`, `nearestVerticalRange`, `createHitTestDataCache`\n\nFor a renderer's `hitTest` (called from 5.2).\n\n- `seriesHitTestTolerance(options)` reads the series' `hitTestTolerance`\n  option, in CSS pixels, with the library's default of 3 for an invalid value.\n- `nearestVerticalRange(data, x, y, halfWidth, tolerance, span)` returns\n  `{ index, distance }` for the visible bar whose box — `halfWidth` either\n  side of its `x`, between the two ends `span(bar, index)` returns — is\n  nearest the pointer and within `tolerance`, or `null`. It finds the bars\n  near `x` by binary search. Return `null` from `span` for a bar with\n  nothing to hit.\n- `nearestBar(data, x, reach, tolerance, distance)` is the same search with\n  your own `distance(bar, index)`, for geometry that is not one box per bar:\n  a dot, a ring, a shape. Only the bars whose `x` is within `reach` of the\n  pointer are measured, so make `reach` the widest the geometry gets from a\n  bar's `x`, plus `tolerance`. Measure to the shape itself; picking the bar by\n  a box around it reports the wrong bar where neighboring shapes touch.\n- `distanceToRange(value, a, b)` is the distance to a range, `0` inside it.\n- `createHitTestDataCache()` returns `get(key, create)`, which hands back the\n  same object while the same key is asked for. Use it for an object\n  `hitTestData`, keyed by the `objectId`: the chart compares `hitTestData` by\n  reference and repaints on every pointer move when it changes.\n\nReturn the result typed as `CustomSeriesHitTestResult` from\n`custom-series/compat`, which also has `ConflationContext` for a\n`conflationReducer`'s arguments. Both are types only: the library exports its\nown from 5.2 and 5.1, and importing them would raise the plugin's floor.\n\nRead: `rounded-candles-series/src/renderer.ts` (boxes), `lollipop-series/src/renderer.ts`\n(a stem and a dot).\n\n### `custom-series/options-aware-series` — `createOptionsAwareSeries`, `createWhitespaceSeries`, `OptionsAwareSeries`\n\nFactories that wrap `chart.addCustomSeries` so a series can do two things a\nplain `ICustomSeriesPaneView` cannot:\n\n- **Read options in `priceValueBuilder`.** The chart calls the builder at\n  `setData`, before any `update(data, options)`, so a plain view has only its\n  defaults there. `createOptionsAwareSeries(chart, createView, defaults,\n  options, priceOptions, paneIndex?)` passes `createView` an options getter\n  bound to the real series, and re-ingests the retained data whenever one of\n  `priceOptions` changes through `applyOptions`. Use it whenever an option\n  changes what a value *means* — a base, percent mode, a scale mode. The\n  getter keeps one copy of the options until `applyOptions`, so a builder can\n  call it for every point; `series.options()` deep-copies on every call, so\n  never call that from a builder or a renderer.\n- **Know its own whitespace.** The wrapper retains a copy of the accepted\n  input (the host's `data()` exposes fulfilled points only) as an\n  `AcceptedInput`: a chronological array plus a `revision`, kept sorted\n  incrementally so a streaming `update` is a binary insert.\n  `createWhitespaceSeries(chart, createView, defaults, options,\n  priceOptions?, paneIndex?)` builds on it and hands `createView` a ready\n  `GapCheck` plus the options getter.\n\nThe returned API keeps its identity in chart events; `setData`, `update`,\n`pop` and `applyOptions` are wrapped, everything else is the host's.\n\nRead: `stacked-area-series/src/stacked-area-series.ts` (both concerns),\n`stacked-bars-series/src/stacked-bars-series.ts` (options only).\n\n### `custom-series/stacking` — `cumulativeSum`, `stackLevels`, `stackedPlotValues`\n\nRunning totals of a values array; the band boundaries of a stack drawn from\na `base` (negative values fold back towards it, so bands never overlap); and\n`[min, max, total]` for `priceValueBuilder`, where min and max are taken over\nthe running totals *and* the base so a stack with negatives stays in view.\n\nRead: `stacked-area-series/src/stacked-area-series.ts`, `stacked-bars-series/src/stack.ts`.\n\n### `custom-series/line-paths` — `buildLinePath`, `buildStepLinePath`, `areaBetween`, `strokeStyledPolyline`\n\n`Path2D` builders in bitmap space: a polyline over a bar range with an\naccessor for `y`, its stepped variant, the closed area between two such\nlines (for bands and stacks), and a polyline whose color changes along its\nlength without a visible seam (adjacent runs share their boundary bar). A run\nof `strokeStyledPolyline` may carry a `dashPattern` (`getDashPattern(style,\nlineWidth)`), stroked with `butt` caps; runs without one keep the context's\nown dash and cap.\n\nRead: `hlc-area-series/src/renderer.ts`, `brushable-area-series/src/renderer.ts`.\n\n## Primitives\n\n### `plugin-base` — `PluginBase`\n\nSeries-primitive base: holds `chart` and `series` from `attached`, exposes\n`requestUpdate()`, and throws if `chart` is read before attach. Subclasses\nthat override `attached`/`detached` call `super`.\n\nRead: `vertical-line/src/vertical-line.ts`, `image-watermark/src/image-watermark.ts`.\n\n### `pane-plugin-base` — `PanePluginBase<T>`\n\nThe same for a pane primitive: `chart` and `requestUpdate()`; there is no\nseries. Read: `accessibility/src/pane-primitive.ts`.\n\n### `axis-label-view` — `AxisLabelView`, `AxisLabelSource`, `OFFSCREEN_LABEL_COORDINATE`\n\nAn `ISeriesPrimitiveAxisView` over a source of callbacks (`coordinate`,\n`text`, `textColor`, `backColor`, `visible`, `tickVisible`). Returns the\noff-screen coordinate when the source has none, so the axis draws nothing\nrather than a stray label at 0.\n\nRead: `vertical-line/src/vertical-line.ts`.\n\n### `dom/pane-element` — `paneContentElement`, `chartTableElement`\n\nThe pane's canvas wrapper cell, to append a DOM overlay to, and the chart's\ntable element. Pane widgets reuse rows when panes move, so hold the pane API\nby identity and re-resolve the element on `updateAllViews`.\n\nRead: `accessibility/src/dom/pane-dom.ts`.\n\n### `dom/media-query` — `subscribeMediaQuery`, `mediaQueryMatches`, `HIGH_CONTRAST_QUERIES`, `REDUCED_MOTION_QUERY`\n\nShared, SSR-safe `matchMedia` subscriptions (no `window` at import time).\nRead: `accessibility/src/high-contrast.ts`.\n\n## Pixel-perfect dimensions\n\nAll return bitmap-space `{ position, length }` (`BitmapPositionLength`, from\n`dimensions/common`), computed the way the chart's own renderers do so a\nplugin lines up with built-in series at every device pixel ratio.\n\n| Module | Export | Use |\n| --- | --- | --- |\n| `dimensions/positions` | `positionsLine(centre, pixelRatio, width)`, `positionsBox(a, b, pixelRatio)` | a crisp line of a given CSS width; a box between two coordinates |\n| `dimensions/columns` | `calculateColumnPositions(items, barSpacing, pixelRatio)`, `…InPlace` | evenly spaced columns with the histogram's gap; items may carry `time` (logical index) so a gap is not bridged |\n| `dimensions/candles` | `candlestickWidth(barSpacing, pixelRatio)` | the body width the built-in candlestick uses |\n| `dimensions/full-width` | `fullBarWidth(x, halfSpacing, pixelRatio)`, `fullBarWidthAfter(previousRight, x, halfSpacing, pixelRatio)` | a bar filling its whole slot; neighboring columns that share an edge, with no seam |\n| `dimensions/crosshair-width` | `gridAndCrosshairMediaWidth`, `gridAndCrosshairBitmapWidth` | line widths matching the grid |\n\nRead: `rounded-candles-series/src/renderer.ts`, `pretty-histogram-series/src/renderer.ts`.\n\n## Canvas and style\n\n### `canvas/round-rect` — `drawRoundRect`, `drawRoundRectWithBorder`, `clampCornerRadius`, `CornerRadii`\n\nRounded rectangles in bitmap space, with per-corner radii, radius clamping\nto the rectangle's size, and an inset border that does not shrink the fill.\nRead: `pretty-histogram-series/src/renderer.ts`, `dual-range-histogram-series/src/renderer.ts`.\n\n### `canvas/markers` — `beginMarker`, `beginMarkerOffset`, `traceMarker`, `traceMarkerOffset`, `markerDistance`, `markerVertices`, `segmentDistance`, `MarkerShape`\n\nPoint markers (`circle`, `square`, `diamond`, `triangleUp`, `triangleDown`),\ntwo ways:\n\n- one marker per path (a different color or opacity per point):\n  `beginMarker(ctx, shape, x, y, radius)` calls `ctx.beginPath()` and traces\n  the marker as the path's only subpath, then fill or stroke. A circle is a\n  bare `arc`, which Chromium draws faster, as an exact oval.\n- many markers per path (one style, one `fill()`): `traceMarker(path, shape,\n  x, y, radius)` adds each to a context or `Path2D` as a subpath of its own,\n  so no line joins them. Begin the path yourself.\n\n`traceMarkerOffset(…, offset)` / `beginMarkerOffset(…, offset)` trace the\noutline `offset` outside the marker, with rounded corners, for a hover ring\nor halo of even width;\n`markerDistance(shape, dx, dy, radius, strokeWidth)` is the distance from a\npoint to the marker as drawn, stroke and rounded corners included, `0` inside,\nfor `hitTest`. All three read the same vertices, so a marker is hit where it is\ndrawn. `segmentDistance` is the building block for hovering a polyline.\nRead: `scatter-series/src/renderer.ts`, `scatter-series/src/hit-test.ts`.\n\n### `line-style` — `setLineStyle`, `getDashPattern`, `LineStyle`\n\nThe chart's own dash patterns for a renderer that receives no drawing utils\n(custom series renderers before 5.1, primitives on some hosts). The `LineStyle`\ntype takes the library's enum as well, so an option passes without a cast.\nStroke a dashed style with `ctx.lineCap = 'butt'`, as the chart does: a round\ncap closes the gaps of a dotted line (`strokeStyledPolyline` does it for a\nrun given a `dashPattern`).\nRead: `vertical-line/src/vertical-line.ts`.\n\n## Chart behavior\n\nLibrary rules a plugin otherwise copies from the library's source. Each\nmodule names the source it mirrors; the interaction flags are pinned to it by\na unit test.\n\n| Module | Export | Use |\n| --- | --- | --- |\n| `chart/compat` | `supportsSeriesOrder(series)` | calling `setSeriesOrder` (5.0.6) from a plugin whose floor is 5.0: the guard narrows the series, so the call compiles against the 5.0 typings and is skipped on a host without the method |\n| `chart/interaction-flags` | `canUserMoveTimeScale(chart.options())`, `TIME_SCALE_MOVE_FLAGS` | whether the user can scroll or zoom the time scale; with none of the flags on, the chart treats both edges as fixed |\n| `chart/lifecycle` | `isChartRemoved(chart)`, `isSeriesAttached(chart, series)` | for a plugin with its own API in front of a series: stop writing to a chart the host removed, or a series it took off with `chart.removeSeries`. Read-only; decide outside the chart's event dispatch what to release |\n| `chart/time-axis-labels` | `timeAxisLabelFont`, `tickMarkPixelsPerCharacter`, `tickMarkMaxLabelWidth`, `tickMarkCharactersForWidth` | the time axis' label font, and `timeScale.tickMarkMaxCharacterLength` to pixels and back |\n| `text/measure` | `textMeasureContext()`, `createTextWidthCache()` | measuring labels before painting (layout, overlap avoidance); `null` without a DOM |\n\nRead: `scatter-series/src/x-axis-controller.ts`, and `scatter-series-api.ts` for\nthe lifecycle checks; `background-shade-series/src/background-shade-series.ts`\nfor `supportsSeriesOrder`.\n\n## General\n\n| Module | Export | Use |\n| --- | --- | --- |\n| `assertions` | `ensureDefined`, `ensureNotNull` | narrow or throw, for state that must exist after attach |\n| `delegate` | `Delegate`, `ISubscription` | a small subscribe/fire event; expose the `ISubscription` half publicly |\n| `time` | `convertTime`, `convertTimeUTC`, `displayTime`, `formattedDateAndTime` | `Time` (string, business day, timestamp) to a number or display string |\n| `closest-index` | `ClosestTimeIndexFinder` | cached binary search for the index at or after a time |\n| `min-max-in-range` | `UpperLowerInRange` | cached extremes over a range, for autoscale providers |\n| `simple-clone` | `cloneReadonly` | deep clone that drops readonly-ness, through JSON (functions and `undefined` are lost) |\n| `options/merge` | `mergeOptions`, `cloneOptions`, `freezeOptions` | `applyOptions` with nested options: a partial nested option changes only its keys (a spread replaces the whole object); arrays and functions replace; unsafe keys are skipped; pass `defaults` to make `null` reset a value |\n| `numbers` | `isFiniteNumber`, `finiteOr`, `nonNegativeOr`, `clampOpacity` | numeric options from JavaScript: the canvas ignores a `NaN` width or opacity silently |\n| `scheduling/coalesced-task` | `createCoalescedTask(run, enqueue?)` | `{ schedule, cancel, pending }`: once per microtask (or frame) for a burst of events, never inside the chart's dispatch; `cancel()` on removal |\n",".github/skills/lightweight-charts/SKILL.md":"---\nname: lightweight-charts\ndescription: >-\n  Use when working with TradingView's lightweight-charts — creating charts,\n  adding series (Line/Area/Bar/Candlestick/Histogram), configuring time and\n  price scales, streaming realtime or historical data, panes, markers,\n  per-bar/per-point colors, tooltips, coordinate conversion, custom plugins or\n  primitives, non-financial horizontal scales, SSR/browser loading, or\n  React/Vue/Web Components wrappers. Covers v5 API conventions and the common\n  time, scale, marker, plugin, and wrapper foot-guns.\n---\n\n# Lightweight Charts skill\n\nWorks the same whether the project is a downstream npm consumer app or an upstream `lightweight-charts` source checkout. Detect which one you are in (below) and resolve every API name from whatever typings are locally available.\n\n## Source lookup order\n\nDo not assume you are inside the upstream source repository.\n\n1. In a consumer app, inspect the installed package first:\n   - `node_modules/lightweight-charts/package.json` for the actual version.\n   - `node_modules/lightweight-charts/dist/typings.d.ts` for the API surface.\n2. In the upstream repo, inspect `dist/typings.d.ts` first, then `src/` if generated output is unavailable.\n3. Use official docs/examples as supporting evidence, but local typings win when they disagree.\n\nVerify before answering (copy-paste):\n\n```sh\nnode -p \"require('./node_modules/lightweight-charts/package.json').version\"\nrg -n \"createSeriesMarkers|addSeries|IPrimitivePaneRenderer|createImageWatermark|createOptionsChart\" node_modules/lightweight-charts/dist/typings.d.ts\n# upstream checkout instead of a consumer app:\nrg -n \"createSeriesMarkers|IPrimitivePaneRenderer|createImageWatermark|createOptionsChart\" dist/typings.d.ts src\n```\n\nIf the relevant file is unavailable, say what could not be verified. Do not invent option names, methods, exports, or wrapper behavior.\n\nIf the user's code imports `from lightweight_charts import ...` (underscore), uses pandas/asyncio, or talks about a Python window wrapper, they are probably using the third-party Python wrapper rather than the TypeScript package. Say that clearly before giving core `lightweight-charts` v5 JavaScript advice.\n\n## Mental model\n\nEight layers, in dependency order. Most bugs come from confusing one for another:\n\n1. **Chart** — `createChart(container, options)` returns an `IChartApi`. One chart per container element.\n2. **Series** — added via `chart.addSeries(SeriesType, options, paneIndex?)`. Each call returns an `ISeriesApi`. v5 requires importing the series type explicitly.\n3. **Scales** — `chart.timeScale()` (`ITimeScaleApi`), `chart.priceScale(id)` (`IPriceScaleApi`). Govern range, ticks, autoscale, visibility.\n4. **Data model** — arrays of `{ time, … }` points. `Time = UTCTimestamp | BusinessDay | string`. `UTCTimestamp` is **seconds**, not milliseconds. Times must be unique and ascending per series.\n5. **Interaction** — `chart.subscribeCrosshairMove`, `chart.subscribeClick`, `timeScale.subscribeVisibleLogicalRangeChange`, etc.\n6. **Layout** — `chart.panes()`, `chart.addPane()`. Adding a series with an out-of-range `paneIndex` auto-creates the pane.\n7. **Extension** — pane primitives, series primitives, custom series, watermarks, custom renderers (canvas via `fancy-canvas`).\n8. **Wrappers** — React/Vue/Web Components/iOS/Android. Lifecycle is the wrapper's responsibility; the core library is framework-agnostic.\n\n## v5 essentials\n\nThe conventions that catch people copying older snippets:\n\n```ts\nimport { createChart, CandlestickSeries, LineSeries } from 'lightweight-charts';\n\nconst chart = createChart(container, { /* ChartOptions */ });\nconst candles = chart.addSeries(CandlestickSeries, { /* options */ });\ncandles.setData([\n    { time: 1700000000, open: 1, high: 2, low: 0.5, close: 1.5 },\n]);\n```\n\nKey v5 changes versus older snippets:\n\n- `chart.addSeries(SeriesType, options, paneIndex?)` replaces `addLineSeries` / `addCandlestickSeries` / …\n- `createSeriesMarkers(series, markers)` replaces `series.setMarkers(...)`. The returned primitive owns `.setMarkers(...)` / `.markers()`.\n- `createTextWatermark(pane, options)` and `createImageWatermark(pane, imageUrl, options)` replace the `watermark` chart option.\n- Series types are tree-shaken — importing them is required for ESM.\n\nIf a snippet calls `addLineSeries` or `series.setMarkers`, it's v4 or older. Confirm the user's version before forwarding it.\n\nWhen the task targets v5, show the v5 API directly — do not hedge by mixing in v4 syntax.\n\n## Triage (problem → API → avoid)\n\n| User asks about | First check | Answer with | Avoid |\n|---|---|---|---|\n| v5 series creation | package version + typings | `chart.addSeries(SeriesType, options)` | `addLineSeries` / `addCandlestickSeries` |\n| markers | `createSeriesMarkers` export | marker primitive + required `color` | `series.setMarkers` |\n| timezone | formatter need vs data semantics | `Intl.DateTimeFormat` in formatters | fake `timeScale.timezone` |\n| realtime updates | last-bar vs full replace | `series.update(point)` | `setData` on every tick |\n| panes | `paneIndex` + `chart.panes()` | v5 pane APIs, `pane.setHeight` | private widget / DOM hacks |\n| per-bar colors | data-point color fields | `color`/`borderColor`/`wickColor` on points | extra series / markers to recolor |\n| plugins | primitive vs custom series | scaffold/examples + public coordinate APIs | invented renderer names |\n\n### v4 → v5 replacement matrix\n\nStale copy-pasted snippets are the most common failure. Map them directly:\n\n| Old or wrong | v5 replacement |\n|---|---|\n| `chart.addLineSeries(options)` | `chart.addSeries(LineSeries, options)` |\n| `chart.addCandlestickSeries(options)` | `chart.addSeries(CandlestickSeries, options)` |\n| `series.setMarkers(markers)` | `createSeriesMarkers(series, markers)` |\n| chart `watermark` option | `createTextWatermark(chart.panes()[0], options)` |\n| `createImageWatermark(pane, options)` | `createImageWatermark(pane, imageUrl, options)` |\n| `IPanePrimitivePaneRenderer` | `IPrimitivePaneRenderer` |\n| `timeScale: { timezone }` | label formatters using `Intl.DateTimeFormat` |\n| `time: Date.now()` (ms) | `time: Math.floor(Date.now() / 1000)` for `UTCTimestamp` |\n\n## Routing map (problem → where to look)\n\nUse local typings first. The repo paths below exist only in the upstream `lightweight-charts` checkout; in a consumer app, translate them to the installed package typings or official docs.\n\n| Task | Canonical sources |\n|---|---|\n| First chart / series | `website/docs/intro.mdx`, `website/tutorials/customization/` |\n| Time / range behavior | `website/docs/time-scale.md`, `website/docs/time-zones.md` |\n| Realtime / history | `website/examples/data/realtime-updates.{mdx,js}`, `website/examples/data/infinite-history.{mdx,js}` |\n| Whitespace / gaps | `website/examples/data/whitespace.{mdx,js}` |\n| Price format / locale | `website/tutorials/customization/price-format.mdx`, `website/examples/styling/custom-locale.{mdx,js}` |\n| Two scales / inverted | `website/examples/price-scales/two-price-scales.{mdx,js}`, `website/examples/price-scales/inverted-price-scale.{mdx,js}` |\n| Panes / price + volume | `website/docs/panes.md`, `website/examples/panes/multiple-panes.{mdx,js}`, `website/examples/price-scales/price-and-volume.{mdx,js}` |\n| Markers / tooltips / legends | `website/examples/markers-and-lines/series-markers.{mdx,js}`, `website/examples/tooltips-and-legends/*-tooltip.{mdx,js}`, `website/examples/tooltips-and-legends/*legend.{mdx,js}` |\n| Crosshair (programmatic) | `website/examples/crosshair/*.{mdx,js}` |\n| Watermarks | `website/examples/styling/*-watermark.{mdx,js}` |\n| Plugins / custom series / primitives | `website/docs/plugins/`, `plugin-examples/src/plugins/` |\n| Coordinate conversion / hit-testing | `dist/typings.d.ts` for `subscribeClick`, `coordinateToPrice`, `timeScale().coordinateToLogical` |\n| Non-time horizontal scales / options chart | `dist/typings.d.ts` for `createOptionsChart`, `createChartEx`, `IHorzScaleBehavior` |\n| Pixel-perfect rendering | `website/docs/plugins/pixel-perfect-rendering/` |\n| React / Vue / Web Components | `website/tutorials/react/`, `website/tutorials/vuejs/`, `website/tutorials/webcomponents/` |\n| SSR / script loading / bundlers | installed package `dist/` files, package `exports`, framework docs for client-only components |\n| iOS / Android wrappers | `website/docs/ios.md`, `website/docs/android.md` |\n| Version migration | `website/docs/migrations/from-v2-to-v3.md`, `from-v3-to-v4.md`, `from-v4-to-v5.md` |\n\nIf these repo paths do not exist in the user's project, do not ask them to create or clone the source tree just to answer a normal usage question. Use `node_modules/lightweight-charts/dist/typings.d.ts` and concise v5 examples.\n\n## Foot-guns (assertions, not categories)\n\n### Time\n\n- **`UTCTimestamp` is in seconds.** Use `Math.floor(Date.now() / 1000)`, never `Date.now()`.\n- **There is no built-in `timeScale.timezone` option.** For display-only timezone conversion, use `timeScale.tickMarkFormatter` for axis labels and `localization.timeFormatter` (or your own tooltip formatter) for crosshair/hover labels. Use `Intl.DateTimeFormat(..., { timeZone })`, Luxon, or date-fns-tz for DST-safe IANA timezone formatting.\n- **Pre-shifting timestamps changes chart semantics.** It can make ticks line up in a chosen timezone, but it also changes where bars sit on the UTC time scale. Prefer formatter-based display unless the user intentionally wants shifted data.\n- **Series data must be strictly ascending by `time`, with unique values.** Duplicates replace silently; out-of-order points are dropped or throw.\n- **One time format per series.** `BusinessDay` (`'YYYY-MM-DD'` string or `{ year, month, day }`) or `UTCTimestamp`, but do not mix within a single series.\n- **Business day strings must be zero-padded `'YYYY-MM-DD'`.** `'2024-1-5'`, `'2024/01/05'` or `'Jan 5 2024'` throw. Pad the string or pass `{ year, month, day }`.\n- **Whitespace points carry `time` only** (no `value` / `open` / …). Use them to create gaps or align overlays; do not set values to `null`.\n- **`setData` replaces the dataset and can reset the visible range. `update(point)` appends if `time > last` and replaces if `time === last`.** `update(point, true)` can update an existing historical point, but it is slower and does not insert missing old points. To prepend older history, build a new array and call `setData` again — there is no prepend method; save and restore the visible logical range to avoid the chart snapping.\n- **`timeScale.setVisibleLogicalRange` is logical (bar indices), not time-based.** Use `setVisibleRange` for time bounds, or `fitContent()` to reset.\n\n### Scales and panes\n\n- **Two visible price scales** requires both assigning series with `priceScaleId: 'right'` / `'left'` and making the left scale visible. Use `chart.applyOptions({ leftPriceScale: { visible: true }, rightPriceScale: { visible: true } })` or `chart.priceScale('left').applyOptions({ visible: true })`.\n- **Overlay series** (`priceScaleId: ''` or any custom id) get an autoscaled, hidden scale by default. Make it visible explicitly if you want axis labels.\n- **`autoscaleInfoProvider` runs on every layout pass.** Keep it cheap; do not allocate per call.\n- **`addSeries(_, _, paneIndex)` creates the pane** if `paneIndex` is one past the current count. Pane order is creation order; sizes are controlled via `chart.panes()[i].setHeight(px)`.\n- **Keep pane references if panes can move.** `const mainPane = chart.panes()[0]` remains the same `IPaneApi`; `mainPane.paneIndex()` gives its current index after `swapPanes` or moves.\n- **Sync separate charts with public time-scale events.** Use `subscribeVisibleLogicalRangeChange` and `setVisibleLogicalRange`; avoid `_private__chartWidget`, `paneWidgets`, or DOM offset hacks.\n- **Price-scale width is readable, not directly settable.** Use `series.priceScale().width()` or `chart.priceScale(id).width()` to measure when aligning adjacent containers.\n\n### Markers and interaction\n\n- **v5 markers are a primitive.** `const m = createSeriesMarkers(series, [...]); m.setMarkers([...])`. `series.setMarkers` does not exist on `ISeriesApi` in v5.\n- **Marker `time` must match an existing data point's `time`** for that series. Misaligned markers are dropped silently.\n- **`subscribeCrosshairMove`** fires with `param.time === undefined` outside the data range. Always null-check before reading.\n- **`param.seriesData.get(series)`** returns `undefined` between bars or before the first bar.\n- **Click/crosshair coordinates need API conversion.** Use `series.coordinateToPrice(y)` / `series.priceToCoordinate(price)` and `chart.timeScale().coordinateToLogical(x)` / `logicalToCoordinate(logical)` / `timeToCoordinate(time)`; do not infer price/time from canvas DOM geometry.\n\n### Plugins and custom rendering\n\n- **Start plugins from the scaffold/examples.** Prefer `npm create lwc-plugin@latest` and `plugin-examples/` before writing a primitive from scratch.\n- **Interactive drawing tools need two parts:** a primitive/custom series for rendering, and chart interaction handlers (`subscribeClick`, `subscribeCrosshairMove`, drag state) that convert coordinates with public APIs.\n- **`CanvasRenderingTarget2D` is imported from `fancy-canvas`,** not from `lightweight-charts`.\n- Use `target.useBitmapCoordinateSpace(scope => …)` for pixel-aligned strokes; use `target.useMediaCoordinateSpace(scope => …)` for CSS-pixel logic. Mixing them causes blur or sub-pixel jitter on HiDPI displays.\n- **`IPanePrimitive` views render across the whole pane; `ISeriesPrimitive` views are clipped to the series.** Pick the right base.\n- **The renderer interface is `IPrimitivePaneRenderer`, not `IPanePrimitivePaneRenderer`.** The view is `IPanePrimitivePaneView` and its `renderer()` returns `IPrimitivePaneRenderer | null` — the names are deliberately asymmetric. There is no `IPanePrimitivePaneRenderer` export; grep `dist/typings.d.ts` if unsure.\n- **`ICustomSeriesPaneView` is heavier than a primitive** — only use it when you need a true series API (data, scales, autoscale). For decorations, use a primitive.\n\n### Wrappers (React/Vue/etc.)\n\n- **Create the chart once** in `useEffect` / `onMounted` and destroy it in cleanup with `chart.remove()`. Recreating on every render duplicates DOM and leaks listeners.\n- **Resize can be automatic in v5** with `autoSize: true` when `ResizeObserver` is available. If you need manual control, subscribe a `ResizeObserver` to the container and call `chart.resize(width, height)` (or `applyOptions({ width, height })`).\n- **Don't drive `setData` from props on every render.** Use `series.update(...)` for incremental changes; only call `setData` when the dataset truly replaces.\n- **`undefined` in `applyOptions` means \"not specified\", not \"reset\".** `{ priceFormatter: custom ? fmt : undefined }` leaves the current formatter in place. To clear a `localization` formatter or `autoscaleInfoProvider`, pass `null`. Other options have no reset value: pass the default explicitly.\n- **Next.js/SSR must be client-only.** Put chart code in a `'use client'` component, create it in `useEffect`, and import that component with `next/dynamic(..., { ssr: false })` from server-rendered pages when needed.\n- **Plain HTML is not npm resolution.** The standalone `.js` build exposes `window.LightweightCharts`; ESM in the browser must import an actual `.mjs` URL or use an import map. `import { createChart } from 'lightweight-charts'` only works when a bundler/runtime resolves the package name.\n\n## Canonical recipes\n\n### Realtime updates\n\n```ts\nimport { createChart, CandlestickSeries } from 'lightweight-charts';\n\nconst chart = createChart(container, {});\nconst series = chart.addSeries(CandlestickSeries, {});\nseries.setData(initialBars); // full history once\n\nws.onmessage = ev => {\n    const bar = JSON.parse(ev.data); // { time, open, high, low, close }\n    series.update(bar); // appends if time > last; replaces if time === last\n};\n```\n\n`update()` only handles the latest bar. To insert in the middle or prepend, rebuild the array and call `setData`.\n\n### Two price scales (left + right)\n\n```ts\nconst right = chart.addSeries(LineSeries, { priceScaleId: 'right' });\nconst left  = chart.addSeries(LineSeries, { priceScaleId: 'left' });\nchart.applyOptions({\n    leftPriceScale: { visible: true },\n    rightPriceScale: { visible: true },\n});\n```\n\n### Volume in its own pane\n\n```ts\nconst price  = chart.addSeries(CandlestickSeries, {}, 0);\nconst volume = chart.addSeries(\n    HistogramSeries,\n    { priceFormat: { type: 'volume' } },\n    1,\n);\nchart.panes()[1].setHeight(120);\n```\n\n### Per-bar / per-point colors\n\nColor individual bars by putting the color on the **data point**, not via a separate API:\n\n```ts\n// Candlesticks: per-point color / borderColor / wickColor override series defaults\ncandles.setData([\n    { time: 1700000000, open: 1, high: 2, low: 0.5, close: 1.5,\n      color: '#26a69a', borderColor: '#26a69a', wickColor: '#26a69a' },\n    { time: 1700003600, open: 1.5, high: 1.8, low: 1.1, close: 1.2,\n      color: '#ef5350', borderColor: '#ef5350', wickColor: '#ef5350' },\n]);\n\n// Histogram (e.g. up/down volume): per-point color\nvolume.setData([\n    { time: 1700000000, value: 100, color: 'rgba(38,166,154,0.5)' },\n    { time: 1700003600, value: 80, color: 'rgba(239,83,80,0.5)' },\n]);\n```\n\nLine/Area points also take a per-point `color`. An omitted point color falls back to the series option. Do not create extra series or use markers to recolor bars.\n\n### Series markers\n\n```ts\nimport { createSeriesMarkers } from 'lightweight-charts';\n\nconst markers = createSeriesMarkers(candles, [\n    { time: 1700000000, position: 'aboveBar', color: '#e53935', shape: 'arrowDown', text: 'Sell' },\n]);\n\nmarkers.setMarkers([\n    { time: 1700003600, position: 'belowBar', color: '#43a047', shape: 'arrowUp', text: 'Buy' },\n]);\n```\n\n`color` is required on every marker (`position`, `shape`, `time` too); `text`, `size`, `id`, `price` are optional. Do not put marker objects into `setData()` points. Do not call `series.setMarkers(...)` in v5.\n\n### Timezone display\n\n```ts\nconst zone = 'America/New_York';\nconst formatTime = (timestamp: number) =>\n    new Intl.DateTimeFormat('en-US', {\n        timeZone: zone,\n        hour: '2-digit',\n        minute: '2-digit',\n        second: '2-digit',\n        hour12: false,\n    }).format(new Date(timestamp * 1000));\n\nchart.applyOptions({\n    timeScale: {\n        timeVisible: true,\n        secondsVisible: true,\n        tickMarkFormatter: (time) =>\n            typeof time === 'number' ? formatTime(time) : String(time),\n    },\n    localization: {\n        timeFormatter: (time) =>\n            typeof time === 'number' ? formatTime(time) : String(time),\n    },\n});\n```\n\nDo not invent `timeScale: { timezone: 'America/New_York' }`. If the user needs exchange-session boundaries to generate in a local timezone, explain the trade-off of shifting source timestamps separately from display formatting.\n\n### Text watermark\n\n```ts\nimport { createTextWatermark } from 'lightweight-charts';\n\ncreateTextWatermark(chart.panes()[0], {\n    horzAlign: 'center',\n    vertAlign: 'center',\n    lines: [{ text: 'DEMO', color: 'rgba(0, 0, 0, 0.25)', fontSize: 48 }],\n});\n```\n\nThe old `watermark` chart option is not the v5 API.\n\n### Whitespace gaps\n\n```ts\nline.setData([\n    { time: '2024-01-01', value: 10 },\n    { time: '2024-01-02' }, // whitespace point: time only\n    { time: '2024-01-03', value: 12 },\n]);\n```\n\nDo not use `value: null`, `undefined`, or `NaN` to create gaps.\n\n### Sync separate charts or panes\n\n```ts\nlet syncing = false;\n\npriceChart.timeScale().subscribeVisibleLogicalRangeChange((range) => {\n    if (!range || syncing) return;\n    syncing = true;\n    indicatorChart.timeScale().setVisibleLogicalRange(range);\n    syncing = false;\n});\n\nindicatorChart.timeScale().subscribeVisibleLogicalRangeChange((range) => {\n    if (!range || syncing) return;\n    syncing = true;\n    priceChart.timeScale().setVisibleLogicalRange(range);\n    syncing = false;\n});\n```\n\nFor v5 panes inside one chart, prefer `chart.addSeries(SeriesType, options, paneIndex)` and `chart.panes()[i].setHeight(px)`. If the original pane can move, keep the `IPaneApi` reference and call `pane.paneIndex()` instead of assuming index `0` forever.\n\n### Coordinate conversion\n\n```ts\nchart.subscribeClick((param) => {\n    if (!param.point || param.time === undefined) return;\n\n    const price = series.coordinateToPrice(param.point.y);\n    const logical = chart.timeScale().coordinateToLogical(param.point.x);\n    if (price === null || logical === null) return;\n\n    // Store { time: param.time, price } or convert logical back later:\n    const x = chart.timeScale().logicalToCoordinate(logical);\n    const y = series.priceToCoordinate(price);\n});\n```\n\nUse the public conversion APIs for drawing tools and annotations. DOM canvas coordinates alone cannot tell you the chart price/time.\n\n### Next.js client-only component\n\n```tsx\n'use client';\n\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport type { ISeriesApi, LineData, Time } from 'lightweight-charts';\nimport { useEffect, useRef } from 'react';\n\nexport function LwcChart({ data }: { data: LineData<Time>[] }) {\n    const ref = useRef<HTMLDivElement | null>(null);\n    const seriesRef = useRef<ISeriesApi<'Line'> | null>(null);\n\n    useEffect(() => {\n        if (!ref.current) return;\n        const chart = createChart(ref.current, { autoSize: true });\n        const series = chart.addSeries(LineSeries);\n        seriesRef.current = series;\n        return () => {\n            seriesRef.current = null;\n            chart.remove();\n        };\n    }, []);\n\n    useEffect(() => {\n        seriesRef.current?.setData(data);\n    }, [data]);\n\n    return <div ref={ref} style={{ width: '100%', height: 320 }} />;\n}\n```\n\nFrom a server-rendered Next.js page, import the component with:\n\n```tsx\nimport dynamic from 'next/dynamic';\n\nconst LwcChart = dynamic(() => import('./LwcChart').then((m) => m.LwcChart), {\n    ssr: false,\n});\n```\n\n### Plain HTML loading\n\nUse the standalone IIFE build when there is no bundler:\n\n```html\n<div id=\"chart\" style=\"width: 600px; height: 300px\"></div>\n<script src=\"https://unpkg.com/lightweight-charts/dist/lightweight-charts.standalone.production.js\"></script>\n<script>\n  const chart = LightweightCharts.createChart(document.getElementById('chart'));\n  const series = chart.addSeries(LightweightCharts.LineSeries);\n</script>\n```\n\nChoose the loading shape by environment:\n\n- **Bundler (Vite/webpack/Next):** bare `import { createChart } from 'lightweight-charts'`. The package `exports` resolve the right ESM/CJS build.\n- **Browser `<script>` (no bundler):** the standalone IIFE build above exposes the `LightweightCharts` global; there is no bare-specifier resolution.\n- **Browser native ESM (`<script type=\"module\">`):** import from a concrete `.mjs` URL (e.g. the standalone `.mjs`) or add an import map; a bare `'lightweight-charts'` specifier will not resolve.\n- **SSR frameworks:** load client-only (see the Next.js recipe above) — never import at module top level in a server component.\n\n### Plugin starter\n\n```sh\nnpm create lwc-plugin@latest\n```\n\nUse the generated project and `plugin-examples/` as the base. Decide the extension type first:\n\n- **Primitive** (`IPanePrimitive` / `ISeriesPrimitive`, attached via `attachPrimitive`) — for drawings, overlays, labels, bands, annotations, hit-testing. This is the default; reach for it unless you need real series behavior.\n- **Custom series** (`ICustomSeriesPaneView`) — only when the extension needs its own data, autoscale, or price/time-scale integration. It is heavier; do not use it for decorations.\n\nFor draggable drawings, attach a primitive with `series.attachPrimitive(...)` or `pane.attachPrimitive(...)`, then manage interaction with `subscribeClick` / `subscribeCrosshairMove` and coordinate conversion APIs. Import renderer-only `CanvasRenderingTarget2D` from `fancy-canvas`. The renderer interface is `IPrimitivePaneRenderer` (not `IPanePrimitivePaneRenderer`).\n\n### Non-financial data\n\n```ts\nimport { createOptionsChart } from 'lightweight-charts';\n\nconst chart = createOptionsChart(container);\n```\n\nDecide first whether the horizontal axis is truly non-time:\n\n- **True custom horizontal scale** (option chains, sensor sweeps by a non-time key): use `createOptionsChart` for a numeric x-axis, or `createChartEx` with a custom `IHorzScaleBehavior` (verify both in local typings).\n- **Just non-financial y units** (temperature, load) on an ordinary time/category axis: keep the normal `createChart` series model and set `priceFormat` / `localization.priceFormatter` so labels match the domain.\n- **Categorical x that is really ordered**: mapping categories to ascending `BusinessDay` strings is simpler than a custom scale — but say that the axis is then date-like, not truly categorical.\n\n### Custom price formatter\n\n```ts\nchart.applyOptions({\n    localization: {\n        priceFormatter: (p: number) => `$${p.toFixed(2)}`,\n    },\n});\n```\n\nFor per-series formatting, set `priceFormat: { type: 'custom', formatter, minMove }` in the series options — the chart-level `priceFormatter` is the fallback.\n\nTo go back to the built-in formatting, pass `null`: `chart.applyOptions({ localization: { priceFormatter: null } })`. Passing `undefined` leaves the current formatter in place.\n\n### Minimal pane primitive\n\n```ts\nimport type {\n    IPanePrimitive,\n    IPanePrimitivePaneView,\n    IPrimitivePaneRenderer,\n    Time,\n} from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D } from 'fancy-canvas';\n\nclass Overlay implements IPanePrimitive<Time> {\n    paneViews(): IPanePrimitivePaneView[] { return [new View()]; }\n}\nclass View implements IPanePrimitivePaneView {\n    renderer(): IPrimitivePaneRenderer { return new Renderer(); }\n}\nclass Renderer implements IPrimitivePaneRenderer {\n    draw(target: CanvasRenderingTarget2D): void {\n        target.useMediaCoordinateSpace(({ context, mediaSize }) => {\n            context.fillStyle = 'rgba(0,0,0,0.05)';\n            context.fillRect(0, 0, mediaSize.width, mediaSize.height);\n        });\n    }\n}\n\nchart.panes()[0].attachPrimitive(new Overlay());\n```\n\nWorking examples live under `plugin-examples/src/plugins/` — copy structure from there before writing one from scratch.\n\n## Worked example\n\n> *\"My chart snaps to the right edge every time new data arrives.\"*\n\n1. **Layers involved:** data model (4) and time scale (3).\n2. **Suspect:** the code calls `series.setData(...)` on every tick instead of `series.update(...)`. `setData` resets the visible range.\n3. **Verify:** ask whether the call path is `setData` or `update`. If `setData`, ask whether the visible logical range is captured before and restored after — the v4-era workaround.\n4. **Fix:** switch to `series.update(bar)` for incremental ticks; reserve `setData` for full-history replacement; only use `chart.timeScale().scrollToRealTime()` if the user explicitly wants follow-the-latest behavior.\n5. **References:** `website/examples/data/realtime-updates.js`, `website/docs/time-scale.md`.\n\n## Code-generation rules\n\n- **Default to v5.** Assume v5 APIs unless the user's installed package or prompt pins an older version. If they're on v4, explain the v5 migration point instead of mixing syntaxes.\n- **Use real option names.** In consumer apps, grep `node_modules/lightweight-charts/dist/typings.d.ts`; in the upstream repo, grep `dist/typings.d.ts` or `src/api/options/`. Many similarly-named options exist across chart/series/scale — confirm which level owns the option.\n- **Minimal snippets.** One feature per code block. Combining markers + watermark + custom pane primitive in one snippet hides which API does what.\n- **Match the user's framework.** A React user wants the `useEffect` lifecycle; a vanilla user does not.\n- **Don't invent.** If an API name does not appear in the installed typings or upstream source, it does not exist.\n\n## Answer contract\n\nWhen answering a lightweight-charts question:\n\n1. Name the relevant v5 API.\n2. Show one minimal snippet, not a mega-demo.\n3. Call out the main foot-gun for that task.\n4. Say what local source was checked (version/typings), or state that it could not be verified.\n","packages/create-lwc-plugin/README.md":"# create-lwc-plugin\n\n**create-lwc-plugin** scaffolds a new plugin project for Lightweight Charts™.\nThe wizard asks a few questions and generates a ready-to-run project from a\ntemplate for one of the three plugin types:\n\n- a series primitive\n- a pane primitive\n- a custom series\n\nThe scaffolded project is ready to publish: its `package.json` follows the\nconventions used by the Lightweight Charts™ plugin catalog, so the plugin can\nbe listed there once it is published to npm.\n\n✨ Need some examples for inspiration? Check out the\n[plugin-examples](https://github.com/tradingview/lightweight-charts/tree/master/plugin-examples)\nfolder in the Lightweight Charts™ repo.\n\n## Scaffold your first Lightweight Charts™ plugin\n\nWith npm:\n\n```bash\nnpm create lwc-plugin@latest\n```\n\nWith Yarn:\n\n```bash\nyarn create lwc-plugin\n```\n\nWith pnpm:\n\n```bash\npnpm create lwc-plugin\n```\n\nThe wizard asks for the plugin's name, description, author, license, the minimum\nversion of Lightweight Charts™ it supports, and the tags to list it under. Those\nanswers populate the generated `package.json`, including the `lwcPlugin` block\nread by the plugin catalog.\n\nBefore any of that, the wizard offers to install the\n[plugin-authoring Agent Skill](https://github.com/tradingview/lightweight-charts/blob/master/.github/skills/lightweight-charts-plugin-authoring/SKILL.md)\nfor AI coding assistants such as Claude Code, Codex, and Cursor. The skill helps\nchoose the plugin type, build on `@tradingview/lwc-toolkit`, and pick the right\nofficial plugin as the reference for your idea. It also points to the docs and\nwarns about the autoscale, whitespace, and hit-test mistakes a first plugin\ntends to make.\n\nSay yes, and you have two ways to continue. Carry on with the wizard: the skill\nis installed into the new project when the wizard finishes. Or quit right\nthere: the skill is installed into the current directory, and you hand the rest\nover to your assistant. The assistant knows how to run this wizard with you.\n\nThe skill is installed with the [`skills` CLI](https://github.com/vercel-labs/skills).\nThe CLI asks which assistants to set it up for. You can also run it yourself at\nany time:\n\n```bash\nnpx skills add tradingview/lightweight-charts --skill lightweight-charts-plugin-authoring\n```\n\n## The generated project\n\n### Run locally\n\n```shell\nnpm install\nnpm run dev\n```\n\nVisit `localhost:5173` in the browser.\n\n### Build the plugin\n\n```shell\nnpm run build\n```\n\nThis writes three files into the `dist` folder: the package entry point\n(`<name>.js`), a standalone build for use over a CDN\n(`<name>.standalone.js`) which inlines every dependency except\nLightweight Charts™ itself, and the bundled type declarations (`<name>.d.ts`).\nPlugins are published as ES modules only.\n\n### Publish to npm\n\nThe `package.json` in the project root is the published manifest. Check its\n`description`, `version`, `license` and `lwcPlugin` fields, then publish from\nthe project root:\n\n```shell\nnpm publish\n```\n\nHint: append `--dry-run` to the end of the publish command to see the results of\nthe publish command without actually uploading the package to npm.\n\n## Scaffold an official in-repo plugin\n\nMaintainers working inside the Lightweight Charts™ repository can scaffold a\nworkspace package instead of a standalone project:\n\n```shell\npnpm create lwc-plugin --workspace\n```\n\nWorkspace mode targets `packages/`, scopes the package name to `@tradingview/`,\ndepends on the library and the shared plugin utilities through `workspace:*`,\nseeds a `CHANGELOG.md`, `LICENSE` and `NOTICE`, and marks the plugin as an\nofficial catalog entry.\n","packages/create-lwc-plugin/template-common/README.md":"# _PLUGINNAME_\n\n_DESCRIPTION_\n\n<!--\nExpand the line above into a short paragraph: what the plugin draws or does, and\nwhen someone would reach for it. This is the first thing a reader sees, both on\nnpm and on the plugin registry page.\n-->\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `_PEERVERSION_` in your\nproject:\n\n```shell\nnpm install _PACKAGENAME_\n```\n\nThen import the plugin and add it to a chart:\n\n```js\n_ATTACH_SNIPPET_\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"_PACKAGENAME_\": \"https://unpkg.com/_PACKAGENAME_/dist/_ENTRYNAME_.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\n_ATTACH_SNIPPET_\n</script>\n```\n\n## Usage\n\n<!-- Describe the plugin's typical usage, and anything a caller has to own. -->\n\n```js\n_USAGE_SNIPPET_\n```\n\n## Options\n\n<!--\nList the options the plugin accepts. Add further tables for any nested option\ngroups. Keep this in sync with the option types in the source.\n-->\n\n| Option | Type | Default | Description |\n| ------ | ---- | ------- | ----------- |\n|        |      |         |             |\n\nThe full typed surface is published with the package — see\n[`dist/_ENTRYNAME_.d.ts`](https://unpkg.com/_PACKAGENAME_/dist/_ENTRYNAME_.d.ts),\nalso browsable from the Code tab on the package's npm page.\n\n## Development\n\nInstall the dependencies and start the example page:\n\n```shell\nnpm install\nnpm run dev\n```\n\nVisit `localhost:5173` in the browser. The example under `src/example/` is the\nplugin's live preview — keep it working, and keep it filling the window so that\nit can be embedded.\n\nBuild the publishable bundles into `dist/`:\n\n```shell\nnpm run build\n```\n\nThis produces the package entry point (`dist/_ENTRYNAME_.js`), the standalone\nbuild used over a CDN (`dist/_ENTRYNAME_.standalone.js`) and the bundled type\ndeclarations (`dist/_ENTRYNAME_.d.ts`).\n\n<!-- EXTERNAL_ONLY -->\n## The plugin toolkit\n\nThis project depends on\n[`@tradingview/lwc-toolkit`](https://www.npmjs.com/package/@tradingview/lwc-toolkit),\na small set of helpers written for plugin authors: pixel-perfect coordinate and\nwidth calculations for candles, columns and full-width bars, crosshair-aligned\nline widths, time conversion, and a `PluginBase` class that keeps the chart and\nseries references wired up for you.\n\nDepending on the starter this project was generated from, the code may already\nuse it — check the imports in `src/`. It is a `devDependency`, bundled into\n`dist/` when the plugin is built, so it never becomes a dependency for anyone\ninstalling the plugin. If none of it is needed, uninstall it; nothing else has\nto change.\n<!-- /EXTERNAL_ONLY -->\n\n<!-- EXTERNAL_ONLY -->\n## Publishing to npm\n\nThe `package.json` in the project root is the published manifest: check the\n`description`, `version`, `license` and `lwcPlugin` fields before releasing.\n\nCheck the packaging before publishing:\n\n```shell\nnpm run check-package\n```\n\nThat runs [publint](https://publint.dev), which checks the manifest, and\n[arethetypeswrong](https://arethetypeswrong.github.io), which resolves every\nentry point the way a consumer's TypeScript would — the check that catches an\n`exports` entry with no `types` alongside it. Two of its rules are ignored\nbecause an ESM-only package is meant to fail them: `node10` predates the\n`exports` field entirely, and `require`-ing an ES module is an error rather\nthan a mistake in the package.\n\nPublish from the project root once the plugin has been built:\n\n```shell\nnpm publish\n```\n\nHint: append `--dry-run` to inspect the result without uploading anything.\n\n## Discoverability\n\nTag the plugin so that others can find it: add the `lightweight-charts-plugin`\ntopic to its GitHub repository, and keep the `lightweight-charts-plugin` keyword\nin `package.json`.\n<!-- /EXTERNAL_ONLY -->\n","packages/lwc-plugin-accessibility/README.md":"# Accessibility\n\nA drop-in accessibility layer for a Lightweight Charts™ chart. The plugin is\nbuilt on\n[pane primitives](https://tradingview.github.io/lightweight-charts/docs/plugins/pane-primitives)\nand helps your application meet\n[WCAG 2.1 Level AA](https://www.w3.org/TR/WCAG21/).\n\nCanvas-based charts are opaque to assistive technology. This plugin packages\nthe techniques from the\n[accessibility tutorial](https://tradingview.github.io/lightweight-charts/tutorials/a11y/intro).\nYou get keyboard navigation, screen-reader announcements, and a visible focus\nindicator without any manual wiring.\n\nUse the chart-level helper for normal integration. It attaches one primitive\nper pane. Each pane gets its own labeled, keyboard-focusable semantic layer.\nThe plugin handles every series in a pane, so multi-series and multi-pane\ncharts work out of the box.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-accessibility\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { addAccessibilityPlugin } from '@tradingview/lwc-plugin-accessibility';\n\nconst chart = createChart(document.getElementById('chart'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(myData);\n\nconst accessibility = addAccessibilityPlugin(chart, {\n    chartTitle: 'Apple daily close',\n});\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-accessibility\": \"https://unpkg.com/@tradingview/lwc-plugin-accessibility/dist/accessibility.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { addAccessibilityPlugin } from '@tradingview/lwc-plugin-accessibility';\n\nconst chart = createChart(document.getElementById('chart'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(myData);\n\nconst accessibility = addAccessibilityPlugin(chart, {\n    chartTitle: 'Apple daily close',\n});\n</script>\n```\n\n## Usage\n\nEnable the plugin for every current pane with one chart-level call:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { addAccessibilityPlugin } from '@tradingview/lwc-plugin-accessibility';\n\nconst chart = createChart(document.getElementById('chart'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(myData);\n\nconst accessibility = addAccessibilityPlugin(chart, {\n    chartTitle: 'Apple daily close',\n});\n```\n\n`chartTitle` is optional; without it every pane is announced with\n`messages.defaultChartTitle` (*\"Interactive financial chart\"*), distinguished by\na *\"Pane 2 of 2\"* suffix. For a multi-pane chart, pass a title resolver instead:\n\n```js\naddAccessibilityPlugin(chart, {\n    chartTitle: paneIndex => paneIndex === 0 ? 'Price' : 'Volume',\n});\n```\n\nTo turn it off again, detach the controller – the plugin restores the DOM to\nthe state it found it in:\n\n```js\naccessibility.detach();\n```\n\nCall `accessibility.refresh()` to attach it again (it re-attaches whatever panes\nthe chart has at that moment). Detach before `chart.remove()` where you can; the\nother order is safe too — `detach()` skips panes that are already gone.\n\nIf you need low-level control, you can still attach `AccessibilityPlugin`\ndirectly as a pane primitive. It takes `AccessibilityPaneOptions` and, as a\nsecond constructor argument, the index of the pane you attach it to (only needed\nfor a pane other than the first):\n\n```js\nimport { AccessibilityPlugin } from '@tradingview/lwc-plugin-accessibility';\n\nchart.panes()[1].attachPrimitive(\n    new AccessibilityPlugin({ chartTitle: 'Volume' }, 1)\n);\n```\n\nThat index is only used to find the pane before the layer exists: the first\ntime the chart draws the primitive it reports the pane it is really attached to,\nand the plugin follows that pane from then on, by identity, through reordering.\nAn index that does not match the pane you attached to therefore costs nothing\nbut a frame.\n\nA directly attached primitive keeps its own polite live region and takes a plain\nboolean `announceDataUpdates`; the chart-level `dataUpdates` settings only exist\non the helper.\n\n## What it does\n\n- **Semantic layer.** Each pane gets a labeled, keyboard-focusable overlay\n  (`role=\"application\"`, `aria-label`, `tabindex=\"0\"`), while the pane's table\n  scaffolding is marked presentational and the visual canvases are hidden from\n  assistive technology with `aria-hidden`. Focusable chart internals such as the\n  attribution link are removed from the tab order and hidden from the\n  accessibility tree.\n- **Keyboard navigation.** Users traverse every data point with the left/right\n  arrows and switch between the series in the pane with the up/down arrows. The\n  focused point is always paged into view, so the whole series is reachable by\n  keyboard even when only part of it is on screen.\n- **ARIA-live announcements.** The focused point, series changes, on-demand\n  summaries, the visible range after a zoom, markers on the focused point and\n  the active series' price lines are announced through a per-pane assertive live\n  region. Background\n  data updates go through a single polite live region shared by the whole chart,\n  so simultaneous updates in different panes never talk over each other\n  (`dataUpdates`, see below).\n- **A text alternative.** `T` renders the active series as a real `<table>` over\n  the pane, on demand (see below).\n- **Visible focus indicator.** The focused pane receives an outline, and an\n  optional focus ring is drawn over the active point. The point ring stays\n  aligned with the canvas as you scroll or zoom, and `syncCrosshair` moves the\n  chart's crosshair with it.\n- **Visible shortcuts & high contrast (opt-in).** With `showShortcuts: true`,\n  sighted keyboard users get a \"Press H\" hint on focus and an `H`-toggled\n  on-screen list of the controls. `highContrast` (default `'auto'`, following the\n  OS) restyles the plugin's own focus ring and overlay, and `onHighContrastChange`\n  lets you restyle the chart itself to match — for users who navigate by keyboard\n  or need higher contrast but don't use a screen reader.\n\n### Keyboard map\n\n| Key | Action |\n| --- | --- |\n| `Tab` | Move focus between panes / out of the chart |\n| `←` / `→` | Move to the previous / next data point |\n| `↑` / `↓` | Switch to the previous / next series in the pane |\n| `Page Up` / `Page Down` | Jump by `pageStep` points (default 10): `Page Up` forward in time, `Page Down` back — following the ARIA slider convention that `Page Up` increases the value |\n| `Home` / `End` | Jump to the first / last point |\n| `+` / `-` | Zoom the chart in / out |\n| `Enter` / `Space` | Announce a summary of the active series |\n| `T` | Show / hide the data as a table (see below) |\n| `Esc` | Close the open panel (table or shortcuts) |\n| `H` | Announce the controls, and — when `showShortcuts` is on — show / hide the visible shortcuts panel |\n\nThe letter keys are matched by physical key as well as by character, so `H` and\n`T` also work on non-Latin keyboard layouts. Remap anything with `keyBindings`:\n\n```js\naddAccessibilityPlugin(chart, {\n    keyBindings: {\n        s: 'summary',   // add a key\n        KeyD: 'viewAsTable', // by physical key\n        h: null,        // remove a built-in binding\n    },\n});\n```\n\n## Options\n\nAll options are optional and have sensible defaults. `addAccessibilityPlugin`\ntakes `AccessibilityOptions`, a single `AccessibilityPlugin` takes\n`AccessibilityPaneOptions`; the two differ only in the rows marked *chart-level*\nbelow.\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `chartTitle` | `string` — *chart-level:* `string \\| (paneIndex) => string` | `messages.defaultChartTitle` | Accessible name of the pane region. |\n| `showFocusIndicator` | `boolean` | `true` | Draw a visible focus ring on the active point. |\n| `focusIndicatorColor` | `string` | `'#2962FF'` | Color of the focus ring. |\n| `focusIndicatorSize` | `number` | `14` | Diameter of the focus ring, in CSS pixels. |\n| `dataUpdates` | *chart-level only:* `{ mode: 'active' \\| 'all' \\| 'none'; panes?: (paneIndex) => boolean; debounceMs?: number }` | `{ mode: 'active' }` | Which panes announce data updates, and how they combine (see below). |\n| `announceDataUpdates` | *pane-level only:* `boolean` | `true` | Whether this pane announces data updates. Set for you from `dataUpdates`. |\n| `updateDebounceMs` | *pane-level only:* `number` | `1000` | Window over which data changes are coalesced before being announced. Use `dataUpdates.debounceMs` at chart level. |\n| `updateMaxSeries` | `number` | `3` | Maximum number of changed series listed in one update announcement. |\n| `pageStep` | `number` | `10` | Points to jump with `Page Up` / `Page Down`. |\n| `zoomStep` | `number` | `0.2` | Fraction the visible range grows / shrinks per `+` / `-` keypress. |\n| `minZoomSpan` | `number` | `2` | Smallest visible span, in bars, that zooming in will produce. |\n| `dataScope` | `'all' \\| 'visible'` | `'visible'` | Whether the on-demand summary and data-update announcements describe the visible range or the full data set (see below). |\n| `priceFormatter` | `(value: number) => string` | chart `localization.priceFormatter`, else the active series price formatter | Formats values for announcements. |\n| `timeFormatter` | `(time: Time) => string` | chart `localization.timeFormatter`, else a locale-aware date | Formats times for announcements (uses the chart's `localization.locale`). |\n| `timeFormat` | `'auto' \\| 'date' \\| 'dateTime' \\| 'seconds' \\| 'time'` | `'auto'` | How much of a time the built-in formatter speaks. `'auto'` follows the chart's `timeScale.timeVisible` / `secondsVisible`, so intraday bars are distinguishable. Ignored when a `timeFormatter` is set. |\n| `valueAccessor` | `(point, series) => number \\| undefined` | `value`, else `close` | Reads the announced value out of a data point — needed for custom series (see below). |\n| `rangeAccessor` | `(point, series) => { high, low, open?, close? } \\| undefined` | the point's own `high` / `low` | Reads a point's high / low band, so a custom series is announced like an OHLC one. |\n| `seriesLabel` | `(series, index) => string` | series `title`, else `Series N` | Accessible label for each series. |\n| `keyBindings` | `Record<string, AccessibilityCommand \\| null>` | — | Key → command overrides, merged onto the built-in map. The key is a `KeyboardEvent.key` or `.code`; `null` removes a binding. |\n| `announceOnFocus` | `boolean` | `false` | Announce the visible range when the pane receives focus (an assertive message can interrupt the accessible name, hence off by default). |\n| `focusOnPointerDown` | `boolean` | `false` | Move the keyboard focus into the pane when the user presses a pointer on it. |\n| `syncCrosshair` | `boolean` | `false` | Move the chart's crosshair to the focused point (`chart.setCrosshairPosition`). |\n| `tableMaxRows` | `number` | `200` | Maximum number of rows rendered by the `T` table; the cap is spoken with the caption. |\n| `markers` | `(series) => readonly SeriesMarker<Time>[]` | — | The markers of a series, announced with the point they sit on. The library does not expose a series' markers, so pass the array you gave `createSeriesMarkers`. |\n| `announcePriceLines` | `boolean` | `true` | Append the active series' `priceLines()` to the `Enter` / `Space` summary. |\n| `onAnnounce` | `(message: string) => void` | — | Called with every string this pane announces — for captions, a transcript, or a test. |\n| `onFocusChange` | `(event: AccessibilityFocusEvent) => void` | — | Called whenever the active point or series changes, with the pane, series, point and value. |\n| `onSonify` | `(note: SonificationNote) => void` | — | Called for every focused point with the data a sonification needs. `createToneSonifier()` is a ready-made handler (see below). |\n| `describeChart` | `(context: DescribeChartContext) => string` | built-in summary | Generates the `Enter` / `Space` summary. The context carries `points` (already narrowed to `dataScope`), `series`, `label` and `scope`. |\n| `messages` | `PartialAccessibilityMessages` | English `defaultMessages` | Overrides for the announced text — translate some or all of it (see Localization). |\n| `lang` | `string` | chart `localization.locale` | BCP-47 `lang` set on the announced regions so screen readers use the right voice. |\n| `showShortcuts` | `boolean` | `false` | Show a visible keyboard-shortcuts overlay (focus hint + `H`-toggled panel) for sighted keyboard users (see below). |\n| `highContrast` | `boolean \\| 'auto'` | `'auto'` | High-contrast styling for the plugin's own focus ring / outline / overlay. `'auto'` follows the OS `prefers-contrast` / `forced-colors`; pass a boolean to drive it from your own setting. |\n| `onHighContrastChange` | `(enabled: boolean) => void` | — | Called when the resolved high-contrast state changes (and once on attach), so you can restyle the chart's own series / grid / font to match. |\n\nOptions can be changed at runtime. Use the controller's\n`accessibility.applyOptions({ ... })` for chart-level changes (`chartTitle`,\n`dataUpdates`, `messages`, `lang`, `highContrast`, …): it updates every pane\n**and** the shared update region together. A single primitive also has its own\n`plugin.applyOptions({ ... })` for per-pane tweaks (e.g. `dataScope`), but that\ndoes not reach the chart-level shared update region — use the controller for\n`dataUpdates` / `messages` / `lang`.\n\n### Scoping announcements to the visible range\n\nKeyboard navigation always covers the whole series – the arrow keys page the\nchart so every point is reachable regardless of this setting. `dataScope` only\ncontrols what the *summaries* describe.\n\nBy default (`dataScope: 'visible'`) the on-demand summary (`Enter` / `Space`) and\nthe background data-update announcements describe only the points within the\ncurrent visible range – for example *\"65 data points in view\"*. This is the\nrecommended setting for charts with large data sets because it keeps those\nsummaries focused on what the user is currently inspecting. The update\nannouncement's *\"Latest\"* value is the one exception: it always reports the\nseries' newest bar – the bar the update actually changed – even when that bar\nis outside the visible range.\n\nUse `dataScope: 'all'` when you want the summary and update announcements to\ndescribe the full data set, even if only part of the history is visible.\n\nPer-point announcements always report the absolute position (*\"Point 247 of\n500\"*) so the user knows where they are in the whole series.\n\n### Announcing data updates\n\nWhen a chart streams live data, several panes can update in the same tick. Each\npane keeps its own assertive region for navigation, but all *data-update*\nannouncements go through **one** polite region shared by the whole chart, so the\nupdates never talk over each other.\n\n`dataUpdates` (on `addAccessibilityPlugin`) chooses which panes speak:\n\n```js\naddAccessibilityPlugin(chart, {\n    dataUpdates: { mode: 'active', debounceMs: 1500 },\n});\n```\n\n- `mode: 'active'` (the default): only the **last-focused** pane announces (pane 0\n  until you focus one). Navigating the volume pane, for example, makes its updates\n  the ones you hear; otherwise you hear the main pane.\n- `mode: 'all'`: every pane announces; simultaneous updates are combined into a\n  single message in pane order (*\"Chart data updated. 3 series changed. …\"*).\n- `mode: 'none'`: no update announcements.\n- `panes: (paneIndex) => boolean`: restricts announcements to the panes the\n  predicate accepts, on top of `mode`.\n- `debounceMs`: how long changes are coalesced before being announced (default\n  `1000`). A live feed can tick far faster than a screen reader can speak.\n\nSwitch this at runtime through the controller —\n`accessibility.applyOptions({ dataUpdates: { mode: 'all' } })` — which\nreconfigures the shared region's mode; a per-pane `plugin.applyOptions` cannot\nchange it.\n\nA directly-attached `AccessibilityPlugin` (without the helper) takes a plain\nboolean `announceDataUpdates` with its own `updateDebounceMs`, and uses its own\npolite region.\n\n## View as table\n\nPressing `T` renders the active series into a real `<table>` over the pane —\nthe text alternative WCAG asks for, and the most requested way to read a chart\nwithout navigating it point by point. The rows follow `dataScope`, are capped at\n`tableMaxRows` (the cap is announced), and use OHLC columns whenever the points\ncarry a high / low band. `Esc` (or `T` again) closes it. The table is built only\nwhile it is open, so a 50,000-bar series costs nothing until it is asked for.\nIts column headers and caption come from the `messages` bundle\n(`tableColumns`, `tableCaption`, `tableTruncated`, `tableClose`).\n\n## Custom series\n\nA custom series' data shape is only known to its author, so the plugin cannot\nguess where the value is. Without help every point of a custom series announces\n*\"no value\"* and the focus ring has nowhere to go. Point the plugin at the right\nfield:\n\n```js\naddAccessibilityPlugin(chart, {\n    valueAccessor: point => (point.high + point.low) / 2,\n    // Optional: announce it like an OHLC series and report true extremes.\n    rangeAccessor: point => ({ high: point.high, low: point.low }),\n});\n```\n\nBoth are called for every series in the pane; return `undefined` to fall back to\nthe built-in extraction (`value`, then `close`), so a chart mixing built-in and\ncustom series needs only the custom branch.\n\n## Following along: crosshair, captions and sound\n\n- `syncCrosshair: true` moves the chart's crosshair with the keyboard, so a\n  sighted user can follow a screen-reader user point by point.\n- `onAnnounce` receives every string this pane speaks, in order — mirror it into\n  captions, a transcript, or an assertion in a test.\n- `onFocusChange` reports the pane, series, point index and value whenever the\n  focus moves, for your own status bar or analytics.\n- `onSonify` receives each focused point with its position in the series' value\n  range. `createToneSonifier()` is a ready-made handler that plays a short tone\n  whose pitch follows the value, so holding `→` plays the series:\n\n```js\nimport { addAccessibilityPlugin, createToneSonifier } from '@tradingview/lwc-plugin-accessibility';\n\nconst sonifier = createToneSonifier();\naddAccessibilityPlugin(chart, { onSonify: sonifier });\n// sonifier.dispose() releases the AudioContext.\n```\n\nThe `AudioContext` is created on the first note (after a key press, so the\nbrowser's autoplay policy is satisfied) and reused afterwards.\n\n## Localization\n\nOut of the box the announcements are English, but **numbers and dates follow the\nchart's locale** and **every spoken string is translatable**.\n\n**Numbers and dates** come from the chart's\n[`localization`](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/LocalizationOptions):\ndates use `localization.locale`, the summary's percentage uses it via\n`Intl.NumberFormat`, and if you set `localization.priceFormatter` /\n`localization.timeFormatter` the announcements use those too. So a chart you have\nalready localized (see the\n[Custom locale](https://tradingview.github.io/lightweight-charts/tutorials/demos/custom-locale)\nand [Price format](https://tradingview.github.io/lightweight-charts/tutorials/customization/price-format)\ntutorials) gets localized announcements for free. You can still override per\nplugin with `priceFormatter` / `timeFormatter`.\n\n**Strings** are supplied through the `messages` bundle. Every announced sentence\nis a formatter function (so a translation controls word order and pluralization);\natomic words are plain strings. Pass a partial override — anything you leave out\nstays English:\n\n```js\nimport { addAccessibilityPlugin } from '@tradingview/lwc-plugin-accessibility';\n\naddAccessibilityPlugin(chart, {\n    chartTitle: 'Gráfico de precios',\n    lang: 'es',\n    messages: {\n        ohlc: { close: 'cierre' }, // only some keys — the rest stay English\n        point: ({ position, total, time, label, values }) =>\n            `${label} ${values}, ${time}. Punto ${position} de ${total}.`,\n        help: ({ multiSeries }) =>\n            `Controles de teclado. Las flechas izquierda y derecha se mueven entre los puntos de datos. ${multiSeries ? 'Las flechas arriba y abajo cambian de serie. ' : ''}Intro o Espacio lee un resumen de la serie.`,\n    },\n});\n```\n\n`lang` sets the BCP-47 `lang` attribute on the announced regions so a screen\nreader pronounces them with the right voice; it defaults to\n`localization.locale`. `messages`/`lang` are uniform across panes. To switch\nlanguage at runtime, call `accessibility.applyOptions({ messages, lang })` on the\ncontroller — it updates every pane and the shared update region together.\n\nA complete Spanish bundle ships with the package as `esMessages`, both as a\nready-made translation and as a template for your own:\n\n```js\nimport { addAccessibilityPlugin, esMessages } from '@tradingview/lwc-plugin-accessibility';\n\naddAccessibilityPlugin(chart, { messages: esMessages, lang: 'es' });\n```\n\n`defaultMessages` is the English bundle. It is **frozen and read-only** — write a\ntranslation by passing your own entries through `messages` (they are merged onto\n`defaultMessages`), never by mutating it. `paneLabel` receives `paneIndex` and\n`paneCount` alongside the title, so a translation can keep multi-pane titles\ndistinguishable, and `defaultChartTitle` is the fallback used when `chartTitle`\nis unset.\n\nThe precedence for the overridable pieces:\n\n- **value:** `priceFormatter` → chart `localization.priceFormatter` → series formatter\n- **time:** `timeFormatter` → chart `localization.timeFormatter` → locale-aware date\n- **summary:** `describeChart` (full override) → `messages.summary`\n- **strings:** your `messages` entry → English `defaultMessages`\n\n## Visible shortcuts and high contrast\n\nThese help users who navigate by keyboard, or need higher contrast, but don't use\na screen reader.\n\n**Shortcuts overlay** — set `showShortcuts: true`. While the pane is focused a\nsmall *\"Press H for keyboard shortcuts\"* hint is shown; `H` toggles an on-screen\npanel listing the controls. It is `aria-hidden` (screen-reader\nusers already get the spoken `H` help) and its text comes from the `messages`\nbundle (`shortcutsHint`, `shortcutsTitle`, `shortcuts`), so it localizes with the\nrest. The overlay text is sized in `rem`, so it scales with the page/browser font.\n\n**High contrast** — `highContrast` (`boolean | 'auto'`, default `'auto'`) controls\nthe plugin's *own* visuals (focus ring, focus outline, the overlay). `'auto'`\nfollows the OS `prefers-contrast` / `forced-colors` and updates live; to wire it\nto your own app setting, pass a boolean and keep it in step with\n`accessibility.applyOptions({ highContrast })`.\n\nThe plugin deliberately does **not** restyle the chart's series, grid or font —\nthat's the chart theme's job (see the\n[Readability](https://tradingview.github.io/lightweight-charts/tutorials/a11y/readability)\ntutorial). Instead it calls `onHighContrastChange(enabled)` whenever the state\nchanges (and once on attach) so you can apply your own high-contrast chart theme\nin one place:\n\n```js\naddAccessibilityPlugin(chart, {\n    showShortcuts: true,\n    onHighContrastChange: enabled => {\n        chart.applyOptions({ layout: { textColor: enabled ? '#000' : '#222' } });\n        series.applyOptions({ lineWidth: enabled ? 4 : 2 });\n    },\n});\n```\n\nThe example wires both of these up (the \"Enable high contrast\" and \"Large font\"\nbuttons).\n\n## Performance\n\nThe plugin uses an **active-point-only** strategy: it never mirrors every data\npoint into the DOM. Regardless of whether a series holds 500 or 50,000 bars each\npane adds only a small fixed set of nodes (a semantic overlay, a visually-hidden\ndescription, an assertive live region, a focus ring and — when `showShortcuts` is\non — the shortcuts hint and panel), plus one polite live region shared across the\nwhole chart for data-update announcements.\n\nData stays in sync through one `subscribeDataChanged` listener per series.\nScrolling and zooming reposition the focus ring with coordinate lookups; they\ndo not copy series data. Data-change events invalidate a shared snapshot because\nthey do not distinguish a tail tick from a historical correction or `pop()`.\n\nAn unfocused pane reads data only when its debounced announcement is prepared.\nWith update announcements disabled, it defers the read until keyboard focus\nreturns. Focused navigation refreshes immediately after a data change and shares\nthat snapshot with announcement statistics. Each refresh is proportional to the\nseries length; visible-point counts use binary searches within the snapshot, so\nwhitespace and gaps supplied by other series do not inflate the count.\n\n## CSS class hooks\n\nEvery element the plugin injects carries a stable class name, so you can restyle\nthe layer from your own stylesheet. These names are part of the public API and\nwill not change without a major version:\n\n| Class | Element |\n| --- | --- |\n| `lw-chart-a11y-layer` | The focusable semantic overlay per pane (`role=\"application\"`). |\n| `lw-chart-a11y-description` | Visually hidden pane description (`aria-describedby` target). |\n| `lw-chart-a11y-live-region` | Per-pane assertive region for navigation announcements. |\n| `lw-chart-a11y-status-region` | Per-pane polite region, only present on a directly attached primitive. |\n| `lw-chart-a11y-shared-status-region` | The single chart-level polite region created by `addAccessibilityPlugin`. |\n| `lw-chart-a11y-focus-ring` | The visible focus ring drawn over the active point. |\n| `lw-chart-a11y-shortcuts-hint` | The \"Press H\" hint (`showShortcuts`). |\n| `lw-chart-a11y-shortcuts-panel` | The `H`-toggled shortcuts panel (`showShortcuts`). |\n| `lw-chart-a11y-data-table` | The `T`-toggled table panel. |\n\nThe plugin sets its own geometry and colors inline, so an inline style wins over\na plain rule — use `!important`, or restyle through the options where one exists\n(`focusIndicatorColor`, `focusIndicatorSize`, `highContrast`).\n\n## Notes & limitations\n\n- Built-in series work out of the box: OHLC series announce their open / high /\n  low / close, value series announce their value. A **custom series** needs\n  `valueAccessor` (and optionally `rangeAccessor`), because only its author knows\n  where its value lives.\n- Series **and panes** added or removed at runtime are picked up automatically:\n  the controller reconciles its layers with `chart.panes()` on the next redraw\n  and attaches or detaches only the difference, so the focus of the panes that\n  were already there is never disturbed. `controller.refresh()` forces that check\n  immediately and is rarely needed.\n- The library forces `direction: ltr` on the chart element, so the plugin reads\n  the writing direction from the element you created the chart in: on a\n  right-to-left page its panels sit on the leading (right) side.\n- Series in a pane do not need to share timestamps. Navigation is aligned by\n  *time* on the chart's shared time scale: switching series with the up / down\n  arrows keeps the focused time (the nearest point in the new series is\n  selected and paged into view), and the visible-range scoping follows each\n  series' own data.\n- The plugin provides the semantic layer and keyboard model. Visual contrast and\n  font-scaling (covered in the\n  [Readability](https://tradingview.github.io/lightweight-charts/tutorials/a11y/readability)\n  part of the tutorial) remain the responsibility of your chart theme.\n- The API is typed for a `Time`-based chart (`IChartApi`), not the generic\n  `IChartApiBase<HorzScaleItem>`. The announcements format UTC timestamps and\n  business days and the navigation maps points through the `Time` scale, so every\n  internal path assumes `Time`; a custom horizontal scale is not supported.\n- Always validate with real assistive technology (VoiceOver, NVDA) as part of\n  your own accessibility testing before shipping.\n","packages/lwc-plugin-anchored-text/README.md":"# Anchored text\n\nA single line of text anchored to an edge, a corner or the center of a pane,\nas a [series primitive](https://tradingview.github.io/lightweight-charts/docs/plugins/series-primitives)\n(`AnchoredText`) or as a\n[pane primitive](https://tradingview.github.io/lightweight-charts/docs/plugins/pane-primitives)\n(`AnchoredTextPane`). The text keeps its place while the chart scrolls and\nzooms, inset from the pane edges by a margin you choose. The text, its anchor,\nmargins, font, color, layer and visibility can all be changed after the\nprimitive has been attached.\n\nThe series primitive belongs to the series it is attached to: it lives in that\nseries' pane and is removed together with the series. The pane primitive needs\nno series at all.\n\nUse it for a chart title, a symbol or interval label, a data-source credit, or\na \"preview\" or \"draft\" stamp.\n\n> **Lightweight Charts™ 5 also ships a built-in text watermark.**\n> [`createTextWatermark(pane, options)`](https://tradingview.github.io/lightweight-charts/docs/api/functions/createTextWatermark)\n> is a pane primitive which draws one or more lines of text, centered by default\n> and scaled down to fit the pane. If that is all you need, the built-in\n> function is the right choice. Use this package for text tied to a specific\n> series rather than to a pane, or for what the built-in does not offer:\n> margins from the pane edge, a CSS `font` shorthand, `zOrder` and\n> `setText`.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-anchored-text\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { AnchoredText } from '@tradingview/lwc-plugin-anchored-text';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(data);\n\nseries.attachPrimitive(new AnchoredText({ text: 'BTC/USD · 1D' }));\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-anchored-text\": \"https://unpkg.com/@tradingview/lwc-plugin-anchored-text/dist/anchored-text.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { AnchoredText } from '@tradingview/lwc-plugin-anchored-text';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(data);\n\nseries.attachPrimitive(new AnchoredText({ text: 'BTC/USD · 1D' }));\n</script>\n```\n\n## Usage\n\n### On a series\n\nCreate the text, then attach it to the series whose pane it should sit in:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { AnchoredText } from '@tradingview/lwc-plugin-anchored-text';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(data);\n\nconst title = new AnchoredText({\n    text: 'BTC/USD · 1D',\n    horzAlign: 'right',\n    vertAlign: 'top',\n    font: 'bold 16px sans-serif',\n    color: '#2962FF',\n});\nseries.attachPrimitive(title);\n```\n\nTo remove the text, detach it from the series:\n\n```js\nseries.detachPrimitive(title);\n```\n\n### On a pane\n\n`AnchoredTextPane` takes the same options and is attached to a pane instead\nof a series. Use it when the text should stay put while series are added and\nremoved:\n\n```js\nimport { AnchoredTextPane } from '@tradingview/lwc-plugin-anchored-text';\n\nconst title = new AnchoredTextPane({ text: 'Volume', vertAlign: 'bottom' });\nchart.panes()[1].attachPrimitive(title);\n\n// later\nchart.panes()[1].detachPrimitive(title);\n```\n\n### Changing the text\n\nBoth classes have the same methods:\n\n```js\ntitle.applyOptions({ horzAlign: 'center', color: '#787B86' });\ntitle.setText('ETH/USD · 1D'); // same as applyOptions({ text })\ntitle.options(); // the current options, with the defaults filled in\n```\n\n`applyOptions` merges: an option which is not passed, or is passed as\n`undefined`, is left unchanged. The one exception is `lineHeight`: passing\n`lineHeight: undefined` goes back to measuring the height from the font.\n\n## Options\n\nOptions are passed as the constructor argument, which is optional, as is every\noption in it. The type is `AnchoredTextOptions`, and the defaults are exported\nas `defaultOptions`.\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `text` | `string` | `''` | The line of text. An empty string draws nothing. |\n| `horzAlign` | `'left' \\| 'center' \\| 'right'` | `'left'` | Which side of the pane the text is anchored to, or centered. |\n| `vertAlign` | `'top' \\| 'center' \\| 'bottom'` | `'top'` | Which edge of the pane the text is anchored to, or centered. |\n| `horzMargin` | `number` | `20` | Distance from the left or right pane edge, in CSS pixels. Not used when `horzAlign` is `'center'`. |\n| `vertMargin` | `number` | `10` | Distance from the top or bottom pane edge, in CSS pixels. Not used when `vertAlign` is `'center'`. |\n| `font` | `string` | `bold 14px` system sans-serif | Font, as a CSS `font` shorthand. |\n| `lineHeight` | `number` | — (measured) | Height of the text, in CSS pixels. Measured from the font when not set. |\n| `color` | `string` | `'#131722'` | Text color. |\n| `visible` | `boolean` | `true` | Whether the text is drawn at all. |\n| `zOrder` | `'bottom' \\| 'normal' \\| 'top'` | `'normal'` | Layer the text is drawn in. `'normal'` draws it with the series, under the crosshair; `'top'` puts it over everything in the pane, the crosshair included; `'bottom'` puts it behind the series. |\n\n### Alignment and margins\n\nThe text is placed against the anchored edge of its pane, `horzMargin` and\n`vertMargin` away from it. A centered axis ignores its margin. With a\n`lineHeight` the text's baseline sits at the bottom of that height, as it did\nin the `plugin-examples` version; without one the height is that of the font,\nso it does not change with the text, and the baseline sits at the font's\nascent.\n\n## Notes\n\n- The text is drawn on one line, as given. It is neither wrapped nor scaled:\n  text wider than the pane is clipped at the pane edge. The built-in\n  `createTextWatermark` scales its text down to fit, if that is what you need.\n- The text appears only in the pane it belongs to. It never covers the price\n  scales or the time scale, and a visible left price scale or a second pane\n  does not move it.\n- Sizes are in CSS pixels; the text is drawn in the media coordinate space, so\n  it stays sharp at any device pixel ratio.\n- `'middle'` is still accepted as a value of `horzAlign` and `vertAlign`, the\n  spelling used in the `plugin-examples` collection, and is read as `'center'`.\n  It is kept for compatibility and will be removed in a future major version.\n","packages/lwc-plugin-background-shade-series/README.md":"# Background shade series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series)\nthat shades the full height of the pane behind each bar. The shade is mixed\nfrom two colors by where the bar's value sits between a low and a high value,\nso the background follows an indicator while the price series stays readable\non top of it.\n\nUse it to show a regime or a reading behind the price: an oscillator, the\nshare of up days, volatility, a sentiment score, or a session's volume\nrelative to normal.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-background-shade-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { createBackgroundShadeSeries } from '@tradingview/lwc-plugin-background-shade-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst line = chart.addSeries(LineSeries);\nline.setData([\n    { time: '2024-04-22', value: 101.2 },\n    { time: '2024-04-23', value: 102.8 },\n    { time: '2024-04-24', value: 100.9 },\n]);\n\nconst shade = createBackgroundShadeSeries(chart, {\n    lowColor: '#F23645',\n    highColor: '#089981',\n    opacity: 0.25,\n});\nshade.setData([\n    { time: '2024-04-22', value: 35 },\n    { time: '2024-04-23', value: 70 },\n    { time: '2024-04-24', value: 20 },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-background-shade-series\": \"https://unpkg.com/@tradingview/lwc-plugin-background-shade-series/dist/background-shade-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { createBackgroundShadeSeries } from '@tradingview/lwc-plugin-background-shade-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst line = chart.addSeries(LineSeries);\nline.setData([\n    { time: '2024-04-22', value: 101.2 },\n    { time: '2024-04-23', value: 102.8 },\n    { time: '2024-04-24', value: 100.9 },\n]);\n\nconst shade = createBackgroundShadeSeries(chart, {\n    lowColor: '#F23645',\n    highColor: '#089981',\n    opacity: 0.25,\n});\nshade.setData([\n    { time: '2024-04-22', value: 35 },\n    { time: '2024-04-23', value: 70 },\n    { time: '2024-04-24', value: 20 },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `createBackgroundShadeSeries`, then set data with a\n`value` per bar:\n\n```js\nconst shade = createBackgroundShadeSeries(chart, {\n    lowColor: 'rgb(50, 50, 255)',\n    highColor: 'rgb(255, 50, 50)',\n    lowValue: 0,\n    highValue: 100,\n    opacity: 0.8,\n});\n\nshade.setData([\n    { time: '2024-04-22', value: 35 },\n    { time: '2024-04-23', value: 120 },\n    { time: '2024-04-24' },\n    { time: '2024-04-25', value: 50, color: '#131722' },\n]);\n```\n\nEach data point is `{ time, value }`:\n\n- A value of `lowValue` gets `lowColor`, a value of `highValue` gets\n  `highColor`, and a value in between a mix of the two. Values beyond the\n  range get the color of the nearer end. `lowValue` may be the larger of the\n  two. With `lowValue` equal to `highValue` the shading becomes a two-color\n  threshold: values below it get `lowColor` and the rest `highColor`.\n- A point without a finite `value`, `null` and `NaN` included, is whitespace\n  and leaves its slot unshaded.\n- A `color` on a point shades that bar with it, whatever its value. A color\n  the canvas does not accept is ignored, and the bar is shaded from its value.\n  The series' own `color` option is not drawn; it is empty by default, and a\n  point whose `color` equals it is shaded from its value.\n\n`lowColor` and `highColor` can be hex, `rgb()`, `rgba()`, `hsl()` or named\ncolors. They are mixed with premultiplied alpha, as CSS gradients are, so a\ntransparent end, `'transparent'` included, fades the other color out. A color\nthat cannot be parsed, or one in another color space such as `oklch()`, falls\nback to the default for that end.\n\nThe series shades the full height of its pane and takes no part in the price\nscale. It sits on a price scale of its own, `'background-shade'`, an overlay\nscale with nothing drawn on it, so it never sets the number format of the\nprice axis; its values never change any autoscale range; and it has no price\nline or last value label. It still draws when it is the only series in the\nchart. It is never reported as hovered, so it does not get in the way of the\nseries on top of it.\n\n## Creating a series\n\nUse `createBackgroundShadeSeries(chart, options?, paneIndex?)`. It adds the\nseries and moves it behind every other series in its pane with\n`series.setSeriesOrder(0)`, so it reads as a background whatever order the\nseries are added in. `setSeriesOrder` arrived in `lightweight-charts` 5.0.6;\non older versions the series keeps the order it was added in, so add it\nbefore the others.\n\nMoving the series to another pane, with `series.moveToPane`, puts it on top\nof that pane's series, as for any series; call `series.setSeriesOrder(0)`\nagain afterwards.\n\nThe `BackgroundShadeSeries` class remains available for\n`chart.addCustomSeries(new BackgroundShadeSeries(), options)`. Added that way,\nit gets the same options, its own price scale included, but is drawn in the\norder it was added: added after the main series, an opaque shade covers it.\nAdd it first, or call `series.setSeriesOrder(0)`.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `lowColor` | `string` | `'rgb(50, 50, 255)'` | Shade of a bar whose value is `lowValue`, or beyond it. |\n| `highColor` | `string` | `'rgb(255, 50, 50)'` | Shade of a bar whose value is `highValue`, or beyond it. |\n| `lowValue` | `number` | `0` | Value shaded with `lowColor`. |\n| `highValue` | `number` | `100` | Value shaded with `highColor`. |\n| `opacity` | `number` | `0.8` | Opacity of the whole shading, `0`–`1`, on top of any alpha in the colors. |\n\n`priceLineVisible` and `lastValueVisible` default to `false`, since the series\nhas no value on the price scale, and `priceScaleId` to `'background-shade'`.\nSetting `priceScaleId` to `'right'` or `'left'` puts the shade on a visible\nscale, where, being the bottom series, it would set that scale's number\nformat; it still never changes the scale's range.\n\n## Notes\n\n- Each bar is shaded across one bar spacing centered on it, in whole device\n  pixels, so the slots of consecutive bars abut with no seam and no overlap at\n  every zoom level and device pixel ratio. Time points that only other series\n  have stay unshaded: daily values over hourly candles, say, shade one slot a\n  day. On `lightweight-charts` 5.1 and later, while the chart conflates data, a\n  conflated bar's column is as wide as the slots it stands for, centered where\n  the chart places the bar, and it keeps the later of the two values it\n  merges.\n- Only the bars on screen are drawn. Their shades come from 256 steps between\n  the two end colors, worked out when the colors change, so no color is\n  mixed while drawing.\n- The shading covers its own pane only. To shade another pane, add a second\n  series to it with the `paneIndex` argument.\n","packages/lwc-plugin-box-whisker-series/README.md":"# Box and whisker series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series)\nthat draws a box plot per time point: a box from the first to the third\nquartile split at the median, whiskers out to the `min` and `max` you give,\nand a dot for each outlier you list beyond them. Where the whiskers end is\nyours to decide, such as 1.5 times the interquartile range or the 5th and\n95th percentiles, and the values past them are the outliers.\n\nUse it to show how a distribution changes over time rather than a single\nvalue: intraday price distribution per day, latency percentiles per hour,\nor the spread of forecasts per period.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-box-whisker-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createBoxWhiskerSeries } from '@tradingview/lwc-plugin-box-whisker-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createBoxWhiskerSeries(chart);\n\nseries.setData([\n    { time: '2024-04-22', min: 55, q1: 70, median: 80, q3: 85, max: 95 },\n    { time: '2024-04-23', min: 50, q1: 70, median: 78, q3: 83, max: 90, outliers: [40] },\n    { time: '2024-04-24', min: 58, q1: 68, median: 75, q3: 85, max: 90 },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-box-whisker-series\": \"https://unpkg.com/@tradingview/lwc-plugin-box-whisker-series/dist/box-whisker-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createBoxWhiskerSeries } from '@tradingview/lwc-plugin-box-whisker-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createBoxWhiskerSeries(chart);\n\nseries.setData([\n    { time: '2024-04-22', min: 55, q1: 70, median: 80, q3: 85, max: 95 },\n    { time: '2024-04-23', min: 50, q1: 70, median: 78, q3: 83, max: 90, outliers: [40] },\n    { time: '2024-04-24', min: 58, q1: 68, median: 75, q3: 85, max: 90 },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `createBoxWhiskerSeries`, then set data with five\nnumbers per point:\n\n```js\nconst series = createBoxWhiskerSeries(chart, {\n    whiskerColor: '#131722',\n    lowerBoxColor: '#90BFF9',\n    upperBoxColor: '#2962FF',\n    medianColor: '#FFFFFF',\n    outlierColor: '#F23645',\n});\n\nseries.setData([\n    { time: '2024-04-22', min: 55, q1: 70, median: 80, q3: 85, max: 95 },\n    { time: '2024-04-23', min: 50, q1: 70, median: 78, q3: 83, max: 90, outliers: [40, 100] },\n    { time: '2024-04-24' },\n    { time: '2024-04-25', min: 58, q1: 68, median: 75, q3: 85, max: 90, upperBoxColor: '#F23645' },\n]);\n```\n\nEach data point is `{ time, min, q1, median, q3, max, outliers? }`:\n\n- The whiskers run from `min` to `q1` and from `q3` to `max`, and the box from\n  `q1` to `q3`, split at the `median` into a lower and an upper half.\n- `outliers` holds the values beyond the whiskers, each drawn as a dot. `null`\n  means none, and an outlier which is not a finite number is not drawn.\n- A point without five finite numbers, a missing or `null` one included, is\n  whitespace: it keeps its place on the time scale, is not drawn, and takes\n  no part in the price scale.\n- `whiskerColor`, `lowerBoxColor`, `upperBoxColor`, `medianColor` and\n  `outlierColor` on a point override the series options of the same names\n  for that point.\n\nThe autoscale range covers the lowest and the highest of the five numbers and\nthe outliers, so every dot is in view, and a point whose numbers are not in\norder still fits on the scale.\n\nThe series' price line and last value label follow the median of the last\npoint. Options can be changed at runtime with `series.applyOptions({ ... })`.\n\nIn the `plugin-examples` collection this series was `WhiskerBoxSeries`, with a\n`quartiles` array instead of the five named numbers and `lowerQuartileFill` /\n`upperQuartileFill` for the box colors. The package was never published under\nthose names, so it does not keep them.\n\n## Creating a series\n\nUse `createBoxWhiskerSeries(chart, options?, paneIndex?)`. It adds a\n`BoxWhiskerSeries` with `chart.addCustomSeries` and returns the normal series\nAPI, typed `BoxWhiskerSeriesApi`, with the plugin's data and options types\npreserved. The `BoxWhiskerSeries` class remains available for\n`chart.addCustomSeries(new BoxWhiskerSeries(), options)` too; no option\nchanges the plot values, so both behave the same.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `whiskerColor` | `string` | `'rgba(106, 27, 154, 1)'` | Color of the whiskers and their end caps. |\n| `lowerBoxColor` | `string` | `'rgba(103, 58, 183, 1)'` | Fill of the lower half of the box, from `q1` to the median. |\n| `upperBoxColor` | `string` | `'rgba(233, 30, 99, 1)'` | Fill of the upper half of the box, from the median to `q3`. |\n| `medianColor` | `string` | `'rgba(106, 27, 154, 1)'` | Color of the median line across the box. |\n| `outlierColor` | `string` | `'rgba(149, 152, 161, 1)'` | Color of the outlier dots. |\n\nThe standard `color` option is not used for the box plots; it colors the\nseries' price line.\n\n## Notes\n\n- The box is as wide as a candlestick body at the same bar spacing, and every\n  part is centered on the whisker line in whole device pixels, the way the\n  built-in candlestick centers its body on the wick. The median line spans\n  the slot, each whisker cap is as wide as a candlestick body at half the bar\n  spacing, and outlier dots shrink with the box down to a 1.5 px radius, so\n  they stay visible when the chart is zoomed out.\n- Only the points on screen are drawn. The series is never conflated: with\n  `timeScale.enableConflation` on, the chart still draws every point.\n- On `lightweight-charts` 5.2 and later the series reports the part under the\n  pointer through `hitTest`, within the series' `hitTestTolerance` (3 px by\n  default). The crosshair event's `hoveredInfo.objectId` is `'box-<point>'`,\n  `'median-<point>'`, `'whisker-<point>'` or `'outlier-<point>-<index>'`,\n  where `<point>` is the point's position in `series.data()` and `<index>`\n  the index into its `outliers`. Elsewhere in a point's slot, between its\n  lowest and highest value, the chart's own fallback still reports the series\n  as hovered, without an `objectId`, so check `objectId` before reading it.\n  The median line, drawn over the box, is reported on its own row of pixels.\n  An outlier dot is reported as a point and the box and the lines as ranges,\n  so a candle body the pointer is inside wins over a whisker it is only near.\n  Older versions never call `hitTest`.\n","packages/lwc-plugin-brushable-area-series/README.md":"# Brushable area series\n\nAn area series that can style parts of the data differently. You set a base\nstyle for the whole series and any number of *brush ranges*. A brush range is\na span of data points with its own line and fill colors.\n\nThe series itself only draws the styles. Attach the optional\n`BrushableAreaInteraction` primitive, or add your own pointer handling, to turn\nit into a brush selection: the user drags across the chart, the brush range for\nthe selected span is set, and the rest of the series keeps the base style.\nGive `outsideStyle` a semi-transparent style to get the classic effect where\nthe selection stays vivid and the rest looks faded.\n\nUse it for range selection on a sparkline or an overview chart. It also fits\nhighlighting a period, such as a trading session, an event window, or a\nbacktest sample, and comparing segments of one series visually.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-brushable-area-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createBrushableAreaSeries } from '@tradingview/lwc-plugin-brushable-area-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createBrushableAreaSeries(chart, {\n    lineColor: 'rgb(41, 98, 255)',\n    topColor: 'rgba(41, 98, 255, 0.4)',\n    bottomColor: 'rgba(41, 98, 255, 0)',\n    priceLineVisible: false,\n});\nseries.setData(data); // [{ time, value }, ...]\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-brushable-area-series\": \"https://unpkg.com/@tradingview/lwc-plugin-brushable-area-series/dist/brushable-area-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createBrushableAreaSeries } from '@tradingview/lwc-plugin-brushable-area-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createBrushableAreaSeries(chart, {\n    lineColor: 'rgb(41, 98, 255)',\n    topColor: 'rgba(41, 98, 255, 0.4)',\n    bottomColor: 'rgba(41, 98, 255, 0)',\n    priceLineVisible: false,\n});\nseries.setData(data); // [{ time, value }, ...]\n</script>\n```\n\n## Usage\n\nAdd the [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series) with `createBrushableAreaSeries`, set single-value data, then set\n`brushRanges` whenever the selection changes:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createBrushableAreaSeries } from '@tradingview/lwc-plugin-brushable-area-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createBrushableAreaSeries(chart, {\n    lineColor: 'rgb(41, 98, 255)',\n    topColor: 'rgba(41, 98, 255, 0.4)',\n    bottomColor: 'rgba(41, 98, 255, 0)',\n    priceLineVisible: false,\n});\nseries.setData(data); // [{ time, value }, ...]\n\n// Highlight points 40–80 in green and fade everything else.\nseries.applyOptions({\n    brushRanges: [\n        {\n            range: { from: 40, to: 80 },\n            style: {\n                lineColor: '#089981',\n                topColor: 'rgba(8, 153, 129, 0.4)',\n                bottomColor: 'rgba(8, 153, 129, 0)',\n                lineWidth: 3,\n            },\n        },\n    ],\n    outsideStyle: {\n        lineColor: 'rgba(41, 98, 255, 0.2)',\n        topColor: 'rgba(41, 98, 255, 0.05)',\n    },\n});\n\n// Clear the selection: the whole series goes back to the base style.\nseries.applyOptions({ brushRanges: [] });\n```\n\nA range's `style` and `outsideStyle` are both partial: every property left out\nfalls back to the base style set on the series.\n\nRanges are expressed in **logical indices** of the time scale (the position on\nthe chart's own index, shared by every series), not in time and not in the\nseries' own array positions. To turn a pointer position into a logical index,\nuse `chart.timeScale().coordinateToLogical(x)`, where `x` is the pointer's\nhorizontal position within the plot area.\n\nEach data point is `{ time, value }`. Points without a `value` are treated as\nwhitespace, and the line breaks at the gap rather than bridging it.\n\n### Brush selection\n\n`BrushableAreaInteraction` is an optional\n[series primitive](https://tradingview.github.io/lightweight-charts/docs/plugins/series-primitives)\nthat turns a mouse drag, a one-finger drag or a two-finger gesture into a brush\nrange, so the pointer handling does not have to be written again in every\napplication:\n\n```js\nimport {\n    BrushableAreaInteraction,\n} from '@tradingview/lwc-plugin-brushable-area-series';\n\nconst brush = new BrushableAreaInteraction({\n    style: { lineColor: '#089981', topColor: 'rgba(8, 153, 129, 0.4)' },\n    outsideStyle: { lineColor: 'rgba(41, 98, 255, 0.2)' },\n});\nseries.attachPrimitive(brush);\n\nbrush.activeRange().subscribe(range => {\n    // null once the selection is cleared by a click without a drag\n    if (range !== null) {\n        console.log(range.from, range.to, range.fromTime, range.toTime);\n    }\n});\n```\n\n| Interaction option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `style` | `Partial<style>` | green | Style applied to the brushed range. |\n| `outsideStyle` | `Partial<style>` | faded blue | Style applied outside the brushed range. |\n| `applyToSeries` | `boolean` | `true` | Set the series' `brushRanges` as the user drags. Turn it off to only receive `activeRange` events. |\n| `minimumRangeWidth` | `number` | `1` | Smallest drag, in logical indices, that counts as a range. |\n\nThe defaults are exported as `defaultInteractionOptions`. The range reported by\n`activeRange()` carries `from` / `to` as logical indices and `fromTime` /\n`toTime` as the times of the data points at those indices (`null` where the\nseries has no point there). `brush.clear()` removes the selection, and\n`brush.range()` returns the current one.\n\nThe chart's own drag gesture competes with brushing, so a chart using this\nprimitive normally sets `handleScroll: false` and `handleScale: false`.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `lineColor` | `string` | `'rgb(40,98,255)'` | Base line color, used outside brush ranges. |\n| `topColor` | `string` | `'rgba(40,98,255, 0.4)'` | Base fill color at the line (top of the gradient). |\n| `bottomColor` | `string` | `'rgba(40,98,255, 0)'` | Base fill color at the base price (bottom of the gradient). |\n| `lineWidth` | `1 \\| 2 \\| 3 \\| 4` | `2` | Base line width, in CSS pixels. |\n| `lineStyle` | `LineStyle` | `LineStyle.Solid` | Base dash pattern of the line. |\n| `lineVisible` | `boolean` | `true` | Draw the line itself. Set it to `false` for the fill only. |\n| `lineType` | `LineType` | `LineType.Simple` | Shape of the line between two points: straight, stepped or curved. The fill follows the same shape. |\n| `relativeGradient` | `boolean` | `false` | Anchor the far end of the fill gradient to the outermost point in view rather than to the edge of the pane, as `AreaSeries` does. |\n| `invertFilledArea` | `boolean` | `false` | Fill the area above the line, up to the top of the pane, instead of down to `basePrice`. |\n| `basePrice` | `number` | `0` | Price the area is filled down to. |\n| `brushRanges` | `{ range: { from: number; to: number }; style: Partial<style> }[]` | `[]` | Ranges of logical indices rendered in their own style. `from` is inclusive, `to` is exclusive. Set an empty array to clear. |\n| `outsideStyle` | `Partial<style>` | — | Style of the points outside every brush range. Used only while at least one range is set. |\n\n`style` is `{ lineColor, topColor, bottomColor, lineWidth, lineStyle }` — the\nsame five properties as the base style, and each one optional.\n\n## Notes\n\n- A point inside a brush range is drawn with that range's style; if ranges\n  overlap, the **last** matching range wins, so a new selection covers the ones\n  it is dragged over.\n- Each drawn segment takes the style of its right-hand point, and consecutive\n  points sharing a style are drawn as one path, so no seam shows inside a run.\n- The fill is a vertical gradient from `bottomColor` at `basePrice` to\n  `topColor` at the edge of the pane the fill extends towards (or at the\n  outermost point in view with `relativeGradient`). When `basePrice` falls\n  outside the visible price range, the fill reaches the edge of the pane.\n- The line and the fill are drawn one bar past each edge of the visible range,\n  so they leave the pane rather than stopping at the last visible point while\n  the chart is panned.\n- Points whose value falls outside the current price scale, and gaps in the\n  data, break the line rather than being drawn to an invalid coordinate.\n- The examples disable chart scrolling and scaling (`handleScroll`,\n  `handleScale`) so that dragging brushes instead of panning; decide which\n  gesture your chart should own.\n\n### Explicit whitespace\n\nUse `createBrushableAreaSeries` to retain whitespace passed through `setData` and\n`update`, including historical corrections. Other series' timestamps do not\nbreak the area. The low-level `BrushableAreaSeries` view remains available, but\nwithout the factory's gap predicate it draws continuously: the host does not\nprovide whitespace to custom renderers.\n\nUnder time-scale conflation the area is drawn from buckets of several bars, and\na whitespace run narrower than one bucket cannot be resolved at that bar\nspacing: it is absorbed into the bucket rather than breaking the area at every\nbar. Zooming in past the conflation threshold shows the gap again.\n","packages/lwc-plugin-dual-range-histogram-series/README.md":"# Dual range histogram series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series) that draws columns above and below a zero line. At each time\npoint it can show up to two nested columns in each direction: an outer range\nin a lighter color and an inner range in a darker color.\n\nBy default the columns are not sized in price units. The series has a fixed\nheight in pixels: the largest value gets the full height, and the other columns\nare scaled relative to it. This makes the series a compact overlay. It sits on\nthe zero line of another series' price scale and does not disturb that scale.\nSet `scaleMode: 'price'` to have the values read as prices and autoscale like\nany other series instead.\n\nUse it to show paired values around a center line. Typical examples: buy and\nsell volume with an inner share of \"aggressive\" orders, bid and ask depth, or\ninflows and outflows with a highlighted component. Any positive and negative\npair with a nested subset fits.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-dual-range-histogram-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createDualRangeHistogramSeries } from '@tradingview/lwc-plugin-dual-range-histogram-series';\n\nconst chart = createChart(document.getElementById('container'));\n\nconst histogram = createDualRangeHistogramSeries(chart, {\n    priceLineVisible: false,\n    lastValueVisible: false,\n});\nhistogram.setData([\n    { time: '2024-04-22', values: [120, 45, -80, -30] },\n    { time: '2024-04-23', values: [90, 60, -110, -20] },\n    { time: '2024-04-24', values: [140, 35, -60, -40] },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-dual-range-histogram-series\": \"https://unpkg.com/@tradingview/lwc-plugin-dual-range-histogram-series/dist/dual-range-histogram-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createDualRangeHistogramSeries } from '@tradingview/lwc-plugin-dual-range-histogram-series';\n\nconst chart = createChart(document.getElementById('container'));\n\nconst histogram = createDualRangeHistogramSeries(chart, {\n    priceLineVisible: false,\n    lastValueVisible: false,\n});\nhistogram.setData([\n    { time: '2024-04-22', values: [120, 45, -80, -30] },\n    { time: '2024-04-23', values: [90, 60, -110, -20] },\n    { time: '2024-04-24', values: [140, 35, -60, -40] },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `addCustomSeries`, then set data with a `values` array per\npoint — positive values draw upward, negative values downward. The array is\n`[upOuter, upInner, downOuter, downInner]`, which is also how the styling\noptions name their columns:\n\n```js\nimport { createChart, BaselineSeries } from 'lightweight-charts';\nimport { createDualRangeHistogramSeries } from '@tradingview/lwc-plugin-dual-range-histogram-series';\n\nconst chart = createChart(document.getElementById('container'), {\n    timeScale: { barSpacing: 21, minBarSpacing: 4 },\n});\n\nconst histogram = createDualRangeHistogramSeries(chart, {\n    priceLineVisible: false,\n    lastValueVisible: false,\n});\nhistogram.setData([\n    { time: '2024-04-22', values: [120, 45, -80, -30] },\n    { time: '2024-04-23', values: [90, 60, -110, -20] },\n    { time: '2024-04-24', values: [140, 35, -60, -40] },\n]);\n\n// A main series sharing the price scale; the histogram sits on its zero line.\nconst baseline = chart.addSeries(BaselineSeries, {\n    baseValue: { type: 'price', price: 0 },\n});\nbaseline.setData(mainData);\n```\n\nEach data point is `{ time, values: number[], colors? }`. Points with an empty\nor missing `values` array are treated as whitespace. A `colors` entry overrides\nthe series color for the column at the same position; an `undefined` entry\nkeeps the series color.\n\nColors and corner radii are set per column:\n\n```js\nhistogram.applyOptions({\n    colors: {\n        upOuter: '#BBDEFB',\n        upInner: '#1565C0',\n        downOuter: '#FFE0B2',\n        downInner: '#EF6C00',\n    },\n    borderRadius: { upOuter: 8, upInner: 4, downOuter: 8, downInner: 4 },\n    borderColor: '#131722',\n    borderWidth: 1,\n});\n```\n\n### Keeping the histogram in view\n\nIn the default `pixels` scale mode the histogram is `maxHeight` pixels tall and\ncentered on `baseValue`. It does not report its values to the price scale, so\nit never distorts the scaling of the main series — but if the base line is\nclose to the top or bottom of the pane, the columns are clipped. Reserve room\nwith `keepPixelSeriesInView`, which sets the price scale's margins and keeps\nthem correct while the chart is resized:\n\n```js\nimport { keepPixelSeriesInView } from '@tradingview/lwc-plugin-dual-range-histogram-series';\n\nconst stop = keepPixelSeriesInView(chart, histogram);\n// … later, before removing the chart:\nstop();\n```\n\nThe helper follows the series' current pane, including pane resizing and moves.\nIt uses a sizing primitive attached to the series; call `stop()` before removing\nthe chart. Calling `stop()` more than once is safe.\n\nPass a height as the third argument to reserve room for something other than\nthe series' own `maxHeight`.\n\n### Scale modes\n\n`scaleMode: 'price'` treats the values as prices measured from `baseValue`, so\nthe columns are autoscaled by the price scale like any other series;\n`maxHeight` and `normalize` are then ignored and no margins need reserving.\n\n`createDualRangeHistogramSeries` keeps the plot values synchronized with\n`scaleMode` and `baseValue`, including changes made through `applyOptions`.\n\nIn `pixels` mode, `normalize` chooses what the heights are scaled against:\n`'visible'` (the default) rescales the columns as you pan, `'all'` keeps their\nrelative heights across the whole data set, and a number fixes the value which\nfills half of `maxHeight`.\n\nOptions can be changed at runtime with `series.applyOptions({ ... })`.\n\n## Creating a series\n\nUse `createDualRangeHistogramSeries(chart, options?, paneIndex?)`. It returns the\nnormal series API, with the plugin's data and options types preserved. The helper\nmakes scaling options available before the first `setData` and rebuilds plot\nvalues automatically when those options change through `series.applyOptions`.\nThis keeps autoscaling, last-value labels and crosshair values consistent. The\nhelper retains a shallow copy of the input data, including whitespace, and\nre-ingests it only when a scaling option changes. Streaming updates remain\nincremental.\n\nThe low-level `DualRangeHistogramSeries` pane view remains available for integrations\nthat supply their own options getter to its constructor. Passing scaling options\nonly to `chart.addCustomSeries(new DualRangeHistogramSeries(), options)` cannot make\nthem available before data ingestion on LWC 5.0; use the creation helper instead.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `colors` | `{ upOuter, upInner, downOuter, downInner }` of `string` | `{ upOuter: '#ACE5DC', upInner: '#42BDA8', downOuter: '#FCCACD', downInner: '#F77C80' }` | Fill color of each column. A per-point `colors` entry overrides it. |\n| `borderRadius` | `{ upOuter, upInner, downOuter, downInner }` of `number` | `{ upOuter: 2, upInner: 0, downOuter: 2, downInner: 0 }` | Corner radius of each column, in CSS pixels, applied to the column's outer end. |\n| `borderColor` | `string \\| null` | `null` | Border color of the columns. `null` for no border. |\n| `borderWidth` | `number` | `1` | Border width in CSS pixels. Only drawn when `borderColor` is set. |\n| `maxHeight` | `number` | `130` | Total height of the histogram in CSS pixels; the largest value reaches half of it above or below the base line. `pixels` scale mode only. |\n| `scaleMode` | `'pixels' \\| 'price'` | `'pixels'` | Whether the column heights are a fixed number of pixels or prices measured from `baseValue`. See [Scale modes](#scale-modes). |\n| `normalize` | `'visible' \\| 'all' \\| number` | `'visible'` | What the heights are scaled against in `pixels` mode: the largest value in the visible range, in the whole data set, or a fixed value. |\n| `gap` | `number` | `0` | Gap between the upward and the downward half, in CSS pixels. |\n| `widthPercent` | `number` | `100` | Column width as a percentage of the bar spacing, `0`–`100`. |\n| `baseValue` | `number` | `0` | Price the columns are centered on. |\n| `highlightHovered` | `boolean` | `false` | Whether hovering the series fades every point except the one under the cursor. Requires Lightweight Charts 5.2 or later. |\n\n## Notes\n\n- Columns are matched to `colors` and `borderRadius` by their **position** in\n  `values`, not by their sign: a negative value in the `upOuter` slot points\n  downwards but is still drawn in the `upOuter` color.\n- Columns for the same point share one width and position; values are drawn in\n  array order, so later (inner) values paint over earlier (outer) ones. Keep\n  inner values smaller than outer ones for the nested look.\n- A point may carry more than four values; the four columns then repeat, so\n  `values[4]` is styled as `upOuter` again.\n- Column widths follow the same pixel grid as the built-in histogram series,\n  and the alignment is not carried across a gap of whitespace.\n- Values which are not finite are skipped, and nothing is drawn when there is\n  no value to scale the columns against (an all-zero data set, say).\n- `hitTest`, which reports the hovered point through the crosshair as\n  `bar-<index>`, is used by Lightweight Charts 5.2 and later, and\n  `conflationReducer` from 5.1. Older versions simply never call them, and\n  `highlightHovered` has no effect before 5.2.\n","packages/lwc-plugin-grouped-bars-series/README.md":"# Grouped bars series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series)\nthat draws several values per time point as columns side by side, one group\nof columns per point.\n\nUse it to compare a few quantities period by period, when a stack would hide\nthe smaller ones: revenue by region per quarter, buy and sell volume per day,\nor a forecast next to the actual value.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-grouped-bars-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createGroupedBarsSeries } from '@tradingview/lwc-plugin-grouped-bars-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createGroupedBarsSeries(chart, {\n    colors: ['#2962FF', '#F23645', '#FF9800'],\n});\n\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    { time: '2024-04-23', values: [14, 7, 6] },\n    { time: '2024-04-24', values: [11, 9, 4] },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-grouped-bars-series\": \"https://unpkg.com/@tradingview/lwc-plugin-grouped-bars-series/dist/grouped-bars-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createGroupedBarsSeries } from '@tradingview/lwc-plugin-grouped-bars-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createGroupedBarsSeries(chart, {\n    colors: ['#2962FF', '#F23645', '#FF9800'],\n});\n\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    { time: '2024-04-23', values: [14, 7, 6] },\n    { time: '2024-04-24', values: [11, 9, 4] },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `createGroupedBarsSeries`, then set data with a `values`\narray per point. The array order is the column order: `values[0]` is the\nleftmost column of the group.\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createGroupedBarsSeries } from '@tradingview/lwc-plugin-grouped-bars-series';\n\nconst chart = createChart(document.getElementById('container'), {\n    timeScale: { barSpacing: 18, minBarSpacing: 6 },\n});\nconst series = createGroupedBarsSeries(chart, {\n    colors: ['#2962FF', '#F23645', '#FF9800'],\n    widthPercent: 80,\n});\n\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    { time: '2024-04-23', values: [14, -7, 6] },\n    { time: '2024-04-24' },\n    { time: '2024-04-25', values: [11, 9, 4], colors: [undefined, '#131722'] },\n]);\n```\n\nEach data point is `{ time, values: (number | null)[] }`. A point with an empty or\nmissing `values` array is whitespace: it keeps its place on the time scale and\ndraws nothing. Columns grow from `base` (`0` by default), up for values above\nit and down for values below it. A `null` value, a number which is not finite,\nand a value equal to `base`, which would draw a column of no height, leave\ntheir column empty and stay out of the autoscale range, and the other columns\nkeep their places; use `null` for a missing value coming from JSON, which has\nno `NaN`. A point none of whose values draws a column is whitespace.\n\nEvery group is split into as many columns as the longest point has values, so\na column is as wide in every group; a point with fewer values leaves its last\ncolumns empty.\n\nA point may override the series colors for its own columns with a `colors`\narray. A missing or `undefined` entry keeps the series color for that column.\n\nThe series' price line and last value label follow the last value of the last\npoint that draws a column. Options can be changed at runtime with\n`series.applyOptions({ ... })`.\n\n## Creating a series\n\nUse `createGroupedBarsSeries(chart, options?, paneIndex?)`. It returns the\nnormal series API, with the plugin's data and options types preserved. It\nmakes `base` available to the series before the first `setData`, so the base\nline is part of the autoscale range from the start, and changing `base`\nthrough `series.applyOptions` rescales the series without setting the data\nagain. The helper keeps a shallow copy of the input data for that purpose,\nand counts the columns once per data change: a streamed `update()` recounts\nthem over all the points once, on the next redraw.\n\nThe `GroupedBarsSeries` class remains available for\n`chart.addCustomSeries(new GroupedBarsSeries(), options)`. Added that way, the\nseries only learns its options at the first render, so the data set before\nthen is read as if `base` were `0` until the data is set again: values around\n100 with `base: 50` are stretched down to 0, and a value of `0`, equal to that\nassumed base, draws nothing. It also counts the columns over all its points\non every redraw, after a scroll, a zoom or a data change.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `colors` | `string[]` | `['#2962FF', '#E1575A', '#F28E2C', 'rgb(164, 89, 209)', 'rgb(27, 156, 133)']` | Fill color of each column, in the order of `values`. If there are more values than colors, the colors repeat. An empty array falls back to this default. |\n| `base` | `number` | `0` | Price the columns are drawn from. It is part of the autoscale range, so the base line always stays in view. |\n| `columnWidthMode` | `'percent' \\| 'histogram'` | `'percent'` | How wide a group is: a share of the bar spacing, given by `widthPercent`, or as wide as the built-in histogram's columns, the whole bar spacing but a one pixel gap. |\n| `widthPercent` | `number` | `80` | Share of the bar spacing that each group fills in `percent` mode, `0`–`100`. The rest is the gap between neighboring groups; at `100` they touch, or are a device pixel apart where the bar spacing covers a fractional number of them. |\n\nPer-point overrides, on the data item:\n\n| Field | Type | Description |\n| --- | --- | --- |\n| `colors` | `(string \\| undefined)[]` | Fill color of each column of this point. A missing or `undefined` entry falls back to the series color for that column. |\n\n`values` is typed `(number | null)[]`.\n\nThe standard `color` option is not used for the columns; it colors the\nseries' price line and last value label.\n\n## Notes\n\n- In `percent` mode every group is the same whole number of device pixels\n  wide. In `histogram` mode groups can differ by a pixel, as the built-in\n  histogram's columns do, to keep the gap between them even. Each group's\n  width is split among its columns so that they abut with no seam and no\n  overlap and differ by at most one pixel, as long as every column gets at\n  least one device pixel. Set `timeScale.minBarSpacing` to keep that when the\n  user zooms out. Below it, every column still gets a pixel and columns share\n  pixels: the tallest are drawn first so that the shorter ones stay visible.\n- Only the points on screen are drawn. The series is never conflated: with\n  `timeScale.enableConflation` on, the chart still draws every point.\n- On `lightweight-charts` 5.2 and later the series reports the column nearest\n  the pointer through `hitTest`, within the series' `hitTestTolerance` (3 px\n  by default): the crosshair event's `hoveredInfo.objectId` is\n  `'column-<point>-<index>'`, where `<point>` is the point's position in\n  `series.data()` and `<index>` the column's index in its `values`. The\n  nearest column can belong to the next point, so read the point from\n  `<point>` rather than from the crosshair's time. Elsewhere in a point's slot,\n  between its lowest and highest value or the base, the chart's own fallback\n  still reports the series as hovered, without an `objectId`. Older versions\n  never call `hitTest`.\n","packages/lwc-plugin-heatmap-series/README.md":"# Heatmap series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series)\nthat draws a column of cells per time point, each cell covering a price range\nand colored by an amount.\n\nUse it to show how something is spread over prices through time: the size\nresting at each level of an order book, the volume traded at each price, the\ndensity of a forecast, or any value bucketed by price.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-heatmap-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createColorScale, createHeatmapSeries } from '@tradingview/lwc-plugin-heatmap-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createHeatmapSeries(chart, {\n    cellShader: createColorScale({ stops: ['rgba(41, 98, 255, 0.1)', '#2962FF', '#F23645'] }),\n});\n\nseries.setData([\n    { time: '2024-04-22', cells: [{ low: 100, high: 101, amount: 20 }, { low: 101, high: 102, amount: 80 }] },\n    { time: '2024-04-23', cells: [{ low: 100, high: 101, amount: 60 }, { low: 101, high: 102, amount: 40 }] },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-heatmap-series\": \"https://unpkg.com/@tradingview/lwc-plugin-heatmap-series/dist/heatmap-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createColorScale, createHeatmapSeries } from '@tradingview/lwc-plugin-heatmap-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createHeatmapSeries(chart, {\n    cellShader: createColorScale({ stops: ['rgba(41, 98, 255, 0.1)', '#2962FF', '#F23645'] }),\n});\n\nseries.setData([\n    { time: '2024-04-22', cells: [{ low: 100, high: 101, amount: 20 }, { low: 101, high: 102, amount: 80 }] },\n    { time: '2024-04-23', cells: [{ low: 100, high: 101, amount: 60 }, { low: 101, high: 102, amount: 40 }] },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `createHeatmapSeries`, then set data with a `cells`\narray per point:\n\n```js\nconst series = createHeatmapSeries(chart, {\n    cellShader: (amount, range) => (amount > (range.min + range.max) / 2 ? '#F23645' : '#2962FF'),\n    cellGap: 1,\n});\n\nseries.setData([\n    {\n        time: '2024-04-22',\n        cells: [\n            { low: 100, high: 101, amount: 20 },\n            { low: 101, high: 102, amount: 80 },\n        ],\n    },\n    { time: '2024-04-23' },\n]);\n```\n\nEach data point is `{ time, cells }`, and each cell `{ low, high, amount }`:\n\n- A cell is drawn from `low` to `high` across the point's whole slot, in the\n  color `cellShader(amount, range)` returns. The edges may come in either\n  order, and the cells of a column in any order. Cells are not expected to\n  overlap: cells of the same color are filled together, so where two\n  overlap, which one shows depends on their colors, not on their order.\n- A cell whose `low`, `high` or `amount` is not a finite number is skipped,\n  and so is a `null` cell, as a JSON feed may send.\n- A point with no cell to draw is whitespace, `cells` that is missing or\n  `null` included.\n\nCells whose price edges meet share a pixel edge, and so do neighboring\ncolumns, so with no gap they abut with no seam and no overlap at every zoom\nlevel and device pixel ratio.\n\nThe series autoscales to the lowest and highest cell edge of the points on\nscreen. The price line and the last value label, off by default, show the\nmiddle of a column's lowest and highest edge. Options can be changed at\nruntime with `series.applyOptions({ ... })`.\n\nIn the `plugin-examples` collection the types were spelled `HeatMapSeries`,\n`HeatMapData`, `HeatMapSeriesOptions` and `HeatMapCellShader`; the package\nspells them `HeatmapSeries`, `HeatmapData`, `HeatmapSeriesOptions` and\n`HeatmapCellShader`. `HeatmapCell` is unchanged.\n\n## Colors\n\nThe shader is called with the cell's amount and the range of the amounts in\nview, `{ min, max }`: the lowest and the highest amount among the cells of\nthe points on screen. A shader can spread its colors over that range rather\nthan over a maximum worked out in advance, so the colors keep their spread as\nthe chart scrolls.\n\n`createColorScale({ stops, domain?, steps? })` builds such a shader from a\nlist of colors:\n\n```js\nconst shader = createColorScale({\n    // Spread evenly from the low end to the high end.\n    stops: ['rgba(41, 98, 255, 0.1)', '#2962FF', '#F7A600', '#F23645'],\n    // The amounts that take the first and the last stop. Without it, the\n    // range of the amounts in view.\n    domain: [0, 100],\n    // How many colors the scale holds, 2 to 1024. Defaults to 32.\n    steps: 16,\n});\n```\n\nThe stops can be any CSS color the canvas accepts, and are mixed with\npremultiplied alpha, as CSS gradients are. A stop the canvas cannot parse, or\none in a color space other than sRGB such as `oklch()`, is left out; without a\nDOM, as in server-side rendering, only `#rrggbb`, `rgb()` and `rgba()` stops\ncan be read. An amount\nbeyond the domain takes the color at that end; a domain given high end first\nreverses the scale, and one whose ends are not both finite numbers is ignored.\nThe colors are worked out once, so the shader builds no color string while\ndrawing, and the fewer steps there are, the more cells share a fill.\n\nA shader of your own is called for every cell on screen on every paint, so\nkeep it cheap, and return a limited set of colors: cells are filled together\nby color, once per color per paint. A cell whose color the canvas cannot\nparse is not drawn.\n\n## Creating a series\n\nUse `createHeatmapSeries(chart, options?, paneIndex?)`. It adds the series and\nreturns the normal series API, with the plugin's data and options types\nfilled in. Its options type keeps `cellShader` a function, here and in\n`applyOptions`, so an inline shader gets its parameters typed; the library's\n`DeepPartial`, which `chart.addCustomSeries` uses, turns a function option\ninto an object type.\n\nThe `HeatmapSeries` class remains available for\n`chart.addCustomSeries(new HeatmapSeries(), options)`.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `cellShader` | `(amount: number, range: { min: number; max: number }) => string` | green, from faint at `0` to opaque at `100` | Turns a cell's amount into its fill color, given the range of the amounts in view. A value that is not a function falls back to the default. |\n| `cellGap` | `number` | `1` | Space between neighboring cells, in CSS pixels, both between the columns and between the cells of a column. Left out along a side where the cell is not more than three times as long. `0` for none. |\n| `cellBorderWidth` | `number` | `0` | Width of the border drawn inside the edge of every cell, in CSS pixels. Left out along a side where the cell, less the gap, is not more than three times as long. `0` for none. |\n| `cellBorderColor` | `string` | `'rgba(255, 255, 255, 1)'` | Color of the cell border. A color the canvas cannot parse draws no border. |\n\nThe gap and the border are rounded to whole device pixels along each axis.\nWhether a cell is long enough for them is decided before its edges are\nrounded, so cells of one size all get them or all go without.\nA negative width counts as `0`, and one that is not a number as the default.\n`lastValueVisible` and `priceLineVisible` default to `false`.\n\n## Notes\n\n- Only the points on screen are drawn, and of their cells only those on the\n  pane. A cell whose two edges round to the same device pixel is not drawn,\n  which can happen to one under a pixel tall.\n- The series has no `conflationReducer`, so the chart never merges its\n  points: zoomed out to a bar spacing under a device pixel, every column is\n  still worked out, and those that round to no width are skipped.\n- On `lightweight-charts` 5.2 and later the series reports the cell under the\n  pointer through `hitTest`, in the column whose slot holds the pointer and\n  within the series' `hitTestTolerance` (3 px by default) above or below the\n  cell: the crosshair's `hoveredInfo.objectId` is `'cell-<index>'`, the index\n  into that point's `cells`, and `param.seriesData` holds the point to read\n  the cell from. Between a column's lowest and highest edge, holes\n  included, the chart's own fallback reports the series as hovered without\n  an `objectId`, so check `objectId` before reading a cell. Hovering changes\n  nothing in how the series is drawn.\n- On 5.2 and later the chart also draws the hovered series above the others\n  by default. A heatmap is hovered anywhere over the span of its columns, so\n  it then covers a price series drawn on top of it. Create the chart with\n  `hoveredSeriesOnTop: false` to keep the other series on top.\n","packages/lwc-plugin-hlc-area-series/README.md":"# HLC area series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series) for high-low-close data. It draws the high, low, and close\nvalues as three lines. The band between the lines is filled with two colors:\none between high and close, another between close and low. The result reads\nlike a candlestick's range without the visual weight of individual candles.\n\nUse it to show a value together with its range over time. Typical examples: a\ndaily close between its high and low, a forecast with its confidence band, the\nminimum, average, and maximum of a metric, or a mid price between bid and ask.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-hlc-area-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createHLCAreaSeries } from '@tradingview/lwc-plugin-hlc-area-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createHLCAreaSeries(chart, {\n    highLineColor: '#089981',\n    lowLineColor: '#F23645',\n    closeLineColor: '#787B86',\n});\n\nseries.setData([\n    { time: '2024-04-22', high: 104.2, low: 98.7, close: 101.3 },\n    { time: '2024-04-23', high: 105.0, low: 100.1, close: 104.6 },\n    { time: '2024-04-24', high: 106.8, low: 103.2, close: 103.9 },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-hlc-area-series\": \"https://unpkg.com/@tradingview/lwc-plugin-hlc-area-series/dist/hlc-area-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createHLCAreaSeries } from '@tradingview/lwc-plugin-hlc-area-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createHLCAreaSeries(chart, {\n    highLineColor: '#089981',\n    lowLineColor: '#F23645',\n    closeLineColor: '#787B86',\n});\n\nseries.setData([\n    { time: '2024-04-22', high: 104.2, low: 98.7, close: 101.3 },\n    { time: '2024-04-23', high: 105.0, low: 100.1, close: 104.6 },\n    { time: '2024-04-24', high: 106.8, low: 103.2, close: 103.9 },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `createHLCAreaSeries`, then set data with `high`, `low`, and\n`close` values:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createHLCAreaSeries } from '@tradingview/lwc-plugin-hlc-area-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createHLCAreaSeries(chart, {\n    highLineColor: '#089981',\n    lowLineColor: '#F23645',\n    closeLineColor: '#787B86',\n});\n\nseries.setData([\n    { time: '2024-04-22', high: 104.2, low: 98.7, close: 101.3 },\n    { time: '2024-04-23', high: 105.0, low: 100.1, close: 104.6 },\n    { time: '2024-04-24', high: 106.8, low: 103.2, close: 103.9 },\n]);\n```\n\nEach data point is `{ time, high, low, close }`. Points missing any of the three\nvalues are treated as whitespace, and leave a gap. The series' price line and last-value label follow the\n`close` value.\n\nOptions can be changed at runtime with `series.applyOptions({ ... })`.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `highLineColor` | `string` | `'#049981'` | Color of the high line. |\n| `lowLineColor` | `string` | `'#F23645'` | Color of the low line. |\n| `closeLineColor` | `string` | `'#878993'` | Color of the close line. |\n| `highAreaColor` | `string` | `'rgba(4, 153, 129, 0.2)'` | Fill color between the high line and the close line. |\n| `lowAreaColor` | `string` | `'rgba(242, 54, 69, 0.2)'` | Fill color between the close line and the low line. |\n| `highLineWidth` | `LineWidth` | `2` | Width of the high line, in CSS pixels (`1`–`4`). |\n| `lowLineWidth` | `LineWidth` | `2` | Width of the low line, in CSS pixels (`1`–`4`). |\n| `closeLineWidth` | `LineWidth` | `2` | Width of the close line, in CSS pixels (`1`–`4`). |\n| `highLineStyle` | `LineStyle` | `LineStyle.Solid` | Dash pattern of the high line. |\n| `lowLineStyle` | `LineStyle` | `LineStyle.Solid` | Dash pattern of the low line. |\n| `closeLineStyle` | `LineStyle` | `LineStyle.Solid` | Dash pattern of the close line. |\n| `highLineVisible` | `boolean` | `true` | Whether the high line is drawn. |\n| `lowLineVisible` | `boolean` | `true` | Whether the low line is drawn. |\n| `closeLineVisible` | `boolean` | `true` | Whether the close line is drawn. |\n| `areaVisible` | `boolean` | `true` | Whether the two fills between the lines are drawn. |\n| `lineType` | `'simple' \\| 'step'` | `'simple'` | How the lines and the fills get from one point to the next. `'step'` matches the built-in `LineType.WithSteps`. |\n| `highAreaTopColor` | `string` | `''` | Upper stop of a vertical gradient filling the high–close band. |\n| `highAreaBottomColor` | `string` | `''` | Lower stop of the high–close band gradient. |\n| `lowAreaTopColor` | `string` | `''` | Upper stop of a vertical gradient filling the close–low band. |\n| `lowAreaBottomColor` | `string` | `''` | Lower stop of the close–low band gradient. |\n| `hoverPointRadius` | `number` | `4` | Radius, in CSS pixels, of the dots drawn on the high, low and close of the bar under the cursor while the series is hovered. `0` turns the highlight off. |\n\n`areaTopColor` and `areaBottomColor` are deprecated aliases of `highAreaColor`\nand `lowAreaColor`. They still work, and take precedence when both are set.\n\nA band is filled with a gradient only when both stops of its pair are set; while\neither is an empty string the flat `highAreaColor` / `lowAreaColor` is used. The\ngradient runs down the whole pane, like the built-in Area series' `topColor` and\n`bottomColor` without `relativeGradient`.\n\n## Notes\n\n- The price scale autoscales to the full `low`–`high` range, so the band is\n  never clipped.\n- Points missing any of `high`, `low` and `close` are whitespace. The lines and\n  the fills break at a run of whitespace instead of bridging it, and a point\n  whose price falls off the scale is skipped rather than turned into a NaN\n  coordinate.\n- The lines and the fills continue past the first and the last visible point, so\n  they reach the edges of the pane while panning.\n- Line widths follow the library's `LineWidth` type, so `0` is not one of them.\n  Use `highLineVisible` / `lowLineVisible` / `closeLineVisible` to hide a line\n  and `areaVisible` to hide both fills.\n- On Lightweight Charts™ 5.2 and later the series reports the bar under the\n  cursor through `hitTest` and highlights its three values, and from 5.1\n  conflated points are merged as the highest high, the lowest low and the\n  last close.\n\n### Explicit whitespace\n\nUse `createHLCAreaSeries` to retain whitespace passed through `setData` and\n`update`, including historical corrections. Other series' timestamps do not\nbreak the area. The low-level `HLCAreaSeries` view remains available, but\nwithout the factory's gap predicate it draws continuously: the host does not\nprovide whitespace to custom renderers.\n\nUnder time-scale conflation the area is drawn from buckets of several bars, and\na whitespace run narrower than one bucket cannot be resolved at that bar\nspacing: it is absorbed into the bucket rather than breaking the area at every\nbar. Zooming in past the conflation threshold shows the gap again.\n","packages/lwc-plugin-image-watermark/README.md":"# Image watermark\n\nAn image drawn behind the chart content, as a\n[series primitive](https://tradingview.github.io/lightweight-charts/docs/plugins/series-primitives)\n(`ImageWatermark`) or as a\n[pane primitive](https://tradingview.github.io/lightweight-charts/docs/plugins/pane-primitives)\n(`ImageWatermarkPane`). The image is placed within the pane — centered by\ndefault, or anchored to a corner — and scaled to fit, to fill, or not at all.\nPosition, size limits, padding, opacity and visibility can all be changed after\nthe watermark has been attached.\n\nThe series primitive belongs to the series it is attached to: it lives in that\nseries' pane and is removed together with the series. The pane primitive needs\nno series at all.\n\nUse it to brand a chart with a logo, or to mark a chart as a preview or draft,\nwithout touching the chart's own rendering.\n\n> **Lightweight Charts™ 5 also ships a built-in image watermark.**\n> [`createImageWatermark(pane, url, options)`](https://tradingview.github.io/lightweight-charts/docs/api/functions/createImageWatermark)\n> is a pane primitive which centers an image and scales it to fit. If that is\n> all you need, the built-in function is the right choice. Use this package for\n> a watermark tied to a specific series rather than to a pane, or for anything\n> the built-in does not offer: corner and fractional positions, `objectFit`,\n> `crossOrigin`, `visible`, `zOrder`, `applyOptions` / `setImage` and an\n> `onError` callback.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-image-watermark\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { ImageWatermark } from '@tradingview/lwc-plugin-image-watermark';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(data);\n\nseries.attachPrimitive(new ImageWatermark('/logo.svg', { alpha: 0.4 }));\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-image-watermark\": \"https://unpkg.com/@tradingview/lwc-plugin-image-watermark/dist/image-watermark.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { ImageWatermark } from '@tradingview/lwc-plugin-image-watermark';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(data);\n\nseries.attachPrimitive(new ImageWatermark('/logo.svg', { alpha: 0.4 }));\n</script>\n```\n\n## Usage\n\n### Behind a series\n\nCreate the watermark with the image URL, then attach it to the series it\nshould follow:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { ImageWatermark } from '@tradingview/lwc-plugin-image-watermark';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(data);\n\nconst watermark = new ImageWatermark('/logo.svg', {\n    maxHeight: 400,\n    maxWidth: 400,\n    padding: 50,\n    alpha: 0.4,\n});\nseries.attachPrimitive(watermark);\n```\n\nTo remove the watermark, detach it from the series:\n\n```js\nseries.detachPrimitive(watermark);\n```\n\n### Behind a pane\n\n`ImageWatermarkPane` takes the same image URL and the same options, and is\nattached to a pane instead of a series. Use it when the watermark should stay\nput while series are added and removed:\n\n```js\nimport { ImageWatermarkPane } from '@tradingview/lwc-plugin-image-watermark';\n\nconst watermark = new ImageWatermarkPane('/logo.svg', { alpha: 0.4 });\nchart.panes()[0].attachPrimitive(watermark);\n\n// later\nchart.panes()[0].detachPrimitive(watermark);\n```\n\n### Changing the watermark\n\nBoth classes have the same methods:\n\n```js\nwatermark.applyOptions({ position: 'bottom-right', alpha: 0.2 });\nwatermark.setImage('/other-logo.svg'); // same as applyOptions({ imageUrl })\nwatermark.options(); // the current options, with the defaults filled in\n```\n\n`applyOptions` merges: an option which is not passed, or is passed as\n`undefined`, is left unchanged.\n\nThe image is loaded when the primitive is attached and drawn once it has\ndecoded; until then nothing is rendered. A new image passed to `setImage` or\n`applyOptions` replaces the current one once it has decoded, so the watermark\ndoes not blink out in between. Any URL the browser can load into an\n`<img>` element works, including SVG and data URLs. Decoded images are cached\nby URL, so detaching and re-attaching a watermark — or using the same image\ntwice — never loads it again.\n\n## Options\n\nOptions are passed as the second constructor argument, which is optional, as\nis every option in it. The type is `ImageWatermarkPluginOptions`, and the\ndefaults are exported as `defaultOptions`.\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `imageUrl` | `string` | `''` | URL of the image. The first constructor argument sets the same option. |\n| `position` | `WatermarkPosition` | `'center'` | Where the image sits in the pane: `'center'`, `'top-left'`, `'top-right'`, `'bottom-left'`, `'bottom-right'`, or `{ x, y }`. |\n| `objectFit` | `WatermarkObjectFit` | `'contain'` | `'contain'` scales the image to fit, `'cover'` scales it to fill and crops the overflow, `'none'` draws it at its natural size. |\n| `maxWidth` | `number` | — (pane width) | Maximum width of the drawing area, in CSS pixels. |\n| `maxHeight` | `number` | — (pane height) | Maximum height of the drawing area, in CSS pixels. |\n| `padding` | `number` | `0` | Minimum distance between the drawing area and the edges of the pane, in CSS pixels. |\n| `alpha` | `number` | `1` | Opacity of the image, from `0` (invisible) to `1` (opaque). |\n| `visible` | `boolean` | `true` | Whether the watermark is drawn at all. |\n| `zOrder` | `'bottom' \\| 'normal' \\| 'top'` | `'bottom'` | Layer the watermark is drawn in. `'bottom'` puts it behind the grid and the series. |\n| `crossOrigin` | `'anonymous' \\| 'use-credentials'` | — | `crossOrigin` attribute of the underlying `<img>` element. |\n| `onError` | `(error, imageUrl) => void` | — | Called when the image cannot be loaded. Nothing else reports the failure. |\n\n### Position and size\n\nThe drawing area is the pane inset by `padding` and limited to `maxWidth` /\n`maxHeight`. `position` places that area within the pane and the image within\nthat area:\n\n- a named anchor — `'center'` or one of the four corners;\n- `{ x, y }`, fractions of the free space from `0` to `1`. `{ x: 0, y: 0 }` is\n  the top-left corner, `{ x: 1, y: 1 }` the bottom-right one, `{ x: 0.5, y: 0 }`\n  the middle of the top edge. Values outside `0`…`1` are clamped.\n\n`objectFit` then decides the scale. With `'contain'` (the default) the image is\nscaled up or down to fit, keeping its aspect ratio; set `maxWidth` /\n`maxHeight` to its natural size if it should never be enlarged. With `'cover'`\nit is scaled to fill the drawing area and the overflow is cropped, and with\n`'none'` it is drawn at its natural size. Nothing is ever drawn outside the\ndrawing area, so `padding` always holds.\n\n## Notes\n\n- The watermark is drawn behind the chart content by default: the grid, the\n  series, and other primitives all appear on top of it. Only the pane\n  background is below it. Pass `zOrder: 'top'` to draw it over everything\n  instead.\n- The image appears only in the pane it belongs to, where the series is drawn.\n  It never covers the price scales or the time scale, and a visible left price\n  scale or a second pane does not move it.\n- A watermark whose image cannot be loaded draws nothing and throws nothing.\n  Pass `onError` to be told about it; the plugin logs nothing itself.\n- `ImageWatermarkOptions` is still exported, as a deprecated alias of\n  `ImageWatermarkPluginOptions`. The plugin option type was renamed because\n  the library exports an `ImageWatermarkOptions` of its own, for the built-in\n  `createImageWatermark`. The alias is kept for compatibility and will be\n  removed in a future major version.\n- The image can be loaded from any origin. However, an image served without\n  CORS headers marks the canvas as \"tainted\", and\n  [`takeScreenshot`](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/IChartApi#takescreenshot)\n  fails on a tainted canvas. If you plan to export the chart as an image, serve\n  the watermark image with CORS headers and set `crossOrigin: 'anonymous'`.\n","packages/lwc-plugin-lollipop-series/README.md":"# Lollipop series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series)\nthat draws each value as a dot at the end of a stem. The stem runs from a\nbase line, `0` by default, up to a value above it or down to a value below it.\n\nUse it where a histogram would put too much ink on the chart: values that\nswing around a reference, such as daily returns, net flows or a difference\nfrom a target, where the dot marks the value and the stem shows how far it is\nfrom the base.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-lollipop-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createLollipopSeries } from '@tradingview/lwc-plugin-lollipop-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createLollipopSeries(chart, { color: '#2962FF' });\n\nseries.setData([\n    { time: '2024-04-22', value: 4.2 },\n    { time: '2024-04-23', value: -1.8 },\n    { time: '2024-04-24', value: 2.6 },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-lollipop-series\": \"https://unpkg.com/@tradingview/lwc-plugin-lollipop-series/dist/lollipop-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createLollipopSeries } from '@tradingview/lwc-plugin-lollipop-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createLollipopSeries(chart, { color: '#2962FF' });\n\nseries.setData([\n    { time: '2024-04-22', value: 4.2 },\n    { time: '2024-04-23', value: -1.8 },\n    { time: '2024-04-24', value: 2.6 },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `createLollipopSeries`, then set data with a `value` per\npoint:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createLollipopSeries } from '@tradingview/lwc-plugin-lollipop-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createLollipopSeries(chart, {\n    base: 0,\n    lineWidth: 2,\n    markerSize: 8,\n});\n\nseries.setData([\n    { time: '2024-04-22', value: 4.2 },\n    { time: '2024-04-23', value: -1.8, color: '#F23645' },\n    { time: '2024-04-24' },\n    { time: '2024-04-25', value: 2.6 },\n]);\n```\n\nEach data point is `{ time, value }`. A point without a finite `value`,\n`null` included, as JSON sends a missing one, is whitespace: it keeps its\nplace on the time scale and draws nothing. A `color` on a point\noverrides the series `color` for that point's stem and dot.\n\nThe series' price line and last value label follow the last value. Options can\nbe changed at runtime with `series.applyOptions({ ... })`.\n\n## Creating a series\n\nUse `createLollipopSeries(chart, options?, paneIndex?)`. It returns the normal\nseries API, with the plugin's data and options types preserved. It makes `base`\navailable to the series before the first `setData`, so the base line is part\nof the autoscale range from the start, and changing `base` through\n`series.applyOptions` rescales the series without setting the data again. The\nhelper keeps a shallow copy of the input data for that purpose; streaming\nupdates stay incremental.\n\nThe `LollipopSeries` class remains available for\n`chart.addCustomSeries(new LollipopSeries(), options)`. Added that way, the\nseries only learns its options at the first render, so the data set before\nthen is scaled as if `base` were `0`: values around 100 with `base: 100` are\nstretched down to 0 until the data is set again.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`color`, `priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `base` | `number` | `0` | Price the stems are drawn from. It is part of the autoscale range, so the base line always stays in view. |\n| `lineWidth` | `number` | `2` | Width of the stem, in CSS pixels, at most half the bar spacing and at least one device pixel. |\n| `markerSize` | `number` | `8` | Diameter of the dot at the value, in CSS pixels, at most 20 and at most the bar spacing. `0` draws no dots. |\n\nThe standard `color` option colors the stems, the dots and the price line.\n\n## Notes\n\n- Stems and dots shrink with the bar spacing when the chart is zoomed out: a\n  stem is at most half the bar spacing wide, down to one device pixel, and a\n  dot at most as wide as the bar spacing, so neighboring dots can touch but\n  stay apart from the next stem. At a bar spacing of one device pixel the\n  one-pixel stems fill every pixel. Set `timeScale.minBarSpacing` to keep\n  lollipops from getting that small.\n- Autoscale covers the values and the base, not the dots around them, so a\n  dot at the highest or lowest value sticks out by its radius. The 20 px cap\n  on `markerSize` keeps it within the price scale's default margins in a pane\n  at least 100 px tall.\n- Only the points on screen are drawn. The series is never conflated: with\n  `timeScale.enableConflation` on, the chart still draws every point.\n- On `lightweight-charts` 5.2 and later the series reports the lollipop under\n  the pointer through `hitTest`, within the series' `hitTestTolerance` (3 px\n  by default): the crosshair event's `hoveredInfo.objectId` is `bar-<index>`,\n  where `<index>` is the point's position in `series.data()`. The dot is\n  reported as a point and the stem as a range, like a column, so a candle body\n  the pointer is inside wins over a stem the pointer is only near. Elsewhere\n  in a point's slot, between the base and the value, the chart's own fallback\n  still reports the series as hovered, without an `objectId`. Older versions\n  never call `hitTest`.\n","packages/lwc-plugin-pretty-histogram-series/README.md":"# Pretty histogram series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series) that draws a histogram with rounded bars. Unlike the built-in\nhistogram series, it can round the outer corners of each bar, control the bar\nwidth as a share of the bar spacing, color bars by their sign, draw a border\nand fade the fill into a second color. The result is a softer look that fits\ndashboards and marketing-style charts.\n\nUse it for volume panes, single-value indicators, or any bar chart where the\ndefault square bars look too heavy.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-pretty-histogram-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createPrettyHistogramSeries } from '@tradingview/lwc-plugin-pretty-histogram-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createPrettyHistogramSeries(chart, {\n    color: '#2962FF',\n    widthPercent: 60,\n    radius: 6,\n});\n\nseries.setData([\n    { time: '2024-04-22', value: 12.5 },\n    { time: '2024-04-23', value: -4.1 },\n    { time: '2024-04-24', value: 8.3, color: '#F23645' },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-pretty-histogram-series\": \"https://unpkg.com/@tradingview/lwc-plugin-pretty-histogram-series/dist/pretty-histogram-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createPrettyHistogramSeries } from '@tradingview/lwc-plugin-pretty-histogram-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createPrettyHistogramSeries(chart, {\n    color: '#2962FF',\n    widthPercent: 60,\n    radius: 6,\n});\n\nseries.setData([\n    { time: '2024-04-22', value: 12.5 },\n    { time: '2024-04-23', value: -4.1 },\n    { time: '2024-04-24', value: 8.3, color: '#F23645' },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `addCustomSeries`, then set histogram data:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createPrettyHistogramSeries } from '@tradingview/lwc-plugin-pretty-histogram-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createPrettyHistogramSeries(chart, {\n    color: '#2962FF',\n    widthPercent: 60,\n    radius: 6,\n});\n\nseries.setData([\n    { time: '2024-04-22', value: 12.5 },\n    { time: '2024-04-23', value: -4.1 },\n    { time: '2024-04-24', value: 8.3, color: '#F23645' },\n]);\n```\n\nEach data point is `{ time, value, color? }` — the same shape as the built-in\nhistogram series. A per-point `color` overrides the series `color` for that\nbar. Points without a `value` are treated as whitespace.\n\nOptions can be changed at runtime with `series.applyOptions({ ... })`.\n\n### Two-tone bars\n\nSet `upColor` and `downColor` to color each bar by its sign relative to\n`base`, the way a volume pane usually does:\n\n```js\nseries.applyOptions({\n    base: 0,\n    upColor: '#089981',\n    downColor: '#F23645',\n});\n```\n\nA per-point `color` still wins over both.\n\n### The base line\n\nBars grow from `base` (`0` by default), and the base is always reported to the\nautoscale alongside the values, exactly as the built-in histogram series does.\nBars are therefore never cut off at the edge of the pane, and no custom\n`autoscaleInfoProvider` is needed.\n\n`base` is read when the data is set, so change it before or together with\n`setData` if you also rely on the autoscale following it.\n\n## Creating a series\n\nUse `createPrettyHistogramSeries(chart, options?, paneIndex?)`. It returns the\nnormal series API, with the plugin's data and options types preserved. The helper\nmakes scaling options available before the first `setData` and rebuilds plot\nvalues automatically when those options change through `series.applyOptions`.\nThis keeps autoscaling, last-value labels and crosshair values consistent. The\nhelper retains a shallow copy of the input data, including whitespace, and\nre-ingests it only when a scaling option changes. Streaming updates remain\nincremental.\n\nThe low-level `PrettyHistogramSeries` pane view remains available for integrations\nthat supply their own options getter to its constructor. Passing scaling options\nonly to `chart.addCustomSeries(new PrettyHistogramSeries(), options)` cannot make\nthem available before data ingestion on LWC 5.0; use the creation helper instead.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `color` | `string` | `'#D63864'` | Fill color of the bars, used whenever no more specific color applies. A per-point `color` in the data overrides it. |\n| `upColor` | `string \\| null` | `null` | Fill color of bars at or above `base`. `null` falls back to `color`. |\n| `downColor` | `string \\| null` | `null` | Fill color of bars below `base`. `null` falls back to `color`. |\n| `base` | `number` | `0` | Price the bars grow from. Always included in the autoscale. |\n| `widthPercent` | `number` | `50` | Bar width as a percentage of the bar spacing, `0`–`100`. Ignored when `widthMode` is `'histogram'`. |\n| `widthMode` | `'percent' \\| 'histogram'` | `'percent'` | `'percent'` sizes each bar from `widthPercent`. `'histogram'` uses the full slot with a one-pixel gap, exactly as the built-in histogram series does. |\n| `minColumnWidth` | `number` | `1` | Lower bound for the bar width, in CSS pixels. |\n| `radius` | `number` | `4` | Corner radius of the bar's outer end, in CSS pixels. Positive bars are rounded at the top, negative bars at the bottom. The radius is capped at half the bar width and at the bar height. |\n| `roundInnerCorners` | `boolean` | `false` | Whether the corners at the `base` end are rounded with the same radius. |\n| `borderColor` | `string \\| null` | `null` | Border color of the bars. `null` for no border. |\n| `borderWidth` | `number` | `1` | Border width in CSS pixels. Only drawn when `borderColor` is set. |\n| `gradientColor` | `string \\| null` | `null` | Color the fill fades into at the outer end of each bar. `null` for a flat fill. |\n| `highlightHovered` | `boolean` | `false` | Whether hovering the series fades every bar except the one under the cursor. Requires Lightweight Charts 5.2 or later. |\n\n## Notes\n\n- Bars are anchored at `base` and the base is always part of the autoscale, so\n  the series behaves like the built-in histogram; see\n  [The base line](#the-base-line).\n- Bar widths reproduce the built-in histogram exactly in `'histogram'` width\n  mode and at `widthPercent: 100`: the same pixel grid, the same one-pixel gap,\n  and no alignment carried across a whitespace gap.\n- Flat, borderless bars are drawn in batches: consecutive bars of the same\n  color are filled in one canvas operation. Setting `borderColor`,\n  `gradientColor` or `highlightHovered` paints bar by bar instead.\n- `hitTest`, which reports the hovered bar through the crosshair as\n  `bar-<index>`, is used by Lightweight Charts 5.2 and later, and\n  `conflationReducer` from 5.1. Older versions simply never call them, and\n  `highlightHovered` has no effect before 5.2.\n","packages/lwc-plugin-preview-kit/README.md":"# Preview kit\n\nPrivate, never published. Shared layout and controls for the catalog preview\npages of the plugin packages: `src/example/preview.html` and `preview.ts` of\nevery `packages/lwc-plugin-*`, declared as `lwcPlugin.preview` and built to\n`/plugin-previews/<slug>/` by `pnpm plugins:build-demos`.\n\nA preview page is not the plugin's demo. The demo (`lwcPlugin.demo`) is the\npage a developer opens on its own: it carries edge cases, whitespace runs,\nnegative values and every option the plugin has. A preview is what the\ncatalog frames next to the README, so it shows the plugin at its best in a\nshort frame and nothing else.\n\nThree entry points:\n\n- `@tradingview/lwc-plugin-preview-kit/preview.css` — the whole layout. One\n  compact `#controls` row above a `#chart` that fills the rest of the frame.\n  Light and dark, keyed on the root element's `data-theme`. Nothing is\n  restyled after load, so the chart is created at its final size and does not\n  jump.\n- `@tradingview/lwc-plugin-preview-kit/preview-theme` — follows the theme of\n  the docs page that frames the preview, live: toggling the site theme\n  restyles the running preview without reloading it. `?theme=light|dark` in\n  the page URL pins a theme instead (a page opened on its own is light).\n  `themeChart(chart, onTheme?)` themes the chart's background, text, grid,\n  scale borders and crosshair labels now and on every switch; `onTheme` is\n  where a preview recolours anything of its own that would not read on the\n  other background.\n- `@tradingview/lwc-plugin-preview-kit/preview-controls` — `mountControls(defs)`\n  builds the control row from `select`, `checkbox` and `button` declarations,\n  and `addRefreshButton(onRefresh)` adds a \"New data\" button for the previews\n  whose sample data is random. Plain DOM, no framework.\n\nA preview page is therefore two elements and a script:\n\n```html\n<div id=\"controls\"></div>\n<div id=\"chart\"></div>\n<script type=\"module\" src=\"./preview.ts\"></script>\n```\n\nThe page script is a module and can run after the first paint, so\n`src/theme-boot.js` sets the theme before it: `pnpm plugins:build-demos`\ninlines it straight after `<meta charset>` of every built preview page (the\nbuild fails without one), which is why a preview page needs no script of its\nown in its HTML. It applies the same rules as `preview-theme`; change them in\nboth places.\n\nAdd the kit to a package with `@tradingview/lwc-plugin-preview-kit: workspace:*` in\n`devDependencies` — `create-lwc-plugin --workspace` does this for you — and\ndeclare `lwcPlugin.preview` (and `previewHeight`, when 330 px is not enough).\n","packages/lwc-plugin-rounded-candles-series/README.md":"# Rounded candles series\n\nA [custom candlestick series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series) with rounded candle bodies. It renders the same\nopen-high-low-close data as the built-in candlestick series. Each body is\ndrawn as a rounded rectangle. The corner radius adapts to the bar spacing:\nsharp when zoomed out, soft when zoomed in.\n\nUse it as a drop-in replacement for the built-in candlesticks wherever a\nsofter visual style fits, such as dashboards, embedded widgets, or marketing\npages.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-rounded-candles-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { RoundedCandleSeries } from '@tradingview/lwc-plugin-rounded-candles-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addCustomSeries(new RoundedCandleSeries(), {\n    upColor: '#089981',\n    downColor: '#F23645',\n    wickUpColor: '#089981',\n    wickDownColor: '#F23645',\n});\n\nseries.setData([\n    { time: '2024-04-22', open: 100.2, high: 104.6, low: 99.1, close: 103.8 },\n    { time: '2024-04-23', open: 103.8, high: 105.0, low: 101.4, close: 102.0 },\n    { time: '2024-04-24', open: 102.0, high: 106.1, low: 101.7, close: 105.4 },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-rounded-candles-series\": \"https://unpkg.com/@tradingview/lwc-plugin-rounded-candles-series/dist/rounded-candles-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { RoundedCandleSeries } from '@tradingview/lwc-plugin-rounded-candles-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addCustomSeries(new RoundedCandleSeries(), {\n    upColor: '#089981',\n    downColor: '#F23645',\n    wickUpColor: '#089981',\n    wickDownColor: '#F23645',\n});\n\nseries.setData([\n    { time: '2024-04-22', open: 100.2, high: 104.6, low: 99.1, close: 103.8 },\n    { time: '2024-04-23', open: 103.8, high: 105.0, low: 101.4, close: 102.0 },\n    { time: '2024-04-24', open: 102.0, high: 106.1, low: 101.7, close: 105.4 },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `addCustomSeries`, then set candlestick data:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { RoundedCandleSeries } from '@tradingview/lwc-plugin-rounded-candles-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addCustomSeries(new RoundedCandleSeries(), {\n    upColor: '#089981',\n    downColor: '#F23645',\n    wickUpColor: '#089981',\n    wickDownColor: '#F23645',\n});\n\nseries.setData([\n    { time: '2024-04-22', open: 100.2, high: 104.6, low: 99.1, close: 103.8 },\n    { time: '2024-04-23', open: 103.8, high: 105.0, low: 101.4, close: 102.0 },\n    { time: '2024-04-24', open: 102.0, high: 106.1, low: 101.7, close: 105.4 },\n]);\n```\n\nEach data point is `{ time, open, high, low, close }` — the same shape as the\nbuilt-in candlestick series. Points missing any of the four values are treated\nas whitespace, and leave a gap.\n\nA constant `radius` fixes the corner rounding regardless of zoom:\n\n```js\nseries.applyOptions({ radius: 6 });\n```\n\nOptions can be changed at runtime with `series.applyOptions({ ... })`.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `upColor` | `string` | `'#26a69a'` | Body color of rising candles. |\n| `downColor` | `string` | `'#ef5350'` | Body color of falling candles. |\n| `borderVisible` | `boolean` | `true` | Whether a border is drawn around the body. |\n| `borderUpColor` | `string` | `'#26a69a'` | Border color of rising candles. |\n| `borderDownColor` | `string` | `'#ef5350'` | Border color of falling candles. |\n| `borderColor` | `string` | — | Border color of both directions. Wins over `borderUpColor` / `borderDownColor` while it is set to a non-empty string. |\n| `wickVisible` | `boolean` | `true` | Whether wicks are drawn. |\n| `wickUpColor` | `string` | `'#26a69a'` | Wick color of rising candles. |\n| `wickDownColor` | `string` | `'#ef5350'` | Wick color of falling candles. |\n| `wickColor` | `string` | — | Wick color of both directions. Wins over `wickUpColor` / `wickDownColor` while it is set to a non-empty string. |\n| `wickLineCap` | `'butt' \\| 'round'` | `'butt'` | Shape of the two wick ends. |\n| `radius` | `number \\| ((barSpacing: number) => number)` | `bs => bs < 4 ? 0 : bs / 3` | Corner radius of the candle body, in CSS pixels. Either a constant, or a function of the current bar spacing. Use `0` for square candles. |\n| `upDownMode` | `'openClose' \\| 'previousClose'` | `'openClose'` | How a candle is decided to be rising or falling. `'openClose'` compares `open <= close`, exactly as the built-in candlestick series does. `'previousClose'` compares the close with the previous candle's close and treats the first candle as rising. |\n| `hoverDimOpacity` | `number` | `1` | Opacity of the candles other than the hovered one while the series is hovered. `1` leaves the series unchanged. |\n\nEach data point may also carry `color`, `borderColor` and `wickColor`, which\noverride the corresponding options for that candle only — the same per-item\noverrides the built-in candlestick series supports.\n\n## Notes\n\n- A candle counts as *rising* when `open <= close`, exactly as the built-in\n  candlestick series decides it. `upDownMode: 'previousClose'` restores the\n  behavior this plugin had while it was an example (close compared with the\n  previous close, the first candle always rising).\n- `borderColor` and `wickColor` are resolved at draw time, so clearing them\n  (setting them to an empty string) brings the up/down pair back. The built-in\n  series copies them into the pair once, in `applyOptions`, and cannot be\n  reverted that way.\n- Wicks are drawn above and below the body rather than as one bar behind it, so\n  a translucent body does not show its own wick through itself.\n- On Lightweight Charts™ 5.2 and later the series reports the candle under the\n  cursor through `hitTest`, and from 5.1 conflated candles are merged\n  open-first, close-last with the extremes of both.\n- Rounded corners use `CanvasRenderingContext2D.roundRect`, which every browser\n  the library supports provides.\n","packages/lwc-plugin-scatter-series/README.md":"# Scatter series\n\nA scatter and bubble chart for Lightweight Charts™: points placed by two\nnumbers on a numeric X axis, in named groups with their own colors and marker\nshapes, sized by a data value, optionally connected by lines, with baselines\nand accent borders around the plot.\n\nUse it to show how two measures relate across many items, where time is not\nthe horizontal axis: trades by maximum adverse excursion and result, bonds by\nmaturity and yield with the issue size as the bubble, or sectors on a relative\nrotation graph with their recent path as a tail. The plugin draws the chart\ncontent only: titles, legends and tooltips stay with your page, and the series\ntells it which point is hovered and where it is drawn.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.2.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-scatter-series\n```\n\nThen create a scatter chart and add the series to it:\n\n```js\nimport { createScatterChart, createScatterSeries } from '@tradingview/lwc-plugin-scatter-series';\n\nconst chart = createScatterChart(document.getElementById('container'), { autoSize: true });\n\nconst series = createScatterSeries(chart, {\n    groups: [\n        { id: 'win', name: 'Win trades', color: '#089981' },\n        { id: 'loss', name: 'Loss trades', color: '#F23645' },\n    ],\n    baselines: [{ axis: 'y', value: 0 }],\n});\n\nseries.setData([\n    { x: 12, y: 540000, group: 'win', sizeValue: 14 },\n    { x: 31, y: -320000, group: 'loss', sizeValue: 3 },\n    { x: 18, y: 120000, group: 'win', sizeValue: 40 },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-scatter-series\": \"https://unpkg.com/@tradingview/lwc-plugin-scatter-series/dist/scatter-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createScatterChart, createScatterSeries } from '@tradingview/lwc-plugin-scatter-series';\n\nconst series = createScatterSeries(createScatterChart(document.getElementById('container'), { autoSize: true }));\nseries.setData([{ x: 1, y: 2 }, { x: 3, y: 5 }, { x: 4, y: 1 }]);\n</script>\n```\n\n## Usage\n\n`createScatterChart(container, options?)` creates a chart whose horizontal\nscale is a numeric X axis (see [The scatter chart](#the-scatter-chart)), and\n`createScatterSeries(chart, options?, paneIndex?)` adds the series, which\nholds the whole dataset, every group included. Fields of your own travel with\nthe points; give the series their type:\n\n```ts\nimport { createScatterChart, createScatterSeries, type ScatterPoint } from '@tradingview/lwc-plugin-scatter-series';\n\ninterface Bond extends ScatterPoint {\n    title: string;\n}\n\nconst chart = createScatterChart(document.getElementById('container')!, { autoSize: true });\nconst series = createScatterSeries<Bond>(chart, {\n    groups: [\n        { id: 'aaa', name: 'AAA-AA', color: '#089981' },\n        { id: 'hy', name: 'High yield', color: '#FF9800' },\n    ],\n    xRange: { min: 0, max: 30 },\n    xFormatter: (x: number) => `${x}Y`,\n    priceFormat: { type: 'custom', minMove: 0.01, formatter: (y: number) => `${y.toFixed(2)}%` },\n});\n\nseries.setData([\n    { id: 'PEMX1', x: 4.5, y: 3.2, group: 'aaa', sizeValue: 120, title: 'PEMX1' },\n    { id: 'PEMX3', x: 21.7, y: 9.4, group: 'hy', sizeValue: 75, title: 'PEMX3' },\n]);\n```\n\nChange options with `series.applyOptions({ ... })` and replace the points with\n`series.setData(points)`; the chart applies both on its next frame. Every\noption and method is documented in the package's type declarations.\n\n### Points\n\n| Field | Type | Description |\n| --- | --- | --- |\n| `x`, `y` | `number` | Position, in X axis and price scale units. Required. A point is drawn only when both are finite and `x` is within the X range. |\n| `id` | `string` | Reported as the `objectId` when the point is hovered; defaults to its index. Keep it unique. |\n| `group` | `string` | Identifier of the point's group. |\n| `sizeValue` | `number` | A value mapped to the point's size (see [Dynamic size](#dynamic-size)). |\n| `size` | `number` | Size in CSS pixels, stroke included. Overrides `sizeValue`. |\n| `color`, `opacity`, `shape`, `strokeColor`, `strokeWidth`, `hollow` | | Overrides of the group's style (see [Point styles](#point-styles)). |\n\nPoints need no ordering, and may share an X value. Any other field is kept\nand handed back with the point by the hover API.\n\n### Groups\n\nA group is a named set of points sharing a style — what a user calls a\n\"series\" of the scatter chart. Declare groups in `groups`, in drawing order; a\ngroup a point names without it being declared comes after them. `groups` is\nreplaced as a whole by `applyOptions`.\n\n| Field | Default | Description |\n| --- | --- | --- |\n| `id` | — | Identifier points refer to. Required. |\n| `name` | `id` | Display name, for your legend. |\n| `color` | the `palette` entry | Fill color. |\n| `opacity`, `shape`, `pointSize`, `strokeColor`, `strokeWidth`, `hollow` | the series option | Style of the group's points; `opacity` is `1` with `lineVisible`. |\n| `visible` | `true` | Whether the group is drawn, hovered and autoscaled. |\n| `lineVisible` | `false` | Connect the group's points in data order, as a tail. |\n| `lineWidth`, `lineColor`, `lineStyle` | `1`, the group color, solid | The connecting line. |\n\nA hidden group still counts for the automatic X range and size domain, so\nswitching it moves neither; `series.setGroupVisible(id, visible)` switches one\nwithout passing every group again. A connecting line is cut at the plot edge.\n\n### Point styles\n\nA point's style beats its group's, which beats the series options; its size\nis its `size`, else its mapped `sizeValue`, else the `pointSize` of its group,\nelse of the series. Every point has a thin ring, `strokeWidth` wide but at\nmost a quarter of its size, to show where points overlap; a `hollow` point is\nan outline at least 1 px wide and no fill. The ring color is automatic by\ndefault: the chart's background, following theme changes, or the point's own\ncolor when it is hollow.\n\n`strokeColor` is the only style that also takes `null`, on a group or a point,\nand `null` is not the same as leaving it out: left out, the color comes from\nthe group, then the series; `null` asks for the automatic color even when the\ngroup or the series sets one.\n\n```js\nseries.applyOptions({\n    strokeColor: '#131722',\n    groups: [\n        { id: 'aaa', hollow: true, strokeWidth: 2, strokeColor: null }, // outlined in its own color\n        { id: 'bbb', strokeWidth: 2 }, // ringed in #131722\n    ],\n});\n```\n\n### Dynamic size\n\n`sizeValue` is mapped onto `sizeRange` (5–25 px by default): `sizeDomain.min`\nto the smallest size, `sizeDomain.max` to the largest, and values beyond the\ndomain to its ends. An open end of the domain (`null`, the default) is taken\nfrom the points of every group, hidden ones included. When every value is the\nsame, the points are drawn at the middle of the range. When every value lies\npast the one given end, the domain is that end alone and the points take its\nsize: the smallest below a given `min`, the largest above a given `max`.\n`sizeScale: 'area'` grows the area\nrather than the diameter, which is what the eye compares in a bubble chart.\n\n```js\nseries.applyOptions({ sizeRange: { min: 5, max: 50 }, sizeDomain: { min: 0, max: null }, sizeScale: 'area' });\n```\n\nEvery size, stroke included, is clamped to `pointSizeLimits`: 5–50 px by\ndefault (`defaultOptions.pointSizeLimits`), each end within 1–500 px.\n`series.sizeMapping()` returns the mapping as drawn — `domain`, `range`,\n`scale` and `sizeFor(value)` — for a bubble-size legend.\n\n### Baselines and border\n\n`baselines` are reference lines under the points: `{ axis: 'y', value: 0 }`\nis horizontal at a Y value, `axis: 'x'` vertical at an X value, each with an\noptional `color`, `width` and `style`. The price scale and the automatic X\nrange include them. `plotBorder` draws an accent border inside the edges of\nthe plot, on the sides you choose: `{ visible: true, top: false, right: false }`.\n\n### The X axis\n\nThe X axis spans `xRange`. An open end (`null`, the default) is taken from\nevery point and rounded outwards to a nice tick — 1, 2 or 5 × 10ⁿ, about ten\nintervals across; a given end off the axis grid (slots a tenth or a twentieth\nof a tick apart) is moved outwards to it. `series.xDomain()` returns the range\nin use. The labels are evenly spaced nice values, thinned out on narrow charts\nso that none overlap, and formatted with `xFormatter`.\n\nThe ends of the range sit on the plot edges, so a bubble there is cut in half;\n`xMargins` keeps room for it, in pixels. A fixed edge allows no such room, so\nwhile `xMargins` is above 0 the series frees the chart's fixed edges, and fixes\nthem again when the margins return to 0 or the series is removed. An edge the\nhost fixes meanwhile is kept fixed then; one it frees meanwhile cannot be told\nfrom the freed one, so free it again once the margins are 0. For dates, pass\ntimestamps and format them: the ticks are nice numbers of the unit, not\ncalendar boundaries, and next to large offsets such as epoch milliseconds the\nslots stay coarse enough to be distinct numbers. X values beyond ±1e300 cannot\nbe laid out: those points are not drawn, and the series warns once; nor can a\nspan below 1e-98, which is widened, with a warning. Data spanning only a few\nfloating-point steps of its own magnitude, such as `[1e15, 1e15 + 1]`, gets\nan axis of very few slots, since finer ones would not be distinct numbers;\nthe chart keeps neighboring slots at most half the plot width apart (its\ndefault `timeScale.maxBarSpacing`), so such data spans about half the plot.\n\n```js\nseries.applyOptions({\n    xFormatter: x => new Date(x).toLocaleDateString('en-GB', { day: 'numeric', month: 'short', timeZone: 'UTC' }),\n    xMargins: 12,\n});\nseries.setData(trades.map(trade => ({ id: trade.id, x: trade.closedAt, y: trade.pnl }))); // epoch milliseconds\n```\n\n### The Y axis\n\nThe Y axis is the series' price scale: format it with `priceFormat`, and pin\neither end with `yRange` (an open end autoscales, with room for the largest\npoint; ends in the wrong order are swapped, as in `xRange`). Its modes apply as they are — `PriceScaleMode.Logarithmic`, or\n`invertScale` — and the points, hit tests and `pointById` follow; the\npercentage and indexed-to-100 modes mean nothing here, and the series warns\nonce when either is set. For the scale on the left, give the chart\n`leftPriceScale: { visible: true }` and `rightPriceScale: { visible: false }`,\nand the series `priceScaleId: 'left'`.\n\n## The scatter chart\n\n`createScatterChart` is `createChartEx` with a numeric horizontal scale\nbehavior (`ScatterHorzScaleBehavior`) and these defaults\n(`scatterChartDefaults`), which the options you pass override:\n\n- scrolling and zooming off, flag by flag: `handleScroll`'s `mouseWheel`,\n  `pressedMouseMove`, `horzTouchDrag` and `vertTouchDrag`, and `handleScale`'s\n  `mouseWheel`, `pinch`, and `axisPressedMouseMove` and `axisDoubleClickReset`\n  for both axes, so that the X axis spans its range edge to edge;\n- `crosshair.mode: CrosshairMode.Hidden`; hover and the crosshair events keep\n  working;\n- dotted grid lines, and no time or price scale borders;\n- on the time scale: `allowBoldLabels: false`, `uniformDistribution: true`,\n  `lockVisibleTimeRangeOnResize: true`, `shiftVisibleRangeOnNewBar: false`,\n  `rightOffset: 0`, `minBarSpacing: 0.001`, `fixLeftEdge: true` and\n  `fixRightEdge: true`;\n- price `scaleMargins` of 0.05 at the top and the bottom, on both price\n  scales; the series adds room for its largest point.\n\n`scatterChartDefaults` is frozen. A `handleScroll` or `handleScale` object you\npass switches on just the flags it sets; `true` switches them all on. To build\nthe chart yourself, give `createChartEx` both type arguments, which it cannot\ninfer:\n`createChartEx<number, ScatterHorzScaleBehavior>(container, new ScatterHorzScaleBehavior(), scatterChartDefaults)`.\n\nThe series manages the chart's `timeScale.tickMarkMaxCharacterLength`, and\ngives the chart its own value back on `remove()`. A crosshair you show\n(`CrosshairMode.Normal`) snaps its vertical line to the slots of the X axis,\nnot to the points; its magnet modes snap to the extremes of a slot.\n\n### Scrolling and zooming\n\nWith scrolling or zooming switched on (`handleScroll`, `handleScale`), the\nseries keeps the user's zoom through data refreshes, option changes and\nresizes, and labels the part of the axis in view. A new X range is fitted\nagain, as `series.fitXDomain()` does. Zoomed out to the span of the fit or\nfurther, wherever the range sat, the user is back at the fit: a pan at that\nzoom springs back to it, as does the chart's double-click reset of the time\naxis. Keep the fixed edges: they keep the user within the X range, and only at\na fixed edge does the chart move an end label inside the plot. At a free edge\nit centers the label on its value, so the series keeps that end of the range\nfar enough inside for it. To let the user pan past the range, set `xMargins`.\nZoom from code with `chart.timeScale().setVisibleLogicalRange(...)`: a zoom\nset through the `timeScale.barSpacing` and `rightOffset` options looks like the\nchart's double-click reset, so the series fits the range again.\n\n## Hover, tooltips and legends\n\n`subscribeHoveredPointChange(handler)` is the one subscription a tooltip\nneeds. After the chart has painted, at most once a frame, it hands the handler\nthe hovered point — under the pointer, else the one set with\n`setHoveredPoint` — whenever anything about it changes (another point, new\ndata or options, a resize, a rescaled axis), and `null` when there is none any\nmore, the removal of the series included.\n\n```js\nconst tooltip = document.getElementById('tooltip'); // absolutely positioned in the chart container\n\nseries.subscribeHoveredPointChange(info => {\n    if (info === null) {\n        tooltip.style.display = 'none';\n        return;\n    }\n    // Pane coordinates: the plot starts after the left price scale, if it is shown.\n    const left = chart.priceScale('left').width() + info.x;\n    tooltip.textContent = `${info.point.title}: ${info.point.x}, ${info.point.y}`;\n    tooltip.style.display = 'block';\n    tooltip.style.transform = `translate(${left}px, ${info.y - info.radius}px) translate(-50%, -100%)`;\n});\n```\n\nIt gets what `series.pointById(objectId)` returns: your point, its `index`\nand `groupId`, its center `x` and `y` in pane coordinates (CSS pixels from the\ntop-left corner of the plot), its `radius` as drawn, and its resolved style.\nThe chart's crosshair and click events carry the hovered `objectId` in\n`param.hoveredInfo` (with `hoveredInfo.series === series.series()`), but come\nwith pointer moves, and when the series lays the X axis out again, and never\nreport a point set with `setHoveredPoint`: prefer the subscription. To highlight a point from outside\nthe chart, a table row say, call `series.setHoveredPoint(objectId)`, and\n`null` to clear it.\n\nBuild a legend from `series.groups()`, the groups as drawn, with their palette\ncolor, shape, ring and `pointCount` resolved, and switch them with\n`setGroupVisible`:\n\n```js\nfunction renderLegend() {\n    legend.replaceChildren(...series.groups().map(group => {\n        const item = document.createElement('button');\n        item.textContent = `${group.name} (${group.pointCount})`;\n        item.style.cssText = `color: ${group.color}; opacity: ${group.visible ? 1 : 0.4}`;\n        item.onclick = () => { series.setGroupVisible(group.id, !group.visible); renderLegend(); };\n        return item;\n    }));\n}\nrenderLegend();\n```\n\nThe hovered point is drawn on top at `hoveredOpacity`, and can grow\n(`hoveredSizeIncrease`) and get a ring (`hoveredRingWidth`). Of overlapping\npoints the topmost is hovered; over no point, the pointer hovers one within\n`hitTestTolerance` pixels.\n\n## Draw your own overlays\n\nFor anything else — a shaded region, a band, an annotation — attach a\n[series primitive](https://tradingview.github.io/lightweight-charts/docs/plugins/series-primitives)\nto `series.series()`, placed with `series.xToCoordinate(x)` and\n`series.series().priceToCoordinate(y)` in its `updateAllViews`, which the\nchart calls before every paint. This one shades rectangles given in data\nunits under the grid and the points — the quadrants of a relative rotation\ngraph, say:\n\n```ts\nimport type { IPrimitivePaneView, ISeriesPrimitive } from 'lightweight-charts';\nimport type { ScatterSeriesApi } from '@tradingview/lwc-plugin-scatter-series';\n\n/** A rectangle in data units. An open end (`null`) runs to the edge of the pane. */\ninterface ShadedRegion {\n    xMin: number | null;\n    xMax: number | null;\n    yMin: number | null;\n    yMax: number | null;\n    color: string;\n}\n\nfunction regionShading(scatter: ScatterSeriesApi, regions: readonly ShadedRegion[]): ISeriesPrimitive<number> {\n    let boxes: { left: number; right: number; top: number; bottom: number; color: string }[] = [];\n    const view: IPrimitivePaneView = {\n        zOrder: () => 'bottom',\n        renderer: () => ({\n            // Whole device pixels within the pane, so that the edges stay sharp.\n            draw: target => target.useBitmapCoordinateSpace(({ context, bitmapSize, horizontalPixelRatio: h, verticalPixelRatio: v }) => {\n                for (const box of boxes) {\n                    const left = Math.max(0, Math.round(box.left * h));\n                    const right = Math.min(bitmapSize.width, Math.round(box.right * h));\n                    const top = Math.max(0, Math.round(box.top * v));\n                    const bottom = Math.min(bitmapSize.height, Math.round(box.bottom * v));\n                    if (right > left && bottom > top) {\n                        context.fillStyle = box.color;\n                        context.fillRect(left, top, right - left, bottom - top);\n                    }\n                }\n            }),\n        }),\n    };\n    return {\n        attached: ({ requestUpdate }) => requestUpdate(), // attaching does not repaint the chart\n        paneViews: () => [view],\n        updateAllViews: () => {\n            const series = scatter.series();\n            boxes = [];\n            if (!series.options().visible) {\n                return; // the chart draws the primitives of a hidden series too\n            }\n            // An open Y end runs to the top of the pane, or to the bottom of an inverted scale.\n            const up = series.priceScale().options().invertScale ? Infinity : -Infinity;\n            const x = (value: number | null, open: number) => (value === null ? open : scatter.xToCoordinate(value));\n            const y = (value: number | null, open: number) => (value === null ? open : series.priceToCoordinate(value));\n            for (const region of regions) {\n                const left = x(region.xMin, -Infinity);\n                const right = x(region.xMax, Infinity);\n                const low = y(region.yMin, -up);\n                const high = y(region.yMax, up);\n                if (left !== null && right !== null && low !== null && high !== null) {\n                    boxes.push({ left, right, top: Math.min(low, high), bottom: Math.max(low, high), color: region.color });\n                }\n            }\n        },\n    };\n}\n\nseries.series().attachPrimitive(regionShading(series, [\n    { xMin: 100, xMax: null, yMin: 100, yMax: null, color: 'rgba(8, 153, 129, 0.1)' }, // leading\n    { xMin: 100, xMax: null, yMin: null, yMax: 100, color: 'rgba(251, 192, 45, 0.12)' }, // weakening\n    { xMin: null, xMax: 100, yMin: null, yMax: 100, color: 'rgba(242, 54, 69, 0.08)' }, // lagging\n    { xMin: null, xMax: 100, yMin: 100, yMax: null, color: 'rgba(41, 98, 255, 0.08)' }, // improving\n]));\n```\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceFormat`, `priceScaleId`, `visible`, `autoscaleInfoProvider`, …):\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `color` | `'#2962FF'` | Fill color of points with no group, and of groups when `palette` is empty. |\n| `opacity` | `0.65` | Opacity of the points, `0`–`1`. |\n| `pointSize` | `9` | Size of the points in CSS pixels, stroke included. |\n| `pointSizeLimits` | `{ min: 5, max: 50 }` | Smallest and largest size of any point. |\n| `shape` | `'circle'` | `'circle'`, `'square'`, `'diamond'`, `'triangleUp'` or `'triangleDown'`. |\n| `strokeColor`, `strokeWidth` | `null`, `1` | Color (`null`: automatic) and width in CSS pixels (`0`: none) of the ring around every point. |\n| `hollow` | `false` | Draw points as open markers. |\n| `palette` | `DEFAULT_SCATTER_PALETTE` | Colors of the groups which set none, in group order: ten by default. |\n| `groups` | `[]` | The groups, in drawing order. |\n| `sizeRange` | `{ min: 5, max: 25 }` | Sizes `sizeValue` is mapped onto, in CSS pixels. |\n| `sizeDomain` | `{ min: null, max: null }` | Values mapped to the ends of `sizeRange`; `null` takes the end from the data. |\n| `sizeScale` | `'linear'` | Whether the diameter (`'linear'`) or the area (`'area'`) grows with `sizeValue`. |\n| `xRange` | `{ min: null, max: null }` | The X axis range; `null` takes the end from the data. |\n| `xMargins` | `0` | Room between each end of the X range and the plot edge, in CSS pixels. |\n| `xFormatter` | `null` | Formats the X labels; `null` prints the number. |\n| `yRange` | `{ min: null, max: null }` | Pins the ends of the Y axis; `null` autoscales. |\n| `baselines` | `[]` | Reference lines under the points. |\n| `plotBorder` | `visible: false`, `'#9598A1'`, 1 px, solid, every side | Accent border along the edges of the plot (`visible`, `color`, `width`, `style`, `top`, `right`, `bottom`, `left`). |\n| `hoveredOpacity` | `1` | Opacity of the hovered point, drawn on top. |\n| `hoveredSizeIncrease` | `0` | Pixels added to the size of the hovered point. |\n| `hoveredRingWidth`, `hoveredRingGap`, `hoveredRingColor` | `0`, `1`, `null` | Width (`0`: none), distance and color (`null`: the point's) of a ring around the hovered point. |\n| `hitTestTolerance` | `3` | How many pixels outside a point the pointer may be and still hover it. |\n\n`applyOptions` merges nested objects; `groups`, `baselines`, `palette` and\n`xFormatter` are replaced whole. `null` sets an option back to its default: an\nend of a range to automatic, or (from JavaScript) a whole option. An\n`applyOptions` or `setData` call that throws — an `xFormatter` that throws,\nsay — changes nothing. Set `visible` through the scatter series. Keep the\nprice line and last-value label off: the underlying values are X axis slots.\n\n## API\n\n`createScatterSeries` returns a `ScatterSeriesApi`:\n\n| Method | Description |\n| --- | --- |\n| `setData(points)` / `data()` | Replaces / reads the points. The array is copied, the points are not. |\n| `applyOptions(options)` / `options()` | Changes / reads (a copy of) the options. |\n| `series()` | The underlying custom series, for its price scale and Y conversions. |\n| `groups()` | The groups as drawn, resolved, with their point counts, for a legend. |\n| `setGroupVisible(groupId, visible)` | Shows or hides a group, keeping its color and the X axis. |\n| `xDomain()` / `fitXDomain()` | The X axis range in use and its tick step / fits it to the plot again. |\n| `xToCoordinate(x)` / `coordinateToX(coordinate)` | An X value to a horizontal pane coordinate and back, as the points are drawn, or `null`. |\n| `sizeMapping()` | How `sizeValue` maps to sizes, or `null` when no point uses it. |\n| `pointById(objectId)` / `hitTest(x, y)` | Where a point is drawn / the point at a pane coordinate, or `null`. |\n| `hoveredPoint()` / `setHoveredPoint(objectId \\| null)` | Reads / sets the hovered point. |\n| `subscribeHoveredPointChange(handler)` / `unsubscribeHoveredPointChange(handler)` | Follows the hovered point: which point, and where it is drawn. |\n| `remove()` | Removes the series, and gives the chart back the options the series manages. Safe to call twice, or after `chart.remove()`. |\n\n## Notes\n\n- Requires `lightweight-charts` 5.2 or later, for the custom series hit test\n  and the `hoveredInfo` of chart events.\n- One scatter series per chart: it holds every group, and creating a second\n  throws until the first is removed. Other series on a scatter chart are not\n  supported, as their time points break the even spacing of the X axis: use\n  `baselines`, a group's `lineVisible`, or a\n  [primitive](#draw-your-own-overlays).\n- Take the series off with `series.remove()`; one taken off with\n  `chart.removeSeries(series.series())` releases itself right after the next\n  chart event or API call. After `chart.remove()` the API returns `null`.\n- `series.series()` serves the price scale and Y conversions, not data or\n  scatter options: its data is the slot grid of the X axis, and its own\n  `options().hitTestTolerance` is `-Infinity`, which turns the chart's hit test\n  of the slots off (the scatter tolerance is in `series.options()`).\n- A chart and a series from different copies of the package (the standalone\n  build and the main entry point, say) do not mix: `createScatterSeries`\n  throws.\n","packages/lwc-plugin-session-highlighting/README.md":"# Session highlighting\n\nA [series primitive](https://tradingview.github.io/lightweight-charts/docs/plugins/series-primitives)\nthat shades the background behind each bar of a series. You give it a\nfunction from a bar's time to a color, and every bar of the attached series\ngets a full-height column in that color, as wide as the bar itself. The\ncolumns follow the series as the chart scrolls and zooms.\n\nUse it to show where one trading session ends and the next begins, to tint\npre-market and after-hours bars, to mark weekends or holidays, or to shade any\nother time-based condition behind the data.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-session-highlighting\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart, CandlestickSeries } from 'lightweight-charts';\nimport { SessionHighlighting } from '@tradingview/lwc-plugin-session-highlighting';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(CandlestickSeries);\nseries.setData(data);\n\nseries.attachPrimitive(new SessionHighlighting(time => {\n    const day = new Date(time * 1000).getUTCDay();\n    return day === 0 || day === 6 ? 'rgba(255, 152, 1, 0.2)' : '';\n}));\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-session-highlighting\": \"https://unpkg.com/@tradingview/lwc-plugin-session-highlighting/dist/session-highlighting.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart, CandlestickSeries } from 'lightweight-charts';\nimport { SessionHighlighting } from '@tradingview/lwc-plugin-session-highlighting';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(CandlestickSeries);\nseries.setData(data);\n\nseries.attachPrimitive(new SessionHighlighting(time => {\n    const day = new Date(time * 1000).getUTCDay();\n    return day === 0 || day === 6 ? 'rgba(255, 152, 1, 0.2)' : '';\n}));\n</script>\n```\n\n## Usage\n\n### The highlighter\n\nThe first constructor argument is the highlighter: a function which receives\na bar's time and returns a CSS color. Return an empty string for a bar that\nshould not be shaded. The time comes in whatever form your data uses, so for\nbusiness-day data check for an object:\n\n```js\nimport { isBusinessDay } from 'lightweight-charts';\n\nfunction toDate(time) {\n    if (isBusinessDay(time)) {\n        return new Date(Date.UTC(time.year, time.month - 1, time.day));\n    }\n    return typeof time === 'number' ? new Date(time * 1000) : new Date(time);\n}\n\nconst highlighter = time => {\n    const hour = toDate(time).getUTCHours();\n    if (hour < 9 || hour >= 16) {\n        return 'rgba(120, 123, 134, 0.15)'; // outside the main session\n    }\n    return '';\n};\n\nconst highlighting = new SessionHighlighting(highlighter);\nseries.attachPrimitive(highlighting);\n```\n\nThe highlighter is called once per bar when the series data is set, and once\nfor the last bar when `series.update()` appends or replaces it, so it can do\nreal work per call; `series.pop()` drops the popped bars without calling it.\nKeep it a function of the time alone: a historical update, which is\n`series.update(bar, true)`, re-asks it for the last bar rather than for the\nbar it changed, and one that turns a bar into whitespace, or whitespace into a\nbar, re-asks it for every bar. Translucent colors let the grid and the series show through; the shading\nis drawn behind both by default.\n\nTo remove the shading, detach it from the series:\n\n```js\nseries.detachPrimitive(highlighting);\n```\n\n### Changing the shading\n\n```js\nhighlighting.applyOptions({ zOrder: 'top', visible: false });\nhighlighting.setHighlighter(time => '#F0F3FA'); // recolors every bar\nhighlighting.options(); // the current options, with the defaults filled in\n```\n\n`applyOptions` merges: an option which is not passed, or is passed as\n`undefined`, is left unchanged.\n\n## Options\n\nOptions are passed as the second constructor argument, which is optional, as\nis every option in it. The type is `SessionHighlightingOptions`, and the\ndefaults are exported as `defaultOptions`.\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `visible` | `boolean` | `true` | Whether the shading is drawn at all. |\n| `zOrder` | `'bottom' \\| 'normal' \\| 'top'` | `'bottom'` | Layer the shading is drawn in. `'bottom'` puts it behind the grid and the series. |\n\n## Notes\n\n- Each column is exactly one bar wide, taken from the time scale's bar\n  spacing, so neighboring columns abut with no seams and no overlap at any\n  zoom level or device pixel ratio.\n- Only bars of the attached series are shaded. Whitespace items and gaps in\n  the data get no column, even where another series has a bar at that time.\n- The shading appears only in the pane the series is drawn in, never under\n  the price scales or the time scale. To shade a second pane, attach another\n  `SessionHighlighting` to a series in that pane.\n- Only the bars on screen are drawn, so the cost of a paint is bounded by the\n  width of the chart, not by the length of the history. An incremental\n  `series.update()` or `series.pop()` does read the series data once to find\n  out what changed, which is proportional to the number of bars.\n","packages/lwc-plugin-stacked-area-series/README.md":"# Stacked area series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series) that stacks several values per\ntime point into cumulative\nbands. Each value is drawn as an area on top of the previous one, with a line\nalong its upper edge. The top edge of the stack shows the total.\n\nUse it to show composition over time, when the parts and the whole matter at\nthe same time. Typical examples: portfolio allocation, revenue by segment,\ntraffic by source, or volume by venue.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-stacked-area-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createStackedAreaSeries } from '@tradingview/lwc-plugin-stacked-area-series';\n\nconst chart = createChart(document.getElementById('container'), {\n    rightPriceScale: { scaleMargins: { top: 0.05, bottom: 0.05 } },\n});\nconst series = createStackedAreaSeries(chart, {\n    colors: [\n        { line: '#2962FF', area: 'rgba(41, 98, 255, 0.2)' },\n        { line: '#F23645', area: 'rgba(242, 54, 69, 0.2)' },\n        { line: '#FF9800', area: 'rgba(255, 152, 0, 0.2)' },\n    ],\n    lineWidth: 2,\n});\n\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    { time: '2024-04-23', values: [14, 7, 6] },\n    { time: '2024-04-24', values: [11, 9, 4] },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-stacked-area-series\": \"https://unpkg.com/@tradingview/lwc-plugin-stacked-area-series/dist/stacked-area-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createStackedAreaSeries } from '@tradingview/lwc-plugin-stacked-area-series';\n\nconst chart = createChart(document.getElementById('container'), {\n    rightPriceScale: { scaleMargins: { top: 0.05, bottom: 0.05 } },\n});\nconst series = createStackedAreaSeries(chart, {\n    colors: [\n        { line: '#2962FF', area: 'rgba(41, 98, 255, 0.2)' },\n        { line: '#F23645', area: 'rgba(242, 54, 69, 0.2)' },\n        { line: '#FF9800', area: 'rgba(255, 152, 0, 0.2)' },\n    ],\n    lineWidth: 2,\n});\n\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    { time: '2024-04-23', values: [14, 7, 6] },\n    { time: '2024-04-24', values: [11, 9, 4] },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `createStackedAreaSeries`, then set data with a `values` array per\npoint. The array order is the stacking order: `values[0]` is the bottom band.\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createStackedAreaSeries } from '@tradingview/lwc-plugin-stacked-area-series';\n\nconst chart = createChart(document.getElementById('container'), {\n    rightPriceScale: { scaleMargins: { top: 0.05, bottom: 0.05 } },\n});\nconst series = createStackedAreaSeries(chart, {\n    colors: [\n        { line: '#2962FF', area: 'rgba(41, 98, 255, 0.2)' },\n        { line: '#F23645', area: 'rgba(242, 54, 69, 0.2)' },\n        { line: '#FF9800', area: 'rgba(255, 152, 0, 0.2)' },\n    ],\n    lineWidth: 2,\n});\n\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    { time: '2024-04-23', values: [14, 7, 6] },\n    { time: '2024-04-24', values: [11, 9, 4] },\n]);\n```\n\nEach data point is `{ time, values: number[] }`. Points do not have to carry\nthe same number of values: a point with fewer values is padded with zeroes, so\nits missing bands collapse onto the one below them. Points with an empty or\nmissing `values` array are treated as whitespace. The series' price line and\nlast-value label follow the stack total.\n\nValues are stacked from `base` (`0` by default): a positive value continues\naway from the base, a negative one comes back towards it and past it, so each\nband is a single ribbon between two lines and never folds over itself.\n\nA point may override the colors of its own bands:\n\n```js\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    {\n        time: '2024-04-23',\n        values: [14, 7, 6],\n        colors: [{ line: '#000000', area: 'rgba(0, 0, 0, 0.2)' }],\n    },\n]);\n```\n\nAn override applies to the piece of the band which starts at that point.\n\nOptions can be changed at runtime with `series.applyOptions({ ... })`.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `colors` | `StackedAreaColor[]` | five preset pairs (blue, red, orange, purple, teal); in each pair the area is the line color at 20% opacity | Appearance of each band, in stacking order. If there are more values than entries, the entries repeat. An empty array falls back to this default. |\n| `lineWidth` | `LineWidth` | `2` | Width of the band lines, in CSS pixels (`1`–`4`). |\n| `lineStyle` | `LineStyle` | `LineStyle.Solid` | Style of the band lines. |\n| `lineVisible` | `boolean` | `true` | Whether the band lines are drawn. |\n| `areaVisible` | `boolean` | `true` | Whether the bands are filled. |\n| `base` | `number` | `0` | Price the bands are stacked from. |\n| `lineType` | `'simple' \\| 'step' \\| 'curved'` | `'simple'` | How the points of a band are joined: straight lines, a value held until the next point, or a smooth curve. |\n| `gapHandling` | `'break' \\| 'bridge'` | `'break'` | Whether the bands stop at a whitespace gap and start again after it, or are drawn straight across it. |\n| `percent` | `boolean` | `false` | Scale every point so that its bands total 100 in absolute terms, giving a 100% stacked chart. |\n\nEach entry of `colors` is a `StackedAreaColor`, which may also override the\nseries-wide line options for that band:\n\n| Field | Type | Description |\n| --- | --- | --- |\n| `line` | `string` | Color of the line along the top of the band. |\n| `area` | `string` | Fill color of the band, or the top of its gradient when `areaBottom` is set. |\n| `areaBottom` | `string` (optional) | Bottom color of the band's gradient. |\n| `lineWidth` | `LineWidth` (optional) | Width of this band's line. |\n| `lineStyle` | `LineStyle` (optional) | Style of this band's line. |\n| `lineVisible` | `boolean` (optional) | Whether this band's line is drawn. |\n| `areaVisible` | `boolean` (optional) | Whether this band is filled. |\n\nPer-point overrides, on the data item:\n\n| Field | Type | Description |\n| --- | --- | --- |\n| `colors` | `StackedAreaPointColor[]` | `line`, `area` and `areaBottom` for each band at this point. Anything missing falls back to the series color. |\n\n## Notes\n\n- The price scale autoscales over the whole run of the stack, not just its\n  total, so a point containing negative values stays fully in view. The\n  outermost line sits exactly on the edge of the range; add a small\n  `scaleMargins` on the price scale (as in the example above) if you want\n  breathing room around it.\n- Autoscaling follows `percent` and `base`, so a 100% stack scales to\n  `base`…`base + 100` and not to the raw totals, and changing either option\n  rescales the series. This needs the current options at the moment the library\n  asks for the plot values, which only `createStackedAreaSeries` can provide: a\n  bare `new StackedAreaSeries()` added with `chart.addCustomSeries` autoscales\n  from the raw `values` measured from zero, and needs an\n  `autoscaleInfoProvider` of its own for `percent` or a non-zero `base`.\n- The factory retains explicit whitespace, and `gapHandling` decides whether\n  to break or bridge it. Timestamps from other series do not create gaps.\n- On `lightweight-charts` 5.2 and later the series reports the hovered band\n  through `hitTest` (the `objectId` is the index of the band) and dims the\n  other bands while one is hovered, and from 5.1 conflated points are merged\n  by summing each band. Older versions simply never call those hooks.\n\n### Explicit whitespace\n\nUse `createStackedAreaSeries` to retain whitespace passed through `setData` and\n`update`, including historical corrections. Other series' timestamps do not\nbreak the area. The low-level `StackedAreaSeries` view remains available, but\nwithout the factory's gap predicate it draws continuously: the host does not\nprovide whitespace to custom renderers.\n\nUnder time-scale conflation the area is drawn from buckets of several bars, and\na whitespace run narrower than one bucket cannot be resolved at that bar\nspacing: it is absorbed into the bucket rather than breaking the area at every\nbar. Zooming in past the conflation threshold shows the gap again.\n","packages/lwc-plugin-stacked-bars-series/README.md":"# Stacked bars series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series) that stacks several values per\ntime point into one column.\nEach value is a segment drawn on top of the previous one. The column height\nshows the total, and the segments show its composition.\n\nUse it to show composition over time in discrete periods, when a bar reads\nbetter than an area. Typical examples: volume by venue, revenue by product\nline, or trades by side.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-stacked-bars-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createStackedBarsSeries } from '@tradingview/lwc-plugin-stacked-bars-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createStackedBarsSeries(chart, {\n    colors: ['#2962FF', '#F23645', '#FF9800'],\n});\n\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    { time: '2024-04-23', values: [14, 7, 6] },\n    { time: '2024-04-24', values: [11, 9, 4] },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-stacked-bars-series\": \"https://unpkg.com/@tradingview/lwc-plugin-stacked-bars-series/dist/stacked-bars-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createStackedBarsSeries } from '@tradingview/lwc-plugin-stacked-bars-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createStackedBarsSeries(chart, {\n    colors: ['#2962FF', '#F23645', '#FF9800'],\n});\n\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    { time: '2024-04-23', values: [14, 7, 6] },\n    { time: '2024-04-24', values: [11, 9, 4] },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `addCustomSeries`, then set data with a `values` array per\npoint. The array order is the stacking order: `values[0]` is the bottom\nsegment.\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createStackedBarsSeries } from '@tradingview/lwc-plugin-stacked-bars-series';\n\nconst chart = createChart(document.getElementById('container'), {\n    timeScale: { minBarSpacing: 3 },\n});\nconst series = createStackedBarsSeries(chart, {\n    colors: ['#2962FF', '#F23645', '#FF9800'],\n});\n\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    { time: '2024-04-23', values: [14, 7, 6] },\n    { time: '2024-04-24', values: [11, 9, 4] },\n]);\n```\n\nEach data point is `{ time, values: number[] }`. Points with an empty or\nmissing `values` array are treated as whitespace. The series' price line and\nlast-value label follow the column total.\n\nValues are stacked from `base` (`0` by default): a positive value continues\naway from the base, a negative one comes back towards it and past it, so a\nmixed point stays contiguous and never overlaps. Values which are not finite\nare skipped without shifting the segments above them.\n\nA point may override the series colors for its own segments:\n\n```js\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    { time: '2024-04-23', values: [14, 7, 6], colors: ['#000000', undefined, '#BBBBBB'] },\n]);\n```\n\nOptions can be changed at runtime with `series.applyOptions({ ... })`.\n\n## Creating a series\n\nUse `createStackedBarsSeries(chart, options?, paneIndex?)`. It returns the\nnormal series API, with the plugin's data and options types preserved. The helper\nmakes scaling options available before the first `setData` and rebuilds plot\nvalues automatically when those options change through `series.applyOptions`.\nThis keeps autoscaling, last-value labels and crosshair values consistent. The\nhelper retains a shallow copy of the input data, including whitespace, and\nre-ingests it only when a scaling option changes. Streaming updates remain\nincremental.\n\nThe low-level `StackedBarsSeries` pane view remains available for integrations\nthat supply their own options getter to its constructor. Passing scaling options\nonly to `chart.addCustomSeries(new StackedBarsSeries(), options)` cannot make\nthem available before data ingestion on LWC 5.0; use the creation helper instead.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `colors` | `string[]` | `['#2962FF', '#E1575A', '#F28E2C', 'rgb(164, 89, 209)', 'rgb(27, 156, 133)']` | Fill color of each segment, in stacking order. If there are more values than colors, the colors repeat. An empty array falls back to this default. |\n| `base` | `number` | `0` | Price the columns are stacked from. |\n| `columnWidthMode` | `'histogram' \\| 'percent'` | `'histogram'` | `histogram` uses the width the built-in histogram series uses (as wide as the bar spacing allows, with a one pixel gap); `percent` uses a share of the bar spacing, given by `widthPercent`. |\n| `widthPercent` | `number` | `80` | Column width as a percentage of the bar spacing, `0`–`100`. Only used when `columnWidthMode` is `percent`. |\n| `segmentBorderColor` | `string` | `'#FFFFFF'` | Color of the border drawn inside the edge of every segment. |\n| `segmentBorderWidth` | `number` | `0` | Width of the segment border in pixels. `0` draws no border. |\n| `radius` | `number` | `0` | Corner radius of the two ends of a column, in pixels. |\n| `stackOrder` | `'normal' \\| 'reverse'` | `'normal'` | `normal` puts `values[0]` closest to the base; `reverse` puts the last value there. Colors stay with their value. |\n| `percent` | `boolean` | `false` | Scale every point so that its segments total 100 in absolute terms, giving a 100% stacked chart. |\n\nPer-point overrides, on the data item:\n\n| Field | Type | Description |\n| --- | --- | --- |\n| `colors` | `(string \\| undefined)[]` | Fill color of each segment of this point. A missing or `undefined` entry falls back to the series color for that segment. |\n\nThe standard `color` option is not used for the segments; it colors the\nseries' price line.\n\n## Notes\n\n- Column width follows the bar spacing by default, with a small gap between\n  columns. Set `timeScale.minBarSpacing` (as in the example above) to keep\n  columns from collapsing when the user zooms out, or switch to\n  `columnWidthMode: 'percent'` for a fixed share of the slot.\n- The price scale autoscales over the whole run of the stack, not just its\n  total, so a column containing negative values stays fully in view.\n- `createStackedBarsSeries` measures the same ordered, normalized, and offset\n  bands that are drawn. `percent`, nonzero `base`, and `stackOrder: 'reverse'`\n  therefore autoscale without a custom range provider.\n\n- On `lightweight-charts` 5.2 and later the series reports the hovered segment\n  through `hitTest` (the `objectId` is the index of the value within the point)\n  and dims the other segments while one is hovered, and from 5.1 conflated\n  points are merged by summing each band. Older versions simply never call\n  those hooks.\n","packages/lwc-plugin-user-price-lines/README.md":"# User price lines\n\nA [series primitive](https://tradingview.github.io/lightweight-charts/docs/plugins/series-primitives)\nthat lets the user add price lines to a series. When the pointer comes near\nthe right edge of the pane, a small button with a plus follows it up and down;\nclicking the button adds a price line at that price.\n\nUse it for levels the user marks by hand: support and resistance, entry and\nexit prices, or the price an alert should fire at.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-user-price-lines\n```\n\nThen import the plugin and attach it to a series:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { UserPriceLines } from '@tradingview/lwc-plugin-user-price-lines';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData([\n    { time: '2024-04-22', value: 101.2 },\n    { time: '2024-04-23', value: 102.8 },\n    { time: '2024-04-24', value: 100.9 },\n]);\n\nseries.attachPrimitive(new UserPriceLines({ lineColor: '#F23645' }));\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-user-price-lines\": \"https://unpkg.com/@tradingview/lwc-plugin-user-price-lines/dist/user-price-lines.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { UserPriceLines } from '@tradingview/lwc-plugin-user-price-lines';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData([\n    { time: '2024-04-22', value: 101.2 },\n    { time: '2024-04-23', value: 102.8 },\n    { time: '2024-04-24', value: 100.9 },\n]);\n\nseries.attachPrimitive(new UserPriceLines({ lineColor: '#F23645' }));\n</script>\n```\n\n## Usage\n\nAttach the plugin to the series the lines belong to. The button shows near\nthe right edge of that series' pane, wherever the series has a price, and a\nclick on it adds a price line to the series at the price under the pointer:\n\n```js\nconst lines = new UserPriceLines({ maxLines: 3 });\nseries.attachPrimitive(lines);\n\n// Lines can be added and removed from code as well.\nconst line = lines.addLine(102.5);\nlines.lineAdded().subscribe(added => console.log('added', added.options().price));\nlines.lineRemoved().subscribe(removed => console.log('removed', removed.options().price));\nlines.removeLine(line);\nlines.removeAll();\n```\n\n- `addLine(price)` adds a line with the line options and returns its\n  `IPriceLine`. A click on the button does the same. At `maxLines`, the\n  oldest line is removed first. It throws unless the plugin is attached to a\n  series that is on a chart.\n- `removeLine(line)` removes a line the plugin added and returns `true`; a\n  line it did not add, or one already removed, is left alone and gives\n  `false`. `removeAll()` removes every line the plugin added.\n- `lines()` lists the lines the plugin added that are still on the series,\n  oldest first. A line removed with `series.removePriceLine` is left out.\n- `lineAdded()` and `lineRemoved()` fire with each line the plugin adds and\n  removes. Lines are removed by `removeLine` and `removeAll`, to stay within\n  `maxLines`, and when the plugin is detached.\n\nDetaching the plugin, `series.detachPrimitive(lines)`, stops it listening to\nthe pointer, removes the lines it added and puts the crosshair mode back.\nAttaching it to another series while it is attached moves it there: it is\ndetached from the first series, which removes its lines there.\n`chart.removeSeries` takes the lines away with the series, and the plugin\nlets go of the chart on the next pointer event.\n\n### Crosshair mode\n\nThe button follows the pointer, so the plugin sets the chart's crosshair to\n`CrosshairMode.Normal` while it is attached: in the `Magnet` modes the\ncrosshair would jump between the series' values instead. The mode the chart\nhad is put back when the plugin is detached, unless something changed it\nfrom `Normal` in the meantime, in which case it is left as it is. Pass\n`setCrosshairMode: false` to leave the crosshair mode alone.\n\n### Several instances\n\nWithin a pane, only the instance attached last shows its button and adds\nlines, so a click never adds a line to two series at once. When it is\ndetached, the one attached before it takes over.\n\n## Options\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `lineColor` | `string` | `'#000000'` | Color of the price lines the plugin adds. |\n| `lineWidth` | `LineWidth` | `1` | Width of the price lines, in CSS pixels. |\n| `lineStyle` | `LineStyle` | `LineStyle.Dashed` | Style of the price lines. |\n| `axisLabelVisible` | `boolean` | `true` | Whether the price lines show their price on the price scale. |\n| `buttonColor` | `string` | `''` | Background of the add button. An empty string uses the background of the crosshair's horizontal line label. |\n| `hoverColor` | `string` | `'#777777'` | Background of the add button while the pointer is over it. |\n| `maxLines` | `number` | `Infinity` | The most lines the plugin keeps; adding one more removes the oldest. Rounded down and at least `1`; a value that is not a number means no limit. |\n| `setCrosshairMode` | `boolean` | `true` | Whether the plugin sets the crosshair to `Normal` mode while attached. |\n\nChange them with `lines.applyOptions({ ... })`; `lines.options()` returns\nthem all. The line options apply to the lines added afterwards. Lowering\n`maxLines` removes the oldest lines over the new limit.\n\n## Notes\n\n- The button is reported to the chart's hit test, so the cursor becomes a\n  pointer over it and pointer events report `ADD_BUTTON_ID` as the hovered\n  object (`param.hoveredObjectId`).\n- The button only comes up for the pointer. A crosshair placed with\n  `chart.setCrosshairPosition`, as charts kept in sync do, never shows it.\n- A tap on a touch screen moves no crosshair, so no button is shown and a tap\n  at the edge adds nothing; after a long press has brought the button up,\n  only a tap on the button adds a line. The chart reports no click after a\n  drag, so a drag that starts on the button adds nothing either.\n- The button always sits at the right edge of the pane, which is where the\n  pointer leaves the pane for the right price scale. Clicking a line to remove\n  it, placing the button by the left price scale and rounding prices to the\n  series' price step are not part of this release.\n\n## Migrating from `plugin-examples`\n\nIn the `plugin-examples` collection the plugin was created with\n`new UserPriceLines(chart, series, options)` and taken off with `remove()`.\nBoth still work and are deprecated: pass the options only and attach the\nplugin with `series.attachPrimitive`, and detach it with\n`series.detachPrimitive`. `remove()` now removes the lines the plugin added,\nas detaching does, and does not throw once the chart or the series is gone.\n\nThe options are renamed: `color`, the color of the lines, is `lineColor`, and\n`limitToOne`, which was never read, is `maxLines` (`maxLines: 1` keeps one\nline). The lines can now be removed, and the plugin no longer adds lines for\nclicks in other panes or for two instances at once.\n","packages/lwc-plugin-vertical-line/README.md":"# Vertical line\n\nA [series primitive](https://tradingview.github.io/lightweight-charts/docs/plugins/series-primitives)\nthat draws a full-height vertical line at a given time, with an optional label\non the time axis. You attach the line to a series. The line then follows that\nseries' time scale as the user scrolls and zooms.\n\nUse it to mark a moment in time that matters on your chart:\n\n- an event, such as earnings, a news release, or a dividend date;\n- a trade, such as entry and exit points, with a label like `Buy` or `Sell`;\n- a boundary, such as a session open or close, the start of a backtest, or\n  the current bar.\n\nBecause each line is a separate primitive, you can place as many as you need\non the same series, each with its own color, width, and label.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-vertical-line\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { VerticalLine } from '@tradingview/lwc-plugin-vertical-line';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(data);\n\nseries.attachPrimitive(new VerticalLine('2024-04-25'));\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-vertical-line\": \"https://unpkg.com/@tradingview/lwc-plugin-vertical-line/dist/vertical-line.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { VerticalLine } from '@tradingview/lwc-plugin-vertical-line';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(data);\n\nseries.attachPrimitive(new VerticalLine('2024-04-25'));\n</script>\n```\n\n## Usage\n\nCreate a line for a time that exists in your series data, then attach it to that series:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { VerticalLine } from '@tradingview/lwc-plugin-vertical-line';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(data);\n\nconst earningsLine = new VerticalLine('2024-04-25', {\n    color: '#2962FF',\n    width: 2,\n    showLabel: true,\n    labelText: 'Earnings',\n    labelBackgroundColor: '#2962FF',\n    labelTextColor: '#FFFFFF',\n});\nseries.attachPrimitive(earningsLine);\n```\n\nTo remove a line, detach it from the series:\n\n```js\nseries.detachPrimitive(earningsLine);\n```\n\nThe `time` argument accepts any [`Time`](https://tradingview.github.io/lightweight-charts/docs/api/type-aliases/Time)\nvalue supported by the chart (a business day string, a `BusinessDay` object,\nor a UTC timestamp) — use the same format as your series data.\n\nChange a line after it has been created with `applyOptions` and `setTime`:\n\n```js\nearningsLine.applyOptions({ color: '#F23645', labelText: 'Moved' });\nearningsLine.setTime('2024-05-02');\n```\n\n## Options\n\nAll options are optional. Pass them as the second constructor argument.\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `color` | `string` | `'green'` | Color of the line. |\n| `width` | `number` | `3` | Width of the line, in CSS pixels. |\n| `lineStyle` | `LineStyle` | `LineStyle.Solid` | Dash pattern of the line. |\n| `lineVisible` | `boolean` | `true` | Draw the line itself. Set it to `false` for a time-axis label with no line. |\n| `showLabel` | `boolean` | `false` | Show a label at the line's position on the time axis. |\n| `tickVisible` | `boolean` | `true` | Draw the tick mark of the time-axis label. |\n| `labelText` | `string` | `''` | Text of the time-axis label. Overrides `labelFormatter` when set. |\n| `labelFormatter` | `(time) => string` | — | Builds the label text from the line's time. Used only while `labelText` is empty; the default formats the time the way the chart's own time axis does. |\n| `labelBackgroundColor` | `string` | `'green'` | Background color of the label. |\n| `labelTextColor` | `string` | `'white'` | Text color of the label. |\n| `zOrder` | `'bottom' \\| 'normal' \\| 'top'` | `'normal'` | Layer the line is drawn in. |\n| `snap` | `'exact' \\| 'nearest'` | `'exact'` | `'exact'` draws the line only at a time which is a bar of the chart; `'nearest'` places it on the closest bar instead. |\n| `draggable` | `boolean` | `false` | Lets the user drag the line along the time scale. |\n| `hitTestTolerance` | `number` | `4` | Distance from the line, in CSS pixels, still counted as a hit. |\n| `id` | `string` | `'vertical-line'` | Reported as `externalId` for a hit on this line. |\n| `badge` | `Partial<VerticalLineBadgeOptions> & { text }` | — | Text badge drawn on the line. Omit it for no badge. |\n\nThe defaults are exported as `defaultOptions`.\n\n### Badge\n\nA badge is a short caption drawn on the line itself, for text that should stay\nnext to the line rather than sit on the time axis:\n\n```js\nseries.attachPrimitive(new VerticalLine('2024-04-25', {\n    badge: { text: 'Earnings', backgroundColor: '#2962FF' },\n}));\n```\n\n| Badge option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `text` | `string` | `''` | Text of the badge. An empty string hides it. |\n| `color` | `string` | `'white'` | Text color. |\n| `backgroundColor` | `string` | `'green'` | Background color. |\n| `borderColor` | `string` | — | Border color. Leave it out for no border. |\n| `borderWidth` | `number` | `0` | Border width, in CSS pixels. |\n| `borderRadius` | `number` | `4` | Corner radius of the background, in CSS pixels. |\n| `font` | `string` | system sans-serif, 12px | Font, as a CSS `font` shorthand. |\n| `padding` | `number` | `4` | Space between the text and the edge of the background. |\n| `margin` | `number` | `4` | Distance from the line and from the pane edge. |\n| `verticalAlign` | `'top' \\| 'middle' \\| 'bottom'` | `'top'` | Where along the line the badge sits. |\n| `horizontalAlign` | `'left' \\| 'right'` | `'right'` | Which side of the line the badge sits on. |\n\nThe badge defaults are exported as `defaultBadgeOptions`.\n\n### Dragging\n\nWith `draggable: true` the line can be moved along the time scale with the\npointer, and `timeChanged()` reports every new time:\n\n```js\nconst line = new VerticalLine('2024-04-25', { draggable: true });\nseries.attachPrimitive(line);\nline.timeChanged().subscribe(time => console.log(time));\n```\n\nDragging suspends the chart's own scroll and scale handling for the duration of\nthe gesture, so the chart does not pan under the pointer. Only one line per\nchart holds that suspension at a time: where two draggable lines overlap, the\none attached first takes the gesture and the other ignores it, so the chart's\noptions are restored exactly once. Ownership is tracked per loaded copy of this\nmodule, so two bundles of the plugin on the same page each track their own\nowner; load it once per page if you attach overlapping draggable lines.\n\n## Notes\n\n- With the default `snap: 'exact'` the line is drawn only when its time is a\n  bar of the chart's time scale; a time between bars or outside the data draws\n  nothing, and its time-axis label is hidden with it. Use `snap: 'nearest'` to\n  place the line on the closest bar instead.\n- The line spans the full height of the pane the series belongs to. To mark a\n  time across several panes, attach a line to a series in each pane.\n- The label is rendered by the chart's time axis, so it inherits the axis font\n  and is hidden together with the axis if `timeScale.visible` is `false`.\n- `VertLine` and `VertLineOptions` are still exported, as deprecated aliases of\n  `VerticalLine` and `VerticalLineOptions`, and the old\n  `new VertLine(chart, series, time, options)` form of the constructor still\n  works: the chart and the series arguments are ignored. Both are kept for\n  compatibility and will be removed in a future major version.\n","packages/lwc-toolkit/README.md":"# @tradingview/lwc-toolkit\n\nHelpers for authoring [Lightweight Charts™](https://www.tradingview.com/lightweight-charts/)\nplugins — the pixel-arithmetic, subscription and base-class pieces that every\nplugin ends up needing, so they do not have to be copied into each project.\n\nRequires `lightweight-charts` 5.0 or later as a peer dependency.\n\n```shell\nnpm install --save-dev @tradingview/lwc-toolkit\n```\n\nA dev dependency is usually the right choice: a plugin bundles the handful of\nhelpers it uses into its own output, so the people installing that plugin never\nneed this package themselves. See [Bundling](#bundling) below.\n\n## Usage\n\nEvery helper is imported from its own sub-path. There is no barrel entry point,\nso `@tradingview/lwc-toolkit` on its own does not resolve — import the module\nyou want:\n\n```js\nimport { PluginBase } from '@tradingview/lwc-toolkit/plugin-base';\nimport { positionsBox, positionsLine } from '@tradingview/lwc-toolkit/dimensions/positions';\n```\n\nSub-path exports need a modern module resolver. Set `moduleResolution` to\n`\"bundler\"`, `\"node16\"` or `\"nodenext\"` in `tsconfig.json`; the legacy `\"node\"`\nsetting ignores the `exports` field and will report the imports as unresolved.\n\n## Modules\n\n| Sub-path | Provides |\n| --- | --- |\n| `assertions` | `ensureDefined`, `ensureNotNull` — narrow a value or throw |\n| `axis-label-view` | `AxisLabelView`, `AxisLabelSource` — a price- or time-axis label over a source that may have no coordinate yet |\n| `canvas/markers` | `beginMarker`, `beginMarkerOffset`, `traceMarker`, `traceMarkerOffset`, `markerDistance`, `markerVertices`, `segmentDistance`, `MarkerShape` — circle, square, diamond and triangle markers, one per path (`begin*`, which start the path) or many to a path (`trace*`), the ring around them, and the distance to them as drawn, for hit testing, all from the same vertices |\n| `canvas/round-rect` | `drawRoundRect`, `drawRoundRectWithBorder`, `clampCornerRadius`, `CornerRadii` — rounded rectangles with an inset border |\n| `chart/compat` | `supportsSeriesOrder` — runtime checks for series methods newer than 5.0 (`setSeriesOrder`, 5.0.6) that narrow the series, so that a plugin calls them where the host has them and still supports 5.0 |\n| `chart/interaction-flags` | `canUserMoveTimeScale`, `TIME_SCALE_MOVE_FLAGS` — whether `handleScroll` / `handleScale` let the user scroll or zoom the time scale, by the library's own rule |\n| `chart/lifecycle` | `isChartRemoved`, `isSeriesAttached` — side-effect-free checks for a removed chart and a series taken off the chart |\n| `chart/time-axis-labels` | `timeAxisLabelFont`, `tickMarkPixelsPerCharacter`, `tickMarkMaxLabelWidth`, `tickMarkCharactersForWidth` — the time axis' label font, and `tickMarkMaxCharacterLength` to pixels and back |\n| `closest-index` | `ClosestTimeIndexFinder` — cached binary search for the first index at or after (or last at or before) a time |\n| `custom-series/compat` | `CustomSeriesHitTestResult`, `ConflationContext` — types only: the library's hit test result (5.2) and conflation context (5.1), so a plugin can implement `hitTest` and `conflationReducer` and still support 5.0 |\n| `custom-series/hit-test` | `distanceToRange`, `seriesHitTestTolerance`, `nearestBar`, `nearestVerticalRange`, `createHitTestDataCache` — a renderer's `hitTest`: the series' tolerance, the visible bar nearest the pointer within it by any distance or, for bars that span a vertical range, by the distance to their box, and one `hitTestData` object per hovered item |\n| `custom-series/line-paths` | `buildLinePath`, `buildStepLinePath`, `areaBetween`, `strokeStyledPolyline` — polylines (straight or stepped), the band between two lines, and a line whose style, dash pattern included, changes along its length |\n| `custom-series/options-aware-series` | `createOptionsAwareSeries`, `createWhitespaceSeries`, `OptionsAwareSeries` — retain accepted input, bind price-value builders to current options and refresh stored values when scaling options change |\n| `custom-series/renderer-base` | `CustomSeriesRendererBase`, `CustomSeriesDrawArgs` — a custom series renderer with the data and visible-range guards done, leaving `drawImpl`. A renderer's `hitTest` must return the same `hitTestData` object while the same item stays hovered |\n| `custom-series/stacking` | `cumulativeSum`, `stackLevels`, `stackedPlotValues` — running totals, the band boundaries of a stack drawn from a base, and the autoscale values of a stack that may contain negatives |\n| `custom-series/visible-bars` | `forEachVisibleBar`, `mapVisibleBars`, `extendRange`, `visibleSegments`, `whitespaceGapCheck`, `AcceptedInput`, `barCoordinate`, `getConflationFactor`, `effectiveBarSpacing` — iterate the visible bars only, reach the pane edge, split at whitespace gaps wide enough to see at the current bar spacing, size a conflated bar to the slots it covers |\n| `delegate` | `Delegate`, `ISubscription` — a small subscribe/fire event primitive |\n| `dimensions/candles` | `candlestickWidth` — the body width the chart itself would use at a given bar spacing |\n| `dimensions/columns` | `calculateColumnPositions`, `calculateColumnPositionsInPlace` — evenly spaced column bars with consistent gaps |\n| `dimensions/common` | `BitmapPositionLength` — the `{ position, length }` pair the other dimension helpers return |\n| `dimensions/crosshair-width` | `gridAndCrosshairMediaWidth`, `gridAndCrosshairBitmapWidth` — line widths matching the grid and crosshair |\n| `dimensions/full-width` | `fullBarWidth`, `fullBarWidthAfter` — a bar spanning the whole slot, and one starting where its neighbor ended, so neighbors share an edge |\n| `dimensions/positions` | `positionsBox`, `positionsLine` — pixel-perfect boxes and lines from two coordinates |\n| `dom/media-query` | `subscribeMediaQuery`, `mediaQueryMatches`, `HIGH_CONTRAST_QUERIES`, `REDUCED_MOTION_QUERY` — shared, SSR-safe media query subscriptions |\n| `dom/pane-element` | `paneContentElement`, `chartTableElement` — the pane's canvas wrapper to append DOM overlays to, and the chart table |\n| `line-style` | `setLineStyle`, `getDashPattern`, `LineStyle` — the chart's dash patterns for renderers that receive no drawing utils; takes the library's `LineStyle` too |\n| `min-max-in-range` | `UpperLowerInRange` — cached upper/lower bounds over a range, for autoscaling |\n| `numbers` | `isFiniteNumber`, `finiteOr`, `nonNegativeOr`, `clampOpacity` — checks for numeric options, which the canvas otherwise ignores silently when they are `NaN` |\n| `options/merge` | `mergeOptions`, `cloneOptions`, `freezeOptions`, `isPlainObject`, `isUnsafeKey` — deep merge of partial options (a `null` reset to the default is opt-in), a copy that keeps functions, and frozen defaults |\n| `pane-plugin-base` | `PanePluginBase` — the pane-primitive counterpart of `PluginBase`: chart reference and `requestUpdate` hook |\n| `plugin-base` | `PluginBase` — a series-primitive base class holding the chart and series references and a `requestUpdate` hook |\n| `scheduling/coalesced-task` | `createCoalescedTask`, `CoalescedTask` — work run at most once per microtask (or frame), with `cancel()` for disposal |\n| `simple-clone` | `cloneReadonly` — deep clone that drops readonly-ness, through JSON: functions and `undefined` are dropped (`cloneOptions` in `options/merge` keeps them) |\n| `text/measure` | `textMeasureContext`, `createTextWidthCache` — a shared offscreen context to measure text with, and a bounded cache of widths |\n| `time` | `convertTime`, `convertTimeUTC`, `displayTime`, `formattedDateAndTime` — `Time` to local or UTC timestamps and display strings |\n\nThe dimension helpers exist because canvas drawing has to land on whole device\npixels to look sharp at every device pixel ratio. See\n[Pixel Perfect Rendering](https://tradingview.github.io/lightweight-charts/docs/plugins/pixel-perfect-rendering)\nfor the reasoning.\n\n## Bundling\n\nThe package is ESM only, ships no side effects (`\"sideEffects\": false`) and\nkeeps one module per file, so a bundler drops whatever a plugin does not\nreference. Since each plugin inlines only the helpers it actually uses — a few\nhundred bytes, typically — the usual arrangement is to keep this as a\n`devDependency` and let it disappear into the plugin's own bundle, rather than\nmaking every consumer of the plugin install it.\n\n`lightweight-charts` is a peer dependency and must stay external: the chart and\nseries objects are compared by identity, so a second copy of the library is a\nbug rather than an inefficiency.\n\n## Contributing\n\nThe sources live in the\n[Lightweight Charts™ repository](https://github.com/tradingview/lightweight-charts/tree/master/packages/lwc-toolkit).\n\n```shell\npnpm --filter @tradingview/lwc-toolkit build\n```\n\nOn a fresh checkout, build the library first (`pnpm build:prod` in the\nrepository root) — this package compiles against the `lightweight-charts`\ntypings from the root `dist/`.\n\nConsumers inside the repository use the compiled `dist/` output, so re-run the\nbuild after editing a helper. The `plugin-examples` scripts do this\nautomatically before building.\n\n## License\n\nApache-2.0. See [LICENSE](./LICENSE) and [NOTICE](./NOTICE).\n","plugin-examples/src/plugins/accessibility/README.md":"# Accessibility\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-accessibility`](https://www.npmjs.com/package/@tradingview/lwc-plugin-accessibility).\nIts source lives in [`packages/lwc-plugin-accessibility`](../../../../packages/lwc-plugin-accessibility),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/accessibility/` and `/plugin-previews/accessibility/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","plugin-examples/src/plugins/anchored-text/README.md":"# Anchored text\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-anchored-text`](https://www.npmjs.com/package/@tradingview/lwc-plugin-anchored-text).\nIts source lives in [`packages/lwc-plugin-anchored-text`](../../../../packages/lwc-plugin-anchored-text),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/anchored-text/` and `/plugin-previews/anchored-text/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","plugin-examples/src/plugins/background-shade-series/README.md":"# Background shade series\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-background-shade-series`](https://www.npmjs.com/package/@tradingview/lwc-plugin-background-shade-series).\nIts source lives in [`packages/lwc-plugin-background-shade-series`](../../../../packages/lwc-plugin-background-shade-series),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/background-shade-series/` and `/plugin-previews/background-shade-series/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","plugin-examples/src/plugins/box-whisker-series/README.md":"# Box and whisker series\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-box-whisker-series`](https://www.npmjs.com/package/@tradingview/lwc-plugin-box-whisker-series).\nIts source lives in [`packages/lwc-plugin-box-whisker-series`](../../../../packages/lwc-plugin-box-whisker-series),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/box-whisker-series/` and `/plugin-previews/box-whisker-series/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","plugin-examples/src/plugins/brushable-area-series/README.md":"# Brushable area series\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-brushable-area-series`](https://www.npmjs.com/package/@tradingview/lwc-plugin-brushable-area-series).\nIts source lives in [`packages/lwc-plugin-brushable-area-series`](../../../../packages/lwc-plugin-brushable-area-series),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/brushable-area-series/` and `/plugin-previews/brushable-area-series/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","plugin-examples/src/plugins/dual-range-histogram-series/README.md":"# Dual range histogram series\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-dual-range-histogram-series`](https://www.npmjs.com/package/@tradingview/lwc-plugin-dual-range-histogram-series).\nIts source lives in [`packages/lwc-plugin-dual-range-histogram-series`](../../../../packages/lwc-plugin-dual-range-histogram-series),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/dual-range-histogram-series/` and `/plugin-previews/dual-range-histogram-series/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","plugin-examples/src/plugins/grouped-bars-series/README.md":"# Grouped bars series\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-grouped-bars-series`](https://www.npmjs.com/package/@tradingview/lwc-plugin-grouped-bars-series).\nIts source lives in [`packages/lwc-plugin-grouped-bars-series`](../../../../packages/lwc-plugin-grouped-bars-series),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/grouped-bars-series/` and `/plugin-previews/grouped-bars-series/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","plugin-examples/src/plugins/heatmap-series/README.md":"# Heatmap series\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-heatmap-series`](https://www.npmjs.com/package/@tradingview/lwc-plugin-heatmap-series).\nIts source lives in [`packages/lwc-plugin-heatmap-series`](../../../../packages/lwc-plugin-heatmap-series),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/heatmap-series/` and `/plugin-previews/heatmap-series/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working. `example/example2.html`, the old\nsecond example, redirects to the same demo, which now holds both data sets.\n","plugin-examples/src/plugins/hlc-area-series/README.md":"# HLC area series\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-hlc-area-series`](https://www.npmjs.com/package/@tradingview/lwc-plugin-hlc-area-series).\nIts source lives in [`packages/lwc-plugin-hlc-area-series`](../../../../packages/lwc-plugin-hlc-area-series),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/hlc-area-series/` and `/plugin-previews/hlc-area-series/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","plugin-examples/src/plugins/image-watermark/README.md":"# Image watermark\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-image-watermark`](https://www.npmjs.com/package/@tradingview/lwc-plugin-image-watermark).\nIts source lives in [`packages/lwc-plugin-image-watermark`](../../../../packages/lwc-plugin-image-watermark),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/image-watermark/` and `/plugin-previews/image-watermark/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","plugin-examples/src/plugins/lollipop-series/README.md":"# Lollipop series\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-lollipop-series`](https://www.npmjs.com/package/@tradingview/lwc-plugin-lollipop-series).\nIts source lives in [`packages/lwc-plugin-lollipop-series`](../../../../packages/lwc-plugin-lollipop-series),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/lollipop-series/` and `/plugin-previews/lollipop-series/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","plugin-examples/src/plugins/pretty-histogram-series/README.md":"# Pretty histogram series\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-pretty-histogram-series`](https://www.npmjs.com/package/@tradingview/lwc-plugin-pretty-histogram-series).\nIts source lives in [`packages/lwc-plugin-pretty-histogram-series`](../../../../packages/lwc-plugin-pretty-histogram-series),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/pretty-histogram-series/` and `/plugin-previews/pretty-histogram-series/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","plugin-examples/src/plugins/rounded-candles-series/README.md":"# Rounded candles series\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-rounded-candles-series`](https://www.npmjs.com/package/@tradingview/lwc-plugin-rounded-candles-series).\nIts source lives in [`packages/lwc-plugin-rounded-candles-series`](../../../../packages/lwc-plugin-rounded-candles-series),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/rounded-candles-series/` and `/plugin-previews/rounded-candles-series/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","plugin-examples/src/plugins/session-highlighting/README.md":"<!-- Skill available on-demand via /api/skills/tradingview/lightweight-charts?path=plugin-examples%2Fsrc%2Fplugins%2Fsession-highlighting%2FREADME.md -->","plugin-examples/src/plugins/stacked-area-series/README.md":"<!-- Skill available on-demand via /api/skills/tradingview/lightweight-charts?path=plugin-examples%2Fsrc%2Fplugins%2Fstacked-area-series%2FREADME.md -->","plugin-examples/src/plugins/stacked-bars-series/README.md":"<!-- Skill available on-demand via /api/skills/tradingview/lightweight-charts?path=plugin-examples%2Fsrc%2Fplugins%2Fstacked-bars-series%2FREADME.md -->","plugin-examples/src/plugins/user-price-lines/README.md":"<!-- Skill available on-demand via /api/skills/tradingview/lightweight-charts?path=plugin-examples%2Fsrc%2Fplugins%2Fuser-price-lines%2FREADME.md -->","plugin-examples/src/plugins/vertical-line/README.md":"<!-- Skill available on-demand via /api/skills/tradingview/lightweight-charts?path=plugin-examples%2Fsrc%2Fplugins%2Fvertical-line%2FREADME.md -->","website/docs/plugins/canvas-rendering-target.md":"---\nsidebar_label: Canvas rendering target\ntitle: Canvas rendering target\nsidebar_position: 4\n---\n\nThe renderer functions of a plugin — whether it is a custom series or a\nprimitive — receive a `CanvasRenderingTarget2D` target to execute their\ndrawing logic on, using the browser's\n[2D Canvas API](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D).\n`CanvasRenderingTarget2D` comes from the\n[Fancy Canvas](https://github.com/tradingview/fancy-canvas) library; its\ndefinition can be viewed in\n[canvas-rendering-target.d.ts](https://unpkg.com/fancy-canvas/canvas-rendering-target.d.ts)\nwithin the published\n[TypeScript declarations](https://www.npmjs.com/package/fancy-canvas?activeTab=code).\n\n## Using CanvasRenderingTarget2D\n\n`CanvasRenderingTarget2D` provides two rendering scopes which you can use:\n\n- `useMediaCoordinateSpace`\n- `useBitmapCoordinateSpace`\n\n## Difference between bitmap and media\n\nBitmap sizing represents the actual physical pixels on the device's screen,\nwhile media sizing represents the size of a pixel as seen by the operating\nsystem and the browser. The number of physical pixels used to render one media\npixel is referred to as the device pixel ratio.\n\nBitmap sizing gives you more control over the drawn image and lets you keep\nthe graphics crisp and pixel perfect; the cost is that the code multiplies\ncoordinates by the pixel ratio throughout. When you don't need that precision,\nmedia sizing is easier: you don't have to think about the device pixel ratio\nat all.\n\n### Bitmap coordinate space\n\nUse `useBitmapCoordinateSpace` to draw with the actual device pixels as the\ncoordinate sizing. The provided scope (of type\n`BitmapCoordinatesRenderingScope`) contains readonly values for the following:\n\n- `context`\n  ([CanvasRenderingContext2D](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D)).\n  Context which can be used for rendering.\n- `horizontalPixelRatio` (number)\n- `verticalPixelRatio` (number)\n- `bitmapSize` (Size). Height and width of the canvas in bitmap dimensions.\n- `mediaSize` (Size). Height and width of the canvas in media dimensions.\n\n#### Bitmap coordinate space usage\n\n```js title='javascript'\n// target is an instance of CanvasRenderingTarget2D\ntarget.useBitmapCoordinateSpace(scope => {\n    // scope is an instance of BitmapCoordinatesRenderingScope\n\n    // example of drawing a filled rectangle which fills the canvas\n    scope.context.beginPath();\n    scope.context.rect(0, 0, scope.bitmapSize.width, scope.bitmapSize.height);\n    scope.context.fillStyle = 'rgba(100, 200, 50, 0.5)';\n    scope.context.fill();\n});\n```\n\n### Media coordinate space\n\nUse `useMediaCoordinateSpace` to draw with the media dimensions as the\ncoordinate sizing. The provided scope (of type\n`MediaCoordinatesRenderingScope`) contains readonly values for the following:\n\n- `context`\n  ([CanvasRenderingContext2D](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D)).\n  Context which can be used for rendering.\n- `mediaSize` (Size). Height and width of the canvas in media dimensions.\n\n#### Media coordinate space usage\n\n```js title='javascript'\n// target is an instance of CanvasRenderingTarget2D\ntarget.useMediaCoordinateSpace(scope => {\n    // scope is an instance of MediaCoordinatesRenderingScope\n\n    // example of drawing a filled rectangle which fills the canvas\n    scope.context.beginPath();\n    scope.context.rect(0, 0, scope.mediaSize.width, scope.mediaSize.height);\n    scope.context.fillStyle = 'rgba(100, 200, 50, 0.5)';\n    scope.context.fill();\n});\n```\n\n## General tips\n\nIt is recommended that rendering functions save and restore the canvas context\nbefore and after all their rendering logic, so the canvas state is the same as\nwhen the function was called. Wrap the logic in a `try…finally` block so the\ncontext is restored even when an error interrupts the drawing.\n\n**Note** that `useBitmapCoordinateSpace` and `useMediaCoordinateSpace`\nautomatically save and restore the canvas context for the logic defined within\nthem. This tip applies to your additional rendering functions called inside\n`use*CoordinateSpace`.\n\n```js title='javascript'\nfunction myRenderingFunction(scope) {\n    const ctx = scope.context;\n\n    // save the current state of the context to the stack\n    ctx.save();\n\n    try {\n        // example code\n        scope.context.beginPath();\n        scope.context.rect(0, 0, scope.mediaSize.width, scope.mediaSize.height);\n        scope.context.fillStyle = 'rgba(100, 200, 50, 0.5)';\n        scope.context.fill();\n    } finally {\n        // restore the saved context from the stack\n        ctx.restore();\n    }\n}\n\ntarget.useMediaCoordinateSpace(scope => {\n    myRenderingFunction(scope);\n    myOtherRenderingFunction(scope);\n    /* ... */\n});\n```\n","website/docs/plugins/custom_series.md":"---\nsidebar_label: Custom series\ntitle: Custom series\nsidebar_position: 3\n---\n\n**Custom series** let you define new types of series with your own data\nstructures and rendering logic. A custom series mirrors the API of the\nbuilt-in series: you add it to the chart once, then manage it with the same\nmethods you already use, such as\n[`setData`](../api/interfaces/ISeriesApi.md#setdata) and\n[`applyOptions`](../api/interfaces/ISeriesApi.md#applyoptions). For primitives\nthat decorate an existing series rather than define a new one, see\n[Series primitives](./series-primitives.mdx).\n\n## Adding a custom series\n\nA custom series is defined by a class implementing the\n[`ICustomSeriesPaneView`](../api/interfaces/ICustomSeriesPaneView.md)\ninterface. Pass an instance of it to the\n[`addCustomSeries`](../api/interfaces/IChartApi.md#addcustomseries) method,\nthen work with the returned series as with any other:\n\n```javascript title='javascript'\nclass MyCustomSeries {\n    /* Class implementing the ICustomSeriesPaneView interface */\n}\n\n// Create an instantiated custom series\nconst customSeriesInstance = new MyCustomSeries();\n\nconst chart = createChart(document.getElementById('container'));\nconst myCustomSeries = chart.addCustomSeries(customSeriesInstance, {\n    // Options for MyCustomSeries\n    customOption: 10,\n});\n\nconst data = [\n    { time: 1642425322, value: 123, customValue: 456 },\n    /* ... more data */\n];\n\nmyCustomSeries.setData(data);\n```\n\nTo remove a custom series, use the standard\n[`removeSeries`](../api/interfaces/IChartApi.md#removeseries) method:\n\n```javascript title='javascript'\nchart.removeSeries(myCustomSeries);\n```\n\nThese series are expected to have a uniform width for each data point, which\nensures that the chart maintains a consistent look and feel across all series\ntypes. The only restriction on the data structure is that it should extend the\n[`CustomData`](../api/interfaces/CustomData.md) interface (have a valid time\nproperty for each data point).\n\n## Defining a custom series\n\nThe [`ICustomSeriesPaneView`](../api/interfaces/ICustomSeriesPaneView.md)\ninterface defines the functionality and structure required of a custom series.\nIt includes the following methods and properties:\n\n### Renderer\n\nThe [`renderer`](../api/interfaces/ICustomSeriesPaneView.md#renderer) method\nreturns the renderer that draws the series data on the main chart pane. The\nrenderer must implement the\n[`ICustomSeriesPaneRenderer`](../api/interfaces/ICustomSeriesPaneRenderer.md)\ninterface.\n\nThe library calls the renderer's\n[`draw`](../api/interfaces/ICustomSeriesPaneRenderer.md#draw) method whenever\nthe chart needs to draw the series.\n\nThe [`PriceToCoordinateConverter`](../api/type-aliases/PriceToCoordinateConverter.md)\nprovided as the 2nd argument to the draw method is a convenience function for\nchanging prices into vertical coordinate values. It is provided since the\nseries' original data will most likely be defined in price values, and the\nrenderer needs to draw with coordinates. The values returned by the converter\nare in media coordinates (unscaled by `devicePixelRatio`).\nSee the [Canvas rendering target](./canvas-rendering-target.md) page for more\ndetails on the `CanvasRenderingTarget2D` provided to the `draw` method.\n\n### Update\n\nThe [`update`](../api/interfaces/ICustomSeriesPaneView.md#update) method is\ncalled with the latest data for the renderer to use during the next paint. It\nreceives two parameters: `data` (described below) and `seriesOptions`, a\nreference to the currently applied options for the series.\n\nThe [`PaneRendererCustomData`](../api/interfaces/PaneRendererCustomData.md)\ninterface provides the data that can be used within the renderer for drawing the\nseries data. It includes the following properties:\n\n- `bars`: list of all the series' items and their x coordinates. See\n  [`CustomBarItemData`](../api/interfaces/CustomBarItemData.md) for more details\n- `barSpacing`: spacing between consecutive bars.\n- `visibleRange`: the current visible range of items on the chart.\n\n### Hit testing\n\nThe renderer can implement the optional\n[`hitTest`](../api/interfaces/ICustomSeriesPaneRenderer.md#hittest) method to\nparticipate directly in hover and click resolution.\n\nReturn `null` when the cursor misses the custom geometry. Return a\n[`CustomSeriesHitTestResult`](../api/interfaces/CustomSeriesHitTestResult.md)\nwhen the cursor hits a custom object. The result can provide:\n\n- `distance`: geometric distance from the cursor to the hit\n- `type`: optional geometric classification such as `point`, `line`, `range`, or `custom`\n- `objectId`: optional object identifier that becomes `hoveredObjectId`\n- `cursorStyle`: optional cursor override\n- `hitTestData`: optional renderer-defined hover data passed back into `draw`\n\nThis hook lets the custom series participate in the same geometry-first\narbitration model as built-in series.\n\nThe `type` field is used for hover arbitration only. Public mouse events still\nreport `hoveredInfo.type` as `custom` for custom-series hits. Use `objectId`\nand `hoveredInfo.objectKind` to distinguish custom sub-objects.\n\n### Price value builder\n\nThe\n[`priceValueBuilder`](../api/interfaces/ICustomSeriesPaneView.md#pricevaluebuilder)\nmethod interprets a data item and returns an array of numbers: the equivalent\nhighest, lowest, and current price values for that item.\n\nThese price values are used by the chart to determine the auto-scaling (to\nensure the items are in view) and the crosshair and price line positions. The\nlargest and smallest values in the array will be used to specify the visible\nrange of the painted item, and the last value will be used for the crosshair and\nprice line position.\n\n### Whitespace\n\nThe\n[`isWhitespace`](../api/interfaces/ICustomSeriesPaneView.md#iswhitespace)\nmethod tells the library which data points should be treated as whitespace:\nreturn `true` for a whitespace item. Whitespace data points are not passed to\nthe renderer or to the `priceValueBuilder`.\n\n### Default options\n\nThe\n[`defaultOptions`](../api/interfaces/ICustomSeriesPaneView.md#defaultoptions)\nproperty provides the default options for the series. The user can override\nthem with the options argument of\n[`addCustomSeries`](../api/interfaces/IChartApi.md#addcustomseries), or later\nvia the [`applyOptions`](../api/interfaces/ISeriesApi.md#applyoptions) method\non the series.\n\n### Destroy\n\nThe [`destroy`](../api/interfaces/ICustomSeriesPaneView.md#destroy) method is\ncalled when the series is removed from the chart. Use it to clean up\neverything that could outlive the series and cause memory leaks: event\nlisteners, timers, and references to other objects.\n","website/docs/plugins/intro.md":"---\nsidebar_label: Overview\nsidebar_position: 0\n---\n\n# Plugin development\n\n**Plugins** let you extend Lightweight Charts™ with your own functionality: new\nseries types, drawing tools, indicators, watermarks, and other custom elements\nrendered as part of the chart. This section explains how plugins work and how\nto build your own.\n\n:::tip\n\nLooking for a ready-made plugin instead of building one? Browse the\n[plugin catalog](/plugins).\n\n:::\n\n## Choosing a plugin type\n\n| You want to build | Plugin type | Attach with |\n| --- | --- | --- |\n| A drawing tool, annotation, or overlay tied to a series and its scales | [Series primitive](./series-primitives.mdx) | [`ISeriesApi.attachPrimitive`](../api/interfaces/ISeriesApi.md#attachprimitive) |\n| A pane-wide element independent of any series, such as a watermark | [Pane primitive](./pane-primitives.md) | [`IPaneApi.attachPrimitive`](../api/interfaces/IPaneApi.md#attachprimitive) |\n| A new way to draw data: a series with its own data structure and rendering | [Custom series](./custom_series.md) | [`addCustomSeries`](../api/interfaces/IChartApi.md#addcustomseries) |\n\n:::tip\n\nIf your element visualizes its own data, build a custom series;\nif it decorates a series or reacts to its scales, build a series primitive;\nif it belongs to the pane as a whole, build a pane primitive.\nSeries primitives can also render on the price and time scales; pane primitives cannot.\n\n:::\n\n## Development workflow\n\n1. **Scaffold a project.** Run `npm create lwc-plugin@latest` — the\n   [create-lwc-plugin](https://www.npmjs.com/package/create-lwc-plugin)\n   package generates a ready-to-run project for the plugin type you choose.\n   The wizard also offers to install the plugin-authoring\n   [Agent Skill](../ai.md#ai-coding-assistants), which teaches AI coding\n   assistants how to write Lightweight Charts™ plugins.\n2. **Implement the plugin interface.** Follow the article for your plugin type\n   from the table above.\n3. **Render on the canvas.** Draw in the right coordinate space with\n   [Canvas rendering target](./canvas-rendering-target.md), and keep lines\n   crisp with the [Pixel perfect rendering](./pixel-perfect-rendering/index.md)\n   techniques.\n4. **Learn from working code.** The\n   [Plugin examples demo](https://tradingview.github.io/lightweight-charts/plugin-examples)\n   hosts interactive examples of heatmaps, alerts, watermarks, and tooltips;\n   their sources live in the\n   [`plugin-examples`](https://github.com/tradingview/lightweight-charts/tree/master/plugin-examples)\n   folder of the repository.\n","website/docs/plugins/pane-primitives.md":"---\nsidebar_label: Pane primitives\ntitle: Pane primitives\nsidebar_position: 2\n---\n\n**Pane primitives** are primitives attached to a chart pane rather than to a specific series.\nUse pane primitives for chart-wide elements that are not tied to any series' data, such as watermarks.\nThe library's built-in text and image watermarks are implemented this way.\nFor series-bound primitives, see [Series primitives](./series-primitives.mdx).\n\n## Attaching a primitive\n\nA pane primitive is a class implementing the\n[`IPanePrimitive`](../api/type-aliases/IPanePrimitive.md) interface.\nCreate an instance of your primitive and attach it to a pane with the\n[`attachPrimitive`](../api/interfaces/IPaneApi.md#attachprimitive) method:\n\n```javascript\nclass MyCustomPanePrimitive {\n    /* Class implementing the IPanePrimitive interface */\n}\n\n// Create an instantiated pane primitive\nconst myCustomPanePrimitive = new MyCustomPanePrimitive();\n\nconst chart = createChart(document.getElementById('container'));\n// Get the main pane\nconst mainPane = chart.panes()[0];\n\n// Attach the primitive to the pane\nmainPane.attachPrimitive(myCustomPanePrimitive);\n```\n\nTo remove the primitive from the pane, use the\n[`detachPrimitive`](../api/interfaces/IPaneApi.md#detachprimitive) method:\n\n```javascript\nmainPane.detachPrimitive(myCustomPanePrimitive);\n```\n\n## Key differences from series primitives\n\nPane primitives follow the same model as\n[series primitives](./series-primitives.mdx) — views that return renderers,\nthe `attached` / `detached` lifecycle, `updateAllViews`, and hit testing —\nwith four differences:\n\n- A pane primitive is attached to a pane, so\n  [`paneViews`](../api/interfaces/IPanePrimitiveBase.md#paneviews) is its only\n  view getter: it cannot draw on the price or time scales, or define axis\n  labels.\n- The `attached` method receives\n  [`{ chart, requestUpdate }`](../api/interfaces/PaneAttachedParameter.md)\n  without a series reference.\n- There is no `autoscaleInfo`: a pane primitive is not tied to a price scale.\n- Within each `zOrder` layer, pane primitives are drawn before the series and their primitives, so a pane primitive on `'normal'` sits under the series. Use `'top'` to draw it above the series.\n\n## Implementing a pane primitive\n\nThe `paneViews` method returns the views that draw on the pane. Each view must\nprovide a `renderer()` method returning the renderer that draws on the canvas:\n\n```javascript\nclass MyCustomPanePrimitive {\n    paneViews() {\n        return [\n            {\n                renderer: () => ({\n                    draw: target => {\n                        // Custom drawing logic here\n                    },\n                }),\n            },\n        ];\n    }\n\n    // Other methods as needed...\n}\n```\n","website/docs/plugins/pixel-perfect-rendering/index.md":"---\nsidebar_position: 0\nsidebar_label: Pixel perfect rendering\npagination_title: Pixel perfect rendering\ntitle: Best practices for pixel perfect rendering in canvas drawings\ndescription: Best practices for pixel perfect rendering in canvas drawings when creating plugins for Lightweight Charts\nkeywords:\n  - plugins\n  - extensions\n  - rendering\n  - canvas\n  - bitmap\n  - media\n  - pixels\npagination_prev: null\n---\n\nTo achieve crisp pixel perfect rendering for your plugins, it is recommended that the canvas drawings are created using bitmap coordinates. The difference between media and bitmap coordinate spaces is discussed on the [Canvas rendering target](../canvas-rendering-target.md) page. **Essentially, all drawing actions should use integer positions and dimensions when on the bitmap coordinate space.**\n\nTo ensure consistency between your plugins and the library's built-in logic for rendering points on the chart, use the following calculation functions.\n\n:::info\n\nVariable names containing `media` refer to positions / dimensions specified using the media coordinate space (such as the x and y coordinates provided by the library to the renderers), and names containing `bitmap` refer to positions / dimensions on the bitmap coordinate space (actual device screen pixels).\n\n:::\n\n## Centered shapes\n\nIf you need to draw a shape which is centered on a position (for example a price or x coordinate) and has a desired width then you could use the `positionsLine` function presented below. This can be used for drawing a horizontal line at a specific price, or a vertical line aligned with the center of a series point.\n\n```typescript\ninterface BitmapPositionLength {\n    /** coordinate for use with a bitmap rendering scope */\n    position: number;\n    /** length for use with a bitmap rendering scope */\n    length: number;\n}\n\nfunction centreOffset(lineBitmapWidth: number): number {\n    return Math.floor(lineBitmapWidth * 0.5);\n}\n\n/**\n * Calculates the bitmap position for an item with a desired length (height or width), and centered according to\n * a position coordinate defined in media sizing.\n * @param positionMedia - position coordinate for the bar (in media coordinates)\n * @param pixelRatio - pixel ratio. Either horizontal for x positions, or vertical for y positions\n * @param desiredWidthMedia - desired width (in media coordinates)\n * @returns Position of the start point and length dimension.\n */\nexport function positionsLine(\n    positionMedia: number,\n    pixelRatio: number,\n    desiredWidthMedia: number = 1,\n    widthIsBitmap?: boolean\n): BitmapPositionLength {\n    const scaledPosition = Math.round(pixelRatio * positionMedia);\n    const lineBitmapWidth = widthIsBitmap\n        ? desiredWidthMedia\n        : Math.round(desiredWidthMedia * pixelRatio);\n    const offset = centreOffset(lineBitmapWidth);\n    const position = scaledPosition - offset;\n    return { position, length: lineBitmapWidth };\n}\n```\n\n## Dual point shapes\n\nIf you need to draw a shape between two coordinates (for example, y coordinates for a high and low price) then you can use the `positionsBox` function as presented below.\n\n```typescript\n/**\n * Determines the bitmap position and length for a dimension of a shape to be drawn.\n * @param position1Media - media coordinate for the first point\n * @param position2Media - media coordinate for the second point\n * @param pixelRatio - pixel ratio for the corresponding axis (vertical or horizontal)\n * @returns Position of the start point and length dimension.\n */\nexport function positionsBox(\n    position1Media: number,\n    position2Media: number,\n    pixelRatio: number\n): BitmapPositionLength {\n    const scaledPosition1 = Math.round(pixelRatio * position1Media);\n    const scaledPosition2 = Math.round(pixelRatio * position2Media);\n    return {\n        position: Math.min(scaledPosition1, scaledPosition2),\n        length: Math.abs(scaledPosition2 - scaledPosition1) + 1,\n    };\n}\n```\n\n## Default widths\n\nRefer to the following pages for functions defining the default widths of shapes drawn by the library:\n\n- [Crosshair and grid lines](./widths/crosshair.md)\n- [Candlesticks](./widths/candlestick.md)\n- [Columns (histogram)](./widths/columns.md)\n- [Full bar width](./widths/full-bar-width.md)\n","website/docs/plugins/pixel-perfect-rendering/widths/candlestick.md":"---\nsidebar_position: 0\nsidebar_label: Candlesticks\npagination_title: Candlestick Widths\ntitle: Candlestick width calculations\ndescription: Describes the calculation for candlestick body widths\nkeywords:\n  - plugins\n  - extensions\n  - rendering\n  - canvas\n  - bitmap\n  - media\n  - pixels\n  - candlestick\n  - width\n---\n\n:::tip\n\nIt is recommend that you first read the [Pixel Perfect Rendering](../index.md) page.\n\n:::\n\nThe following functions can be used to get the calculated width that the library would use for a candlestick at a specific bar spacing and device pixel ratio.\n\nBelow a bar spacing of 4, the library will attempt to use as large a width as possible without the possibility of overlapping, while above 4 then the width will start to trend towards an 80% width of the available space.\n\n:::warning\n\nIt is expected that candles can overlap slightly at smaller bar spacings (more pronounced on lower resolution devices). This produces a more readable chart. If you need to ensure that bars can never overlap then rather use the widths for [Columns](./columns.md) or the [full bar width](./full-bar-width.md) calculation.\n\n:::\n\n```typescript\nfunction optimalCandlestickWidth(\n    barSpacing: number,\n    pixelRatio: number\n): number {\n    const barSpacingSpecialCaseFrom = 2.5;\n    const barSpacingSpecialCaseTo = 4;\n    const barSpacingSpecialCaseCoeff = 3;\n    if (barSpacing >= barSpacingSpecialCaseFrom && barSpacing <= barSpacingSpecialCaseTo) {\n        return Math.floor(barSpacingSpecialCaseCoeff * pixelRatio);\n    }\n    // coeff should be 1 on small barspacing and go to 0.8 while bar spacing grows\n    const barSpacingReducingCoeff = 0.2;\n    const coeff =\n        1 -\n        (barSpacingReducingCoeff *\n            Math.atan(\n                Math.max(barSpacingSpecialCaseTo, barSpacing) - barSpacingSpecialCaseTo\n            )) /\n            (Math.PI * 0.5);\n    const res = Math.floor(barSpacing * coeff * pixelRatio);\n    const scaledBarSpacing = Math.floor(barSpacing * pixelRatio);\n    const optimal = Math.min(res, scaledBarSpacing);\n    return Math.max(Math.floor(pixelRatio), optimal);\n}\n\n/**\n * Calculates the candlestick width that the library would use for the current\n * bar spacing.\n * @param barSpacing - bar spacing in media coordinates\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @returns The width (in bitmap coordinates) that the chart would use to draw a candle body\n */\nexport function candlestickWidth(\n    barSpacing: number,\n    horizontalPixelRatio: number\n): number {\n    let width = optimalCandlestickWidth(barSpacing, horizontalPixelRatio);\n    if (width >= 2) {\n        const wickWidth = Math.floor(horizontalPixelRatio);\n        if (wickWidth % 2 !== width % 2) {\n            width--;\n        }\n    }\n    return width;\n}\n```\n","website/docs/plugins/pixel-perfect-rendering/widths/columns.md":"---\nsidebar_position: 0\nsidebar_label: Columns\npagination_title: Histogram Column Widths\ntitle: Histogram column width calculations\ndescription: Describes the calculation for histogram column widths\nkeywords:\n  - plugins\n  - extensions\n  - rendering\n  - canvas\n  - bitmap\n  - media\n  - pixels\n  - histogram\n  - column\n  - width\n---\n\n:::tip\n\nIt is recommend that you first read the [Pixel Perfect Rendering](../index.md) page.\n\n:::\n\nThe following functions can be used to get the calculated width that the library would use for a histogram column at a specific bar spacing and device pixel ratio.\n\nYou can use the `calculateColumnPositionsInPlace` function instead of the `calculateColumnPositions` function to perform the calculation on an existing array of items without needing to create additional arrays (which is more efficient). It is recommended that you memoize the majority of the calculations below to improve the rendering performance.\n\n```typescript\nconst alignToMinimalWidthLimit = 4;\nconst showSpacingMinimalBarWidth = 1;\n\n/**\n * Spacing gap between columns.\n * @param barSpacingMedia - spacing between bars (media coordinate)\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @returns Spacing gap between columns (in Bitmap coordinates)\n */\nfunction columnSpacing(barSpacingMedia: number, horizontalPixelRatio: number) {\n    return Math.ceil(barSpacingMedia * horizontalPixelRatio) <=\n        showSpacingMinimalBarWidth\n        ? 0\n        : Math.max(1, Math.floor(horizontalPixelRatio));\n}\n\n/**\n * Desired width for columns. This may not be the final width because\n * it may be adjusted later to ensure all columns on screen have a\n * consistent width and gap.\n * @param barSpacingMedia - spacing between bars (media coordinate)\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @param spacing - Spacing gap between columns (in Bitmap coordinates). (optional, provide if you have already calculated it)\n * @returns Desired width for column bars (in Bitmap coordinates)\n */\nfunction desiredColumnWidth(\n    barSpacingMedia: number,\n    horizontalPixelRatio: number,\n    spacing?: number\n) {\n    return (\n        Math.round(barSpacingMedia * horizontalPixelRatio) -\n        (spacing ?? columnSpacing(barSpacingMedia, horizontalPixelRatio))\n    );\n}\n\ninterface ColumnCommon {\n    /** Spacing gap between columns */\n    spacing: number;\n    /** Shift columns left by one pixel */\n    shiftLeft: boolean;\n    /** Half width of a column */\n    columnHalfWidthBitmap: number;\n    /** horizontal pixel ratio */\n    horizontalPixelRatio: number;\n}\n\n/**\n * Calculated values which are common to all the columns on the screen, and\n * are required to calculate the individual positions.\n * @param barSpacingMedia - spacing between bars (media coordinate)\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @returns calculated values for subsequent column calculations\n */\nfunction columnCommon(\n    barSpacingMedia: number,\n    horizontalPixelRatio: number\n): ColumnCommon {\n    const spacing = columnSpacing(barSpacingMedia, horizontalPixelRatio);\n    const columnWidthBitmap = desiredColumnWidth(\n        barSpacingMedia,\n        horizontalPixelRatio,\n        spacing\n    );\n    const shiftLeft = columnWidthBitmap % 2 === 0;\n    const columnHalfWidthBitmap = (columnWidthBitmap - (shiftLeft ? 0 : 1)) / 2;\n    return {\n        spacing,\n        shiftLeft,\n        columnHalfWidthBitmap,\n        horizontalPixelRatio,\n    };\n}\n\ninterface ColumnPosition {\n    left: number;\n    right: number;\n    shiftLeft: boolean;\n}\n\n/**\n * Calculate the position for a column. These values can be later adjusted\n * by a second pass which corrects widths, and shifts columns.\n * @param xMedia - column x position (center) in media coordinates\n * @param columnData - precalculated common values (returned by `columnCommon`)\n * @param previousPosition - result from this function for the previous bar.\n * @returns initial column position\n */\nfunction calculateColumnPosition(\n    xMedia: number,\n    columnData: ColumnCommon,\n    previousPosition: ColumnPosition | undefined\n): ColumnPosition {\n    const xBitmapUnRounded = xMedia * columnData.horizontalPixelRatio;\n    const xBitmap = Math.round(xBitmapUnRounded);\n    const xPositions: ColumnPosition = {\n        left: xBitmap - columnData.columnHalfWidthBitmap,\n        right:\n            xBitmap +\n            columnData.columnHalfWidthBitmap -\n            (columnData.shiftLeft ? 1 : 0),\n        shiftLeft: xBitmap > xBitmapUnRounded,\n    };\n    const expectedAlignmentShift = columnData.spacing + 1;\n    if (previousPosition) {\n        if (xPositions.left - previousPosition.right !== expectedAlignmentShift) {\n            // need to adjust alignment\n            if (previousPosition.shiftLeft) {\n                previousPosition.right = xPositions.left - expectedAlignmentShift;\n            } else {\n                xPositions.left = previousPosition.right + expectedAlignmentShift;\n            }\n        }\n    }\n    return xPositions;\n}\n\nfunction fixPositionsAndReturnSmallestWidth(\n    positions: ColumnPosition[],\n    initialMinWidth: number\n): number {\n    return positions.reduce((smallest: number, position: ColumnPosition) => {\n        if (position.right < position.left) {\n            position.right = position.left;\n        }\n        const width = position.right - position.left + 1;\n        return Math.min(smallest, width);\n    }, initialMinWidth);\n}\n\nfunction fixAlignmentForNarrowColumns(\n    positions: ColumnPosition[],\n    minColumnWidth: number\n) {\n    return positions.map((position: ColumnPosition) => {\n        const width = position.right - position.left + 1;\n        if (width <= minColumnWidth) return position;\n        if (position.shiftLeft) {\n            position.right -= 1;\n        } else {\n            position.left += 1;\n        }\n        return position;\n    });\n}\n\n/**\n * Calculates the column positions and widths for the x positions.\n * This function creates a new array. You may get faster performance using the\n * `calculateColumnPositionsInPlace` function instead\n * @param xMediaPositions - x positions for the bars in media coordinates\n * @param barSpacingMedia - spacing between bars in media coordinates\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @returns Positions for the columns\n */\nexport function calculateColumnPositions(\n    xMediaPositions: number[],\n    barSpacingMedia: number,\n    horizontalPixelRatio: number\n): ColumnPosition[] {\n    const common = columnCommon(barSpacingMedia, horizontalPixelRatio);\n    const positions = new Array<ColumnPosition>(xMediaPositions.length);\n    let previous: ColumnPosition | undefined = undefined;\n    for (let i = 0; i < xMediaPositions.length; i++) {\n        positions[i] = calculateColumnPosition(\n            xMediaPositions[i],\n            common,\n            previous\n        );\n        previous = positions[i];\n    }\n    const initialMinWidth = Math.ceil(barSpacingMedia * horizontalPixelRatio);\n    const minColumnWidth = fixPositionsAndReturnSmallestWidth(\n        positions,\n        initialMinWidth\n    );\n    if (common.spacing > 0 && minColumnWidth < alignToMinimalWidthLimit) {\n        return fixAlignmentForNarrowColumns(positions, minColumnWidth);\n    }\n    return positions;\n}\n\nexport interface ColumnPositionItem {\n    x: number;\n    column?: ColumnPosition;\n}\n\n/**\n * Calculates the column positions and widths for bars using the existing\n * array of items.\n * @param items - bar items which include an `x` property, and will be mutated to contain a column property\n * @param barSpacingMedia - bar spacing in media coordinates\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @param startIndex - start index for visible bars within the items array\n * @param endIndex - end index for visible bars within the items array\n */\nexport function calculateColumnPositionsInPlace(\n    items: ColumnPositionItem[],\n    barSpacingMedia: number,\n    horizontalPixelRatio: number,\n    startIndex: number,\n    endIndex: number\n): void {\n    const common = columnCommon(barSpacingMedia, horizontalPixelRatio);\n    let previous: ColumnPosition | undefined = undefined;\n    for (let i = startIndex; i < Math.min(endIndex, items.length); i++) {\n        items[i].column = calculateColumnPosition(items[i].x, common, previous);\n        previous = items[i].column;\n    }\n    const minColumnWidth = (items as ColumnPositionItem[]).reduce(\n        (smallest: number, item: ColumnPositionItem, index: number) => {\n            if (!item.column || index < startIndex || index > endIndex)\n                return smallest;\n            if (item.column.right < item.column.left) {\n                item.column.right = item.column.left;\n            }\n            const width = item.column.right - item.column.left + 1;\n            return Math.min(smallest, width);\n        },\n        Math.ceil(barSpacingMedia * horizontalPixelRatio)\n    );\n    if (common.spacing > 0 && minColumnWidth < alignToMinimalWidthLimit) {\n        (items as ColumnPositionItem[]).forEach(\n            (item: ColumnPositionItem, index: number) => {\n                if (!item.column || index < startIndex || index > endIndex) return;\n                const width = item.column.right - item.column.left + 1;\n                if (width <= minColumnWidth) return item;\n                if (item.column.shiftLeft) {\n                    item.column.right -= 1;\n                } else {\n                    item.column.left += 1;\n                }\n                return item.column;\n            }\n        );\n    }\n}\n\n```\n","website/docs/plugins/pixel-perfect-rendering/widths/crosshair.md":"---\nsidebar_position: 0\nsidebar_label: Crosshair\npagination_title: Crosshair Widths\ntitle: Crosshair and grid line width calculations\ndescription: Describes the calculation for the crosshair line and grid line widths\nkeywords:\n  - plugins\n  - extensions\n  - rendering\n  - canvas\n  - bitmap\n  - media\n  - pixels\n  - crosshair\n  - grid\n  - line\n  - width\n---\n\n:::tip\n\nIt is recommend that you first read the [Pixel Perfect Rendering](../index.md) page.\n\n:::\n\nThe following functions can be used to get the calculated width that the library would use for a crosshair or grid line at a specific device pixel ratio.\n\n```typescript\n/**\n * Default grid / crosshair line width in Bitmap sizing\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @returns default grid / crosshair line width in Bitmap sizing\n */\nexport function gridAndCrosshairBitmapWidth(\n    horizontalPixelRatio: number\n): number {\n    return Math.max(1, Math.floor(horizontalPixelRatio));\n}\n\n/**\n * Default grid / crosshair line width in Media sizing\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @returns default grid / crosshair line width in Media sizing\n */\nexport function gridAndCrosshairMediaWidth(\n    horizontalPixelRatio: number\n): number {\n    return (\n        gridAndCrosshairBitmapWidth(horizontalPixelRatio) / horizontalPixelRatio\n    );\n}\n\n```\n","website/docs/plugins/pixel-perfect-rendering/widths/full-bar-width.md":"---\nsidebar_position: 0\nsidebar_label: Full bar width\npagination_title: Full Bar Width\ntitle: Full bar width calculations\ndescription: Describes the calculation for full bar widths\nkeywords:\n  - plugins\n  - extensions\n  - rendering\n  - canvas\n  - bitmap\n  - media\n  - pixels\n  - histogram\n  - column\n  - width\n---\n\n:::tip\n\nIt is recommend that you first read the [Pixel Perfect Rendering](../index.md) page.\n\n:::\n\nThe following functions can be used to get the calculated width that the library would use for the full width of a bar (data point) at a specific bar spacing and device pixel ratio. This can be used when you would like to use the full width available for each data point on the x axis, and don't want any gaps to be visible.\n\n```typescript\ninterface BitmapPositionLength {\n    /** coordinate for use with a bitmap rendering scope */\n    position: number;\n    /** length for use with a bitmap rendering scope */\n    length: number;\n}\n\n/**\n * Calculates the position and width which will completely full the space for the bar.\n * Useful if you want to draw something that will not have any gaps between surrounding bars.\n * @param xMedia - x coordinate of the bar defined in media sizing\n * @param halfBarSpacingMedia - half the width of the current barSpacing (un-rounded)\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @returns position and width which will completely full the space for the bar\n */\nexport function fullBarWidth(\n    xMedia: number,\n    halfBarSpacingMedia: number,\n    horizontalPixelRatio: number\n): BitmapPositionLength {\n    const fullWidthLeftMedia = xMedia - halfBarSpacingMedia;\n    const fullWidthRightMedia = xMedia + halfBarSpacingMedia;\n    const fullWidthLeftBitmap = Math.round(\n        fullWidthLeftMedia * horizontalPixelRatio\n    );\n    const fullWidthRightBitmap = Math.round(\n        fullWidthRightMedia * horizontalPixelRatio\n    );\n    const fullWidthBitmap = fullWidthRightBitmap - fullWidthLeftBitmap;\n    return {\n        position: fullWidthLeftBitmap,\n        length: fullWidthBitmap,\n    };\n}\n```\n","website/plugins/plugin-catalogue/README.md":"<!-- Skill available on-demand via /api/skills/tradingview/lightweight-charts?path=website%2Fplugins%2Fplugin-catalogue%2FREADME.md -->"},"items":[{"name":"official-plugins.md","path":".github/skills/lightweight-charts-plugin-authoring/references/official-plugins.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/.github/skills/lightweight-charts-plugin-authoring/references/official-plugins.md","title":"References Skill","category":"anthropic-skill","format":"markdown","content":"# The official plugins, and what each one teaches\n\nUpstream: `packages/lwc-plugin-<name>/`. Published: `@tradingview/lwc-plugin-<name>`,\nwhich ships the README and `dist/` (`.js` + `.d.ts`) but not the source. From\na repository that is not the upstream checkout, read the source on GitHub —\n`https://github.com/tradingview/lightweight-charts/tree/master/packages/lwc-plugin-<name>/src`,\nor the raw file URL under `raw.githubusercontent.com/tradingview/lightweight-charts/master/…` —\nor clone once: `git clone --depth 1 https://github.com/tradingview/lightweight-charts /tmp/lightweight-charts`.\n\nEach package has `src/`, a dev demo (`src/example/index.html`), a catalog\npreview (`src/example/preview.html`), `tests/{unit,graphics,interactions}`, a\nREADME in the catalog's shape and a CHANGELOG. Read the whole `src/` of the\nnearest one before designing; they are small.\n\nEvery preview calls `themeChart` from\n`@tradingview/lwc-plugin-preview-kit/preview-theme` and has been checked in\nboth the light and the dark theme. A new package needs the same: open the\nbuilt preview with `?theme=dark` and make sure nothing is left white or\nunreadable on black. For colors that have to change with the theme, see the\npreviews of `session-highlighting`, `image-watermark`,\n`rounded-candles-series` and `box-whisker-series`.\n\nEvery custom series below ships a `create<Name>Series(chart, options?,\npaneIndex?)` factory as the supported entry point and keeps the\n`<Name>Series` class exported for `chart.addCustomSeries` and composition.\nThe factory is where options-aware autoscale and whitespace detection live.\n\n## Custom series\n\n### `stacked-bars-series` — start here for any custom series\n\nStacked columns from a `values: number[]` per point. The shortest complete\ncustom series: `data.ts`, `options.ts`, `stack.ts` (pure maths, unit-tested),\n`renderer.ts` (extends `CustomSeriesRendererBase`), the view, the factory.\nShows `createOptionsAwareSeries` with `['base', 'percent', 'stackOrder']` as\nthe price options; `stackedPlotValues` for autoscale over negatives;\n`calculateColumnPositions` with `time` so columns either side of a gap are\nnot aligned to each other; `hitTest` returning the hovered segment index;\n`conflationReducer` summing bands.\n\n### `pretty-histogram-series` — one value per point, rounded, pixel-aligned\n\nRounded columns with `widthPercent`/`widthMode`, inner corners, a border and\na gradient. Shows `canvas/round-rect` with clamped radii, `base` reported in\n`priceValueBuilder` so bars never clip at the pane edge, `highlightHovered`\ndimming, a `conflationReducer` that keeps the later value, and the guard for\nan empty visible range.\n\n### `lollipop-series` — markers on stems, sized by the bar spacing\n\nA dot at each value on a stem from `base`, drawn with `beginMarker` from\n`canvas/markers`. Read for: sizes that are options but capped by the bar\nspacing, and the dot also by a fixed maximum that keeps it within the price\nscale's margins in a pane at least 100 px tall, since autoscale only knows the\nvalues (`geometry.ts`, unit-tested); a stem kept at least one device pixel\nwide; centering the dot on the stem as it was snapped to the pixel grid; and a\n`hitTest` built on `custom-series/hit-test`: `nearestVerticalRange` for the\nstems and `nearestBar` with `markerDistance` for the dots, so that each dot is\nmeasured as drawn, reporting the dot as a `'point'` and the stem as a\n`'range'`, since the chart prefers any point hit to a range hit whatever the\ndistance. It has no `conflationReducer`, so it sizes against `barSpacing`, not\n`effectiveBarSpacing`. Its `hover-empty-space` interaction test shows the\nlibrary's own fallback: where the renderer's `hitTest` returns `null`, a\npointer inside a bar's slot between its plot values still reports the series\nas hovered, without an `objectId`.\n\n### `grouped-bars-series` — several values per point, side by side\n\nA group of columns per point from `values[]`, with series and per-point\n`colors`, a `base`, and `columnWidthMode`/`widthPercent` named as in\n`stacked-bars-series`. Read for: one column count for the whole series, the\nmost values any point that draws a column has, so a column is as wide in\nevery group, counted once per data change by keying it on the\n`AcceptedInput` revision that `createOptionsAwareSeries` hands the view, and\nread when the renderer draws or hit tests rather than in the view's `update`,\nwhich the chart calls while `setData` is still running, before the revision\nmoves; groups placed with `calculateColumnPositionsInPlace` in `histogram`\nmode and `positionsLine` in `percent` mode, where they are all the same width\nand never wider than the bar spacing covers; splitting each group into\nwhole-pixel columns that tile it exactly (`splitGroup` in `layout.ts`,\nunit-tested), every column keeping at least a pixel and the tallest drawn\nfirst once they share pixels; values equal to `base`, `null` and non-finite\nvalues skipped like whitespace; and a `hitTest` that measures every column\nwithin reach with `nearestBar`, naming the point and the column in\n`objectId`.\n\n### `stacked-area-series` — bands, gaps and conflation together\n\nCumulative bands from `values[]`, negatives folding back to the base,\n`gapHandling: 'break' | 'bridge'`, `percent` mode, per-band and per-point\ncolors, `lineType` simple/step/curved. Shows `createWhitespaceSeries` with\n`['base', 'percent']`; `visibleSegments` with the `GapCheck` and\n`getConflationFactor(data)` as `minGap`; `extendRange` + `barCoordinate` so\nlines reach the pane edge with correct offscreen coordinates; `stackLevels`;\na `hitTest` that ignores whitespace gaps and unpainted extents. Its\ninteraction tests (`shared-timeline`, `whitespace-hit-test`,\n`conflation-holidays`) are the model for testing gap behavior.\n\n### `hlc-area-series` — two lines with a band between\n\nHigh, low and close lines, two-tone fill, gradients, step mode, hover\nmarkers on the bar under the cursor. Shows `line-paths` (`buildLinePath`,\n`buildStepLinePath`, `areaBetween`), skipping points whose prices fall off\nthe scale rather than drawing to `NaN`, `hitTest` by nearest bar, and a\n`conflationReducer` taking highest high / lowest low / last close.\n\n### `brushable-area-series` — a series plus its own interaction primitive\n\nAn area whose `brushRanges` (logical-index ranges) carry their own styles,\nwith `outsideStyle`, `basePrice` and gradient options; and\n`BrushableAreaInteraction`, a series primitive that turns mouse drag,\none-finger drag and two-finger gestures into a range and reports it through\n`activeRange()` as a `Delegate`. Read this for: matching ranges by *logical\nindex* rather than array index (they differ when another series starts\nearlier), `strokeStyledPolyline` for a line whose style changes mid-way, and\nhow a series and a primitive cooperate without the series knowing about\npointers.\n\n### `dual-range-histogram-series` — fixed pixel height, price-scale coexistence\n\nNested up/down columns of fixed pixel height on the zero line, or `scaleMode:\n'price'` to autoscale like a normal series. Shows the problem of a series that\nis *not* part of the autoscale: `keepPixelSeriesInView(chart, series)` reserves\nroom on the price scale and keeps doing so on resize. Also generic horizontal\nscale support, role-keyed `colors`/`borderRadius`, and `normalize`.\n\n### `background-shade-series` — a series that is only a background\n\nFull-height columns behind each bar, colored by where the bar's value sits\nbetween two colors. Read for: a custom series that stays out of the price\nscale (`priceValueBuilder` returns `[NaN]`, so it never changes the autoscale\nrange, has no last value and is never hovered) and sits on an overlay price\nscale of its own, set in `defaultOptions`, since a series at the bottom of the\norder would otherwise set the number format of a shared axis; columns from\n`fullBarWidthAfter`, each starting where the previous one ends, since two\nedges rounded on their own can leave a seam; shades looked up in a table built when the\ncolors change, so no color string is made while drawing; a per-point `color`\nread from `bar.barColor`, since the chart keeps `color` out of\n`originalData` and merges it with the series `color`, which the package\ntherefore leaves empty; parsing a CSS color\nthrough a scratch canvas of its own (never the chart's context, whose\n`fillStyle` a check would change), and spotting an invalid one; mixing colors\nwith premultiplied alpha; a factory that moves the series behind the others\nwith `setSeriesOrder(0)` where the host has it; and `globalAlpha` set inside\n`save`/`restore`. Its `price-format-kept` interaction test compares two\ncharts, since a price axis never narrows once it has grown.\n\n### `box-whisker-series` — a statistical shape on the candle grid\n\nA box plot per point from named fields (`min`, `q1`, `median`, `q3`, `max`)\nand `outliers`, with the five colors overridable on each point. Read for:\nsizing every part from `candlestickWidth` and the grid line width in bitmap\npixels, with the same parity as the whisker so each part is centered on it;\nthe outliers in the autoscale values, so every dot stays in view; malformed\npoints (a non-finite or `null` number) read as whitespace in `isWhitespace`,\nso they never reach the price scale; a factory that is a typed\n`chart.addCustomSeries`, since no option changes the plot values; and a\n`hitTest` on `nearestBar` that names the part and the point under the pointer\n(`'box-<point>'`, `'outlier-<point>-<index>'`, …) in `objectId`, an outlier\nreported as a `'point'` and the rest as `'range'`. It has no\n`conflationReducer`: merging two box plots has no clear meaning.\n\n### `heatmap-series` — many cells per point, filled by color\n\nA column of `{ low, high, amount }` cells per point, colored by a\n`cellShader(amount, range)` option. Read for: drawing many small shapes per\nframe by collecting them per color and filling one path per color, which a\nshader with few colors (`createColorScale` and its `steps`) makes pay off;\nhanding a function option the range of the values in view, worked out over\nthe visible bars, so colors need no maximum fixed in advance; checking a\ncolor a user function returns on a scratch canvas before drawing with it,\nsince the canvas ignores an invalid fill and would reuse the last one;\ncells rounded to pixels edge by edge, so neighbors share an edge, columns\nfrom `fullBarWidthAfter`, and a gap and a border rounded per axis and left out\nof a cell too small for them; rows off the pane skipped; a function-valued\noption, and a factory options type that keeps it a function where the\nlibrary's `DeepPartial` would not; a cell-level `hitTest` limited to the\ncolumn whose slot holds the pointer, so its `objectId` indexes the point\n`param.seriesData` reports, with no `hitTestData` so a pointer moving within a\ncell repaints nothing (its `hover-stable` interaction test counts fills); and\nseeded sample data shared by the demo, the preview and the unit tests.\n\n### `rounded-candles-series` — a drop-in replacement for a built-in\n\nCandlesticks with rounded bodies. Read for how to *match* the built-in:\nthe same color option set and shorthand semantics, `candlestickWidth` for\nthe body, body and wick aligned on one pixel grid at every DPR,\n`upDownMode`, per-point overrides, `conflationFactor` widening candles under\nconflation, and a `radius` that may be a number or a function of bar spacing.\n\n### `scatter-series` — a numeric X axis instead of time\n\nScatter and bubble charts. `createScatterChart` builds the chart on a custom\nhorizontal scale behavior (`ScatterHorzScaleBehavior`) so that the X axis is a\nplain number, and `createScatterSeries` draws the whole data set as one custom\nseries, in named groups with their own colors, marker shapes and connecting\nlines, with bubble sizes driven by a data value. Read for a custom horizontal\nscale, markers drawn and hit tested through `canvas/markers`, and a host API\nfor the tooltip and legend the plugin leaves to the page: `hoveredInfo.objectId`,\n`pointById`, `subscribeHoveredPointChange`. The one official plugin that needs\n`lightweight-charts` 5.2 (`^5.2.0`).\n\n## Series primitives\n\n### `vertical-line` — the model series primitive\n\nA full-height line at a time, with a time-axis label, a badge on the line,\n`snap: 'exact' | 'nearest'`, dragging with an `ew-resize` cursor. Shows\n`PluginBase`, `AxisLabelView` (and the off-screen coordinate when the time is\nnot on the scale), `positionsLine` for a crisp line, `setLineStyle` for dash\npatterns, `Delegate` for `timeChanged()`, hit-testing with a tolerance, and\ndrag ownership — only one line per chart suspends the chart's own scroll and\nscale handling, and restores it exactly once. Its interaction tests cover\ndrag cancel, disabling during a drag, overlapping lines and pointer scope.\n\n### `user-price-lines` — pointer-driven creation on a series\n\nA button at the right edge of the pane that follows the pointer and adds a\nprice line where it is clicked. Read for: driving a tool from\n`subscribeCrosshairMove` and `subscribeClick`, ignoring events from other\npanes with `param.paneIndex` and asking for a repaint only when the button\nchanges; moves with no `sourceEvent` (the chart's own, after\n`setCrosshairPosition`, on data and time scale changes) never bringing the\nbutton up; a click that only counts on the button where it is shown, so a\ntouch tap away from it adds nothing (the chart reports no click after a\ndrag); the pane's width from `chart.paneSize`, since\n`timeScale().width()` is 0 while the time axis is hidden; a geometric\n`hitTest` for the cursor and `hoveredObjectId` (the chart hit tests before it\nreports the move); setting a chart option (`CrosshairMode.Normal`) while\nattached and putting the old value back on detach only if it is still the one\nset, handed over between instances; one active instance per pane, kept in a\nmodule-level `WeakMap` by chart; letting go of the chart once\n`chart.removeSeries` or `chart.remove` has taken its series away (neither\ncalls `detached`); tracking the lines it created by `id`, since\n`series.priceLines()` returns new objects on every call, and removing them on\ndetach; and a deprecated constructor overload kept from the example. Its\ninteraction tests wait out the chart's double-click window between clicks in\none pane: a second click within 500 ms is otherwise swallowed, and a test\nasserting that it added nothing passes for the wrong reason. Its `price-zero`\ntest builds a scale on which a whole pixel row is at exactly 0.\n\n### `image-watermark` — the same idea as both primitive types\n\n`ImageWatermark` (series primitive) and `ImageWatermarkPane` (pane primitive)\nsharing options and a renderer. Read for: drawing nothing until an image has\ndecoded (and reporting failures through `onError` instead of throwing every\nframe), positioning from the *pane's* size rather than the chart element,\n`objectFit`/`position`/`padding` layout, `zOrder`, a decoded-image cache by\nURL, and `detached()` canceling a pending load.\n\n### `anchored-text` — the smallest two-class primitive\n\n`AnchoredText` (series primitive) and `AnchoredTextPane` (pane primitive)\nsharing one core, with no image to load and no interaction: the shape of\n`image-watermark` reduced to its essentials. Read for: laying text out in the\nmedia coordinate space from `measureText` (`layout.ts` is a pure function the\nunit tests cover for all nine anchors), a renderer that returns `null` while\nthere is nothing to draw, `save`/`restore` around context changes, options\nthat accept a deprecated spelling (`'middle'`) on input and never return it,\nand `mergeOptions` where one option (`lineHeight`) treats an explicit\n`undefined` as a value.\n\n### `session-highlighting` — per-bar background from the series' own data\n\n`SessionHighlighting` shades a full-height column behind every bar with the\ncolor a user function returns for its time. Read for: deriving per-bar state\nfrom `series.data()` in `dataUpdated` and patching only the end of it on an\n`'update'` scope. The scope covers more than append and replace: `pop()` and\nan update that turns the last bar into whitespace shrink the data, and a\nhistorical update can remove a bar from the middle or insert one there, so\nthe bar count decides the case: a shrink is only cut back when the kept last\nentry still names the last bar, and a bar is only appended when it comes after\nthe last entry (both compared by the key `timestampOf` stores for each bar: numbers\npass through unchanged, as the time scale keys them, and business days and\ndate strings become the UTC timestamp of their day, so how the time is written\ndoes not matter); otherwise every bar is recolored. Also read for mapping the\nvisible logical range back to data indices by binary search over `timeToIndex`\n(so other series starting earlier do not shift the slice), `fullBarWidth` from\nthe time scale's `barSpacing` for columns as wide as the bar slots (each edge\nrounded on its own, so neighbors can leave a 1 px seam where an edge falls on\na half pixel; `fullBarWidthAfter` rounds a shared edge once), and\n`zOrder: 'bottom'` for a background.\n\n## Pane primitives\n\n### `accessibility` — DOM overlays and multi-pane lifecycle\n\nA pane primitive per pane plus a chart-level `addAccessibilityPlugin(chart,\noptions)` controller. The reference for anything DOM-based: appending a\nsemantic layer to `paneContentElement(pane)`, following the pane by identity\nthrough reordering (the constructor index is only a pre-build hint; the first\ndraw's canvas resolves the real pane), a single shared ARIA-live region,\n`subscribeMediaQuery` for high contrast, message bundles and localization,\nkeyboard handling on the overlay, and a controller that reconciles panes added\nor removed at runtime. Also the largest test suite of the official plugins; its\n`pane-reorder`, `mismatched-pane-index` and `announce-callback-throws`\ninteraction tests show how to assert on DOM state.\n\n## `plugin-examples/` — breadth, not the standard\n\nUpstream `plugin-examples/src/plugins/` holds unpublished proof-of-concept\nplugins: tooltips and delta tooltips, a rectangle drawing tool, trend lines,\nprice alerts, a volume profile, a partial price line,\nand crosshair highlighting. Good for seeing the shape of an\nidea; they predate the toolkit and skip the tests and README the packages\ncarry, so use the official plugins for *how* and these for *what*. The\ngraduated plugins' folders there are redirect stubs to the packages.\n","isInternal":false,"tokens":4431,"sizeBytes":18462},{"name":"package-contract.md","path":".github/skills/lightweight-charts-plugin-authoring/references/package-contract.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/.github/skills/lightweight-charts-plugin-authoring/references/package-contract.md","title":"References Skill","category":"anthropic-skill","format":"markdown","content":"# The plugin package contract\n\nWhat makes a plugin package publishable and catalog-ready. Upstream,\n`pnpm plugins:validate` (`scripts/plugins/validate-metadata.mjs`) enforces all\nof it and fails CI otherwise; a project scaffolded by `create-lwc-plugin`\nalready satisfies every item, so this is mostly a list of what not to break.\nThe catalog on the docs site lists the official packages today; the same\ncontract is what any plugin would need to be listed.\n\nUpstream only: a package under `packages/` also needs its catalog card\nillustration, `website/static/plugin-catalog/assets/previews/<slug>.svg`\n(320×180, TradingView palette colors only). The catalog data README,\n`website/plugins/plugin-catalogue/README.md`, says how to draw it and which\naccent color to pick.\n\n## `package.json`\n\n| Field | Rule | Why |\n| --- | --- | --- |\n| `name` | starts with `lwc-plugin-` (unscoped), or `@tradingview/lwc-plugin-` for an official package | the unscoped remainder is the catalog's URL segment and the entry file name |\n| `version` | valid semver | the release script compares it with npm |\n| `description` | non-empty | shown on the catalog card |\n| `license` | non-empty SPDX id | shown on the detail page |\n| `publishConfig.access` | `\"public\"` | scoped packages default to restricted |\n| `peerDependencies.lightweight-charts` | a valid range, `^5.0.0` unless a 5.1 hook is required | the catalog shows \"works with\"; consumers install the library themselves |\n| `keywords` | includes `lightweight-charts-plugin` | how npm search and the registry find plugins |\n| `files` | `dist` (+ `CHANGELOG.md`, `NOTICE` for official) | ship built output only |\n| `exports` | `.` and `./standalone`, each with `types` + `default` | the standalone build inlines everything but the library, for CDN import maps |\n| `lwcPlugin` | see below | the catalog's curated metadata |\n| `repository.directory` | must equal the package's real path in the repo | the \"source\" link and the catalog read it |\n\n## The `lwcPlugin` block\n\nValidated against `scripts/plugins/lwc-plugin-metadata.schema.json`;\nunknown keys are errors.\n\n| Key | Required | Values |\n| --- | --- | --- |\n| `title` | yes | display name |\n| `category` | yes | `custom-series` \\| `series-primitive` \\| `pane-primitive` |\n| `lifecycle` | yes | `current` \\| `legacy` \\| `deprecated` \\| `experimental` |\n| `origin` | yes | `official` \\| `community` (workspace packages must be `official`) |\n| `demo` | yes | package-relative path of the dev demo page; the file must exist |\n| `author` | no | display name |\n| `preview` | no | package-relative path of the catalog preview page; must exist if declared |\n| `previewHeight` | no | integer ≥ 200, CSS px for the preview frame (default 330); only with `preview` |\n| `tags` | no | search terms |\n\n## Two pages, not one\n\n- **Demo** (`src/example/index.html` + `example.ts`, `lwcPlugin.demo`): the\n  page a developer opens on its own. Put the edge cases here — whitespace\n  runs, negatives, every option as a control. `pnpm dev` serves it; upstream,\n  `pnpm plugins:build-demos` builds it to `/plugin-demos/<slug>/` on the site.\n- **Preview** (`src/example/preview.html` + `preview.ts`, `lwcPlugin.preview`):\n  what the catalog frames next to the README, in a frame ~330 px tall. Show\n  the plugin at its best: clean data, two or three controls, no explanatory\n  text. Official packages build it with the private\n  `@tradingview/lwc-plugin-preview-kit` (layout + `mountControls` /\n  `addRefreshButton`); a standalone project has no preview by default.\n\n  The preview follows the docs site's light or dark theme and switches live\n  when the site theme is toggled. Call `themeChart(chart, onTheme?)` from\n  `@tradingview/lwc-plugin-preview-kit/preview-theme` in the same script run\n  as `createChart`, before anything awaits; it themes the chart's\n  background, text, grid, scales and crosshair labels. Anything the preview\n  colors itself — series and plugin options, a price line color, an image —\n  is your job: recolor it in `onTheme`, which runs right away and again on\n  every switch. Keep a control's current choice in a variable so a theme\n  switch reapplies it, and read `previewTheme()` in the control's handler\n  (see `rounded-candles-series` or `box-whisker-series`). Before you\n  finish, check the built preview in both themes (`?theme=light` and\n  `?theme=dark` on its URL): nothing white or light-only left over, and\n  every line, dot and label readable on black.\n\nNeither page is the plugin's tests. Keep them free of assertions.\n\n## README shape\n\nThe catalog renders the README as the page body (its H1 dropped, since the\npage header shows the title), with the Installation subsections lifted into\nan npm/CDN tab switcher. So:\n\n1. `# <Title>` then a description paragraph.\n2. `## Installation` with `### npm` (install command + import example) and\n   `### CDN` (an import map pointing `lightweight-charts` and the package at\n   their standalone builds, then the same import by name).\n3. `## Usage` with at least one `js`/`ts` code block — the release smoke test\n   compiles the first snippet after `### npm`, so it must be complete and\n   correct.\n4. `## Options`, `## Notes` as needed. Headings become anchors and a table of\n   contents on the site, so keep them descriptive.\n\nIf the series ships a factory, the README's snippets use it, and a line says\nthe plain class draws continuously (no whitespace detection).\n\n## Tests\n\nOfficial packages carry `tests/unit/*.spec.ts` (run by the repo's `pnpm test`),\n`tests/graphics/*.js` (screenshot comparison against the previous build) and\n`tests/interactions/*.js` (async `beforeInteractions(container)` that throws on\na wrong outcome). The e2e runners discover them by folder; a package without\na `tests/<suite>` folder is skipped, never failed.\n\n## CHANGELOG\n\nKeep a Changelog format, one `## <version>` per release. For the **first**\nrelease keep it short: a sentence saying it is the first release (and where\nit came from), an `### Added` list of what the package provides, and\n`### Deprecated` only if it ships a deprecated alias. No `Fixed` or `Changed`\n— nothing has been released to fix or change, and entries written as commit\nsubjects read badly on npm. The release script only checks that an entry for\nthe current version exists.\n\n## Scripts a package is expected to have\n\n`dev` (Vite on the demo page), `build` (`tsc` for declarations, then the\nshared compile producing `dist/<entry>.js` and `dist/<entry>.standalone.js`\nplus bundled `.d.ts`), `typecheck`, and `check-package` (`publint --strict`\nand `@arethetypeswrong/cli`). Upstream adds `plugins:check-compat` (build every\nplugin against the workspace library) and `plugins:smoke` (install the packed\ntarball into a fresh Vite project and compile the README snippet).\n","isInternal":false,"tokens":1707,"sizeBytes":6785},{"name":"toolkit.md","path":".github/skills/lightweight-charts-plugin-authoring/references/toolkit.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/.github/skills/lightweight-charts-plugin-authoring/references/toolkit.md","title":"References Skill","category":"anthropic-skill","format":"markdown","content":"# `@tradingview/lwc-toolkit`, module by module\n\nEvery module is its own sub-path export: `@tradingview/lwc-toolkit/<module>`.\nThere is no root import. This file describes the shape and the reason, not\nevery overload: verify signatures against\n`node_modules/@tradingview/lwc-toolkit/dist/<module>.d.ts`, whose doc comments\nare the module's documentation.\n\n\"Read:\" names the official plugin whose source shows the module used for\nreal. Upstream that is `packages/lwc-plugin-<name>/src/<file>`; from any other\nrepository fetch\n`https://raw.githubusercontent.com/tradingview/lightweight-charts/master/packages/lwc-plugin-<name>/src/<file>`\n(the published package ships `dist/` only).\n\n## Custom series\n\n### `custom-series/renderer-base` — `CustomSeriesRendererBase`, `CustomSeriesDrawArgs`, `CanvasRenderingTarget2D`\n\nBase class for a custom series renderer. `update(data, options)` stores what\nthe chart hands over; `draw(target, priceConverter, isHovered, hitTestData)`\nguards against a missing data set or an empty visible range and then calls\nyour `drawImpl(scope, args)` inside `useBitmapCoordinateSpace`. `args` is\n`{ data, options, priceToCoordinate, from, to, isHovered, hitTestData }`,\nwhere `from`/`to` are the visible range clamped to the bars array.\n\nReach for it because the guards are exactly where a hand-written renderer\nthrows when the whole dataset is scrolled off screen. It also re-exports the\n`CanvasRenderingTarget2D` type so the plugin need not depend on `fancy-canvas`.\n\nIf the renderer also implements `hitTest` (called from 5.2), return the *same*\n`hitTestData` object for as long as the same item stays hovered: the chart\ncompares it by reference and repaints the pane on every pointer move when it\nchanges. Keep the last one, or return a primitive such as the item's index.\n\nRead: `stacked-bars-series/src/renderer.ts` (short), `hlc-area-series/src/renderer.ts`.\n\n### `custom-series/visible-bars` — `forEachVisibleBar`, `mapVisibleBars`, `extendRange`, `visibleSegments`, `whitespaceGapCheck`, `barCoordinate`, `getConflationFactor`, `effectiveBarSpacing`, `GapCheck`, `AcceptedInput`\n\n- `forEachVisibleBar(data, fn)` / `mapVisibleBars(data, fn)` visit only\n  `data.visibleRange`; `fn` receives the bar and its *absolute* index into\n  `data.bars`, which is what per-index option lookups use.\n- `extendRange(range, length, by = 1)` widens a range by `by` bars each side,\n  clamped, so a line's first and last segments leave the pane.\n- `visibleSegments(bars, range, isGap?)` splits a range into runs of\n  increasing logical index, breaking where `isGap(left, right)` says so. A\n  jump in logical index alone is **not** a gap — other series can own those\n  indices — so without a predicate the range is one run.\n- `whitespaceGapCheck(readInput, logicalIndex, isWhitespace)` builds that\n  predicate from the series' accepted input. Its `GapCheck(left, right,\n  minGap = 1)` is true when the *contiguous* whitespace between two drawn\n  bars is at least `minGap` logical indices long. Renderers pass\n  `getConflationFactor(data)` as `minGap`.\n- `barCoordinate(bar, anchor, barSpacing)` reconstructs a media `x` for a bar\n  whose own `x` is stale (it was off screen) from a visible anchor bar.\n- `getConflationFactor(data)` is `data.conflationFactor`, or 1 on hosts\n  before 5.1.\n- `effectiveBarSpacing(data)` is `barSpacing` times that factor: the width a\n  conflated column or candle covers. Use it only in a series with a\n  `conflationReducer`. The chart reports the factor to every custom series\n  but conflates only those with a reducer, so a series without one is still\n  drawn one point per bar and sizes against `barSpacing`.\n\nRead: `stacked-area-series/src/renderer.ts` for all of them together.\n\n### `custom-series/hit-test` — `distanceToRange`, `seriesHitTestTolerance`, `nearestBar`, `nearestVerticalRange`, `createHitTestDataCache`\n\nFor a renderer's `hitTest` (called from 5.2).\n\n- `seriesHitTestTolerance(options)` reads the series' `hitTestTolerance`\n  option, in CSS pixels, with the library's default of 3 for an invalid value.\n- `nearestVerticalRange(data, x, y, halfWidth, tolerance, span)` returns\n  `{ index, distance }` for the visible bar whose box — `halfWidth` either\n  side of its `x`, between the two ends `span(bar, index)` returns — is\n  nearest the pointer and within `tolerance`, or `null`. It finds the bars\n  near `x` by binary search. Return `null` from `span` for a bar with\n  nothing to hit.\n- `nearestBar(data, x, reach, tolerance, distance)` is the same search with\n  your own `distance(bar, index)`, for geometry that is not one box per bar:\n  a dot, a ring, a shape. Only the bars whose `x` is within `reach` of the\n  pointer are measured, so make `reach` the widest the geometry gets from a\n  bar's `x`, plus `tolerance`. Measure to the shape itself; picking the bar by\n  a box around it reports the wrong bar where neighboring shapes touch.\n- `distanceToRange(value, a, b)` is the distance to a range, `0` inside it.\n- `createHitTestDataCache()` returns `get(key, create)`, which hands back the\n  same object while the same key is asked for. Use it for an object\n  `hitTestData`, keyed by the `objectId`: the chart compares `hitTestData` by\n  reference and repaints on every pointer move when it changes.\n\nReturn the result typed as `CustomSeriesHitTestResult` from\n`custom-series/compat`, which also has `ConflationContext` for a\n`conflationReducer`'s arguments. Both are types only: the library exports its\nown from 5.2 and 5.1, and importing them would raise the plugin's floor.\n\nRead: `rounded-candles-series/src/renderer.ts` (boxes), `lollipop-series/src/renderer.ts`\n(a stem and a dot).\n\n### `custom-series/options-aware-series` — `createOptionsAwareSeries`, `createWhitespaceSeries`, `OptionsAwareSeries`\n\nFactories that wrap `chart.addCustomSeries` so a series can do two things a\nplain `ICustomSeriesPaneView` cannot:\n\n- **Read options in `priceValueBuilder`.** The chart calls the builder at\n  `setData`, before any `update(data, options)`, so a plain view has only its\n  defaults there. `createOptionsAwareSeries(chart, createView, defaults,\n  options, priceOptions, paneIndex?)` passes `createView` an options getter\n  bound to the real series, and re-ingests the retained data whenever one of\n  `priceOptions` changes through `applyOptions`. Use it whenever an option\n  changes what a value *means* — a base, percent mode, a scale mode. The\n  getter keeps one copy of the options until `applyOptions`, so a builder can\n  call it for every point; `series.options()` deep-copies on every call, so\n  never call that from a builder or a renderer.\n- **Know its own whitespace.** The wrapper retains a copy of the accepted\n  input (the host's `data()` exposes fulfilled points only) as an\n  `AcceptedInput`: a chronological array plus a `revision`, kept sorted\n  incrementally so a streaming `update` is a binary insert.\n  `createWhitespaceSeries(chart, createView, defaults, options,\n  priceOptions?, paneIndex?)` builds on it and hands `createView` a ready\n  `GapCheck` plus the options getter.\n\nThe returned API keeps its identity in chart events; `setData`, `update`,\n`pop` and `applyOptions` are wrapped, everything else is the host's.\n\nRead: `stacked-area-series/src/stacked-area-series.ts` (both concerns),\n`stacked-bars-series/src/stacked-bars-series.ts` (options only).\n\n### `custom-series/stacking` — `cumulativeSum`, `stackLevels`, `stackedPlotValues`\n\nRunning totals of a values array; the band boundaries of a stack drawn from\na `base` (negative values fold back towards it, so bands never overlap); and\n`[min, max, total]` for `priceValueBuilder`, where min and max are taken over\nthe running totals *and* the base so a stack with negatives stays in view.\n\nRead: `stacked-area-series/src/stacked-area-series.ts`, `stacked-bars-series/src/stack.ts`.\n\n### `custom-series/line-paths` — `buildLinePath`, `buildStepLinePath`, `areaBetween`, `strokeStyledPolyline`\n\n`Path2D` builders in bitmap space: a polyline over a bar range with an\naccessor for `y`, its stepped variant, the closed area between two such\nlines (for bands and stacks), and a polyline whose color changes along its\nlength without a visible seam (adjacent runs share their boundary bar). A run\nof `strokeStyledPolyline` may carry a `dashPattern` (`getDashPattern(style,\nlineWidth)`), stroked with `butt` caps; runs without one keep the context's\nown dash and cap.\n\nRead: `hlc-area-series/src/renderer.ts`, `brushable-area-series/src/renderer.ts`.\n\n## Primitives\n\n### `plugin-base` — `PluginBase`\n\nSeries-primitive base: holds `chart` and `series` from `attached`, exposes\n`requestUpdate()`, and throws if `chart` is read before attach. Subclasses\nthat override `attached`/`detached` call `super`.\n\nRead: `vertical-line/src/vertical-line.ts`, `image-watermark/src/image-watermark.ts`.\n\n### `pane-plugin-base` — `PanePluginBase<T>`\n\nThe same for a pane primitive: `chart` and `requestUpdate()`; there is no\nseries. Read: `accessibility/src/pane-primitive.ts`.\n\n### `axis-label-view` — `AxisLabelView`, `AxisLabelSource`, `OFFSCREEN_LABEL_COORDINATE`\n\nAn `ISeriesPrimitiveAxisView` over a source of callbacks (`coordinate`,\n`text`, `textColor`, `backColor`, `visible`, `tickVisible`). Returns the\noff-screen coordinate when the source has none, so the axis draws nothing\nrather than a stray label at 0.\n\nRead: `vertical-line/src/vertical-line.ts`.\n\n### `dom/pane-element` — `paneContentElement`, `chartTableElement`\n\nThe pane's canvas wrapper cell, to append a DOM overlay to, and the chart's\ntable element. Pane widgets reuse rows when panes move, so hold the pane API\nby identity and re-resolve the element on `updateAllViews`.\n\nRead: `accessibility/src/dom/pane-dom.ts`.\n\n### `dom/media-query` — `subscribeMediaQuery`, `mediaQueryMatches`, `HIGH_CONTRAST_QUERIES`, `REDUCED_MOTION_QUERY`\n\nShared, SSR-safe `matchMedia` subscriptions (no `window` at import time).\nRead: `accessibility/src/high-contrast.ts`.\n\n## Pixel-perfect dimensions\n\nAll return bitmap-space `{ position, length }` (`BitmapPositionLength`, from\n`dimensions/common`), computed the way the chart's own renderers do so a\nplugin lines up with built-in series at every device pixel ratio.\n\n| Module | Export | Use |\n| --- | --- | --- |\n| `dimensions/positions` | `positionsLine(centre, pixelRatio, width)`, `positionsBox(a, b, pixelRatio)` | a crisp line of a given CSS width; a box between two coordinates |\n| `dimensions/columns` | `calculateColumnPositions(items, barSpacing, pixelRatio)`, `…InPlace` | evenly spaced columns with the histogram's gap; items may carry `time` (logical index) so a gap is not bridged |\n| `dimensions/candles` | `candlestickWidth(barSpacing, pixelRatio)` | the body width the built-in candlestick uses |\n| `dimensions/full-width` | `fullBarWidth(x, halfSpacing, pixelRatio)`, `fullBarWidthAfter(previousRight, x, halfSpacing, pixelRatio)` | a bar filling its whole slot; neighboring columns that share an edge, with no seam |\n| `dimensions/crosshair-width` | `gridAndCrosshairMediaWidth`, `gridAndCrosshairBitmapWidth` | line widths matching the grid |\n\nRead: `rounded-candles-series/src/renderer.ts`, `pretty-histogram-series/src/renderer.ts`.\n\n## Canvas and style\n\n### `canvas/round-rect` — `drawRoundRect`, `drawRoundRectWithBorder`, `clampCornerRadius`, `CornerRadii`\n\nRounded rectangles in bitmap space, with per-corner radii, radius clamping\nto the rectangle's size, and an inset border that does not shrink the fill.\nRead: `pretty-histogram-series/src/renderer.ts`, `dual-range-histogram-series/src/renderer.ts`.\n\n### `canvas/markers` — `beginMarker`, `beginMarkerOffset`, `traceMarker`, `traceMarkerOffset`, `markerDistance`, `markerVertices`, `segmentDistance`, `MarkerShape`\n\nPoint markers (`circle`, `square`, `diamond`, `triangleUp`, `triangleDown`),\ntwo ways:\n\n- one marker per path (a different color or opacity per point):\n  `beginMarker(ctx, shape, x, y, radius)` calls `ctx.beginPath()` and traces\n  the marker as the path's only subpath, then fill or stroke. A circle is a\n  bare `arc`, which Chromium draws faster, as an exact oval.\n- many markers per path (one style, one `fill()`): `traceMarker(path, shape,\n  x, y, radius)` adds each to a context or `Path2D` as a subpath of its own,\n  so no line joins them. Begin the path yourself.\n\n`traceMarkerOffset(…, offset)` / `beginMarkerOffset(…, offset)` trace the\noutline `offset` outside the marker, with rounded corners, for a hover ring\nor halo of even width;\n`markerDistance(shape, dx, dy, radius, strokeWidth)` is the distance from a\npoint to the marker as drawn, stroke and rounded corners included, `0` inside,\nfor `hitTest`. All three read the same vertices, so a marker is hit where it is\ndrawn. `segmentDistance` is the building block for hovering a polyline.\nRead: `scatter-series/src/renderer.ts`, `scatter-series/src/hit-test.ts`.\n\n### `line-style` — `setLineStyle`, `getDashPattern`, `LineStyle`\n\nThe chart's own dash patterns for a renderer that receives no drawing utils\n(custom series renderers before 5.1, primitives on some hosts). The `LineStyle`\ntype takes the library's enum as well, so an option passes without a cast.\nStroke a dashed style with `ctx.lineCap = 'butt'`, as the chart does: a round\ncap closes the gaps of a dotted line (`strokeStyledPolyline` does it for a\nrun given a `dashPattern`).\nRead: `vertical-line/src/vertical-line.ts`.\n\n## Chart behavior\n\nLibrary rules a plugin otherwise copies from the library's source. Each\nmodule names the source it mirrors; the interaction flags are pinned to it by\na unit test.\n\n| Module | Export | Use |\n| --- | --- | --- |\n| `chart/compat` | `supportsSeriesOrder(series)` | calling `setSeriesOrder` (5.0.6) from a plugin whose floor is 5.0: the guard narrows the series, so the call compiles against the 5.0 typings and is skipped on a host without the method |\n| `chart/interaction-flags` | `canUserMoveTimeScale(chart.options())`, `TIME_SCALE_MOVE_FLAGS` | whether the user can scroll or zoom the time scale; with none of the flags on, the chart treats both edges as fixed |\n| `chart/lifecycle` | `isChartRemoved(chart)`, `isSeriesAttached(chart, series)` | for a plugin with its own API in front of a series: stop writing to a chart the host removed, or a series it took off with `chart.removeSeries`. Read-only; decide outside the chart's event dispatch what to release |\n| `chart/time-axis-labels` | `timeAxisLabelFont`, `tickMarkPixelsPerCharacter`, `tickMarkMaxLabelWidth`, `tickMarkCharactersForWidth` | the time axis' label font, and `timeScale.tickMarkMaxCharacterLength` to pixels and back |\n| `text/measure` | `textMeasureContext()`, `createTextWidthCache()` | measuring labels before painting (layout, overlap avoidance); `null` without a DOM |\n\nRead: `scatter-series/src/x-axis-controller.ts`, and `scatter-series-api.ts` for\nthe lifecycle checks; `background-shade-series/src/background-shade-series.ts`\nfor `supportsSeriesOrder`.\n\n## General\n\n| Module | Export | Use |\n| --- | --- | --- |\n| `assertions` | `ensureDefined`, `ensureNotNull` | narrow or throw, for state that must exist after attach |\n| `delegate` | `Delegate`, `ISubscription` | a small subscribe/fire event; expose the `ISubscription` half publicly |\n| `time` | `convertTime`, `convertTimeUTC`, `displayTime`, `formattedDateAndTime` | `Time` (string, business day, timestamp) to a number or display string |\n| `closest-index` | `ClosestTimeIndexFinder` | cached binary search for the index at or after a time |\n| `min-max-in-range` | `UpperLowerInRange` | cached extremes over a range, for autoscale providers |\n| `simple-clone` | `cloneReadonly` | deep clone that drops readonly-ness, through JSON (functions and `undefined` are lost) |\n| `options/merge` | `mergeOptions`, `cloneOptions`, `freezeOptions` | `applyOptions` with nested options: a partial nested option changes only its keys (a spread replaces the whole object); arrays and functions replace; unsafe keys are skipped; pass `defaults` to make `null` reset a value |\n| `numbers` | `isFiniteNumber`, `finiteOr`, `nonNegativeOr`, `clampOpacity` | numeric options from JavaScript: the canvas ignores a `NaN` width or opacity silently |\n| `scheduling/coalesced-task` | `createCoalescedTask(run, enqueue?)` | `{ schedule, cancel, pending }`: once per microtask (or frame) for a burst of events, never inside the chart's dispatch; `cancel()` on removal |\n","isInternal":false,"tokens":4128,"sizeBytes":16418},{"name":"SKILL.md","path":".github/skills/lightweight-charts-plugin-authoring/SKILL.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/.github/skills/lightweight-charts-plugin-authoring/SKILL.md","title":"lightweight-charts-plugin-authoring","category":"anthropic-skill","format":"markdown","content":"---\nname: lightweight-charts-plugin-authoring\ndescription: >-\n  Use when creating, extending, debugging or publishing a Lightweight Charts™\n  plugin — a custom series, a series primitive or a pane primitive — or when\n  turning a chart idea (\"I want the chart to show/draw X\") into a working\n  plugin. Covers choosing the plugin type, scaffolding with create-lwc-plugin,\n  building on @tradingview/lwc-toolkit instead of hand-rolled helpers, which of\n  the official plugin packages to read as the reference implementation,\n  where the docs are, and the autoscale, whitespace, visible-range, hit-test\n  and conflation mistakes every plugin author makes once. Reach for it whenever\n  the user mentions a custom series, primitive, renderer, drawing on the chart\n  canvas, lwc-plugin, plugin-examples, the toolkit, or the plugin catalog —\n  even if they never say the word \"plugin\".\n---\n\n# Writing a Lightweight Charts™ plugin\n\nThis skill is about *authoring* plugins. For questions about using the chart\nitself — series, scales, markers, data, wrappers — use the sibling\n`lightweight-charts` skill; the two are designed to be installed together.\n\n## Where you are, and where the sources are\n\nThis skill is used in two places, and the same question has a different\nanswer in each. Detect which before looking anything up:\n\n```sh\n# upstream checkout of lightweight-charts itself?\ntest -f pnpm-workspace.yaml && test -d packages/lwc-toolkit && echo upstream || echo \"a plugin project or other repo\"\n```\n\n**In a plugin project or any other repository** (the common case):\n\n| Looking for | Where |\n| --- | --- |\n| the library's API | `node_modules/lightweight-charts/dist/typings.d.ts`; if it is not installed, the released typings are hosted at `https://tradingview.github.io/lightweight-charts/lightweight-charts.d.ts` |\n| the toolkit's API | `node_modules/@tradingview/lwc-toolkit/dist/<module>.d.ts` — the `.d.ts` carry the doc comments, so they read as documentation |\n| a reference plugin's **source** | not in `node_modules` (packages ship `dist/` only). Fetch it from GitHub: `https://raw.githubusercontent.com/tradingview/lightweight-charts/master/packages/lwc-plugin-<name>/src/<file>`, or clone once and read locally: `git clone --depth 1 https://github.com/tradingview/lightweight-charts /tmp/lightweight-charts` |\n| the docs | every docs page is served as Markdown by appending `.md` to its URL, e.g. `https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series.md`. `https://tradingview.github.io/lightweight-charts/llms.txt` lists every page; `docs_map.md` beside it lists their headings too |\n\n**In the upstream checkout:** `dist/typings.d.ts` (or `src/`) for the library,\n`packages/lwc-toolkit/src/` for the toolkit, `packages/lwc-plugin-*/src/` for\nthe plugins, `website/docs/plugins/*.md` for the docs, `plugin-examples/` for\nthe proof-of-concept examples.\n\n```sh\n# what version is installed, and does the hook I am about to rely on exist in it?\nnode -p \"require('lightweight-charts/package.json').version\"\nrg -n \"hitTest|conflationReducer|isHovered|ICustomSeriesPaneView|IPrimitivePaneRenderer\" node_modules/lightweight-charts/dist/typings.d.ts\n# the toolkit's custom-series surface\nrg -n \"export (declare )?(function|class|interface|type)\" node_modules/@tradingview/lwc-toolkit/dist/custom-series/*.d.ts\n# a reference implementation, without a checkout\ncurl -fsSL https://raw.githubusercontent.com/tradingview/lightweight-charts/master/packages/lwc-plugin-stacked-bars-series/src/renderer.ts\n```\n\nLocal typings win over the docs when they disagree: the docs describe the\ncurrent release, the typings describe what the user actually has. If a file is\nmissing, say what could not be verified. Never invent an option, a hook or a\ntoolkit export — a plugin that compiles against an imagined API fails the\nuser's typecheck, and one that compiles against an option the chart ignores\nfails silently at runtime.\n\n## From idea to plugin type\n\nThe single most consequential decision, and the one to make first. Ask what\nthe idea *is* rather than how it looks:\n\n| The idea is… | Type | Because |\n| --- | --- | --- |\n| a new way to draw a series' own data (bars, bands, stacks, candles) | **custom series** | it needs its own data, autoscale, price line, last value and time-scale integration |\n| a decoration tied to one series (label, marker, band around it, drawing tool on its data) | **series primitive** | it reads that series' coordinates and is clipped to it |\n| a decoration tied to the pane (watermark, legend, title, an overlay for every series) | **pane primitive** | it spans the pane and outlives any one series |\n| a DOM-based accessibility, tooltip or control layer | **pane primitive** with a DOM overlay | the canvas is not the right medium; append to `paneContentElement(pane)` |\n\nDefault to a primitive. A custom series is the heavier construct — it must\nimplement `priceValueBuilder`, `isWhitespace`, `renderer` and `update`, and\nits renderer is called with the series' plot data. Only choose it when the\nidea *is* a series. A drawing tool that needs pointer handling is still a\nprimitive: it draws in a primitive and reacts through `subscribeClick`,\n`subscribeCrosshairMove` and the coordinate-conversion APIs.\n\nKeep hover and interaction in mind when choosing: primitives get a `hitTest`\nso the chart can report them in crosshair and click events; custom series get\na `hitTest` on their renderer only on Lightweight Charts™ 5.2 and later, which\nis what makes the `isHovered` and `hitTestData` arguments of `draw` report a\nhover.\n\n## Working method\n\nBuild in this order. Each step is the cheapest place to find the previous\nstep's mistakes.\n\n1. **Write down the data item and the options** before any code. The data\n   item decides `isWhitespace` (which fields make a point drawable) and the\n   options decide `defaultOptions`. Both go in their own files\n   (`data.ts`, `options.ts`) because the README, the types and the demo all\n   read them.\n2. **Scaffold** (below). Do not start from a blank file.\n3. **Get the renderer drawing with the sample data** the scaffold generates,\n   visible-range only, before touching options or interaction. A renderer that\n   draws everything, or draws nothing, is easier to fix while it is small.\n4. **Wire the options** through `applyOptions`; re-render with\n   `requestUpdate()`. Check every option does something in the demo page.\n5. **Custom series only: autoscale and whitespace.** `priceValueBuilder`\n   drives the price scale and the last-value label; whitespace decides where\n   the line breaks. Both have traps (checklist below).\n6. **Interaction**: `hitTest`, hover, drag. Keep it separate from drawing.\n7. **Tests**, then the README, then the demo and preview pages. The package\n   contract (`references/package-contract.md`) says what each must contain.\n   The preview must use `themeChart` from the preview kit's `preview-theme`\n   and be checked in both the light and the dark theme.\n\n## Scaffold, don't start blank\n\n```sh\nnpm create lwc-plugin@latest\n```\n\nThe wizard is interactive. It first offers to install this skill (say no if it\nis already installed, or the user quit the wizard to hand over to you), then\nasks for the type, a name, a one-sentence description, a package name, a class\nname, author, license, the minimum library version, tags, whether to keep hint\ncomments, and the target folder. Work those answers out with the user before\nanyone runs it — the type decision above is the one that matters — then have\nthe user run the wizard in their terminal, unless your environment gives you a\nTTY to answer the prompts yourself. It writes a Vite project with:\n\n- `src/<entry>.ts` — the plugin class (and, for a custom series, a factory);\n  `src/options.ts`, `src/data.ts`, and a renderer or view file per type\n- `src/example/index.html` + `example.ts` — the dev demo, `pnpm dev` serves it\n- `package.json` with `dev`, `build`, `typecheck` and `check-package` scripts,\n  a `lightweight-charts` peer range, `@tradingview/lwc-toolkit` as a\n  devDependency, and an `lwcPlugin` block for the catalog\n- a README already in the shape the catalog renders\n\nAnswer yes to \"hint comments\": they are `//*` lines that explain each part of\nthe template and are stripped by the wizard otherwise. Read them, then delete\nthe ones you have acted on. Build against the scaffold's own scripts\n(`pnpm typecheck`, `pnpm build`, `pnpm check-package`) — they are what CI and\nthe release tooling run.\n\n## Build on the toolkit\n\n`@tradingview/lwc-toolkit` is what the official plugins are built from,\nextracted from the helpers every example used to copy by hand. Reaching for\nit is not about saving lines; it is that the helpers encode chart behavior\nthat is easy to get subtly wrong — the exact width the built-in candlestick\nuses at a given bar spacing, pixel-perfect line positions at every device\npixel ratio, the dash patterns of `LineStyle`, how conflation changes a bar's\nlogical stride. Import each helper by sub-path:\n\n```ts\nimport { CustomSeriesRendererBase } from '@tradingview/lwc-toolkit/custom-series/renderer-base';\nimport { visibleSegments, extendRange, barCoordinate } from '@tradingview/lwc-toolkit/custom-series/visible-bars';\nimport { PluginBase } from '@tradingview/lwc-toolkit/plugin-base';\n```\n\nProblem → module, for the common cases. `references/toolkit.md` has the rest,\nwith the shape of each API and the official plugin that uses it.\n\n| You need to… | Use |\n| --- | --- |\n| write a custom series renderer without re-doing the data / range guards | `custom-series/renderer-base` — extend `CustomSeriesRendererBase`, implement `drawImpl(scope, args)` |\n| a series or pane primitive with the chart reference and `requestUpdate()` handled | `plugin-base` (`PluginBase`) / `pane-plugin-base` (`PanePluginBase`) |\n| draw only what is on screen, and reach the pane edge with a line | `custom-series/visible-bars` — `forEachVisibleBar`, `mapVisibleBars`, `extendRange`, `barCoordinate` |\n| size a conflated bar to the slots it covers (only with a `conflationReducer`) | `effectiveBarSpacing` (`custom-series/visible-bars`) |\n| implement `hitTest` or `conflationReducer` and still support 5.0 | `custom-series/compat` (types only) — `CustomSeriesHitTestResult`, `ConflationContext` |\n| call a series method newer than 5.0 (`setSeriesOrder`, 5.0.6) and still support 5.0 | `chart/compat` — `supportsSeriesOrder(series)` narrows the series, so the call stays typed |\n| report the bar under the pointer from `hitTest` | `custom-series/hit-test` — `seriesHitTestTolerance`, `nearestVerticalRange` (boxes), `nearestBar` (any shape), `createHitTestDataCache` |\n| break a line at explicit whitespace, not at other series' timestamps | `createWhitespaceSeries` (`custom-series/options-aware-series`) + `visibleSegments` |\n| read options inside `priceValueBuilder` (autoscale that follows options) | `createOptionsAwareSeries` with the option names that affect plot values |\n| stacked values: band edges and autoscale extremes | `custom-series/stacking` — `stackLevels`, `stackedPlotValues` |\n| columns, candles or lines the same width as the built-ins, pixel-aligned | `dimensions/*` — `calculateColumnPositions`, `candlestickWidth`, `positionsLine`, `positionsBox` |\n| rounded rectangles with an inset border | `canvas/round-rect` |\n| polylines, step lines, the area between two lines, a line whose color changes | `custom-series/line-paths` |\n| a label on the price or time axis | `axis-label-view` (`AxisLabelView`) |\n| a DOM overlay inside the pane | `dom/pane-element` (`paneContentElement`) |\n| a small event, or a `Time` as a timestamp or display string | `delegate`, `time` |\n\nWhen the scaffold's template already imports a toolkit helper, keep it; the\ntemplate is the smallest correct plugin of its type.\n\n## Read the reference implementations\n\nThe official packages are the canonical examples: maintained, tested,\npublished, and built exactly the way this skill describes. Read the one\nnearest your idea *before* designing — most questions (\"how do I get the\nhovered item?\", \"how do I autoscale a stack?\") are answered by a file in\none of them. Upstream they are `packages/lwc-plugin-*/src/`. From any other\nrepository the published `@tradingview/lwc-plugin-*` package gives you the\nREADME and the `dist/*.d.ts`, but not the source — fetch that from GitHub\n(raw URL or a shallow clone, see above); each plugin is a handful of files.\n\n| Building… | Read |\n| --- | --- |\n| any custom series | `stacked-bars-series` (the simplest complete one), then `pretty-histogram-series` |\n| a series with several values per point | `stacked-area-series`, `stacked-bars-series`, `grouped-bars-series` (side by side) |\n| a line/area that must break at gaps, or survive conflation | `hlc-area-series`, `brushable-area-series` |\n| a series with its own pointer interaction | `brushable-area-series` (`BrushableAreaInteraction`) |\n| a replacement for a built-in series | `rounded-candles-series` (matches candlestick options and widths) |\n| a chart whose X axis is a number, not time (scatter, bubble) | `scatter-series` (`ScatterHorzScaleBehavior`, `createScatterChart`) |\n| point markers on a series, hovered by their drawn shape | `lollipop-series` (`canvas/markers` dots, `nearestVerticalRange` and `markerDistance` in `hitTest`), `scatter-series` |\n| a shape built from several values per point, on the candle grid | `box-whisker-series` (named fields, per-point colors, part names in `objectId`) |\n| many colored cells per point, an order book or volume profile | `heatmap-series` (fills batched by color, `createColorScale`, a cell-level `hitTest`) |\n| a fixed-pixel-height overlay series | `dual-range-histogram-series` (`scaleMode`, `keepPixelSeriesInView`) |\n| a series primitive with an axis label and dragging | `vertical-line` |\n| a tool the user clicks to add something to a series | `user-price-lines` (pointer events in its own pane, one active instance per pane, a chart option set and put back) |\n| an image or decoration behind a series or pane | `image-watermark` (both a series and a pane primitive) |\n| a background colored from data, outside the price scale | `background-shade-series` (`[NaN]` plot values, `setSeriesOrder(0)`) |\n| a text label anchored to a pane edge or corner | `anchored-text` (the smallest series + pane pair over one core) |\n| a background derived from each bar of a series | `session-highlighting` (per-bar state from `dataUpdated`, visible-range slice) |\n| a DOM layer on a pane, multi-pane lifecycle | `accessibility` |\n\n`references/official-plugins.md` says what each one demonstrates in detail.\n`plugin-examples/src/plugins/` in the repository\n(`https://github.com/tradingview/lightweight-charts/tree/master/plugin-examples`)\nholds a further set of proof-of-concept plugins — tooltips, drawing tools,\na volume profile, … — good for breadth and ideas, but they are\nunpublished starting points, not the standard to match. The graduated\nplugins' folders there are redirects to the packages.\n\n## Read the documentation in this order\n\nFetch pages as Markdown — append `.md` to the URL — rather than scraping the\nHTML: `https://tradingview.github.io/lightweight-charts/docs/plugins/<page>.md`.\n`https://tradingview.github.io/lightweight-charts/llms.txt` is the index of\nevery page, `docs_map.md` the same with headings, and\n`lightweight-charts.d.ts` beside them the released typings.\n\n1. `intro` — the three plugin types and how they attach.\n2. `series-primitives` or `pane-primitives` — the view/renderer/lifecycle\n   contract for your type: `attached` / `detached`, `updateAllViews`,\n   `paneViews`, `priceAxisViews`, `timeAxisViews`, `hitTest`.\n3. `custom_series` — `ICustomSeriesPaneView`: `priceValueBuilder`,\n   `isWhitespace`, `renderer`, `update`, `defaultOptions`, the 5.1 conflation\n   hooks and the 5.2 `hitTest`.\n4. `canvas-rendering-target` — the `CanvasRenderingTarget2D` you draw on and\n   its two coordinate spaces.\n5. `pixel-perfect-rendering` — why widths and positions go through the\n   `dimensions/*` helpers.\n\nFor anything the pages do not cover, read the typings rather than the\ngenerated API reference — they are complete, and the `.d.ts` is what your code\ncompiles against. The docs describe the current release; when your peer range\nstarts earlier, the typings of the installed version are what you actually\nhave.\n\n## Correctness checklist\n\nEach of these has bitten a shipped plugin. The reasons are here so they can\nbe recognized in a new shape, not just avoided in the old one.\n\n### Drawing\n\n- Draw in `useBitmapCoordinateSpace` for anything that must be crisp (lines,\n  bars, borders) and scale widths by `horizontalPixelRatio` /\n  `verticalPixelRatio`; use `useMediaCoordinateSpace` for text and layout in\n  CSS pixels. Mixing them blurs on HiDPI. The `dimensions/*` helpers return\n  bitmap positions for exactly this reason.\n- `CanvasRenderingTarget2D` comes from `fancy-canvas`, not from the library;\n  the toolkit re-exports the type from `custom-series/renderer-base` so a\n  custom series need not depend on it.\n- Restore anything you set on the context (`save`/`restore`, or reset\n  `globalAlpha`, `lineCap`, dash). The next renderer draws on the same\n  context.\n- A `priceToCoordinate` that returns `null` means the price is off the\n  scale. Skip that point or break the line there; drawing to `NaN` loses the\n  whole path.\n\n### Visible range and coordinates\n\n- Draw `data.visibleRange` only; a series can have a million points. For\n  lines and areas widen the range by one bar with `extendRange` so the first\n  and last segments leave the pane instead of stopping at the edge.\n- Bars outside the visible range may carry stale or missing `x`. Rebuild a\n  coordinate from a visible anchor with `barCoordinate(bar, anchor,\n  barSpacing)` — `bar.time` is the *logical index*, and spacing is per index.\n- `bar.time` (logical index) and the array index `i` differ as soon as another\n  series starts earlier or the data has gaps. Per-index option lookups and\n  brush ranges use the logical index.\n\n### Custom series specifics\n\n- `priceValueBuilder` returns the plot values the chart autoscales on and\n  takes the *last* as the current value (price line, last-value label). For\n  a stack report `[min, max, total]` (`stackedPlotValues`); for a band the\n  extremes; for a single value `[value]`.\n- It runs at `setData`, before any render, so a plain view has no options\n  yet — the chart has not called `update` — and `percent`, `base` or\n  `scaleMode` are ignored on the first ingest. `createOptionsAwareSeries`\n  gives the builder a live options getter and re-ingests when a named option\n  changes; this is why the official series ship a `createXSeries` factory as\n  the supported entry point and keep the class exported for composition.\n- The host hands a custom renderer **no whitespace**: bars simply skip the\n  gap, and a jump in logical index may just be another series' timestamps.\n  Break lines only at the series' own whitespace, from its accepted input:\n  `createWhitespaceSeries` provides a `GapCheck`; pass\n  `getConflationFactor(data)` as its `minGap` so a whitespace run narrower\n  than one conflation bucket is absorbed rather than splitting every bucket\n  into a single-point segment.\n- `conflationReducer` and `conflationFactor` exist from 5.1, and the\n  renderer's `hitTest` from 5.2: series hit testing, which reports a custom\n  series hovered through `isHovered` / `hitTestData` (`draw` arguments since\n  5.0), arrived with it. Implement them as optional extras, keep the peer\n  range at `^5.0.0` unless you need them, and say so in the README.\n- `hitTest` must return the same `hitTestData` object while the same item\n  stays hovered: the chart compares it by reference and repaints the pane on\n  every pointer move when it is a new object.\n- `conflationReducer(a, b)` must return a data item of your own type that\n  makes sense as the merge of two: sum for stacks, high/low/last for OHLC,\n  the later value for a rate.\n\n### Primitives specifics\n\n- `requestUpdate()` after any change the chart cannot see (an option, a new\n  time, a decoded image). The chart does not poll your state.\n- `detached()` must undo everything `attached()` did: listeners, DOM nodes,\n  timers, pending image loads. Attach/detach cycles are common (React\n  effects, pane reordering) and leaks show up as ghost drawings and thrown\n  \"disposed\" errors.\n- A pane primitive is drawn only on the pane it is attached to; a pane index\n  given to a constructor is a hint that can be wrong. Resolve the real pane\n  lazily (the first draw's `context.canvas` is inside it) and hold it by\n  identity — indices shift when panes are added, removed or moved.\n- For DOM overlays, append to `paneContentElement(pane)` and keep the\n  overlay's layout independent of the chart's own table cells.\n\n## Testing\n\nThree layers, each catching something the others cannot. The official\npackages have all three under `tests/`; the scaffold sets up the first.\n\n- **Unit** (`tests/unit/*.spec.ts`, `node:test` + `chai`): pure functions —\n  stacking maths, option merging, data padding, gap detection. Fast, run by\n  the repository's `pnpm test`.\n- **Graphics** (`tests/graphics/*.js`): a page that draws one state; CI\n  compares the screenshot against the previous build's. One case per option\n  worth seeing, plus the edge cases: empty visible range, scrolled off, a\n  whitespace run, conflation, inverted scale.\n- **Interactions** (`tests/interactions/*.js`): a page with an async\n  `beforeInteractions(container)` that drives the chart and throws on a\n  wrong outcome — pixel sampling for \"did it paint\", DOM checks, hit tests.\n  This is where whitespace, update, `pop` and pointer behavior are tested.\n\nRun upstream with `pnpm test`, `pnpm e2e:graphics:plugins` and\n`GREP=\"lwc-plugin-<name>/\" pnpm e2e:interactions`, after `pnpm build:prod`\nand `pnpm --filter \"@tradingview/lwc-plugin-*\" build`.\n\n## Publishing and the catalog\n\nA plugin is publishable when `pnpm plugins:validate` passes upstream, or the\nequivalent by hand: an `lwc-plugin-*` name, `publishConfig.access: public`, a\n`lightweight-charts` peer range, the `lightweight-charts-plugin` keyword, a\ncomplete `lwcPlugin` block, a README with `## Installation` (`### npm` and\n`### CDN` tabs) and `## Usage`, and the demo page it declares. The scaffold\nmeets all of it. The docs site's plugin catalog renders the README and\nframes a preview page built from the package; `references/package-contract.md`\nhas the fields, the pages and the first-release changelog convention (short:\nan `Added` list, no `Fixed` — there is nothing to have fixed yet).\n\nWrite documentation and user-facing text (README, CHANGELOG, the package\n`description`, JSDoc on public API) in American English: color, center,\ncatalog, normalize, not colour, centre, catalogue, normalise. Write comments\nin new code the same way, but don't bulk-fix older plugins.\n\n## Answer contract\n\nWhen helping with a plugin:\n\n1. Name the plugin type and say why in one sentence, or explain what the\n   user's idea would lose in the other type.\n2. Point at the toolkit module and the official plugin you are basing the\n   answer on. Read the plugin's file before quoting its pattern.\n3. Verify every library and toolkit name against the local typings; say what\n   you could not verify.\n4. Produce code that the scaffold's own scripts accept: `pnpm typecheck`,\n   `pnpm build`, and `pnpm dev` showing it in the demo page.\n5. When the change touches autoscale, whitespace, the visible range or\n   hover, name the test that would have caught the regression and write it.\n","frontmatter":{"name":"lightweight-charts-plugin-authoring","description":"Use when creating, extending, debugging or publishing a Lightweight Charts™ plugin — a custom series, a series primitive or a pane primitive — or when turning a chart idea (\"I want the chart to show/draw X\") into a working plugin. Covers choosing the plugin type, scaffolding with create-lwc-plugin, building on @tradingview/lwc-toolkit instead of hand-rolled helpers, which of the official plugin packages to read as the reference implementation, where the docs are, and the autoscale, whitespace, visible-range, hit-test and conflation mistakes every plugin author makes once. Reach for it whenever the user mentions a custom series, primitive, renderer, drawing on the chart canvas, lwc-plugin, plugin-examples, the toolkit, or the plugin catalog — even if they never say the word \"plugin\"."},"isInternal":false,"tokens":5766,"sizeBytes":23693},{"name":"SKILL.md","path":".github/skills/lightweight-charts/SKILL.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/.github/skills/lightweight-charts/SKILL.md","title":"lightweight-charts","category":"anthropic-skill","format":"markdown","content":"---\nname: lightweight-charts\ndescription: >-\n  Use when working with TradingView's lightweight-charts — creating charts,\n  adding series (Line/Area/Bar/Candlestick/Histogram), configuring time and\n  price scales, streaming realtime or historical data, panes, markers,\n  per-bar/per-point colors, tooltips, coordinate conversion, custom plugins or\n  primitives, non-financial horizontal scales, SSR/browser loading, or\n  React/Vue/Web Components wrappers. Covers v5 API conventions and the common\n  time, scale, marker, plugin, and wrapper foot-guns.\n---\n\n# Lightweight Charts skill\n\nWorks the same whether the project is a downstream npm consumer app or an upstream `lightweight-charts` source checkout. Detect which one you are in (below) and resolve every API name from whatever typings are locally available.\n\n## Source lookup order\n\nDo not assume you are inside the upstream source repository.\n\n1. In a consumer app, inspect the installed package first:\n   - `node_modules/lightweight-charts/package.json` for the actual version.\n   - `node_modules/lightweight-charts/dist/typings.d.ts` for the API surface.\n2. In the upstream repo, inspect `dist/typings.d.ts` first, then `src/` if generated output is unavailable.\n3. Use official docs/examples as supporting evidence, but local typings win when they disagree.\n\nVerify before answering (copy-paste):\n\n```sh\nnode -p \"require('./node_modules/lightweight-charts/package.json').version\"\nrg -n \"createSeriesMarkers|addSeries|IPrimitivePaneRenderer|createImageWatermark|createOptionsChart\" node_modules/lightweight-charts/dist/typings.d.ts\n# upstream checkout instead of a consumer app:\nrg -n \"createSeriesMarkers|IPrimitivePaneRenderer|createImageWatermark|createOptionsChart\" dist/typings.d.ts src\n```\n\nIf the relevant file is unavailable, say what could not be verified. Do not invent option names, methods, exports, or wrapper behavior.\n\nIf the user's code imports `from lightweight_charts import ...` (underscore), uses pandas/asyncio, or talks about a Python window wrapper, they are probably using the third-party Python wrapper rather than the TypeScript package. Say that clearly before giving core `lightweight-charts` v5 JavaScript advice.\n\n## Mental model\n\nEight layers, in dependency order. Most bugs come from confusing one for another:\n\n1. **Chart** — `createChart(container, options)` returns an `IChartApi`. One chart per container element.\n2. **Series** — added via `chart.addSeries(SeriesType, options, paneIndex?)`. Each call returns an `ISeriesApi`. v5 requires importing the series type explicitly.\n3. **Scales** — `chart.timeScale()` (`ITimeScaleApi`), `chart.priceScale(id)` (`IPriceScaleApi`). Govern range, ticks, autoscale, visibility.\n4. **Data model** — arrays of `{ time, … }` points. `Time = UTCTimestamp | BusinessDay | string`. `UTCTimestamp` is **seconds**, not milliseconds. Times must be unique and ascending per series.\n5. **Interaction** — `chart.subscribeCrosshairMove`, `chart.subscribeClick`, `timeScale.subscribeVisibleLogicalRangeChange`, etc.\n6. **Layout** — `chart.panes()`, `chart.addPane()`. Adding a series with an out-of-range `paneIndex` auto-creates the pane.\n7. **Extension** — pane primitives, series primitives, custom series, watermarks, custom renderers (canvas via `fancy-canvas`).\n8. **Wrappers** — React/Vue/Web Components/iOS/Android. Lifecycle is the wrapper's responsibility; the core library is framework-agnostic.\n\n## v5 essentials\n\nThe conventions that catch people copying older snippets:\n\n```ts\nimport { createChart, CandlestickSeries, LineSeries } from 'lightweight-charts';\n\nconst chart = createChart(container, { /* ChartOptions */ });\nconst candles = chart.addSeries(CandlestickSeries, { /* options */ });\ncandles.setData([\n    { time: 1700000000, open: 1, high: 2, low: 0.5, close: 1.5 },\n]);\n```\n\nKey v5 changes versus older snippets:\n\n- `chart.addSeries(SeriesType, options, paneIndex?)` replaces `addLineSeries` / `addCandlestickSeries` / …\n- `createSeriesMarkers(series, markers)` replaces `series.setMarkers(...)`. The returned primitive owns `.setMarkers(...)` / `.markers()`.\n- `createTextWatermark(pane, options)` and `createImageWatermark(pane, imageUrl, options)` replace the `watermark` chart option.\n- Series types are tree-shaken — importing them is required for ESM.\n\nIf a snippet calls `addLineSeries` or `series.setMarkers`, it's v4 or older. Confirm the user's version before forwarding it.\n\nWhen the task targets v5, show the v5 API directly — do not hedge by mixing in v4 syntax.\n\n## Triage (problem → API → avoid)\n\n| User asks about | First check | Answer with | Avoid |\n|---|---|---|---|\n| v5 series creation | package version + typings | `chart.addSeries(SeriesType, options)` | `addLineSeries` / `addCandlestickSeries` |\n| markers | `createSeriesMarkers` export | marker primitive + required `color` | `series.setMarkers` |\n| timezone | formatter need vs data semantics | `Intl.DateTimeFormat` in formatters | fake `timeScale.timezone` |\n| realtime updates | last-bar vs full replace | `series.update(point)` | `setData` on every tick |\n| panes | `paneIndex` + `chart.panes()` | v5 pane APIs, `pane.setHeight` | private widget / DOM hacks |\n| per-bar colors | data-point color fields | `color`/`borderColor`/`wickColor` on points | extra series / markers to recolor |\n| plugins | primitive vs custom series | scaffold/examples + public coordinate APIs | invented renderer names |\n\n### v4 → v5 replacement matrix\n\nStale copy-pasted snippets are the most common failure. Map them directly:\n\n| Old or wrong | v5 replacement |\n|---|---|\n| `chart.addLineSeries(options)` | `chart.addSeries(LineSeries, options)` |\n| `chart.addCandlestickSeries(options)` | `chart.addSeries(CandlestickSeries, options)` |\n| `series.setMarkers(markers)` | `createSeriesMarkers(series, markers)` |\n| chart `watermark` option | `createTextWatermark(chart.panes()[0], options)` |\n| `createImageWatermark(pane, options)` | `createImageWatermark(pane, imageUrl, options)` |\n| `IPanePrimitivePaneRenderer` | `IPrimitivePaneRenderer` |\n| `timeScale: { timezone }` | label formatters using `Intl.DateTimeFormat` |\n| `time: Date.now()` (ms) | `time: Math.floor(Date.now() / 1000)` for `UTCTimestamp` |\n\n## Routing map (problem → where to look)\n\nUse local typings first. The repo paths below exist only in the upstream `lightweight-charts` checkout; in a consumer app, translate them to the installed package typings or official docs.\n\n| Task | Canonical sources |\n|---|---|\n| First chart / series | `website/docs/intro.mdx`, `website/tutorials/customization/` |\n| Time / range behavior | `website/docs/time-scale.md`, `website/docs/time-zones.md` |\n| Realtime / history | `website/examples/data/realtime-updates.{mdx,js}`, `website/examples/data/infinite-history.{mdx,js}` |\n| Whitespace / gaps | `website/examples/data/whitespace.{mdx,js}` |\n| Price format / locale | `website/tutorials/customization/price-format.mdx`, `website/examples/styling/custom-locale.{mdx,js}` |\n| Two scales / inverted | `website/examples/price-scales/two-price-scales.{mdx,js}`, `website/examples/price-scales/inverted-price-scale.{mdx,js}` |\n| Panes / price + volume | `website/docs/panes.md`, `website/examples/panes/multiple-panes.{mdx,js}`, `website/examples/price-scales/price-and-volume.{mdx,js}` |\n| Markers / tooltips / legends | `website/examples/markers-and-lines/series-markers.{mdx,js}`, `website/examples/tooltips-and-legends/*-tooltip.{mdx,js}`, `website/examples/tooltips-and-legends/*legend.{mdx,js}` |\n| Crosshair (programmatic) | `website/examples/crosshair/*.{mdx,js}` |\n| Watermarks | `website/examples/styling/*-watermark.{mdx,js}` |\n| Plugins / custom series / primitives | `website/docs/plugins/`, `plugin-examples/src/plugins/` |\n| Coordinate conversion / hit-testing | `dist/typings.d.ts` for `subscribeClick`, `coordinateToPrice`, `timeScale().coordinateToLogical` |\n| Non-time horizontal scales / options chart | `dist/typings.d.ts` for `createOptionsChart`, `createChartEx`, `IHorzScaleBehavior` |\n| Pixel-perfect rendering | `website/docs/plugins/pixel-perfect-rendering/` |\n| React / Vue / Web Components | `website/tutorials/react/`, `website/tutorials/vuejs/`, `website/tutorials/webcomponents/` |\n| SSR / script loading / bundlers | installed package `dist/` files, package `exports`, framework docs for client-only components |\n| iOS / Android wrappers | `website/docs/ios.md`, `website/docs/android.md` |\n| Version migration | `website/docs/migrations/from-v2-to-v3.md`, `from-v3-to-v4.md`, `from-v4-to-v5.md` |\n\nIf these repo paths do not exist in the user's project, do not ask them to create or clone the source tree just to answer a normal usage question. Use `node_modules/lightweight-charts/dist/typings.d.ts` and concise v5 examples.\n\n## Foot-guns (assertions, not categories)\n\n### Time\n\n- **`UTCTimestamp` is in seconds.** Use `Math.floor(Date.now() / 1000)`, never `Date.now()`.\n- **There is no built-in `timeScale.timezone` option.** For display-only timezone conversion, use `timeScale.tickMarkFormatter` for axis labels and `localization.timeFormatter` (or your own tooltip formatter) for crosshair/hover labels. Use `Intl.DateTimeFormat(..., { timeZone })`, Luxon, or date-fns-tz for DST-safe IANA timezone formatting.\n- **Pre-shifting timestamps changes chart semantics.** It can make ticks line up in a chosen timezone, but it also changes where bars sit on the UTC time scale. Prefer formatter-based display unless the user intentionally wants shifted data.\n- **Series data must be strictly ascending by `time`, with unique values.** Duplicates replace silently; out-of-order points are dropped or throw.\n- **One time format per series.** `BusinessDay` (`'YYYY-MM-DD'` string or `{ year, month, day }`) or `UTCTimestamp`, but do not mix within a single series.\n- **Business day strings must be zero-padded `'YYYY-MM-DD'`.** `'2024-1-5'`, `'2024/01/05'` or `'Jan 5 2024'` throw. Pad the string or pass `{ year, month, day }`.\n- **Whitespace points carry `time` only** (no `value` / `open` / …). Use them to create gaps or align overlays; do not set values to `null`.\n- **`setData` replaces the dataset and can reset the visible range. `update(point)` appends if `time > last` and replaces if `time === last`.** `update(point, true)` can update an existing historical point, but it is slower and does not insert missing old points. To prepend older history, build a new array and call `setData` again — there is no prepend method; save and restore the visible logical range to avoid the chart snapping.\n- **`timeScale.setVisibleLogicalRange` is logical (bar indices), not time-based.** Use `setVisibleRange` for time bounds, or `fitContent()` to reset.\n\n### Scales and panes\n\n- **Two visible price scales** requires both assigning series with `priceScaleId: 'right'` / `'left'` and making the left scale visible. Use `chart.applyOptions({ leftPriceScale: { visible: true }, rightPriceScale: { visible: true } })` or `chart.priceScale('left').applyOptions({ visible: true })`.\n- **Overlay series** (`priceScaleId: ''` or any custom id) get an autoscaled, hidden scale by default. Make it visible explicitly if you want axis labels.\n- **`autoscaleInfoProvider` runs on every layout pass.** Keep it cheap; do not allocate per call.\n- **`addSeries(_, _, paneIndex)` creates the pane** if `paneIndex` is one past the current count. Pane order is creation order; sizes are controlled via `chart.panes()[i].setHeight(px)`.\n- **Keep pane references if panes can move.** `const mainPane = chart.panes()[0]` remains the same `IPaneApi`; `mainPane.paneIndex()` gives its current index after `swapPanes` or moves.\n- **Sync separate charts with public time-scale events.** Use `subscribeVisibleLogicalRangeChange` and `setVisibleLogicalRange`; avoid `_private__chartWidget`, `paneWidgets`, or DOM offset hacks.\n- **Price-scale width is readable, not directly settable.** Use `series.priceScale().width()` or `chart.priceScale(id).width()` to measure when aligning adjacent containers.\n\n### Markers and interaction\n\n- **v5 markers are a primitive.** `const m = createSeriesMarkers(series, [...]); m.setMarkers([...])`. `series.setMarkers` does not exist on `ISeriesApi` in v5.\n- **Marker `time` must match an existing data point's `time`** for that series. Misaligned markers are dropped silently.\n- **`subscribeCrosshairMove`** fires with `param.time === undefined` outside the data range. Always null-check before reading.\n- **`param.seriesData.get(series)`** returns `undefined` between bars or before the first bar.\n- **Click/crosshair coordinates need API conversion.** Use `series.coordinateToPrice(y)` / `series.priceToCoordinate(price)` and `chart.timeScale().coordinateToLogical(x)` / `logicalToCoordinate(logical)` / `timeToCoordinate(time)`; do not infer price/time from canvas DOM geometry.\n\n### Plugins and custom rendering\n\n- **Start plugins from the scaffold/examples.** Prefer `npm create lwc-plugin@latest` and `plugin-examples/` before writing a primitive from scratch.\n- **Interactive drawing tools need two parts:** a primitive/custom series for rendering, and chart interaction handlers (`subscribeClick`, `subscribeCrosshairMove`, drag state) that convert coordinates with public APIs.\n- **`CanvasRenderingTarget2D` is imported from `fancy-canvas`,** not from `lightweight-charts`.\n- Use `target.useBitmapCoordinateSpace(scope => …)` for pixel-aligned strokes; use `target.useMediaCoordinateSpace(scope => …)` for CSS-pixel logic. Mixing them causes blur or sub-pixel jitter on HiDPI displays.\n- **`IPanePrimitive` views render across the whole pane; `ISeriesPrimitive` views are clipped to the series.** Pick the right base.\n- **The renderer interface is `IPrimitivePaneRenderer`, not `IPanePrimitivePaneRenderer`.** The view is `IPanePrimitivePaneView` and its `renderer()` returns `IPrimitivePaneRenderer | null` — the names are deliberately asymmetric. There is no `IPanePrimitivePaneRenderer` export; grep `dist/typings.d.ts` if unsure.\n- **`ICustomSeriesPaneView` is heavier than a primitive** — only use it when you need a true series API (data, scales, autoscale). For decorations, use a primitive.\n\n### Wrappers (React/Vue/etc.)\n\n- **Create the chart once** in `useEffect` / `onMounted` and destroy it in cleanup with `chart.remove()`. Recreating on every render duplicates DOM and leaks listeners.\n- **Resize can be automatic in v5** with `autoSize: true` when `ResizeObserver` is available. If you need manual control, subscribe a `ResizeObserver` to the container and call `chart.resize(width, height)` (or `applyOptions({ width, height })`).\n- **Don't drive `setData` from props on every render.** Use `series.update(...)` for incremental changes; only call `setData` when the dataset truly replaces.\n- **`undefined` in `applyOptions` means \"not specified\", not \"reset\".** `{ priceFormatter: custom ? fmt : undefined }` leaves the current formatter in place. To clear a `localization` formatter or `autoscaleInfoProvider`, pass `null`. Other options have no reset value: pass the default explicitly.\n- **Next.js/SSR must be client-only.** Put chart code in a `'use client'` component, create it in `useEffect`, and import that component with `next/dynamic(..., { ssr: false })` from server-rendered pages when needed.\n- **Plain HTML is not npm resolution.** The standalone `.js` build exposes `window.LightweightCharts`; ESM in the browser must import an actual `.mjs` URL or use an import map. `import { createChart } from 'lightweight-charts'` only works when a bundler/runtime resolves the package name.\n\n## Canonical recipes\n\n### Realtime updates\n\n```ts\nimport { createChart, CandlestickSeries } from 'lightweight-charts';\n\nconst chart = createChart(container, {});\nconst series = chart.addSeries(CandlestickSeries, {});\nseries.setData(initialBars); // full history once\n\nws.onmessage = ev => {\n    const bar = JSON.parse(ev.data); // { time, open, high, low, close }\n    series.update(bar); // appends if time > last; replaces if time === last\n};\n```\n\n`update()` only handles the latest bar. To insert in the middle or prepend, rebuild the array and call `setData`.\n\n### Two price scales (left + right)\n\n```ts\nconst right = chart.addSeries(LineSeries, { priceScaleId: 'right' });\nconst left  = chart.addSeries(LineSeries, { priceScaleId: 'left' });\nchart.applyOptions({\n    leftPriceScale: { visible: true },\n    rightPriceScale: { visible: true },\n});\n```\n\n### Volume in its own pane\n\n```ts\nconst price  = chart.addSeries(CandlestickSeries, {}, 0);\nconst volume = chart.addSeries(\n    HistogramSeries,\n    { priceFormat: { type: 'volume' } },\n    1,\n);\nchart.panes()[1].setHeight(120);\n```\n\n### Per-bar / per-point colors\n\nColor individual bars by putting the color on the **data point**, not via a separate API:\n\n```ts\n// Candlesticks: per-point color / borderColor / wickColor override series defaults\ncandles.setData([\n    { time: 1700000000, open: 1, high: 2, low: 0.5, close: 1.5,\n      color: '#26a69a', borderColor: '#26a69a', wickColor: '#26a69a' },\n    { time: 1700003600, open: 1.5, high: 1.8, low: 1.1, close: 1.2,\n      color: '#ef5350', borderColor: '#ef5350', wickColor: '#ef5350' },\n]);\n\n// Histogram (e.g. up/down volume): per-point color\nvolume.setData([\n    { time: 1700000000, value: 100, color: 'rgba(38,166,154,0.5)' },\n    { time: 1700003600, value: 80, color: 'rgba(239,83,80,0.5)' },\n]);\n```\n\nLine/Area points also take a per-point `color`. An omitted point color falls back to the series option. Do not create extra series or use markers to recolor bars.\n\n### Series markers\n\n```ts\nimport { createSeriesMarkers } from 'lightweight-charts';\n\nconst markers = createSeriesMarkers(candles, [\n    { time: 1700000000, position: 'aboveBar', color: '#e53935', shape: 'arrowDown', text: 'Sell' },\n]);\n\nmarkers.setMarkers([\n    { time: 1700003600, position: 'belowBar', color: '#43a047', shape: 'arrowUp', text: 'Buy' },\n]);\n```\n\n`color` is required on every marker (`position`, `shape`, `time` too); `text`, `size`, `id`, `price` are optional. Do not put marker objects into `setData()` points. Do not call `series.setMarkers(...)` in v5.\n\n### Timezone display\n\n```ts\nconst zone = 'America/New_York';\nconst formatTime = (timestamp: number) =>\n    new Intl.DateTimeFormat('en-US', {\n        timeZone: zone,\n        hour: '2-digit',\n        minute: '2-digit',\n        second: '2-digit',\n        hour12: false,\n    }).format(new Date(timestamp * 1000));\n\nchart.applyOptions({\n    timeScale: {\n        timeVisible: true,\n        secondsVisible: true,\n        tickMarkFormatter: (time) =>\n            typeof time === 'number' ? formatTime(time) : String(time),\n    },\n    localization: {\n        timeFormatter: (time) =>\n            typeof time === 'number' ? formatTime(time) : String(time),\n    },\n});\n```\n\nDo not invent `timeScale: { timezone: 'America/New_York' }`. If the user needs exchange-session boundaries to generate in a local timezone, explain the trade-off of shifting source timestamps separately from display formatting.\n\n### Text watermark\n\n```ts\nimport { createTextWatermark } from 'lightweight-charts';\n\ncreateTextWatermark(chart.panes()[0], {\n    horzAlign: 'center',\n    vertAlign: 'center',\n    lines: [{ text: 'DEMO', color: 'rgba(0, 0, 0, 0.25)', fontSize: 48 }],\n});\n```\n\nThe old `watermark` chart option is not the v5 API.\n\n### Whitespace gaps\n\n```ts\nline.setData([\n    { time: '2024-01-01', value: 10 },\n    { time: '2024-01-02' }, // whitespace point: time only\n    { time: '2024-01-03', value: 12 },\n]);\n```\n\nDo not use `value: null`, `undefined`, or `NaN` to create gaps.\n\n### Sync separate charts or panes\n\n```ts\nlet syncing = false;\n\npriceChart.timeScale().subscribeVisibleLogicalRangeChange((range) => {\n    if (!range || syncing) return;\n    syncing = true;\n    indicatorChart.timeScale().setVisibleLogicalRange(range);\n    syncing = false;\n});\n\nindicatorChart.timeScale().subscribeVisibleLogicalRangeChange((range) => {\n    if (!range || syncing) return;\n    syncing = true;\n    priceChart.timeScale().setVisibleLogicalRange(range);\n    syncing = false;\n});\n```\n\nFor v5 panes inside one chart, prefer `chart.addSeries(SeriesType, options, paneIndex)` and `chart.panes()[i].setHeight(px)`. If the original pane can move, keep the `IPaneApi` reference and call `pane.paneIndex()` instead of assuming index `0` forever.\n\n### Coordinate conversion\n\n```ts\nchart.subscribeClick((param) => {\n    if (!param.point || param.time === undefined) return;\n\n    const price = series.coordinateToPrice(param.point.y);\n    const logical = chart.timeScale().coordinateToLogical(param.point.x);\n    if (price === null || logical === null) return;\n\n    // Store { time: param.time, price } or convert logical back later:\n    const x = chart.timeScale().logicalToCoordinate(logical);\n    const y = series.priceToCoordinate(price);\n});\n```\n\nUse the public conversion APIs for drawing tools and annotations. DOM canvas coordinates alone cannot tell you the chart price/time.\n\n### Next.js client-only component\n\n```tsx\n'use client';\n\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport type { ISeriesApi, LineData, Time } from 'lightweight-charts';\nimport { useEffect, useRef } from 'react';\n\nexport function LwcChart({ data }: { data: LineData<Time>[] }) {\n    const ref = useRef<HTMLDivElement | null>(null);\n    const seriesRef = useRef<ISeriesApi<'Line'> | null>(null);\n\n    useEffect(() => {\n        if (!ref.current) return;\n        const chart = createChart(ref.current, { autoSize: true });\n        const series = chart.addSeries(LineSeries);\n        seriesRef.current = series;\n        return () => {\n            seriesRef.current = null;\n            chart.remove();\n        };\n    }, []);\n\n    useEffect(() => {\n        seriesRef.current?.setData(data);\n    }, [data]);\n\n    return <div ref={ref} style={{ width: '100%', height: 320 }} />;\n}\n```\n\nFrom a server-rendered Next.js page, import the component with:\n\n```tsx\nimport dynamic from 'next/dynamic';\n\nconst LwcChart = dynamic(() => import('./LwcChart').then((m) => m.LwcChart), {\n    ssr: false,\n});\n```\n\n### Plain HTML loading\n\nUse the standalone IIFE build when there is no bundler:\n\n```html\n<div id=\"chart\" style=\"width: 600px; height: 300px\"></div>\n<script src=\"https://unpkg.com/lightweight-charts/dist/lightweight-charts.standalone.production.js\"></script>\n<script>\n  const chart = LightweightCharts.createChart(document.getElementById('chart'));\n  const series = chart.addSeries(LightweightCharts.LineSeries);\n</script>\n```\n\nChoose the loading shape by environment:\n\n- **Bundler (Vite/webpack/Next):** bare `import { createChart } from 'lightweight-charts'`. The package `exports` resolve the right ESM/CJS build.\n- **Browser `<script>` (no bundler):** the standalone IIFE build above exposes the `LightweightCharts` global; there is no bare-specifier resolution.\n- **Browser native ESM (`<script type=\"module\">`):** import from a concrete `.mjs` URL (e.g. the standalone `.mjs`) or add an import map; a bare `'lightweight-charts'` specifier will not resolve.\n- **SSR frameworks:** load client-only (see the Next.js recipe above) — never import at module top level in a server component.\n\n### Plugin starter\n\n```sh\nnpm create lwc-plugin@latest\n```\n\nUse the generated project and `plugin-examples/` as the base. Decide the extension type first:\n\n- **Primitive** (`IPanePrimitive` / `ISeriesPrimitive`, attached via `attachPrimitive`) — for drawings, overlays, labels, bands, annotations, hit-testing. This is the default; reach for it unless you need real series behavior.\n- **Custom series** (`ICustomSeriesPaneView`) — only when the extension needs its own data, autoscale, or price/time-scale integration. It is heavier; do not use it for decorations.\n\nFor draggable drawings, attach a primitive with `series.attachPrimitive(...)` or `pane.attachPrimitive(...)`, then manage interaction with `subscribeClick` / `subscribeCrosshairMove` and coordinate conversion APIs. Import renderer-only `CanvasRenderingTarget2D` from `fancy-canvas`. The renderer interface is `IPrimitivePaneRenderer` (not `IPanePrimitivePaneRenderer`).\n\n### Non-financial data\n\n```ts\nimport { createOptionsChart } from 'lightweight-charts';\n\nconst chart = createOptionsChart(container);\n```\n\nDecide first whether the horizontal axis is truly non-time:\n\n- **True custom horizontal scale** (option chains, sensor sweeps by a non-time key): use `createOptionsChart` for a numeric x-axis, or `createChartEx` with a custom `IHorzScaleBehavior` (verify both in local typings).\n- **Just non-financial y units** (temperature, load) on an ordinary time/category axis: keep the normal `createChart` series model and set `priceFormat` / `localization.priceFormatter` so labels match the domain.\n- **Categorical x that is really ordered**: mapping categories to ascending `BusinessDay` strings is simpler than a custom scale — but say that the axis is then date-like, not truly categorical.\n\n### Custom price formatter\n\n```ts\nchart.applyOptions({\n    localization: {\n        priceFormatter: (p: number) => `$${p.toFixed(2)}`,\n    },\n});\n```\n\nFor per-series formatting, set `priceFormat: { type: 'custom', formatter, minMove }` in the series options — the chart-level `priceFormatter` is the fallback.\n\nTo go back to the built-in formatting, pass `null`: `chart.applyOptions({ localization: { priceFormatter: null } })`. Passing `undefined` leaves the current formatter in place.\n\n### Minimal pane primitive\n\n```ts\nimport type {\n    IPanePrimitive,\n    IPanePrimitivePaneView,\n    IPrimitivePaneRenderer,\n    Time,\n} from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D } from 'fancy-canvas';\n\nclass Overlay implements IPanePrimitive<Time> {\n    paneViews(): IPanePrimitivePaneView[] { return [new View()]; }\n}\nclass View implements IPanePrimitivePaneView {\n    renderer(): IPrimitivePaneRenderer { return new Renderer(); }\n}\nclass Renderer implements IPrimitivePaneRenderer {\n    draw(target: CanvasRenderingTarget2D): void {\n        target.useMediaCoordinateSpace(({ context, mediaSize }) => {\n            context.fillStyle = 'rgba(0,0,0,0.05)';\n            context.fillRect(0, 0, mediaSize.width, mediaSize.height);\n        });\n    }\n}\n\nchart.panes()[0].attachPrimitive(new Overlay());\n```\n\nWorking examples live under `plugin-examples/src/plugins/` — copy structure from there before writing one from scratch.\n\n## Worked example\n\n> *\"My chart snaps to the right edge every time new data arrives.\"*\n\n1. **Layers involved:** data model (4) and time scale (3).\n2. **Suspect:** the code calls `series.setData(...)` on every tick instead of `series.update(...)`. `setData` resets the visible range.\n3. **Verify:** ask whether the call path is `setData` or `update`. If `setData`, ask whether the visible logical range is captured before and restored after — the v4-era workaround.\n4. **Fix:** switch to `series.update(bar)` for incremental ticks; reserve `setData` for full-history replacement; only use `chart.timeScale().scrollToRealTime()` if the user explicitly wants follow-the-latest behavior.\n5. **References:** `website/examples/data/realtime-updates.js`, `website/docs/time-scale.md`.\n\n## Code-generation rules\n\n- **Default to v5.** Assume v5 APIs unless the user's installed package or prompt pins an older version. If they're on v4, explain the v5 migration point instead of mixing syntaxes.\n- **Use real option names.** In consumer apps, grep `node_modules/lightweight-charts/dist/typings.d.ts`; in the upstream repo, grep `dist/typings.d.ts` or `src/api/options/`. Many similarly-named options exist across chart/series/scale — confirm which level owns the option.\n- **Minimal snippets.** One feature per code block. Combining markers + watermark + custom pane primitive in one snippet hides which API does what.\n- **Match the user's framework.** A React user wants the `useEffect` lifecycle; a vanilla user does not.\n- **Don't invent.** If an API name does not appear in the installed typings or upstream source, it does not exist.\n\n## Answer contract\n\nWhen answering a lightweight-charts question:\n\n1. Name the relevant v5 API.\n2. Show one minimal snippet, not a mega-demo.\n3. Call out the main foot-gun for that task.\n4. Say what local source was checked (version/typings), or state that it could not be verified.\n","frontmatter":{"name":"lightweight-charts","description":"Use when working with TradingView's lightweight-charts — creating charts, adding series (Line/Area/Bar/Candlestick/Histogram), configuring time and price scales, streaming realtime or historical data, panes, markers, per-bar/per-point colors, tooltips, coordinate conversion, custom plugins or primitives, non-financial horizontal scales, SSR/browser loading, or React/Vue/Web Components wrappers. Covers v5 API conventions and the common time, scale, marker, plugin, and wrapper foot-guns."},"isInternal":false,"tokens":6968,"sizeBytes":28340},{"name":"canvas-rendering-target.md","path":"website/docs/plugins/canvas-rendering-target.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/website/docs/plugins/canvas-rendering-target.md","title":"Plugins Skill","category":"anthropic-skill","format":"markdown","content":"---\nsidebar_label: Canvas rendering target\ntitle: Canvas rendering target\nsidebar_position: 4\n---\n\nThe renderer functions of a plugin — whether it is a custom series or a\nprimitive — receive a `CanvasRenderingTarget2D` target to execute their\ndrawing logic on, using the browser's\n[2D Canvas API](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D).\n`CanvasRenderingTarget2D` comes from the\n[Fancy Canvas](https://github.com/tradingview/fancy-canvas) library; its\ndefinition can be viewed in\n[canvas-rendering-target.d.ts](https://unpkg.com/fancy-canvas/canvas-rendering-target.d.ts)\nwithin the published\n[TypeScript declarations](https://www.npmjs.com/package/fancy-canvas?activeTab=code).\n\n## Using CanvasRenderingTarget2D\n\n`CanvasRenderingTarget2D` provides two rendering scopes which you can use:\n\n- `useMediaCoordinateSpace`\n- `useBitmapCoordinateSpace`\n\n## Difference between bitmap and media\n\nBitmap sizing represents the actual physical pixels on the device's screen,\nwhile media sizing represents the size of a pixel as seen by the operating\nsystem and the browser. The number of physical pixels used to render one media\npixel is referred to as the device pixel ratio.\n\nBitmap sizing gives you more control over the drawn image and lets you keep\nthe graphics crisp and pixel perfect; the cost is that the code multiplies\ncoordinates by the pixel ratio throughout. When you don't need that precision,\nmedia sizing is easier: you don't have to think about the device pixel ratio\nat all.\n\n### Bitmap coordinate space\n\nUse `useBitmapCoordinateSpace` to draw with the actual device pixels as the\ncoordinate sizing. The provided scope (of type\n`BitmapCoordinatesRenderingScope`) contains readonly values for the following:\n\n- `context`\n  ([CanvasRenderingContext2D](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D)).\n  Context which can be used for rendering.\n- `horizontalPixelRatio` (number)\n- `verticalPixelRatio` (number)\n- `bitmapSize` (Size). Height and width of the canvas in bitmap dimensions.\n- `mediaSize` (Size). Height and width of the canvas in media dimensions.\n\n#### Bitmap coordinate space usage\n\n```js title='javascript'\n// target is an instance of CanvasRenderingTarget2D\ntarget.useBitmapCoordinateSpace(scope => {\n    // scope is an instance of BitmapCoordinatesRenderingScope\n\n    // example of drawing a filled rectangle which fills the canvas\n    scope.context.beginPath();\n    scope.context.rect(0, 0, scope.bitmapSize.width, scope.bitmapSize.height);\n    scope.context.fillStyle = 'rgba(100, 200, 50, 0.5)';\n    scope.context.fill();\n});\n```\n\n### Media coordinate space\n\nUse `useMediaCoordinateSpace` to draw with the media dimensions as the\ncoordinate sizing. The provided scope (of type\n`MediaCoordinatesRenderingScope`) contains readonly values for the following:\n\n- `context`\n  ([CanvasRenderingContext2D](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D)).\n  Context which can be used for rendering.\n- `mediaSize` (Size). Height and width of the canvas in media dimensions.\n\n#### Media coordinate space usage\n\n```js title='javascript'\n// target is an instance of CanvasRenderingTarget2D\ntarget.useMediaCoordinateSpace(scope => {\n    // scope is an instance of MediaCoordinatesRenderingScope\n\n    // example of drawing a filled rectangle which fills the canvas\n    scope.context.beginPath();\n    scope.context.rect(0, 0, scope.mediaSize.width, scope.mediaSize.height);\n    scope.context.fillStyle = 'rgba(100, 200, 50, 0.5)';\n    scope.context.fill();\n});\n```\n\n## General tips\n\nIt is recommended that rendering functions save and restore the canvas context\nbefore and after all their rendering logic, so the canvas state is the same as\nwhen the function was called. Wrap the logic in a `try…finally` block so the\ncontext is restored even when an error interrupts the drawing.\n\n**Note** that `useBitmapCoordinateSpace` and `useMediaCoordinateSpace`\nautomatically save and restore the canvas context for the logic defined within\nthem. This tip applies to your additional rendering functions called inside\n`use*CoordinateSpace`.\n\n```js title='javascript'\nfunction myRenderingFunction(scope) {\n    const ctx = scope.context;\n\n    // save the current state of the context to the stack\n    ctx.save();\n\n    try {\n        // example code\n        scope.context.beginPath();\n        scope.context.rect(0, 0, scope.mediaSize.width, scope.mediaSize.height);\n        scope.context.fillStyle = 'rgba(100, 200, 50, 0.5)';\n        scope.context.fill();\n    } finally {\n        // restore the saved context from the stack\n        ctx.restore();\n    }\n}\n\ntarget.useMediaCoordinateSpace(scope => {\n    myRenderingFunction(scope);\n    myOtherRenderingFunction(scope);\n    /* ... */\n});\n```\n","frontmatter":{"sidebar_label":"Canvas rendering target","title":"Canvas rendering target","sidebar_position":4},"isInternal":false,"tokens":1053,"sizeBytes":4782},{"name":"custom_series.md","path":"website/docs/plugins/custom_series.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/website/docs/plugins/custom_series.md","title":"Plugins Skill","category":"anthropic-skill","format":"markdown","content":"---\nsidebar_label: Custom series\ntitle: Custom series\nsidebar_position: 3\n---\n\n**Custom series** let you define new types of series with your own data\nstructures and rendering logic. A custom series mirrors the API of the\nbuilt-in series: you add it to the chart once, then manage it with the same\nmethods you already use, such as\n[`setData`](../api/interfaces/ISeriesApi.md#setdata) and\n[`applyOptions`](../api/interfaces/ISeriesApi.md#applyoptions). For primitives\nthat decorate an existing series rather than define a new one, see\n[Series primitives](./series-primitives.mdx).\n\n## Adding a custom series\n\nA custom series is defined by a class implementing the\n[`ICustomSeriesPaneView`](../api/interfaces/ICustomSeriesPaneView.md)\ninterface. Pass an instance of it to the\n[`addCustomSeries`](../api/interfaces/IChartApi.md#addcustomseries) method,\nthen work with the returned series as with any other:\n\n```javascript title='javascript'\nclass MyCustomSeries {\n    /* Class implementing the ICustomSeriesPaneView interface */\n}\n\n// Create an instantiated custom series\nconst customSeriesInstance = new MyCustomSeries();\n\nconst chart = createChart(document.getElementById('container'));\nconst myCustomSeries = chart.addCustomSeries(customSeriesInstance, {\n    // Options for MyCustomSeries\n    customOption: 10,\n});\n\nconst data = [\n    { time: 1642425322, value: 123, customValue: 456 },\n    /* ... more data */\n];\n\nmyCustomSeries.setData(data);\n```\n\nTo remove a custom series, use the standard\n[`removeSeries`](../api/interfaces/IChartApi.md#removeseries) method:\n\n```javascript title='javascript'\nchart.removeSeries(myCustomSeries);\n```\n\nThese series are expected to have a uniform width for each data point, which\nensures that the chart maintains a consistent look and feel across all series\ntypes. The only restriction on the data structure is that it should extend the\n[`CustomData`](../api/interfaces/CustomData.md) interface (have a valid time\nproperty for each data point).\n\n## Defining a custom series\n\nThe [`ICustomSeriesPaneView`](../api/interfaces/ICustomSeriesPaneView.md)\ninterface defines the functionality and structure required of a custom series.\nIt includes the following methods and properties:\n\n### Renderer\n\nThe [`renderer`](../api/interfaces/ICustomSeriesPaneView.md#renderer) method\nreturns the renderer that draws the series data on the main chart pane. The\nrenderer must implement the\n[`ICustomSeriesPaneRenderer`](../api/interfaces/ICustomSeriesPaneRenderer.md)\ninterface.\n\nThe library calls the renderer's\n[`draw`](../api/interfaces/ICustomSeriesPaneRenderer.md#draw) method whenever\nthe chart needs to draw the series.\n\nThe [`PriceToCoordinateConverter`](../api/type-aliases/PriceToCoordinateConverter.md)\nprovided as the 2nd argument to the draw method is a convenience function for\nchanging prices into vertical coordinate values. It is provided since the\nseries' original data will most likely be defined in price values, and the\nrenderer needs to draw with coordinates. The values returned by the converter\nare in media coordinates (unscaled by `devicePixelRatio`).\nSee the [Canvas rendering target](./canvas-rendering-target.md) page for more\ndetails on the `CanvasRenderingTarget2D` provided to the `draw` method.\n\n### Update\n\nThe [`update`](../api/interfaces/ICustomSeriesPaneView.md#update) method is\ncalled with the latest data for the renderer to use during the next paint. It\nreceives two parameters: `data` (described below) and `seriesOptions`, a\nreference to the currently applied options for the series.\n\nThe [`PaneRendererCustomData`](../api/interfaces/PaneRendererCustomData.md)\ninterface provides the data that can be used within the renderer for drawing the\nseries data. It includes the following properties:\n\n- `bars`: list of all the series' items and their x coordinates. See\n  [`CustomBarItemData`](../api/interfaces/CustomBarItemData.md) for more details\n- `barSpacing`: spacing between consecutive bars.\n- `visibleRange`: the current visible range of items on the chart.\n\n### Hit testing\n\nThe renderer can implement the optional\n[`hitTest`](../api/interfaces/ICustomSeriesPaneRenderer.md#hittest) method to\nparticipate directly in hover and click resolution.\n\nReturn `null` when the cursor misses the custom geometry. Return a\n[`CustomSeriesHitTestResult`](../api/interfaces/CustomSeriesHitTestResult.md)\nwhen the cursor hits a custom object. The result can provide:\n\n- `distance`: geometric distance from the cursor to the hit\n- `type`: optional geometric classification such as `point`, `line`, `range`, or `custom`\n- `objectId`: optional object identifier that becomes `hoveredObjectId`\n- `cursorStyle`: optional cursor override\n- `hitTestData`: optional renderer-defined hover data passed back into `draw`\n\nThis hook lets the custom series participate in the same geometry-first\narbitration model as built-in series.\n\nThe `type` field is used for hover arbitration only. Public mouse events still\nreport `hoveredInfo.type` as `custom` for custom-series hits. Use `objectId`\nand `hoveredInfo.objectKind` to distinguish custom sub-objects.\n\n### Price value builder\n\nThe\n[`priceValueBuilder`](../api/interfaces/ICustomSeriesPaneView.md#pricevaluebuilder)\nmethod interprets a data item and returns an array of numbers: the equivalent\nhighest, lowest, and current price values for that item.\n\nThese price values are used by the chart to determine the auto-scaling (to\nensure the items are in view) and the crosshair and price line positions. The\nlargest and smallest values in the array will be used to specify the visible\nrange of the painted item, and the last value will be used for the crosshair and\nprice line position.\n\n### Whitespace\n\nThe\n[`isWhitespace`](../api/interfaces/ICustomSeriesPaneView.md#iswhitespace)\nmethod tells the library which data points should be treated as whitespace:\nreturn `true` for a whitespace item. Whitespace data points are not passed to\nthe renderer or to the `priceValueBuilder`.\n\n### Default options\n\nThe\n[`defaultOptions`](../api/interfaces/ICustomSeriesPaneView.md#defaultoptions)\nproperty provides the default options for the series. The user can override\nthem with the options argument of\n[`addCustomSeries`](../api/interfaces/IChartApi.md#addcustomseries), or later\nvia the [`applyOptions`](../api/interfaces/ISeriesApi.md#applyoptions) method\non the series.\n\n### Destroy\n\nThe [`destroy`](../api/interfaces/ICustomSeriesPaneView.md#destroy) method is\ncalled when the series is removed from the chart. Use it to clean up\neverything that could outlive the series and cause memory leaks: event\nlisteners, timers, and references to other objects.\n","frontmatter":{"sidebar_label":"Custom series","title":"Custom series","sidebar_position":3},"isInternal":false,"tokens":1476,"sizeBytes":6639},{"name":"intro.md","path":"website/docs/plugins/intro.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/website/docs/plugins/intro.md","title":"Plugins Skill","category":"anthropic-skill","format":"markdown","content":"---\nsidebar_label: Overview\nsidebar_position: 0\n---\n\n# Plugin development\n\n**Plugins** let you extend Lightweight Charts™ with your own functionality: new\nseries types, drawing tools, indicators, watermarks, and other custom elements\nrendered as part of the chart. This section explains how plugins work and how\nto build your own.\n\n:::tip\n\nLooking for a ready-made plugin instead of building one? Browse the\n[plugin catalog](/plugins).\n\n:::\n\n## Choosing a plugin type\n\n| You want to build | Plugin type | Attach with |\n| --- | --- | --- |\n| A drawing tool, annotation, or overlay tied to a series and its scales | [Series primitive](./series-primitives.mdx) | [`ISeriesApi.attachPrimitive`](../api/interfaces/ISeriesApi.md#attachprimitive) |\n| A pane-wide element independent of any series, such as a watermark | [Pane primitive](./pane-primitives.md) | [`IPaneApi.attachPrimitive`](../api/interfaces/IPaneApi.md#attachprimitive) |\n| A new way to draw data: a series with its own data structure and rendering | [Custom series](./custom_series.md) | [`addCustomSeries`](../api/interfaces/IChartApi.md#addcustomseries) |\n\n:::tip\n\nIf your element visualizes its own data, build a custom series;\nif it decorates a series or reacts to its scales, build a series primitive;\nif it belongs to the pane as a whole, build a pane primitive.\nSeries primitives can also render on the price and time scales; pane primitives cannot.\n\n:::\n\n## Development workflow\n\n1. **Scaffold a project.** Run `npm create lwc-plugin@latest` — the\n   [create-lwc-plugin](https://www.npmjs.com/package/create-lwc-plugin)\n   package generates a ready-to-run project for the plugin type you choose.\n   The wizard also offers to install the plugin-authoring\n   [Agent Skill](../ai.md#ai-coding-assistants), which teaches AI coding\n   assistants how to write Lightweight Charts™ plugins.\n2. **Implement the plugin interface.** Follow the article for your plugin type\n   from the table above.\n3. **Render on the canvas.** Draw in the right coordinate space with\n   [Canvas rendering target](./canvas-rendering-target.md), and keep lines\n   crisp with the [Pixel perfect rendering](./pixel-perfect-rendering/index.md)\n   techniques.\n4. **Learn from working code.** The\n   [Plugin examples demo](https://tradingview.github.io/lightweight-charts/plugin-examples)\n   hosts interactive examples of heatmaps, alerts, watermarks, and tooltips;\n   their sources live in the\n   [`plugin-examples`](https://github.com/tradingview/lightweight-charts/tree/master/plugin-examples)\n   folder of the repository.\n","frontmatter":{"sidebar_label":"Overview","sidebar_position":0},"isInternal":false,"tokens":597,"sizeBytes":2566},{"name":"pane-primitives.md","path":"website/docs/plugins/pane-primitives.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/website/docs/plugins/pane-primitives.md","title":"Plugins Skill","category":"anthropic-skill","format":"markdown","content":"---\nsidebar_label: Pane primitives\ntitle: Pane primitives\nsidebar_position: 2\n---\n\n**Pane primitives** are primitives attached to a chart pane rather than to a specific series.\nUse pane primitives for chart-wide elements that are not tied to any series' data, such as watermarks.\nThe library's built-in text and image watermarks are implemented this way.\nFor series-bound primitives, see [Series primitives](./series-primitives.mdx).\n\n## Attaching a primitive\n\nA pane primitive is a class implementing the\n[`IPanePrimitive`](../api/type-aliases/IPanePrimitive.md) interface.\nCreate an instance of your primitive and attach it to a pane with the\n[`attachPrimitive`](../api/interfaces/IPaneApi.md#attachprimitive) method:\n\n```javascript\nclass MyCustomPanePrimitive {\n    /* Class implementing the IPanePrimitive interface */\n}\n\n// Create an instantiated pane primitive\nconst myCustomPanePrimitive = new MyCustomPanePrimitive();\n\nconst chart = createChart(document.getElementById('container'));\n// Get the main pane\nconst mainPane = chart.panes()[0];\n\n// Attach the primitive to the pane\nmainPane.attachPrimitive(myCustomPanePrimitive);\n```\n\nTo remove the primitive from the pane, use the\n[`detachPrimitive`](../api/interfaces/IPaneApi.md#detachprimitive) method:\n\n```javascript\nmainPane.detachPrimitive(myCustomPanePrimitive);\n```\n\n## Key differences from series primitives\n\nPane primitives follow the same model as\n[series primitives](./series-primitives.mdx) — views that return renderers,\nthe `attached` / `detached` lifecycle, `updateAllViews`, and hit testing —\nwith four differences:\n\n- A pane primitive is attached to a pane, so\n  [`paneViews`](../api/interfaces/IPanePrimitiveBase.md#paneviews) is its only\n  view getter: it cannot draw on the price or time scales, or define axis\n  labels.\n- The `attached` method receives\n  [`{ chart, requestUpdate }`](../api/interfaces/PaneAttachedParameter.md)\n  without a series reference.\n- There is no `autoscaleInfo`: a pane primitive is not tied to a price scale.\n- Within each `zOrder` layer, pane primitives are drawn before the series and their primitives, so a pane primitive on `'normal'` sits under the series. Use `'top'` to draw it above the series.\n\n## Implementing a pane primitive\n\nThe `paneViews` method returns the views that draw on the pane. Each view must\nprovide a `renderer()` method returning the renderer that draws on the canvas:\n\n```javascript\nclass MyCustomPanePrimitive {\n    paneViews() {\n        return [\n            {\n                renderer: () => ({\n                    draw: target => {\n                        // Custom drawing logic here\n                    },\n                }),\n            },\n        ];\n    }\n\n    // Other methods as needed...\n}\n```\n","frontmatter":{"sidebar_label":"Pane primitives","title":"Pane primitives","sidebar_position":2},"isInternal":false,"tokens":590,"sizeBytes":2740},{"name":"index.md","path":"website/docs/plugins/pixel-perfect-rendering/index.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/website/docs/plugins/pixel-perfect-rendering/index.md","title":"Pixel-perfect-rendering Skill","category":"anthropic-skill","format":"markdown","content":"---\nsidebar_position: 0\nsidebar_label: Pixel perfect rendering\npagination_title: Pixel perfect rendering\ntitle: Best practices for pixel perfect rendering in canvas drawings\ndescription: Best practices for pixel perfect rendering in canvas drawings when creating plugins for Lightweight Charts\nkeywords:\n  - plugins\n  - extensions\n  - rendering\n  - canvas\n  - bitmap\n  - media\n  - pixels\npagination_prev: null\n---\n\nTo achieve crisp pixel perfect rendering for your plugins, it is recommended that the canvas drawings are created using bitmap coordinates. The difference between media and bitmap coordinate spaces is discussed on the [Canvas rendering target](../canvas-rendering-target.md) page. **Essentially, all drawing actions should use integer positions and dimensions when on the bitmap coordinate space.**\n\nTo ensure consistency between your plugins and the library's built-in logic for rendering points on the chart, use the following calculation functions.\n\n:::info\n\nVariable names containing `media` refer to positions / dimensions specified using the media coordinate space (such as the x and y coordinates provided by the library to the renderers), and names containing `bitmap` refer to positions / dimensions on the bitmap coordinate space (actual device screen pixels).\n\n:::\n\n## Centered shapes\n\nIf you need to draw a shape which is centered on a position (for example a price or x coordinate) and has a desired width then you could use the `positionsLine` function presented below. This can be used for drawing a horizontal line at a specific price, or a vertical line aligned with the center of a series point.\n\n```typescript\ninterface BitmapPositionLength {\n    /** coordinate for use with a bitmap rendering scope */\n    position: number;\n    /** length for use with a bitmap rendering scope */\n    length: number;\n}\n\nfunction centreOffset(lineBitmapWidth: number): number {\n    return Math.floor(lineBitmapWidth * 0.5);\n}\n\n/**\n * Calculates the bitmap position for an item with a desired length (height or width), and centered according to\n * a position coordinate defined in media sizing.\n * @param positionMedia - position coordinate for the bar (in media coordinates)\n * @param pixelRatio - pixel ratio. Either horizontal for x positions, or vertical for y positions\n * @param desiredWidthMedia - desired width (in media coordinates)\n * @returns Position of the start point and length dimension.\n */\nexport function positionsLine(\n    positionMedia: number,\n    pixelRatio: number,\n    desiredWidthMedia: number = 1,\n    widthIsBitmap?: boolean\n): BitmapPositionLength {\n    const scaledPosition = Math.round(pixelRatio * positionMedia);\n    const lineBitmapWidth = widthIsBitmap\n        ? desiredWidthMedia\n        : Math.round(desiredWidthMedia * pixelRatio);\n    const offset = centreOffset(lineBitmapWidth);\n    const position = scaledPosition - offset;\n    return { position, length: lineBitmapWidth };\n}\n```\n\n## Dual point shapes\n\nIf you need to draw a shape between two coordinates (for example, y coordinates for a high and low price) then you can use the `positionsBox` function as presented below.\n\n```typescript\n/**\n * Determines the bitmap position and length for a dimension of a shape to be drawn.\n * @param position1Media - media coordinate for the first point\n * @param position2Media - media coordinate for the second point\n * @param pixelRatio - pixel ratio for the corresponding axis (vertical or horizontal)\n * @returns Position of the start point and length dimension.\n */\nexport function positionsBox(\n    position1Media: number,\n    position2Media: number,\n    pixelRatio: number\n): BitmapPositionLength {\n    const scaledPosition1 = Math.round(pixelRatio * position1Media);\n    const scaledPosition2 = Math.round(pixelRatio * position2Media);\n    return {\n        position: Math.min(scaledPosition1, scaledPosition2),\n        length: Math.abs(scaledPosition2 - scaledPosition1) + 1,\n    };\n}\n```\n\n## Default widths\n\nRefer to the following pages for functions defining the default widths of shapes drawn by the library:\n\n- [Crosshair and grid lines](./widths/crosshair.md)\n- [Candlesticks](./widths/candlestick.md)\n- [Columns (histogram)](./widths/columns.md)\n- [Full bar width](./widths/full-bar-width.md)\n","frontmatter":{"sidebar_position":0,"sidebar_label":"Pixel perfect rendering","pagination_title":"Pixel perfect rendering","title":"Best practices for pixel perfect rendering in canvas drawings","description":"Best practices for pixel perfect rendering in canvas drawings when creating plugins for Lightweight Charts","keywords":["plugins","extensions","rendering","canvas","bitmap","media","pixels"],"pagination_prev":null},"isInternal":false,"tokens":894,"sizeBytes":4254},{"name":"candlestick.md","path":"website/docs/plugins/pixel-perfect-rendering/widths/candlestick.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/website/docs/plugins/pixel-perfect-rendering/widths/candlestick.md","title":"Widths Skill","category":"anthropic-skill","format":"markdown","content":"---\nsidebar_position: 0\nsidebar_label: Candlesticks\npagination_title: Candlestick Widths\ntitle: Candlestick width calculations\ndescription: Describes the calculation for candlestick body widths\nkeywords:\n  - plugins\n  - extensions\n  - rendering\n  - canvas\n  - bitmap\n  - media\n  - pixels\n  - candlestick\n  - width\n---\n\n:::tip\n\nIt is recommend that you first read the [Pixel Perfect Rendering](../index.md) page.\n\n:::\n\nThe following functions can be used to get the calculated width that the library would use for a candlestick at a specific bar spacing and device pixel ratio.\n\nBelow a bar spacing of 4, the library will attempt to use as large a width as possible without the possibility of overlapping, while above 4 then the width will start to trend towards an 80% width of the available space.\n\n:::warning\n\nIt is expected that candles can overlap slightly at smaller bar spacings (more pronounced on lower resolution devices). This produces a more readable chart. If you need to ensure that bars can never overlap then rather use the widths for [Columns](./columns.md) or the [full bar width](./full-bar-width.md) calculation.\n\n:::\n\n```typescript\nfunction optimalCandlestickWidth(\n    barSpacing: number,\n    pixelRatio: number\n): number {\n    const barSpacingSpecialCaseFrom = 2.5;\n    const barSpacingSpecialCaseTo = 4;\n    const barSpacingSpecialCaseCoeff = 3;\n    if (barSpacing >= barSpacingSpecialCaseFrom && barSpacing <= barSpacingSpecialCaseTo) {\n        return Math.floor(barSpacingSpecialCaseCoeff * pixelRatio);\n    }\n    // coeff should be 1 on small barspacing and go to 0.8 while bar spacing grows\n    const barSpacingReducingCoeff = 0.2;\n    const coeff =\n        1 -\n        (barSpacingReducingCoeff *\n            Math.atan(\n                Math.max(barSpacingSpecialCaseTo, barSpacing) - barSpacingSpecialCaseTo\n            )) /\n            (Math.PI * 0.5);\n    const res = Math.floor(barSpacing * coeff * pixelRatio);\n    const scaledBarSpacing = Math.floor(barSpacing * pixelRatio);\n    const optimal = Math.min(res, scaledBarSpacing);\n    return Math.max(Math.floor(pixelRatio), optimal);\n}\n\n/**\n * Calculates the candlestick width that the library would use for the current\n * bar spacing.\n * @param barSpacing - bar spacing in media coordinates\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @returns The width (in bitmap coordinates) that the chart would use to draw a candle body\n */\nexport function candlestickWidth(\n    barSpacing: number,\n    horizontalPixelRatio: number\n): number {\n    let width = optimalCandlestickWidth(barSpacing, horizontalPixelRatio);\n    if (width >= 2) {\n        const wickWidth = Math.floor(horizontalPixelRatio);\n        if (wickWidth % 2 !== width % 2) {\n            width--;\n        }\n    }\n    return width;\n}\n```\n","frontmatter":{"sidebar_position":0,"sidebar_label":"Candlesticks","pagination_title":"Candlestick Widths","title":"Candlestick width calculations","description":"Describes the calculation for candlestick body widths","keywords":["plugins","extensions","rendering","canvas","bitmap","media","pixels","candlestick","width"]},"isInternal":false,"tokens":646,"sizeBytes":2790},{"name":"columns.md","path":"website/docs/plugins/pixel-perfect-rendering/widths/columns.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/website/docs/plugins/pixel-perfect-rendering/widths/columns.md","title":"Widths Skill","category":"anthropic-skill","format":"markdown","content":"---\nsidebar_position: 0\nsidebar_label: Columns\npagination_title: Histogram Column Widths\ntitle: Histogram column width calculations\ndescription: Describes the calculation for histogram column widths\nkeywords:\n  - plugins\n  - extensions\n  - rendering\n  - canvas\n  - bitmap\n  - media\n  - pixels\n  - histogram\n  - column\n  - width\n---\n\n:::tip\n\nIt is recommend that you first read the [Pixel Perfect Rendering](../index.md) page.\n\n:::\n\nThe following functions can be used to get the calculated width that the library would use for a histogram column at a specific bar spacing and device pixel ratio.\n\nYou can use the `calculateColumnPositionsInPlace` function instead of the `calculateColumnPositions` function to perform the calculation on an existing array of items without needing to create additional arrays (which is more efficient). It is recommended that you memoize the majority of the calculations below to improve the rendering performance.\n\n```typescript\nconst alignToMinimalWidthLimit = 4;\nconst showSpacingMinimalBarWidth = 1;\n\n/**\n * Spacing gap between columns.\n * @param barSpacingMedia - spacing between bars (media coordinate)\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @returns Spacing gap between columns (in Bitmap coordinates)\n */\nfunction columnSpacing(barSpacingMedia: number, horizontalPixelRatio: number) {\n    return Math.ceil(barSpacingMedia * horizontalPixelRatio) <=\n        showSpacingMinimalBarWidth\n        ? 0\n        : Math.max(1, Math.floor(horizontalPixelRatio));\n}\n\n/**\n * Desired width for columns. This may not be the final width because\n * it may be adjusted later to ensure all columns on screen have a\n * consistent width and gap.\n * @param barSpacingMedia - spacing between bars (media coordinate)\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @param spacing - Spacing gap between columns (in Bitmap coordinates). (optional, provide if you have already calculated it)\n * @returns Desired width for column bars (in Bitmap coordinates)\n */\nfunction desiredColumnWidth(\n    barSpacingMedia: number,\n    horizontalPixelRatio: number,\n    spacing?: number\n) {\n    return (\n        Math.round(barSpacingMedia * horizontalPixelRatio) -\n        (spacing ?? columnSpacing(barSpacingMedia, horizontalPixelRatio))\n    );\n}\n\ninterface ColumnCommon {\n    /** Spacing gap between columns */\n    spacing: number;\n    /** Shift columns left by one pixel */\n    shiftLeft: boolean;\n    /** Half width of a column */\n    columnHalfWidthBitmap: number;\n    /** horizontal pixel ratio */\n    horizontalPixelRatio: number;\n}\n\n/**\n * Calculated values which are common to all the columns on the screen, and\n * are required to calculate the individual positions.\n * @param barSpacingMedia - spacing between bars (media coordinate)\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @returns calculated values for subsequent column calculations\n */\nfunction columnCommon(\n    barSpacingMedia: number,\n    horizontalPixelRatio: number\n): ColumnCommon {\n    const spacing = columnSpacing(barSpacingMedia, horizontalPixelRatio);\n    const columnWidthBitmap = desiredColumnWidth(\n        barSpacingMedia,\n        horizontalPixelRatio,\n        spacing\n    );\n    const shiftLeft = columnWidthBitmap % 2 === 0;\n    const columnHalfWidthBitmap = (columnWidthBitmap - (shiftLeft ? 0 : 1)) / 2;\n    return {\n        spacing,\n        shiftLeft,\n        columnHalfWidthBitmap,\n        horizontalPixelRatio,\n    };\n}\n\ninterface ColumnPosition {\n    left: number;\n    right: number;\n    shiftLeft: boolean;\n}\n\n/**\n * Calculate the position for a column. These values can be later adjusted\n * by a second pass which corrects widths, and shifts columns.\n * @param xMedia - column x position (center) in media coordinates\n * @param columnData - precalculated common values (returned by `columnCommon`)\n * @param previousPosition - result from this function for the previous bar.\n * @returns initial column position\n */\nfunction calculateColumnPosition(\n    xMedia: number,\n    columnData: ColumnCommon,\n    previousPosition: ColumnPosition | undefined\n): ColumnPosition {\n    const xBitmapUnRounded = xMedia * columnData.horizontalPixelRatio;\n    const xBitmap = Math.round(xBitmapUnRounded);\n    const xPositions: ColumnPosition = {\n        left: xBitmap - columnData.columnHalfWidthBitmap,\n        right:\n            xBitmap +\n            columnData.columnHalfWidthBitmap -\n            (columnData.shiftLeft ? 1 : 0),\n        shiftLeft: xBitmap > xBitmapUnRounded,\n    };\n    const expectedAlignmentShift = columnData.spacing + 1;\n    if (previousPosition) {\n        if (xPositions.left - previousPosition.right !== expectedAlignmentShift) {\n            // need to adjust alignment\n            if (previousPosition.shiftLeft) {\n                previousPosition.right = xPositions.left - expectedAlignmentShift;\n            } else {\n                xPositions.left = previousPosition.right + expectedAlignmentShift;\n            }\n        }\n    }\n    return xPositions;\n}\n\nfunction fixPositionsAndReturnSmallestWidth(\n    positions: ColumnPosition[],\n    initialMinWidth: number\n): number {\n    return positions.reduce((smallest: number, position: ColumnPosition) => {\n        if (position.right < position.left) {\n            position.right = position.left;\n        }\n        const width = position.right - position.left + 1;\n        return Math.min(smallest, width);\n    }, initialMinWidth);\n}\n\nfunction fixAlignmentForNarrowColumns(\n    positions: ColumnPosition[],\n    minColumnWidth: number\n) {\n    return positions.map((position: ColumnPosition) => {\n        const width = position.right - position.left + 1;\n        if (width <= minColumnWidth) return position;\n        if (position.shiftLeft) {\n            position.right -= 1;\n        } else {\n            position.left += 1;\n        }\n        return position;\n    });\n}\n\n/**\n * Calculates the column positions and widths for the x positions.\n * This function creates a new array. You may get faster performance using the\n * `calculateColumnPositionsInPlace` function instead\n * @param xMediaPositions - x positions for the bars in media coordinates\n * @param barSpacingMedia - spacing between bars in media coordinates\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @returns Positions for the columns\n */\nexport function calculateColumnPositions(\n    xMediaPositions: number[],\n    barSpacingMedia: number,\n    horizontalPixelRatio: number\n): ColumnPosition[] {\n    const common = columnCommon(barSpacingMedia, horizontalPixelRatio);\n    const positions = new Array<ColumnPosition>(xMediaPositions.length);\n    let previous: ColumnPosition | undefined = undefined;\n    for (let i = 0; i < xMediaPositions.length; i++) {\n        positions[i] = calculateColumnPosition(\n            xMediaPositions[i],\n            common,\n            previous\n        );\n        previous = positions[i];\n    }\n    const initialMinWidth = Math.ceil(barSpacingMedia * horizontalPixelRatio);\n    const minColumnWidth = fixPositionsAndReturnSmallestWidth(\n        positions,\n        initialMinWidth\n    );\n    if (common.spacing > 0 && minColumnWidth < alignToMinimalWidthLimit) {\n        return fixAlignmentForNarrowColumns(positions, minColumnWidth);\n    }\n    return positions;\n}\n\nexport interface ColumnPositionItem {\n    x: number;\n    column?: ColumnPosition;\n}\n\n/**\n * Calculates the column positions and widths for bars using the existing\n * array of items.\n * @param items - bar items which include an `x` property, and will be mutated to contain a column property\n * @param barSpacingMedia - bar spacing in media coordinates\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @param startIndex - start index for visible bars within the items array\n * @param endIndex - end index for visible bars within the items array\n */\nexport function calculateColumnPositionsInPlace(\n    items: ColumnPositionItem[],\n    barSpacingMedia: number,\n    horizontalPixelRatio: number,\n    startIndex: number,\n    endIndex: number\n): void {\n    const common = columnCommon(barSpacingMedia, horizontalPixelRatio);\n    let previous: ColumnPosition | undefined = undefined;\n    for (let i = startIndex; i < Math.min(endIndex, items.length); i++) {\n        items[i].column = calculateColumnPosition(items[i].x, common, previous);\n        previous = items[i].column;\n    }\n    const minColumnWidth = (items as ColumnPositionItem[]).reduce(\n        (smallest: number, item: ColumnPositionItem, index: number) => {\n            if (!item.column || index < startIndex || index > endIndex)\n                return smallest;\n            if (item.column.right < item.column.left) {\n                item.column.right = item.column.left;\n            }\n            const width = item.column.right - item.column.left + 1;\n            return Math.min(smallest, width);\n        },\n        Math.ceil(barSpacingMedia * horizontalPixelRatio)\n    );\n    if (common.spacing > 0 && minColumnWidth < alignToMinimalWidthLimit) {\n        (items as ColumnPositionItem[]).forEach(\n            (item: ColumnPositionItem, index: number) => {\n                if (!item.column || index < startIndex || index > endIndex) return;\n                const width = item.column.right - item.column.left + 1;\n                if (width <= minColumnWidth) return item;\n                if (item.column.shiftLeft) {\n                    item.column.right -= 1;\n                } else {\n                    item.column.left += 1;\n                }\n                return item.column;\n            }\n        );\n    }\n}\n\n```\n","frontmatter":{"sidebar_position":0,"sidebar_label":"Columns","pagination_title":"Histogram Column Widths","title":"Histogram column width calculations","description":"Describes the calculation for histogram column widths","keywords":["plugins","extensions","rendering","canvas","bitmap","media","pixels","histogram","column","width"]},"isInternal":false,"tokens":2023,"sizeBytes":9559},{"name":"crosshair.md","path":"website/docs/plugins/pixel-perfect-rendering/widths/crosshair.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/website/docs/plugins/pixel-perfect-rendering/widths/crosshair.md","title":"Widths Skill","category":"anthropic-skill","format":"markdown","content":"---\nsidebar_position: 0\nsidebar_label: Crosshair\npagination_title: Crosshair Widths\ntitle: Crosshair and grid line width calculations\ndescription: Describes the calculation for the crosshair line and grid line widths\nkeywords:\n  - plugins\n  - extensions\n  - rendering\n  - canvas\n  - bitmap\n  - media\n  - pixels\n  - crosshair\n  - grid\n  - line\n  - width\n---\n\n:::tip\n\nIt is recommend that you first read the [Pixel Perfect Rendering](../index.md) page.\n\n:::\n\nThe following functions can be used to get the calculated width that the library would use for a crosshair or grid line at a specific device pixel ratio.\n\n```typescript\n/**\n * Default grid / crosshair line width in Bitmap sizing\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @returns default grid / crosshair line width in Bitmap sizing\n */\nexport function gridAndCrosshairBitmapWidth(\n    horizontalPixelRatio: number\n): number {\n    return Math.max(1, Math.floor(horizontalPixelRatio));\n}\n\n/**\n * Default grid / crosshair line width in Media sizing\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @returns default grid / crosshair line width in Media sizing\n */\nexport function gridAndCrosshairMediaWidth(\n    horizontalPixelRatio: number\n): number {\n    return (\n        gridAndCrosshairBitmapWidth(horizontalPixelRatio) / horizontalPixelRatio\n    );\n}\n\n```\n","frontmatter":{"sidebar_position":0,"sidebar_label":"Crosshair","pagination_title":"Crosshair Widths","title":"Crosshair and grid line width calculations","description":"Describes the calculation for the crosshair line and grid line widths","keywords":["plugins","extensions","rendering","canvas","bitmap","media","pixels","crosshair","grid","line","width"]},"isInternal":false,"tokens":307,"sizeBytes":1342},{"name":"full-bar-width.md","path":"website/docs/plugins/pixel-perfect-rendering/widths/full-bar-width.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/website/docs/plugins/pixel-perfect-rendering/widths/full-bar-width.md","title":"Widths Skill","category":"anthropic-skill","format":"markdown","content":"---\nsidebar_position: 0\nsidebar_label: Full bar width\npagination_title: Full Bar Width\ntitle: Full bar width calculations\ndescription: Describes the calculation for full bar widths\nkeywords:\n  - plugins\n  - extensions\n  - rendering\n  - canvas\n  - bitmap\n  - media\n  - pixels\n  - histogram\n  - column\n  - width\n---\n\n:::tip\n\nIt is recommend that you first read the [Pixel Perfect Rendering](../index.md) page.\n\n:::\n\nThe following functions can be used to get the calculated width that the library would use for the full width of a bar (data point) at a specific bar spacing and device pixel ratio. This can be used when you would like to use the full width available for each data point on the x axis, and don't want any gaps to be visible.\n\n```typescript\ninterface BitmapPositionLength {\n    /** coordinate for use with a bitmap rendering scope */\n    position: number;\n    /** length for use with a bitmap rendering scope */\n    length: number;\n}\n\n/**\n * Calculates the position and width which will completely full the space for the bar.\n * Useful if you want to draw something that will not have any gaps between surrounding bars.\n * @param xMedia - x coordinate of the bar defined in media sizing\n * @param halfBarSpacingMedia - half the width of the current barSpacing (un-rounded)\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @returns position and width which will completely full the space for the bar\n */\nexport function fullBarWidth(\n    xMedia: number,\n    halfBarSpacingMedia: number,\n    horizontalPixelRatio: number\n): BitmapPositionLength {\n    const fullWidthLeftMedia = xMedia - halfBarSpacingMedia;\n    const fullWidthRightMedia = xMedia + halfBarSpacingMedia;\n    const fullWidthLeftBitmap = Math.round(\n        fullWidthLeftMedia * horizontalPixelRatio\n    );\n    const fullWidthRightBitmap = Math.round(\n        fullWidthRightMedia * horizontalPixelRatio\n    );\n    const fullWidthBitmap = fullWidthRightBitmap - fullWidthLeftBitmap;\n    return {\n        position: fullWidthLeftBitmap,\n        length: fullWidthBitmap,\n    };\n}\n```\n","frontmatter":{"sidebar_position":0,"sidebar_label":"Full bar width","pagination_title":"Full Bar Width","title":"Full bar width calculations","description":"Describes the calculation for full bar widths","keywords":["plugins","extensions","rendering","canvas","bitmap","media","pixels","histogram","column","width"]},"isInternal":false,"tokens":451,"sizeBytes":2065},{"name":"README.md","path":"packages/create-lwc-plugin/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/packages/create-lwc-plugin/README.md","title":"create-lwc-plugin Documentation","category":"plugin-manifest","format":"markdown","content":"# create-lwc-plugin\n\n**create-lwc-plugin** scaffolds a new plugin project for Lightweight Charts™.\nThe wizard asks a few questions and generates a ready-to-run project from a\ntemplate for one of the three plugin types:\n\n- a series primitive\n- a pane primitive\n- a custom series\n\nThe scaffolded project is ready to publish: its `package.json` follows the\nconventions used by the Lightweight Charts™ plugin catalog, so the plugin can\nbe listed there once it is published to npm.\n\n✨ Need some examples for inspiration? Check out the\n[plugin-examples](https://github.com/tradingview/lightweight-charts/tree/master/plugin-examples)\nfolder in the Lightweight Charts™ repo.\n\n## Scaffold your first Lightweight Charts™ plugin\n\nWith npm:\n\n```bash\nnpm create lwc-plugin@latest\n```\n\nWith Yarn:\n\n```bash\nyarn create lwc-plugin\n```\n\nWith pnpm:\n\n```bash\npnpm create lwc-plugin\n```\n\nThe wizard asks for the plugin's name, description, author, license, the minimum\nversion of Lightweight Charts™ it supports, and the tags to list it under. Those\nanswers populate the generated `package.json`, including the `lwcPlugin` block\nread by the plugin catalog.\n\nBefore any of that, the wizard offers to install the\n[plugin-authoring Agent Skill](https://github.com/tradingview/lightweight-charts/blob/master/.github/skills/lightweight-charts-plugin-authoring/SKILL.md)\nfor AI coding assistants such as Claude Code, Codex, and Cursor. The skill helps\nchoose the plugin type, build on `@tradingview/lwc-toolkit`, and pick the right\nofficial plugin as the reference for your idea. It also points to the docs and\nwarns about the autoscale, whitespace, and hit-test mistakes a first plugin\ntends to make.\n\nSay yes, and you have two ways to continue. Carry on with the wizard: the skill\nis installed into the new project when the wizard finishes. Or quit right\nthere: the skill is installed into the current directory, and you hand the rest\nover to your assistant. The assistant knows how to run this wizard with you.\n\nThe skill is installed with the [`skills` CLI](https://github.com/vercel-labs/skills).\nThe CLI asks which assistants to set it up for. You can also run it yourself at\nany time:\n\n```bash\nnpx skills add tradingview/lightweight-charts --skill lightweight-charts-plugin-authoring\n```\n\n## The generated project\n\n### Run locally\n\n```shell\nnpm install\nnpm run dev\n```\n\nVisit `localhost:5173` in the browser.\n\n### Build the plugin\n\n```shell\nnpm run build\n```\n\nThis writes three files into the `dist` folder: the package entry point\n(`<name>.js`), a standalone build for use over a CDN\n(`<name>.standalone.js`) which inlines every dependency except\nLightweight Charts™ itself, and the bundled type declarations (`<name>.d.ts`).\nPlugins are published as ES modules only.\n\n### Publish to npm\n\nThe `package.json` in the project root is the published manifest. Check its\n`description`, `version`, `license` and `lwcPlugin` fields, then publish from\nthe project root:\n\n```shell\nnpm publish\n```\n\nHint: append `--dry-run` to the end of the publish command to see the results of\nthe publish command without actually uploading the package to npm.\n\n## Scaffold an official in-repo plugin\n\nMaintainers working inside the Lightweight Charts™ repository can scaffold a\nworkspace package instead of a standalone project:\n\n```shell\npnpm create lwc-plugin --workspace\n```\n\nWorkspace mode targets `packages/`, scopes the package name to `@tradingview/`,\ndepends on the library and the shared plugin utilities through `workspace:*`,\nseeds a `CHANGELOG.md`, `LICENSE` and `NOTICE`, and marks the plugin as an\nofficial catalog entry.\n","isInternal":false,"tokens":838,"sizeBytes":3610},{"name":"README.md","path":"packages/create-lwc-plugin/template-common/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/packages/create-lwc-plugin/template-common/README.md","title":"template-common Documentation","category":"plugin-manifest","format":"markdown","content":"# _PLUGINNAME_\n\n_DESCRIPTION_\n\n<!--\nExpand the line above into a short paragraph: what the plugin draws or does, and\nwhen someone would reach for it. This is the first thing a reader sees, both on\nnpm and on the plugin registry page.\n-->\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `_PEERVERSION_` in your\nproject:\n\n```shell\nnpm install _PACKAGENAME_\n```\n\nThen import the plugin and add it to a chart:\n\n```js\n_ATTACH_SNIPPET_\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"_PACKAGENAME_\": \"https://unpkg.com/_PACKAGENAME_/dist/_ENTRYNAME_.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\n_ATTACH_SNIPPET_\n</script>\n```\n\n## Usage\n\n<!-- Describe the plugin's typical usage, and anything a caller has to own. -->\n\n```js\n_USAGE_SNIPPET_\n```\n\n## Options\n\n<!--\nList the options the plugin accepts. Add further tables for any nested option\ngroups. Keep this in sync with the option types in the source.\n-->\n\n| Option | Type | Default | Description |\n| ------ | ---- | ------- | ----------- |\n|        |      |         |             |\n\nThe full typed surface is published with the package — see\n[`dist/_ENTRYNAME_.d.ts`](https://unpkg.com/_PACKAGENAME_/dist/_ENTRYNAME_.d.ts),\nalso browsable from the Code tab on the package's npm page.\n\n## Development\n\nInstall the dependencies and start the example page:\n\n```shell\nnpm install\nnpm run dev\n```\n\nVisit `localhost:5173` in the browser. The example under `src/example/` is the\nplugin's live preview — keep it working, and keep it filling the window so that\nit can be embedded.\n\nBuild the publishable bundles into `dist/`:\n\n```shell\nnpm run build\n```\n\nThis produces the package entry point (`dist/_ENTRYNAME_.js`), the standalone\nbuild used over a CDN (`dist/_ENTRYNAME_.standalone.js`) and the bundled type\ndeclarations (`dist/_ENTRYNAME_.d.ts`).\n\n<!-- EXTERNAL_ONLY -->\n## The plugin toolkit\n\nThis project depends on\n[`@tradingview/lwc-toolkit`](https://www.npmjs.com/package/@tradingview/lwc-toolkit),\na small set of helpers written for plugin authors: pixel-perfect coordinate and\nwidth calculations for candles, columns and full-width bars, crosshair-aligned\nline widths, time conversion, and a `PluginBase` class that keeps the chart and\nseries references wired up for you.\n\nDepending on the starter this project was generated from, the code may already\nuse it — check the imports in `src/`. It is a `devDependency`, bundled into\n`dist/` when the plugin is built, so it never becomes a dependency for anyone\ninstalling the plugin. If none of it is needed, uninstall it; nothing else has\nto change.\n<!-- /EXTERNAL_ONLY -->\n\n<!-- EXTERNAL_ONLY -->\n## Publishing to npm\n\nThe `package.json` in the project root is the published manifest: check the\n`description`, `version`, `license` and `lwcPlugin` fields before releasing.\n\nCheck the packaging before publishing:\n\n```shell\nnpm run check-package\n```\n\nThat runs [publint](https://publint.dev), which checks the manifest, and\n[arethetypeswrong](https://arethetypeswrong.github.io), which resolves every\nentry point the way a consumer's TypeScript would — the check that catches an\n`exports` entry with no `types` alongside it. Two of its rules are ignored\nbecause an ESM-only package is meant to fail them: `node10` predates the\n`exports` field entirely, and `require`-ing an ES module is an error rather\nthan a mistake in the package.\n\nPublish from the project root once the plugin has been built:\n\n```shell\nnpm publish\n```\n\nHint: append `--dry-run` to inspect the result without uploading anything.\n\n## Discoverability\n\nTag the plugin so that others can find it: add the `lightweight-charts-plugin`\ntopic to its GitHub repository, and keep the `lightweight-charts-plugin` keyword\nin `package.json`.\n<!-- /EXTERNAL_ONLY -->\n","isInternal":false,"tokens":992,"sizeBytes":4107},{"name":"README.md","path":"packages/lwc-plugin-accessibility/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/packages/lwc-plugin-accessibility/README.md","title":"lwc-plugin-accessibility Documentation","category":"plugin-manifest","format":"markdown","content":"# Accessibility\n\nA drop-in accessibility layer for a Lightweight Charts™ chart. The plugin is\nbuilt on\n[pane primitives](https://tradingview.github.io/lightweight-charts/docs/plugins/pane-primitives)\nand helps your application meet\n[WCAG 2.1 Level AA](https://www.w3.org/TR/WCAG21/).\n\nCanvas-based charts are opaque to assistive technology. This plugin packages\nthe techniques from the\n[accessibility tutorial](https://tradingview.github.io/lightweight-charts/tutorials/a11y/intro).\nYou get keyboard navigation, screen-reader announcements, and a visible focus\nindicator without any manual wiring.\n\nUse the chart-level helper for normal integration. It attaches one primitive\nper pane. Each pane gets its own labeled, keyboard-focusable semantic layer.\nThe plugin handles every series in a pane, so multi-series and multi-pane\ncharts work out of the box.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-accessibility\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { addAccessibilityPlugin } from '@tradingview/lwc-plugin-accessibility';\n\nconst chart = createChart(document.getElementById('chart'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(myData);\n\nconst accessibility = addAccessibilityPlugin(chart, {\n    chartTitle: 'Apple daily close',\n});\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-accessibility\": \"https://unpkg.com/@tradingview/lwc-plugin-accessibility/dist/accessibility.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { addAccessibilityPlugin } from '@tradingview/lwc-plugin-accessibility';\n\nconst chart = createChart(document.getElementById('chart'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(myData);\n\nconst accessibility = addAccessibilityPlugin(chart, {\n    chartTitle: 'Apple daily close',\n});\n</script>\n```\n\n## Usage\n\nEnable the plugin for every current pane with one chart-level call:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { addAccessibilityPlugin } from '@tradingview/lwc-plugin-accessibility';\n\nconst chart = createChart(document.getElementById('chart'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(myData);\n\nconst accessibility = addAccessibilityPlugin(chart, {\n    chartTitle: 'Apple daily close',\n});\n```\n\n`chartTitle` is optional; without it every pane is announced with\n`messages.defaultChartTitle` (*\"Interactive financial chart\"*), distinguished by\na *\"Pane 2 of 2\"* suffix. For a multi-pane chart, pass a title resolver instead:\n\n```js\naddAccessibilityPlugin(chart, {\n    chartTitle: paneIndex => paneIndex === 0 ? 'Price' : 'Volume',\n});\n```\n\nTo turn it off again, detach the controller – the plugin restores the DOM to\nthe state it found it in:\n\n```js\naccessibility.detach();\n```\n\nCall `accessibility.refresh()` to attach it again (it re-attaches whatever panes\nthe chart has at that moment). Detach before `chart.remove()` where you can; the\nother order is safe too — `detach()` skips panes that are already gone.\n\nIf you need low-level control, you can still attach `AccessibilityPlugin`\ndirectly as a pane primitive. It takes `AccessibilityPaneOptions` and, as a\nsecond constructor argument, the index of the pane you attach it to (only needed\nfor a pane other than the first):\n\n```js\nimport { AccessibilityPlugin } from '@tradingview/lwc-plugin-accessibility';\n\nchart.panes()[1].attachPrimitive(\n    new AccessibilityPlugin({ chartTitle: 'Volume' }, 1)\n);\n```\n\nThat index is only used to find the pane before the layer exists: the first\ntime the chart draws the primitive it reports the pane it is really attached to,\nand the plugin follows that pane from then on, by identity, through reordering.\nAn index that does not match the pane you attached to therefore costs nothing\nbut a frame.\n\nA directly attached primitive keeps its own polite live region and takes a plain\nboolean `announceDataUpdates`; the chart-level `dataUpdates` settings only exist\non the helper.\n\n## What it does\n\n- **Semantic layer.** Each pane gets a labeled, keyboard-focusable overlay\n  (`role=\"application\"`, `aria-label`, `tabindex=\"0\"`), while the pane's table\n  scaffolding is marked presentational and the visual canvases are hidden from\n  assistive technology with `aria-hidden`. Focusable chart internals such as the\n  attribution link are removed from the tab order and hidden from the\n  accessibility tree.\n- **Keyboard navigation.** Users traverse every data point with the left/right\n  arrows and switch between the series in the pane with the up/down arrows. The\n  focused point is always paged into view, so the whole series is reachable by\n  keyboard even when only part of it is on screen.\n- **ARIA-live announcements.** The focused point, series changes, on-demand\n  summaries, the visible range after a zoom, markers on the focused point and\n  the active series' price lines are announced through a per-pane assertive live\n  region. Background\n  data updates go through a single polite live region shared by the whole chart,\n  so simultaneous updates in different panes never talk over each other\n  (`dataUpdates`, see below).\n- **A text alternative.** `T` renders the active series as a real `<table>` over\n  the pane, on demand (see below).\n- **Visible focus indicator.** The focused pane receives an outline, and an\n  optional focus ring is drawn over the active point. The point ring stays\n  aligned with the canvas as you scroll or zoom, and `syncCrosshair` moves the\n  chart's crosshair with it.\n- **Visible shortcuts & high contrast (opt-in).** With `showShortcuts: true`,\n  sighted keyboard users get a \"Press H\" hint on focus and an `H`-toggled\n  on-screen list of the controls. `highContrast` (default `'auto'`, following the\n  OS) restyles the plugin's own focus ring and overlay, and `onHighContrastChange`\n  lets you restyle the chart itself to match — for users who navigate by keyboard\n  or need higher contrast but don't use a screen reader.\n\n### Keyboard map\n\n| Key | Action |\n| --- | --- |\n| `Tab` | Move focus between panes / out of the chart |\n| `←` / `→` | Move to the previous / next data point |\n| `↑` / `↓` | Switch to the previous / next series in the pane |\n| `Page Up` / `Page Down` | Jump by `pageStep` points (default 10): `Page Up` forward in time, `Page Down` back — following the ARIA slider convention that `Page Up` increases the value |\n| `Home` / `End` | Jump to the first / last point |\n| `+` / `-` | Zoom the chart in / out |\n| `Enter` / `Space` | Announce a summary of the active series |\n| `T` | Show / hide the data as a table (see below) |\n| `Esc` | Close the open panel (table or shortcuts) |\n| `H` | Announce the controls, and — when `showShortcuts` is on — show / hide the visible shortcuts panel |\n\nThe letter keys are matched by physical key as well as by character, so `H` and\n`T` also work on non-Latin keyboard layouts. Remap anything with `keyBindings`:\n\n```js\naddAccessibilityPlugin(chart, {\n    keyBindings: {\n        s: 'summary',   // add a key\n        KeyD: 'viewAsTable', // by physical key\n        h: null,        // remove a built-in binding\n    },\n});\n```\n\n## Options\n\nAll options are optional and have sensible defaults. `addAccessibilityPlugin`\ntakes `AccessibilityOptions`, a single `AccessibilityPlugin` takes\n`AccessibilityPaneOptions`; the two differ only in the rows marked *chart-level*\nbelow.\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `chartTitle` | `string` — *chart-level:* `string \\| (paneIndex) => string` | `messages.defaultChartTitle` | Accessible name of the pane region. |\n| `showFocusIndicator` | `boolean` | `true` | Draw a visible focus ring on the active point. |\n| `focusIndicatorColor` | `string` | `'#2962FF'` | Color of the focus ring. |\n| `focusIndicatorSize` | `number` | `14` | Diameter of the focus ring, in CSS pixels. |\n| `dataUpdates` | *chart-level only:* `{ mode: 'active' \\| 'all' \\| 'none'; panes?: (paneIndex) => boolean; debounceMs?: number }` | `{ mode: 'active' }` | Which panes announce data updates, and how they combine (see below). |\n| `announceDataUpdates` | *pane-level only:* `boolean` | `true` | Whether this pane announces data updates. Set for you from `dataUpdates`. |\n| `updateDebounceMs` | *pane-level only:* `number` | `1000` | Window over which data changes are coalesced before being announced. Use `dataUpdates.debounceMs` at chart level. |\n| `updateMaxSeries` | `number` | `3` | Maximum number of changed series listed in one update announcement. |\n| `pageStep` | `number` | `10` | Points to jump with `Page Up` / `Page Down`. |\n| `zoomStep` | `number` | `0.2` | Fraction the visible range grows / shrinks per `+` / `-` keypress. |\n| `minZoomSpan` | `number` | `2` | Smallest visible span, in bars, that zooming in will produce. |\n| `dataScope` | `'all' \\| 'visible'` | `'visible'` | Whether the on-demand summary and data-update announcements describe the visible range or the full data set (see below). |\n| `priceFormatter` | `(value: number) => string` | chart `localization.priceFormatter`, else the active series price formatter | Formats values for announcements. |\n| `timeFormatter` | `(time: Time) => string` | chart `localization.timeFormatter`, else a locale-aware date | Formats times for announcements (uses the chart's `localization.locale`). |\n| `timeFormat` | `'auto' \\| 'date' \\| 'dateTime' \\| 'seconds' \\| 'time'` | `'auto'` | How much of a time the built-in formatter speaks. `'auto'` follows the chart's `timeScale.timeVisible` / `secondsVisible`, so intraday bars are distinguishable. Ignored when a `timeFormatter` is set. |\n| `valueAccessor` | `(point, series) => number \\| undefined` | `value`, else `close` | Reads the announced value out of a data point — needed for custom series (see below). |\n| `rangeAccessor` | `(point, series) => { high, low, open?, close? } \\| undefined` | the point's own `high` / `low` | Reads a point's high / low band, so a custom series is announced like an OHLC one. |\n| `seriesLabel` | `(series, index) => string` | series `title`, else `Series N` | Accessible label for each series. |\n| `keyBindings` | `Record<string, AccessibilityCommand \\| null>` | — | Key → command overrides, merged onto the built-in map. The key is a `KeyboardEvent.key` or `.code`; `null` removes a binding. |\n| `announceOnFocus` | `boolean` | `false` | Announce the visible range when the pane receives focus (an assertive message can interrupt the accessible name, hence off by default). |\n| `focusOnPointerDown` | `boolean` | `false` | Move the keyboard focus into the pane when the user presses a pointer on it. |\n| `syncCrosshair` | `boolean` | `false` | Move the chart's crosshair to the focused point (`chart.setCrosshairPosition`). |\n| `tableMaxRows` | `number` | `200` | Maximum number of rows rendered by the `T` table; the cap is spoken with the caption. |\n| `markers` | `(series) => readonly SeriesMarker<Time>[]` | — | The markers of a series, announced with the point they sit on. The library does not expose a series' markers, so pass the array you gave `createSeriesMarkers`. |\n| `announcePriceLines` | `boolean` | `true` | Append the active series' `priceLines()` to the `Enter` / `Space` summary. |\n| `onAnnounce` | `(message: string) => void` | — | Called with every string this pane announces — for captions, a transcript, or a test. |\n| `onFocusChange` | `(event: AccessibilityFocusEvent) => void` | — | Called whenever the active point or series changes, with the pane, series, point and value. |\n| `onSonify` | `(note: SonificationNote) => void` | — | Called for every focused point with the data a sonification needs. `createToneSonifier()` is a ready-made handler (see below). |\n| `describeChart` | `(context: DescribeChartContext) => string` | built-in summary | Generates the `Enter` / `Space` summary. The context carries `points` (already narrowed to `dataScope`), `series`, `label` and `scope`. |\n| `messages` | `PartialAccessibilityMessages` | English `defaultMessages` | Overrides for the announced text — translate some or all of it (see Localization). |\n| `lang` | `string` | chart `localization.locale` | BCP-47 `lang` set on the announced regions so screen readers use the right voice. |\n| `showShortcuts` | `boolean` | `false` | Show a visible keyboard-shortcuts overlay (focus hint + `H`-toggled panel) for sighted keyboard users (see below). |\n| `highContrast` | `boolean \\| 'auto'` | `'auto'` | High-contrast styling for the plugin's own focus ring / outline / overlay. `'auto'` follows the OS `prefers-contrast` / `forced-colors`; pass a boolean to drive it from your own setting. |\n| `onHighContrastChange` | `(enabled: boolean) => void` | — | Called when the resolved high-contrast state changes (and once on attach), so you can restyle the chart's own series / grid / font to match. |\n\nOptions can be changed at runtime. Use the controller's\n`accessibility.applyOptions({ ... })` for chart-level changes (`chartTitle`,\n`dataUpdates`, `messages`, `lang`, `highContrast`, …): it updates every pane\n**and** the shared update region together. A single primitive also has its own\n`plugin.applyOptions({ ... })` for per-pane tweaks (e.g. `dataScope`), but that\ndoes not reach the chart-level shared update region — use the controller for\n`dataUpdates` / `messages` / `lang`.\n\n### Scoping announcements to the visible range\n\nKeyboard navigation always covers the whole series – the arrow keys page the\nchart so every point is reachable regardless of this setting. `dataScope` only\ncontrols what the *summaries* describe.\n\nBy default (`dataScope: 'visible'`) the on-demand summary (`Enter` / `Space`) and\nthe background data-update announcements describe only the points within the\ncurrent visible range – for example *\"65 data points in view\"*. This is the\nrecommended setting for charts with large data sets because it keeps those\nsummaries focused on what the user is currently inspecting. The update\nannouncement's *\"Latest\"* value is the one exception: it always reports the\nseries' newest bar – the bar the update actually changed – even when that bar\nis outside the visible range.\n\nUse `dataScope: 'all'` when you want the summary and update announcements to\ndescribe the full data set, even if only part of the history is visible.\n\nPer-point announcements always report the absolute position (*\"Point 247 of\n500\"*) so the user knows where they are in the whole series.\n\n### Announcing data updates\n\nWhen a chart streams live data, several panes can update in the same tick. Each\npane keeps its own assertive region for navigation, but all *data-update*\nannouncements go through **one** polite region shared by the whole chart, so the\nupdates never talk over each other.\n\n`dataUpdates` (on `addAccessibilityPlugin`) chooses which panes speak:\n\n```js\naddAccessibilityPlugin(chart, {\n    dataUpdates: { mode: 'active', debounceMs: 1500 },\n});\n```\n\n- `mode: 'active'` (the default): only the **last-focused** pane announces (pane 0\n  until you focus one). Navigating the volume pane, for example, makes its updates\n  the ones you hear; otherwise you hear the main pane.\n- `mode: 'all'`: every pane announces; simultaneous updates are combined into a\n  single message in pane order (*\"Chart data updated. 3 series changed. …\"*).\n- `mode: 'none'`: no update announcements.\n- `panes: (paneIndex) => boolean`: restricts announcements to the panes the\n  predicate accepts, on top of `mode`.\n- `debounceMs`: how long changes are coalesced before being announced (default\n  `1000`). A live feed can tick far faster than a screen reader can speak.\n\nSwitch this at runtime through the controller —\n`accessibility.applyOptions({ dataUpdates: { mode: 'all' } })` — which\nreconfigures the shared region's mode; a per-pane `plugin.applyOptions` cannot\nchange it.\n\nA directly-attached `AccessibilityPlugin` (without the helper) takes a plain\nboolean `announceDataUpdates` with its own `updateDebounceMs`, and uses its own\npolite region.\n\n## View as table\n\nPressing `T` renders the active series into a real `<table>` over the pane —\nthe text alternative WCAG asks for, and the most requested way to read a chart\nwithout navigating it point by point. The rows follow `dataScope`, are capped at\n`tableMaxRows` (the cap is announced), and use OHLC columns whenever the points\ncarry a high / low band. `Esc` (or `T` again) closes it. The table is built only\nwhile it is open, so a 50,000-bar series costs nothing until it is asked for.\nIts column headers and caption come from the `messages` bundle\n(`tableColumns`, `tableCaption`, `tableTruncated`, `tableClose`).\n\n## Custom series\n\nA custom series' data shape is only known to its author, so the plugin cannot\nguess where the value is. Without help every point of a custom series announces\n*\"no value\"* and the focus ring has nowhere to go. Point the plugin at the right\nfield:\n\n```js\naddAccessibilityPlugin(chart, {\n    valueAccessor: point => (point.high + point.low) / 2,\n    // Optional: announce it like an OHLC series and report true extremes.\n    rangeAccessor: point => ({ high: point.high, low: point.low }),\n});\n```\n\nBoth are called for every series in the pane; return `undefined` to fall back to\nthe built-in extraction (`value`, then `close`), so a chart mixing built-in and\ncustom series needs only the custom branch.\n\n## Following along: crosshair, captions and sound\n\n- `syncCrosshair: true` moves the chart's crosshair with the keyboard, so a\n  sighted user can follow a screen-reader user point by point.\n- `onAnnounce` receives every string this pane speaks, in order — mirror it into\n  captions, a transcript, or an assertion in a test.\n- `onFocusChange` reports the pane, series, point index and value whenever the\n  focus moves, for your own status bar or analytics.\n- `onSonify` receives each focused point with its position in the series' value\n  range. `createToneSonifier()` is a ready-made handler that plays a short tone\n  whose pitch follows the value, so holding `→` plays the series:\n\n```js\nimport { addAccessibilityPlugin, createToneSonifier } from '@tradingview/lwc-plugin-accessibility';\n\nconst sonifier = createToneSonifier();\naddAccessibilityPlugin(chart, { onSonify: sonifier });\n// sonifier.dispose() releases the AudioContext.\n```\n\nThe `AudioContext` is created on the first note (after a key press, so the\nbrowser's autoplay policy is satisfied) and reused afterwards.\n\n## Localization\n\nOut of the box the announcements are English, but **numbers and dates follow the\nchart's locale** and **every spoken string is translatable**.\n\n**Numbers and dates** come from the chart's\n[`localization`](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/LocalizationOptions):\ndates use `localization.locale`, the summary's percentage uses it via\n`Intl.NumberFormat`, and if you set `localization.priceFormatter` /\n`localization.timeFormatter` the announcements use those too. So a chart you have\nalready localized (see the\n[Custom locale](https://tradingview.github.io/lightweight-charts/tutorials/demos/custom-locale)\nand [Price format](https://tradingview.github.io/lightweight-charts/tutorials/customization/price-format)\ntutorials) gets localized announcements for free. You can still override per\nplugin with `priceFormatter` / `timeFormatter`.\n\n**Strings** are supplied through the `messages` bundle. Every announced sentence\nis a formatter function (so a translation controls word order and pluralization);\natomic words are plain strings. Pass a partial override — anything you leave out\nstays English:\n\n```js\nimport { addAccessibilityPlugin } from '@tradingview/lwc-plugin-accessibility';\n\naddAccessibilityPlugin(chart, {\n    chartTitle: 'Gráfico de precios',\n    lang: 'es',\n    messages: {\n        ohlc: { close: 'cierre' }, // only some keys — the rest stay English\n        point: ({ position, total, time, label, values }) =>\n            `${label} ${values}, ${time}. Punto ${position} de ${total}.`,\n        help: ({ multiSeries }) =>\n            `Controles de teclado. Las flechas izquierda y derecha se mueven entre los puntos de datos. ${multiSeries ? 'Las flechas arriba y abajo cambian de serie. ' : ''}Intro o Espacio lee un resumen de la serie.`,\n    },\n});\n```\n\n`lang` sets the BCP-47 `lang` attribute on the announced regions so a screen\nreader pronounces them with the right voice; it defaults to\n`localization.locale`. `messages`/`lang` are uniform across panes. To switch\nlanguage at runtime, call `accessibility.applyOptions({ messages, lang })` on the\ncontroller — it updates every pane and the shared update region together.\n\nA complete Spanish bundle ships with the package as `esMessages`, both as a\nready-made translation and as a template for your own:\n\n```js\nimport { addAccessibilityPlugin, esMessages } from '@tradingview/lwc-plugin-accessibility';\n\naddAccessibilityPlugin(chart, { messages: esMessages, lang: 'es' });\n```\n\n`defaultMessages` is the English bundle. It is **frozen and read-only** — write a\ntranslation by passing your own entries through `messages` (they are merged onto\n`defaultMessages`), never by mutating it. `paneLabel` receives `paneIndex` and\n`paneCount` alongside the title, so a translation can keep multi-pane titles\ndistinguishable, and `defaultChartTitle` is the fallback used when `chartTitle`\nis unset.\n\nThe precedence for the overridable pieces:\n\n- **value:** `priceFormatter` → chart `localization.priceFormatter` → series formatter\n- **time:** `timeFormatter` → chart `localization.timeFormatter` → locale-aware date\n- **summary:** `describeChart` (full override) → `messages.summary`\n- **strings:** your `messages` entry → English `defaultMessages`\n\n## Visible shortcuts and high contrast\n\nThese help users who navigate by keyboard, or need higher contrast, but don't use\na screen reader.\n\n**Shortcuts overlay** — set `showShortcuts: true`. While the pane is focused a\nsmall *\"Press H for keyboard shortcuts\"* hint is shown; `H` toggles an on-screen\npanel listing the controls. It is `aria-hidden` (screen-reader\nusers already get the spoken `H` help) and its text comes from the `messages`\nbundle (`shortcutsHint`, `shortcutsTitle`, `shortcuts`), so it localizes with the\nrest. The overlay text is sized in `rem`, so it scales with the page/browser font.\n\n**High contrast** — `highContrast` (`boolean | 'auto'`, default `'auto'`) controls\nthe plugin's *own* visuals (focus ring, focus outline, the overlay). `'auto'`\nfollows the OS `prefers-contrast` / `forced-colors` and updates live; to wire it\nto your own app setting, pass a boolean and keep it in step with\n`accessibility.applyOptions({ highContrast })`.\n\nThe plugin deliberately does **not** restyle the chart's series, grid or font —\nthat's the chart theme's job (see the\n[Readability](https://tradingview.github.io/lightweight-charts/tutorials/a11y/readability)\ntutorial). Instead it calls `onHighContrastChange(enabled)` whenever the state\nchanges (and once on attach) so you can apply your own high-contrast chart theme\nin one place:\n\n```js\naddAccessibilityPlugin(chart, {\n    showShortcuts: true,\n    onHighContrastChange: enabled => {\n        chart.applyOptions({ layout: { textColor: enabled ? '#000' : '#222' } });\n        series.applyOptions({ lineWidth: enabled ? 4 : 2 });\n    },\n});\n```\n\nThe example wires both of these up (the \"Enable high contrast\" and \"Large font\"\nbuttons).\n\n## Performance\n\nThe plugin uses an **active-point-only** strategy: it never mirrors every data\npoint into the DOM. Regardless of whether a series holds 500 or 50,000 bars each\npane adds only a small fixed set of nodes (a semantic overlay, a visually-hidden\ndescription, an assertive live region, a focus ring and — when `showShortcuts` is\non — the shortcuts hint and panel), plus one polite live region shared across the\nwhole chart for data-update announcements.\n\nData stays in sync through one `subscribeDataChanged` listener per series.\nScrolling and zooming reposition the focus ring with coordinate lookups; they\ndo not copy series data. Data-change events invalidate a shared snapshot because\nthey do not distinguish a tail tick from a historical correction or `pop()`.\n\nAn unfocused pane reads data only when its debounced announcement is prepared.\nWith update announcements disabled, it defers the read until keyboard focus\nreturns. Focused navigation refreshes immediately after a data change and shares\nthat snapshot with announcement statistics. Each refresh is proportional to the\nseries length; visible-point counts use binary searches within the snapshot, so\nwhitespace and gaps supplied by other series do not inflate the count.\n\n## CSS class hooks\n\nEvery element the plugin injects carries a stable class name, so you can restyle\nthe layer from your own stylesheet. These names are part of the public API and\nwill not change without a major version:\n\n| Class | Element |\n| --- | --- |\n| `lw-chart-a11y-layer` | The focusable semantic overlay per pane (`role=\"application\"`). |\n| `lw-chart-a11y-description` | Visually hidden pane description (`aria-describedby` target). |\n| `lw-chart-a11y-live-region` | Per-pane assertive region for navigation announcements. |\n| `lw-chart-a11y-status-region` | Per-pane polite region, only present on a directly attached primitive. |\n| `lw-chart-a11y-shared-status-region` | The single chart-level polite region created by `addAccessibilityPlugin`. |\n| `lw-chart-a11y-focus-ring` | The visible focus ring drawn over the active point. |\n| `lw-chart-a11y-shortcuts-hint` | The \"Press H\" hint (`showShortcuts`). |\n| `lw-chart-a11y-shortcuts-panel` | The `H`-toggled shortcuts panel (`showShortcuts`). |\n| `lw-chart-a11y-data-table` | The `T`-toggled table panel. |\n\nThe plugin sets its own geometry and colors inline, so an inline style wins over\na plain rule — use `!important`, or restyle through the options where one exists\n(`focusIndicatorColor`, `focusIndicatorSize`, `highContrast`).\n\n## Notes & limitations\n\n- Built-in series work out of the box: OHLC series announce their open / high /\n  low / close, value series announce their value. A **custom series** needs\n  `valueAccessor` (and optionally `rangeAccessor`), because only its author knows\n  where its value lives.\n- Series **and panes** added or removed at runtime are picked up automatically:\n  the controller reconciles its layers with `chart.panes()` on the next redraw\n  and attaches or detaches only the difference, so the focus of the panes that\n  were already there is never disturbed. `controller.refresh()` forces that check\n  immediately and is rarely needed.\n- The library forces `direction: ltr` on the chart element, so the plugin reads\n  the writing direction from the element you created the chart in: on a\n  right-to-left page its panels sit on the leading (right) side.\n- Series in a pane do not need to share timestamps. Navigation is aligned by\n  *time* on the chart's shared time scale: switching series with the up / down\n  arrows keeps the focused time (the nearest point in the new series is\n  selected and paged into view), and the visible-range scoping follows each\n  series' own data.\n- The plugin provides the semantic layer and keyboard model. Visual contrast and\n  font-scaling (covered in the\n  [Readability](https://tradingview.github.io/lightweight-charts/tutorials/a11y/readability)\n  part of the tutorial) remain the responsibility of your chart theme.\n- The API is typed for a `Time`-based chart (`IChartApi`), not the generic\n  `IChartApiBase<HorzScaleItem>`. The announcements format UTC timestamps and\n  business days and the navigation maps points through the `Time` scale, so every\n  internal path assumes `Time`; a custom horizontal scale is not supported.\n- Always validate with real assistive technology (VoiceOver, NVDA) as part of\n  your own accessibility testing before shipping.\n","isInternal":false,"tokens":6852,"sizeBytes":28403},{"name":"README.md","path":"packages/lwc-plugin-anchored-text/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/packages/lwc-plugin-anchored-text/README.md","title":"lwc-plugin-anchored-text Documentation","category":"plugin-manifest","format":"markdown","content":"# Anchored text\n\nA single line of text anchored to an edge, a corner or the center of a pane,\nas a [series primitive](https://tradingview.github.io/lightweight-charts/docs/plugins/series-primitives)\n(`AnchoredText`) or as a\n[pane primitive](https://tradingview.github.io/lightweight-charts/docs/plugins/pane-primitives)\n(`AnchoredTextPane`). The text keeps its place while the chart scrolls and\nzooms, inset from the pane edges by a margin you choose. The text, its anchor,\nmargins, font, color, layer and visibility can all be changed after the\nprimitive has been attached.\n\nThe series primitive belongs to the series it is attached to: it lives in that\nseries' pane and is removed together with the series. The pane primitive needs\nno series at all.\n\nUse it for a chart title, a symbol or interval label, a data-source credit, or\na \"preview\" or \"draft\" stamp.\n\n> **Lightweight Charts™ 5 also ships a built-in text watermark.**\n> [`createTextWatermark(pane, options)`](https://tradingview.github.io/lightweight-charts/docs/api/functions/createTextWatermark)\n> is a pane primitive which draws one or more lines of text, centered by default\n> and scaled down to fit the pane. If that is all you need, the built-in\n> function is the right choice. Use this package for text tied to a specific\n> series rather than to a pane, or for what the built-in does not offer:\n> margins from the pane edge, a CSS `font` shorthand, `zOrder` and\n> `setText`.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-anchored-text\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { AnchoredText } from '@tradingview/lwc-plugin-anchored-text';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(data);\n\nseries.attachPrimitive(new AnchoredText({ text: 'BTC/USD · 1D' }));\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-anchored-text\": \"https://unpkg.com/@tradingview/lwc-plugin-anchored-text/dist/anchored-text.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { AnchoredText } from '@tradingview/lwc-plugin-anchored-text';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(data);\n\nseries.attachPrimitive(new AnchoredText({ text: 'BTC/USD · 1D' }));\n</script>\n```\n\n## Usage\n\n### On a series\n\nCreate the text, then attach it to the series whose pane it should sit in:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { AnchoredText } from '@tradingview/lwc-plugin-anchored-text';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(data);\n\nconst title = new AnchoredText({\n    text: 'BTC/USD · 1D',\n    horzAlign: 'right',\n    vertAlign: 'top',\n    font: 'bold 16px sans-serif',\n    color: '#2962FF',\n});\nseries.attachPrimitive(title);\n```\n\nTo remove the text, detach it from the series:\n\n```js\nseries.detachPrimitive(title);\n```\n\n### On a pane\n\n`AnchoredTextPane` takes the same options and is attached to a pane instead\nof a series. Use it when the text should stay put while series are added and\nremoved:\n\n```js\nimport { AnchoredTextPane } from '@tradingview/lwc-plugin-anchored-text';\n\nconst title = new AnchoredTextPane({ text: 'Volume', vertAlign: 'bottom' });\nchart.panes()[1].attachPrimitive(title);\n\n// later\nchart.panes()[1].detachPrimitive(title);\n```\n\n### Changing the text\n\nBoth classes have the same methods:\n\n```js\ntitle.applyOptions({ horzAlign: 'center', color: '#787B86' });\ntitle.setText('ETH/USD · 1D'); // same as applyOptions({ text })\ntitle.options(); // the current options, with the defaults filled in\n```\n\n`applyOptions` merges: an option which is not passed, or is passed as\n`undefined`, is left unchanged. The one exception is `lineHeight`: passing\n`lineHeight: undefined` goes back to measuring the height from the font.\n\n## Options\n\nOptions are passed as the constructor argument, which is optional, as is every\noption in it. The type is `AnchoredTextOptions`, and the defaults are exported\nas `defaultOptions`.\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `text` | `string` | `''` | The line of text. An empty string draws nothing. |\n| `horzAlign` | `'left' \\| 'center' \\| 'right'` | `'left'` | Which side of the pane the text is anchored to, or centered. |\n| `vertAlign` | `'top' \\| 'center' \\| 'bottom'` | `'top'` | Which edge of the pane the text is anchored to, or centered. |\n| `horzMargin` | `number` | `20` | Distance from the left or right pane edge, in CSS pixels. Not used when `horzAlign` is `'center'`. |\n| `vertMargin` | `number` | `10` | Distance from the top or bottom pane edge, in CSS pixels. Not used when `vertAlign` is `'center'`. |\n| `font` | `string` | `bold 14px` system sans-serif | Font, as a CSS `font` shorthand. |\n| `lineHeight` | `number` | — (measured) | Height of the text, in CSS pixels. Measured from the font when not set. |\n| `color` | `string` | `'#131722'` | Text color. |\n| `visible` | `boolean` | `true` | Whether the text is drawn at all. |\n| `zOrder` | `'bottom' \\| 'normal' \\| 'top'` | `'normal'` | Layer the text is drawn in. `'normal'` draws it with the series, under the crosshair; `'top'` puts it over everything in the pane, the crosshair included; `'bottom'` puts it behind the series. |\n\n### Alignment and margins\n\nThe text is placed against the anchored edge of its pane, `horzMargin` and\n`vertMargin` away from it. A centered axis ignores its margin. With a\n`lineHeight` the text's baseline sits at the bottom of that height, as it did\nin the `plugin-examples` version; without one the height is that of the font,\nso it does not change with the text, and the baseline sits at the font's\nascent.\n\n## Notes\n\n- The text is drawn on one line, as given. It is neither wrapped nor scaled:\n  text wider than the pane is clipped at the pane edge. The built-in\n  `createTextWatermark` scales its text down to fit, if that is what you need.\n- The text appears only in the pane it belongs to. It never covers the price\n  scales or the time scale, and a visible left price scale or a second pane\n  does not move it.\n- Sizes are in CSS pixels; the text is drawn in the media coordinate space, so\n  it stays sharp at any device pixel ratio.\n- `'middle'` is still accepted as a value of `horzAlign` and `vertAlign`, the\n  spelling used in the `plugin-examples` collection, and is read as `'center'`.\n  It is kept for compatibility and will be removed in a future major version.\n","isInternal":false,"tokens":1848,"sizeBytes":7121},{"name":"README.md","path":"packages/lwc-plugin-background-shade-series/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/packages/lwc-plugin-background-shade-series/README.md","title":"lwc-plugin-background-shade-series Documentation","category":"plugin-manifest","format":"markdown","content":"# Background shade series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series)\nthat shades the full height of the pane behind each bar. The shade is mixed\nfrom two colors by where the bar's value sits between a low and a high value,\nso the background follows an indicator while the price series stays readable\non top of it.\n\nUse it to show a regime or a reading behind the price: an oscillator, the\nshare of up days, volatility, a sentiment score, or a session's volume\nrelative to normal.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-background-shade-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { createBackgroundShadeSeries } from '@tradingview/lwc-plugin-background-shade-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst line = chart.addSeries(LineSeries);\nline.setData([\n    { time: '2024-04-22', value: 101.2 },\n    { time: '2024-04-23', value: 102.8 },\n    { time: '2024-04-24', value: 100.9 },\n]);\n\nconst shade = createBackgroundShadeSeries(chart, {\n    lowColor: '#F23645',\n    highColor: '#089981',\n    opacity: 0.25,\n});\nshade.setData([\n    { time: '2024-04-22', value: 35 },\n    { time: '2024-04-23', value: 70 },\n    { time: '2024-04-24', value: 20 },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-background-shade-series\": \"https://unpkg.com/@tradingview/lwc-plugin-background-shade-series/dist/background-shade-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { createBackgroundShadeSeries } from '@tradingview/lwc-plugin-background-shade-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst line = chart.addSeries(LineSeries);\nline.setData([\n    { time: '2024-04-22', value: 101.2 },\n    { time: '2024-04-23', value: 102.8 },\n    { time: '2024-04-24', value: 100.9 },\n]);\n\nconst shade = createBackgroundShadeSeries(chart, {\n    lowColor: '#F23645',\n    highColor: '#089981',\n    opacity: 0.25,\n});\nshade.setData([\n    { time: '2024-04-22', value: 35 },\n    { time: '2024-04-23', value: 70 },\n    { time: '2024-04-24', value: 20 },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `createBackgroundShadeSeries`, then set data with a\n`value` per bar:\n\n```js\nconst shade = createBackgroundShadeSeries(chart, {\n    lowColor: 'rgb(50, 50, 255)',\n    highColor: 'rgb(255, 50, 50)',\n    lowValue: 0,\n    highValue: 100,\n    opacity: 0.8,\n});\n\nshade.setData([\n    { time: '2024-04-22', value: 35 },\n    { time: '2024-04-23', value: 120 },\n    { time: '2024-04-24' },\n    { time: '2024-04-25', value: 50, color: '#131722' },\n]);\n```\n\nEach data point is `{ time, value }`:\n\n- A value of `lowValue` gets `lowColor`, a value of `highValue` gets\n  `highColor`, and a value in between a mix of the two. Values beyond the\n  range get the color of the nearer end. `lowValue` may be the larger of the\n  two. With `lowValue` equal to `highValue` the shading becomes a two-color\n  threshold: values below it get `lowColor` and the rest `highColor`.\n- A point without a finite `value`, `null` and `NaN` included, is whitespace\n  and leaves its slot unshaded.\n- A `color` on a point shades that bar with it, whatever its value. A color\n  the canvas does not accept is ignored, and the bar is shaded from its value.\n  The series' own `color` option is not drawn; it is empty by default, and a\n  point whose `color` equals it is shaded from its value.\n\n`lowColor` and `highColor` can be hex, `rgb()`, `rgba()`, `hsl()` or named\ncolors. They are mixed with premultiplied alpha, as CSS gradients are, so a\ntransparent end, `'transparent'` included, fades the other color out. A color\nthat cannot be parsed, or one in another color space such as `oklch()`, falls\nback to the default for that end.\n\nThe series shades the full height of its pane and takes no part in the price\nscale. It sits on a price scale of its own, `'background-shade'`, an overlay\nscale with nothing drawn on it, so it never sets the number format of the\nprice axis; its values never change any autoscale range; and it has no price\nline or last value label. It still draws when it is the only series in the\nchart. It is never reported as hovered, so it does not get in the way of the\nseries on top of it.\n\n## Creating a series\n\nUse `createBackgroundShadeSeries(chart, options?, paneIndex?)`. It adds the\nseries and moves it behind every other series in its pane with\n`series.setSeriesOrder(0)`, so it reads as a background whatever order the\nseries are added in. `setSeriesOrder` arrived in `lightweight-charts` 5.0.6;\non older versions the series keeps the order it was added in, so add it\nbefore the others.\n\nMoving the series to another pane, with `series.moveToPane`, puts it on top\nof that pane's series, as for any series; call `series.setSeriesOrder(0)`\nagain afterwards.\n\nThe `BackgroundShadeSeries` class remains available for\n`chart.addCustomSeries(new BackgroundShadeSeries(), options)`. Added that way,\nit gets the same options, its own price scale included, but is drawn in the\norder it was added: added after the main series, an opaque shade covers it.\nAdd it first, or call `series.setSeriesOrder(0)`.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `lowColor` | `string` | `'rgb(50, 50, 255)'` | Shade of a bar whose value is `lowValue`, or beyond it. |\n| `highColor` | `string` | `'rgb(255, 50, 50)'` | Shade of a bar whose value is `highValue`, or beyond it. |\n| `lowValue` | `number` | `0` | Value shaded with `lowColor`. |\n| `highValue` | `number` | `100` | Value shaded with `highColor`. |\n| `opacity` | `number` | `0.8` | Opacity of the whole shading, `0`–`1`, on top of any alpha in the colors. |\n\n`priceLineVisible` and `lastValueVisible` default to `false`, since the series\nhas no value on the price scale, and `priceScaleId` to `'background-shade'`.\nSetting `priceScaleId` to `'right'` or `'left'` puts the shade on a visible\nscale, where, being the bottom series, it would set that scale's number\nformat; it still never changes the scale's range.\n\n## Notes\n\n- Each bar is shaded across one bar spacing centered on it, in whole device\n  pixels, so the slots of consecutive bars abut with no seam and no overlap at\n  every zoom level and device pixel ratio. Time points that only other series\n  have stay unshaded: daily values over hourly candles, say, shade one slot a\n  day. On `lightweight-charts` 5.1 and later, while the chart conflates data, a\n  conflated bar's column is as wide as the slots it stands for, centered where\n  the chart places the bar, and it keeps the later of the two values it\n  merges.\n- Only the bars on screen are drawn. Their shades come from 256 steps between\n  the two end colors, worked out when the colors change, so no color is\n  mixed while drawing.\n- The shading covers its own pane only. To shade another pane, add a second\n  series to it with the `paneIndex` argument.\n","isInternal":false,"tokens":2089,"sizeBytes":7620},{"name":"README.md","path":"packages/lwc-plugin-box-whisker-series/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/packages/lwc-plugin-box-whisker-series/README.md","title":"lwc-plugin-box-whisker-series Documentation","category":"plugin-manifest","format":"markdown","content":"# Box and whisker series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series)\nthat draws a box plot per time point: a box from the first to the third\nquartile split at the median, whiskers out to the `min` and `max` you give,\nand a dot for each outlier you list beyond them. Where the whiskers end is\nyours to decide, such as 1.5 times the interquartile range or the 5th and\n95th percentiles, and the values past them are the outliers.\n\nUse it to show how a distribution changes over time rather than a single\nvalue: intraday price distribution per day, latency percentiles per hour,\nor the spread of forecasts per period.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-box-whisker-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createBoxWhiskerSeries } from '@tradingview/lwc-plugin-box-whisker-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createBoxWhiskerSeries(chart);\n\nseries.setData([\n    { time: '2024-04-22', min: 55, q1: 70, median: 80, q3: 85, max: 95 },\n    { time: '2024-04-23', min: 50, q1: 70, median: 78, q3: 83, max: 90, outliers: [40] },\n    { time: '2024-04-24', min: 58, q1: 68, median: 75, q3: 85, max: 90 },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-box-whisker-series\": \"https://unpkg.com/@tradingview/lwc-plugin-box-whisker-series/dist/box-whisker-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createBoxWhiskerSeries } from '@tradingview/lwc-plugin-box-whisker-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createBoxWhiskerSeries(chart);\n\nseries.setData([\n    { time: '2024-04-22', min: 55, q1: 70, median: 80, q3: 85, max: 95 },\n    { time: '2024-04-23', min: 50, q1: 70, median: 78, q3: 83, max: 90, outliers: [40] },\n    { time: '2024-04-24', min: 58, q1: 68, median: 75, q3: 85, max: 90 },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `createBoxWhiskerSeries`, then set data with five\nnumbers per point:\n\n```js\nconst series = createBoxWhiskerSeries(chart, {\n    whiskerColor: '#131722',\n    lowerBoxColor: '#90BFF9',\n    upperBoxColor: '#2962FF',\n    medianColor: '#FFFFFF',\n    outlierColor: '#F23645',\n});\n\nseries.setData([\n    { time: '2024-04-22', min: 55, q1: 70, median: 80, q3: 85, max: 95 },\n    { time: '2024-04-23', min: 50, q1: 70, median: 78, q3: 83, max: 90, outliers: [40, 100] },\n    { time: '2024-04-24' },\n    { time: '2024-04-25', min: 58, q1: 68, median: 75, q3: 85, max: 90, upperBoxColor: '#F23645' },\n]);\n```\n\nEach data point is `{ time, min, q1, median, q3, max, outliers? }`:\n\n- The whiskers run from `min` to `q1` and from `q3` to `max`, and the box from\n  `q1` to `q3`, split at the `median` into a lower and an upper half.\n- `outliers` holds the values beyond the whiskers, each drawn as a dot. `null`\n  means none, and an outlier which is not a finite number is not drawn.\n- A point without five finite numbers, a missing or `null` one included, is\n  whitespace: it keeps its place on the time scale, is not drawn, and takes\n  no part in the price scale.\n- `whiskerColor`, `lowerBoxColor`, `upperBoxColor`, `medianColor` and\n  `outlierColor` on a point override the series options of the same names\n  for that point.\n\nThe autoscale range covers the lowest and the highest of the five numbers and\nthe outliers, so every dot is in view, and a point whose numbers are not in\norder still fits on the scale.\n\nThe series' price line and last value label follow the median of the last\npoint. Options can be changed at runtime with `series.applyOptions({ ... })`.\n\nIn the `plugin-examples` collection this series was `WhiskerBoxSeries`, with a\n`quartiles` array instead of the five named numbers and `lowerQuartileFill` /\n`upperQuartileFill` for the box colors. The package was never published under\nthose names, so it does not keep them.\n\n## Creating a series\n\nUse `createBoxWhiskerSeries(chart, options?, paneIndex?)`. It adds a\n`BoxWhiskerSeries` with `chart.addCustomSeries` and returns the normal series\nAPI, typed `BoxWhiskerSeriesApi`, with the plugin's data and options types\npreserved. The `BoxWhiskerSeries` class remains available for\n`chart.addCustomSeries(new BoxWhiskerSeries(), options)` too; no option\nchanges the plot values, so both behave the same.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `whiskerColor` | `string` | `'rgba(106, 27, 154, 1)'` | Color of the whiskers and their end caps. |\n| `lowerBoxColor` | `string` | `'rgba(103, 58, 183, 1)'` | Fill of the lower half of the box, from `q1` to the median. |\n| `upperBoxColor` | `string` | `'rgba(233, 30, 99, 1)'` | Fill of the upper half of the box, from the median to `q3`. |\n| `medianColor` | `string` | `'rgba(106, 27, 154, 1)'` | Color of the median line across the box. |\n| `outlierColor` | `string` | `'rgba(149, 152, 161, 1)'` | Color of the outlier dots. |\n\nThe standard `color` option is not used for the box plots; it colors the\nseries' price line.\n\n## Notes\n\n- The box is as wide as a candlestick body at the same bar spacing, and every\n  part is centered on the whisker line in whole device pixels, the way the\n  built-in candlestick centers its body on the wick. The median line spans\n  the slot, each whisker cap is as wide as a candlestick body at half the bar\n  spacing, and outlier dots shrink with the box down to a 1.5 px radius, so\n  they stay visible when the chart is zoomed out.\n- Only the points on screen are drawn. The series is never conflated: with\n  `timeScale.enableConflation` on, the chart still draws every point.\n- On `lightweight-charts` 5.2 and later the series reports the part under the\n  pointer through `hitTest`, within the series' `hitTestTolerance` (3 px by\n  default). The crosshair event's `hoveredInfo.objectId` is `'box-<point>'`,\n  `'median-<point>'`, `'whisker-<point>'` or `'outlier-<point>-<index>'`,\n  where `<point>` is the point's position in `series.data()` and `<index>`\n  the index into its `outliers`. Elsewhere in a point's slot, between its\n  lowest and highest value, the chart's own fallback still reports the series\n  as hovered, without an `objectId`, so check `objectId` before reading it.\n  The median line, drawn over the box, is reported on its own row of pixels.\n  An outlier dot is reported as a point and the box and the lines as ranges,\n  so a candle body the pointer is inside wins over a whisker it is only near.\n  Older versions never call `hitTest`.\n","isInternal":false,"tokens":2138,"sizeBytes":7278},{"name":"README.md","path":"packages/lwc-plugin-brushable-area-series/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/packages/lwc-plugin-brushable-area-series/README.md","title":"lwc-plugin-brushable-area-series Documentation","category":"plugin-manifest","format":"markdown","content":"# Brushable area series\n\nAn area series that can style parts of the data differently. You set a base\nstyle for the whole series and any number of *brush ranges*. A brush range is\na span of data points with its own line and fill colors.\n\nThe series itself only draws the styles. Attach the optional\n`BrushableAreaInteraction` primitive, or add your own pointer handling, to turn\nit into a brush selection: the user drags across the chart, the brush range for\nthe selected span is set, and the rest of the series keeps the base style.\nGive `outsideStyle` a semi-transparent style to get the classic effect where\nthe selection stays vivid and the rest looks faded.\n\nUse it for range selection on a sparkline or an overview chart. It also fits\nhighlighting a period, such as a trading session, an event window, or a\nbacktest sample, and comparing segments of one series visually.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-brushable-area-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createBrushableAreaSeries } from '@tradingview/lwc-plugin-brushable-area-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createBrushableAreaSeries(chart, {\n    lineColor: 'rgb(41, 98, 255)',\n    topColor: 'rgba(41, 98, 255, 0.4)',\n    bottomColor: 'rgba(41, 98, 255, 0)',\n    priceLineVisible: false,\n});\nseries.setData(data); // [{ time, value }, ...]\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-brushable-area-series\": \"https://unpkg.com/@tradingview/lwc-plugin-brushable-area-series/dist/brushable-area-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createBrushableAreaSeries } from '@tradingview/lwc-plugin-brushable-area-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createBrushableAreaSeries(chart, {\n    lineColor: 'rgb(41, 98, 255)',\n    topColor: 'rgba(41, 98, 255, 0.4)',\n    bottomColor: 'rgba(41, 98, 255, 0)',\n    priceLineVisible: false,\n});\nseries.setData(data); // [{ time, value }, ...]\n</script>\n```\n\n## Usage\n\nAdd the [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series) with `createBrushableAreaSeries`, set single-value data, then set\n`brushRanges` whenever the selection changes:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createBrushableAreaSeries } from '@tradingview/lwc-plugin-brushable-area-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createBrushableAreaSeries(chart, {\n    lineColor: 'rgb(41, 98, 255)',\n    topColor: 'rgba(41, 98, 255, 0.4)',\n    bottomColor: 'rgba(41, 98, 255, 0)',\n    priceLineVisible: false,\n});\nseries.setData(data); // [{ time, value }, ...]\n\n// Highlight points 40–80 in green and fade everything else.\nseries.applyOptions({\n    brushRanges: [\n        {\n            range: { from: 40, to: 80 },\n            style: {\n                lineColor: '#089981',\n                topColor: 'rgba(8, 153, 129, 0.4)',\n                bottomColor: 'rgba(8, 153, 129, 0)',\n                lineWidth: 3,\n            },\n        },\n    ],\n    outsideStyle: {\n        lineColor: 'rgba(41, 98, 255, 0.2)',\n        topColor: 'rgba(41, 98, 255, 0.05)',\n    },\n});\n\n// Clear the selection: the whole series goes back to the base style.\nseries.applyOptions({ brushRanges: [] });\n```\n\nA range's `style` and `outsideStyle` are both partial: every property left out\nfalls back to the base style set on the series.\n\nRanges are expressed in **logical indices** of the time scale (the position on\nthe chart's own index, shared by every series), not in time and not in the\nseries' own array positions. To turn a pointer position into a logical index,\nuse `chart.timeScale().coordinateToLogical(x)`, where `x` is the pointer's\nhorizontal position within the plot area.\n\nEach data point is `{ time, value }`. Points without a `value` are treated as\nwhitespace, and the line breaks at the gap rather than bridging it.\n\n### Brush selection\n\n`BrushableAreaInteraction` is an optional\n[series primitive](https://tradingview.github.io/lightweight-charts/docs/plugins/series-primitives)\nthat turns a mouse drag, a one-finger drag or a two-finger gesture into a brush\nrange, so the pointer handling does not have to be written again in every\napplication:\n\n```js\nimport {\n    BrushableAreaInteraction,\n} from '@tradingview/lwc-plugin-brushable-area-series';\n\nconst brush = new BrushableAreaInteraction({\n    style: { lineColor: '#089981', topColor: 'rgba(8, 153, 129, 0.4)' },\n    outsideStyle: { lineColor: 'rgba(41, 98, 255, 0.2)' },\n});\nseries.attachPrimitive(brush);\n\nbrush.activeRange().subscribe(range => {\n    // null once the selection is cleared by a click without a drag\n    if (range !== null) {\n        console.log(range.from, range.to, range.fromTime, range.toTime);\n    }\n});\n```\n\n| Interaction option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `style` | `Partial<style>` | green | Style applied to the brushed range. |\n| `outsideStyle` | `Partial<style>` | faded blue | Style applied outside the brushed range. |\n| `applyToSeries` | `boolean` | `true` | Set the series' `brushRanges` as the user drags. Turn it off to only receive `activeRange` events. |\n| `minimumRangeWidth` | `number` | `1` | Smallest drag, in logical indices, that counts as a range. |\n\nThe defaults are exported as `defaultInteractionOptions`. The range reported by\n`activeRange()` carries `from` / `to` as logical indices and `fromTime` /\n`toTime` as the times of the data points at those indices (`null` where the\nseries has no point there). `brush.clear()` removes the selection, and\n`brush.range()` returns the current one.\n\nThe chart's own drag gesture competes with brushing, so a chart using this\nprimitive normally sets `handleScroll: false` and `handleScale: false`.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `lineColor` | `string` | `'rgb(40,98,255)'` | Base line color, used outside brush ranges. |\n| `topColor` | `string` | `'rgba(40,98,255, 0.4)'` | Base fill color at the line (top of the gradient). |\n| `bottomColor` | `string` | `'rgba(40,98,255, 0)'` | Base fill color at the base price (bottom of the gradient). |\n| `lineWidth` | `1 \\| 2 \\| 3 \\| 4` | `2` | Base line width, in CSS pixels. |\n| `lineStyle` | `LineStyle` | `LineStyle.Solid` | Base dash pattern of the line. |\n| `lineVisible` | `boolean` | `true` | Draw the line itself. Set it to `false` for the fill only. |\n| `lineType` | `LineType` | `LineType.Simple` | Shape of the line between two points: straight, stepped or curved. The fill follows the same shape. |\n| `relativeGradient` | `boolean` | `false` | Anchor the far end of the fill gradient to the outermost point in view rather than to the edge of the pane, as `AreaSeries` does. |\n| `invertFilledArea` | `boolean` | `false` | Fill the area above the line, up to the top of the pane, instead of down to `basePrice`. |\n| `basePrice` | `number` | `0` | Price the area is filled down to. |\n| `brushRanges` | `{ range: { from: number; to: number }; style: Partial<style> }[]` | `[]` | Ranges of logical indices rendered in their own style. `from` is inclusive, `to` is exclusive. Set an empty array to clear. |\n| `outsideStyle` | `Partial<style>` | — | Style of the points outside every brush range. Used only while at least one range is set. |\n\n`style` is `{ lineColor, topColor, bottomColor, lineWidth, lineStyle }` — the\nsame five properties as the base style, and each one optional.\n\n## Notes\n\n- A point inside a brush range is drawn with that range's style; if ranges\n  overlap, the **last** matching range wins, so a new selection covers the ones\n  it is dragged over.\n- Each drawn segment takes the style of its right-hand point, and consecutive\n  points sharing a style are drawn as one path, so no seam shows inside a run.\n- The fill is a vertical gradient from `bottomColor` at `basePrice` to\n  `topColor` at the edge of the pane the fill extends towards (or at the\n  outermost point in view with `relativeGradient`). When `basePrice` falls\n  outside the visible price range, the fill reaches the edge of the pane.\n- The line and the fill are drawn one bar past each edge of the visible range,\n  so they leave the pane rather than stopping at the last visible point while\n  the chart is panned.\n- Points whose value falls outside the current price scale, and gaps in the\n  data, break the line rather than being drawn to an invalid coordinate.\n- The examples disable chart scrolling and scaling (`handleScroll`,\n  `handleScale`) so that dragging brushes instead of panning; decide which\n  gesture your chart should own.\n\n### Explicit whitespace\n\nUse `createBrushableAreaSeries` to retain whitespace passed through `setData` and\n`update`, including historical corrections. Other series' timestamps do not\nbreak the area. The low-level `BrushableAreaSeries` view remains available, but\nwithout the factory's gap predicate it draws continuously: the host does not\nprovide whitespace to custom renderers.\n\nUnder time-scale conflation the area is drawn from buckets of several bars, and\na whitespace run narrower than one bucket cannot be resolved at that bar\nspacing: it is absorbed into the bucket rather than breaking the area at every\nbar. Zooming in past the conflation threshold shows the gap again.\n","isInternal":false,"tokens":2592,"sizeBytes":10137},{"name":"README.md","path":"packages/lwc-plugin-dual-range-histogram-series/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/packages/lwc-plugin-dual-range-histogram-series/README.md","title":"lwc-plugin-dual-range-histogram-series Documentation","category":"plugin-manifest","format":"markdown","content":"# Dual range histogram series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series) that draws columns above and below a zero line. At each time\npoint it can show up to two nested columns in each direction: an outer range\nin a lighter color and an inner range in a darker color.\n\nBy default the columns are not sized in price units. The series has a fixed\nheight in pixels: the largest value gets the full height, and the other columns\nare scaled relative to it. This makes the series a compact overlay. It sits on\nthe zero line of another series' price scale and does not disturb that scale.\nSet `scaleMode: 'price'` to have the values read as prices and autoscale like\nany other series instead.\n\nUse it to show paired values around a center line. Typical examples: buy and\nsell volume with an inner share of \"aggressive\" orders, bid and ask depth, or\ninflows and outflows with a highlighted component. Any positive and negative\npair with a nested subset fits.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-dual-range-histogram-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createDualRangeHistogramSeries } from '@tradingview/lwc-plugin-dual-range-histogram-series';\n\nconst chart = createChart(document.getElementById('container'));\n\nconst histogram = createDualRangeHistogramSeries(chart, {\n    priceLineVisible: false,\n    lastValueVisible: false,\n});\nhistogram.setData([\n    { time: '2024-04-22', values: [120, 45, -80, -30] },\n    { time: '2024-04-23', values: [90, 60, -110, -20] },\n    { time: '2024-04-24', values: [140, 35, -60, -40] },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-dual-range-histogram-series\": \"https://unpkg.com/@tradingview/lwc-plugin-dual-range-histogram-series/dist/dual-range-histogram-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createDualRangeHistogramSeries } from '@tradingview/lwc-plugin-dual-range-histogram-series';\n\nconst chart = createChart(document.getElementById('container'));\n\nconst histogram = createDualRangeHistogramSeries(chart, {\n    priceLineVisible: false,\n    lastValueVisible: false,\n});\nhistogram.setData([\n    { time: '2024-04-22', values: [120, 45, -80, -30] },\n    { time: '2024-04-23', values: [90, 60, -110, -20] },\n    { time: '2024-04-24', values: [140, 35, -60, -40] },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `addCustomSeries`, then set data with a `values` array per\npoint — positive values draw upward, negative values downward. The array is\n`[upOuter, upInner, downOuter, downInner]`, which is also how the styling\noptions name their columns:\n\n```js\nimport { createChart, BaselineSeries } from 'lightweight-charts';\nimport { createDualRangeHistogramSeries } from '@tradingview/lwc-plugin-dual-range-histogram-series';\n\nconst chart = createChart(document.getElementById('container'), {\n    timeScale: { barSpacing: 21, minBarSpacing: 4 },\n});\n\nconst histogram = createDualRangeHistogramSeries(chart, {\n    priceLineVisible: false,\n    lastValueVisible: false,\n});\nhistogram.setData([\n    { time: '2024-04-22', values: [120, 45, -80, -30] },\n    { time: '2024-04-23', values: [90, 60, -110, -20] },\n    { time: '2024-04-24', values: [140, 35, -60, -40] },\n]);\n\n// A main series sharing the price scale; the histogram sits on its zero line.\nconst baseline = chart.addSeries(BaselineSeries, {\n    baseValue: { type: 'price', price: 0 },\n});\nbaseline.setData(mainData);\n```\n\nEach data point is `{ time, values: number[], colors? }`. Points with an empty\nor missing `values` array are treated as whitespace. A `colors` entry overrides\nthe series color for the column at the same position; an `undefined` entry\nkeeps the series color.\n\nColors and corner radii are set per column:\n\n```js\nhistogram.applyOptions({\n    colors: {\n        upOuter: '#BBDEFB',\n        upInner: '#1565C0',\n        downOuter: '#FFE0B2',\n        downInner: '#EF6C00',\n    },\n    borderRadius: { upOuter: 8, upInner: 4, downOuter: 8, downInner: 4 },\n    borderColor: '#131722',\n    borderWidth: 1,\n});\n```\n\n### Keeping the histogram in view\n\nIn the default `pixels` scale mode the histogram is `maxHeight` pixels tall and\ncentered on `baseValue`. It does not report its values to the price scale, so\nit never distorts the scaling of the main series — but if the base line is\nclose to the top or bottom of the pane, the columns are clipped. Reserve room\nwith `keepPixelSeriesInView`, which sets the price scale's margins and keeps\nthem correct while the chart is resized:\n\n```js\nimport { keepPixelSeriesInView } from '@tradingview/lwc-plugin-dual-range-histogram-series';\n\nconst stop = keepPixelSeriesInView(chart, histogram);\n// … later, before removing the chart:\nstop();\n```\n\nThe helper follows the series' current pane, including pane resizing and moves.\nIt uses a sizing primitive attached to the series; call `stop()` before removing\nthe chart. Calling `stop()` more than once is safe.\n\nPass a height as the third argument to reserve room for something other than\nthe series' own `maxHeight`.\n\n### Scale modes\n\n`scaleMode: 'price'` treats the values as prices measured from `baseValue`, so\nthe columns are autoscaled by the price scale like any other series;\n`maxHeight` and `normalize` are then ignored and no margins need reserving.\n\n`createDualRangeHistogramSeries` keeps the plot values synchronized with\n`scaleMode` and `baseValue`, including changes made through `applyOptions`.\n\nIn `pixels` mode, `normalize` chooses what the heights are scaled against:\n`'visible'` (the default) rescales the columns as you pan, `'all'` keeps their\nrelative heights across the whole data set, and a number fixes the value which\nfills half of `maxHeight`.\n\nOptions can be changed at runtime with `series.applyOptions({ ... })`.\n\n## Creating a series\n\nUse `createDualRangeHistogramSeries(chart, options?, paneIndex?)`. It returns the\nnormal series API, with the plugin's data and options types preserved. The helper\nmakes scaling options available before the first `setData` and rebuilds plot\nvalues automatically when those options change through `series.applyOptions`.\nThis keeps autoscaling, last-value labels and crosshair values consistent. The\nhelper retains a shallow copy of the input data, including whitespace, and\nre-ingests it only when a scaling option changes. Streaming updates remain\nincremental.\n\nThe low-level `DualRangeHistogramSeries` pane view remains available for integrations\nthat supply their own options getter to its constructor. Passing scaling options\nonly to `chart.addCustomSeries(new DualRangeHistogramSeries(), options)` cannot make\nthem available before data ingestion on LWC 5.0; use the creation helper instead.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `colors` | `{ upOuter, upInner, downOuter, downInner }` of `string` | `{ upOuter: '#ACE5DC', upInner: '#42BDA8', downOuter: '#FCCACD', downInner: '#F77C80' }` | Fill color of each column. A per-point `colors` entry overrides it. |\n| `borderRadius` | `{ upOuter, upInner, downOuter, downInner }` of `number` | `{ upOuter: 2, upInner: 0, downOuter: 2, downInner: 0 }` | Corner radius of each column, in CSS pixels, applied to the column's outer end. |\n| `borderColor` | `string \\| null` | `null` | Border color of the columns. `null` for no border. |\n| `borderWidth` | `number` | `1` | Border width in CSS pixels. Only drawn when `borderColor` is set. |\n| `maxHeight` | `number` | `130` | Total height of the histogram in CSS pixels; the largest value reaches half of it above or below the base line. `pixels` scale mode only. |\n| `scaleMode` | `'pixels' \\| 'price'` | `'pixels'` | Whether the column heights are a fixed number of pixels or prices measured from `baseValue`. See [Scale modes](#scale-modes). |\n| `normalize` | `'visible' \\| 'all' \\| number` | `'visible'` | What the heights are scaled against in `pixels` mode: the largest value in the visible range, in the whole data set, or a fixed value. |\n| `gap` | `number` | `0` | Gap between the upward and the downward half, in CSS pixels. |\n| `widthPercent` | `number` | `100` | Column width as a percentage of the bar spacing, `0`–`100`. |\n| `baseValue` | `number` | `0` | Price the columns are centered on. |\n| `highlightHovered` | `boolean` | `false` | Whether hovering the series fades every point except the one under the cursor. Requires Lightweight Charts 5.2 or later. |\n\n## Notes\n\n- Columns are matched to `colors` and `borderRadius` by their **position** in\n  `values`, not by their sign: a negative value in the `upOuter` slot points\n  downwards but is still drawn in the `upOuter` color.\n- Columns for the same point share one width and position; values are drawn in\n  array order, so later (inner) values paint over earlier (outer) ones. Keep\n  inner values smaller than outer ones for the nested look.\n- A point may carry more than four values; the four columns then repeat, so\n  `values[4]` is styled as `upOuter` again.\n- Column widths follow the same pixel grid as the built-in histogram series,\n  and the alignment is not carried across a gap of whitespace.\n- Values which are not finite are skipped, and nothing is drawn when there is\n  no value to scale the columns against (an all-zero data set, say).\n- `hitTest`, which reports the hovered point through the crosshair as\n  `bar-<index>`, is used by Lightweight Charts 5.2 and later, and\n  `conflationReducer` from 5.1. Older versions simply never call them, and\n  `highlightHovered` has no effect before 5.2.\n","isInternal":false,"tokens":2637,"sizeBytes":10311},{"name":"README.md","path":"packages/lwc-plugin-grouped-bars-series/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/packages/lwc-plugin-grouped-bars-series/README.md","title":"lwc-plugin-grouped-bars-series Documentation","category":"plugin-manifest","format":"markdown","content":"# Grouped bars series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series)\nthat draws several values per time point as columns side by side, one group\nof columns per point.\n\nUse it to compare a few quantities period by period, when a stack would hide\nthe smaller ones: revenue by region per quarter, buy and sell volume per day,\nor a forecast next to the actual value.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-grouped-bars-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createGroupedBarsSeries } from '@tradingview/lwc-plugin-grouped-bars-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createGroupedBarsSeries(chart, {\n    colors: ['#2962FF', '#F23645', '#FF9800'],\n});\n\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    { time: '2024-04-23', values: [14, 7, 6] },\n    { time: '2024-04-24', values: [11, 9, 4] },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-grouped-bars-series\": \"https://unpkg.com/@tradingview/lwc-plugin-grouped-bars-series/dist/grouped-bars-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createGroupedBarsSeries } from '@tradingview/lwc-plugin-grouped-bars-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createGroupedBarsSeries(chart, {\n    colors: ['#2962FF', '#F23645', '#FF9800'],\n});\n\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    { time: '2024-04-23', values: [14, 7, 6] },\n    { time: '2024-04-24', values: [11, 9, 4] },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `createGroupedBarsSeries`, then set data with a `values`\narray per point. The array order is the column order: `values[0]` is the\nleftmost column of the group.\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createGroupedBarsSeries } from '@tradingview/lwc-plugin-grouped-bars-series';\n\nconst chart = createChart(document.getElementById('container'), {\n    timeScale: { barSpacing: 18, minBarSpacing: 6 },\n});\nconst series = createGroupedBarsSeries(chart, {\n    colors: ['#2962FF', '#F23645', '#FF9800'],\n    widthPercent: 80,\n});\n\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    { time: '2024-04-23', values: [14, -7, 6] },\n    { time: '2024-04-24' },\n    { time: '2024-04-25', values: [11, 9, 4], colors: [undefined, '#131722'] },\n]);\n```\n\nEach data point is `{ time, values: (number | null)[] }`. A point with an empty or\nmissing `values` array is whitespace: it keeps its place on the time scale and\ndraws nothing. Columns grow from `base` (`0` by default), up for values above\nit and down for values below it. A `null` value, a number which is not finite,\nand a value equal to `base`, which would draw a column of no height, leave\ntheir column empty and stay out of the autoscale range, and the other columns\nkeep their places; use `null` for a missing value coming from JSON, which has\nno `NaN`. A point none of whose values draws a column is whitespace.\n\nEvery group is split into as many columns as the longest point has values, so\na column is as wide in every group; a point with fewer values leaves its last\ncolumns empty.\n\nA point may override the series colors for its own columns with a `colors`\narray. A missing or `undefined` entry keeps the series color for that column.\n\nThe series' price line and last value label follow the last value of the last\npoint that draws a column. Options can be changed at runtime with\n`series.applyOptions({ ... })`.\n\n## Creating a series\n\nUse `createGroupedBarsSeries(chart, options?, paneIndex?)`. It returns the\nnormal series API, with the plugin's data and options types preserved. It\nmakes `base` available to the series before the first `setData`, so the base\nline is part of the autoscale range from the start, and changing `base`\nthrough `series.applyOptions` rescales the series without setting the data\nagain. The helper keeps a shallow copy of the input data for that purpose,\nand counts the columns once per data change: a streamed `update()` recounts\nthem over all the points once, on the next redraw.\n\nThe `GroupedBarsSeries` class remains available for\n`chart.addCustomSeries(new GroupedBarsSeries(), options)`. Added that way, the\nseries only learns its options at the first render, so the data set before\nthen is read as if `base` were `0` until the data is set again: values around\n100 with `base: 50` are stretched down to 0, and a value of `0`, equal to that\nassumed base, draws nothing. It also counts the columns over all its points\non every redraw, after a scroll, a zoom or a data change.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `colors` | `string[]` | `['#2962FF', '#E1575A', '#F28E2C', 'rgb(164, 89, 209)', 'rgb(27, 156, 133)']` | Fill color of each column, in the order of `values`. If there are more values than colors, the colors repeat. An empty array falls back to this default. |\n| `base` | `number` | `0` | Price the columns are drawn from. It is part of the autoscale range, so the base line always stays in view. |\n| `columnWidthMode` | `'percent' \\| 'histogram'` | `'percent'` | How wide a group is: a share of the bar spacing, given by `widthPercent`, or as wide as the built-in histogram's columns, the whole bar spacing but a one pixel gap. |\n| `widthPercent` | `number` | `80` | Share of the bar spacing that each group fills in `percent` mode, `0`–`100`. The rest is the gap between neighboring groups; at `100` they touch, or are a device pixel apart where the bar spacing covers a fractional number of them. |\n\nPer-point overrides, on the data item:\n\n| Field | Type | Description |\n| --- | --- | --- |\n| `colors` | `(string \\| undefined)[]` | Fill color of each column of this point. A missing or `undefined` entry falls back to the series color for that column. |\n\n`values` is typed `(number | null)[]`.\n\nThe standard `color` option is not used for the columns; it colors the\nseries' price line and last value label.\n\n## Notes\n\n- In `percent` mode every group is the same whole number of device pixels\n  wide. In `histogram` mode groups can differ by a pixel, as the built-in\n  histogram's columns do, to keep the gap between them even. Each group's\n  width is split among its columns so that they abut with no seam and no\n  overlap and differ by at most one pixel, as long as every column gets at\n  least one device pixel. Set `timeScale.minBarSpacing` to keep that when the\n  user zooms out. Below it, every column still gets a pixel and columns share\n  pixels: the tallest are drawn first so that the shorter ones stay visible.\n- Only the points on screen are drawn. The series is never conflated: with\n  `timeScale.enableConflation` on, the chart still draws every point.\n- On `lightweight-charts` 5.2 and later the series reports the column nearest\n  the pointer through `hitTest`, within the series' `hitTestTolerance` (3 px\n  by default): the crosshair event's `hoveredInfo.objectId` is\n  `'column-<point>-<index>'`, where `<point>` is the point's position in\n  `series.data()` and `<index>` the column's index in its `values`. The\n  nearest column can belong to the next point, so read the point from\n  `<point>` rather than from the crosshair's time. Elsewhere in a point's slot,\n  between its lowest and highest value or the base, the chart's own fallback\n  still reports the series as hovered, without an `objectId`. Older versions\n  never call `hitTest`.\n","isInternal":false,"tokens":2187,"sizeBytes":8266},{"name":"README.md","path":"packages/lwc-plugin-heatmap-series/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/packages/lwc-plugin-heatmap-series/README.md","title":"lwc-plugin-heatmap-series Documentation","category":"plugin-manifest","format":"markdown","content":"# Heatmap series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series)\nthat draws a column of cells per time point, each cell covering a price range\nand colored by an amount.\n\nUse it to show how something is spread over prices through time: the size\nresting at each level of an order book, the volume traded at each price, the\ndensity of a forecast, or any value bucketed by price.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-heatmap-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createColorScale, createHeatmapSeries } from '@tradingview/lwc-plugin-heatmap-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createHeatmapSeries(chart, {\n    cellShader: createColorScale({ stops: ['rgba(41, 98, 255, 0.1)', '#2962FF', '#F23645'] }),\n});\n\nseries.setData([\n    { time: '2024-04-22', cells: [{ low: 100, high: 101, amount: 20 }, { low: 101, high: 102, amount: 80 }] },\n    { time: '2024-04-23', cells: [{ low: 100, high: 101, amount: 60 }, { low: 101, high: 102, amount: 40 }] },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-heatmap-series\": \"https://unpkg.com/@tradingview/lwc-plugin-heatmap-series/dist/heatmap-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createColorScale, createHeatmapSeries } from '@tradingview/lwc-plugin-heatmap-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createHeatmapSeries(chart, {\n    cellShader: createColorScale({ stops: ['rgba(41, 98, 255, 0.1)', '#2962FF', '#F23645'] }),\n});\n\nseries.setData([\n    { time: '2024-04-22', cells: [{ low: 100, high: 101, amount: 20 }, { low: 101, high: 102, amount: 80 }] },\n    { time: '2024-04-23', cells: [{ low: 100, high: 101, amount: 60 }, { low: 101, high: 102, amount: 40 }] },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `createHeatmapSeries`, then set data with a `cells`\narray per point:\n\n```js\nconst series = createHeatmapSeries(chart, {\n    cellShader: (amount, range) => (amount > (range.min + range.max) / 2 ? '#F23645' : '#2962FF'),\n    cellGap: 1,\n});\n\nseries.setData([\n    {\n        time: '2024-04-22',\n        cells: [\n            { low: 100, high: 101, amount: 20 },\n            { low: 101, high: 102, amount: 80 },\n        ],\n    },\n    { time: '2024-04-23' },\n]);\n```\n\nEach data point is `{ time, cells }`, and each cell `{ low, high, amount }`:\n\n- A cell is drawn from `low` to `high` across the point's whole slot, in the\n  color `cellShader(amount, range)` returns. The edges may come in either\n  order, and the cells of a column in any order. Cells are not expected to\n  overlap: cells of the same color are filled together, so where two\n  overlap, which one shows depends on their colors, not on their order.\n- A cell whose `low`, `high` or `amount` is not a finite number is skipped,\n  and so is a `null` cell, as a JSON feed may send.\n- A point with no cell to draw is whitespace, `cells` that is missing or\n  `null` included.\n\nCells whose price edges meet share a pixel edge, and so do neighboring\ncolumns, so with no gap they abut with no seam and no overlap at every zoom\nlevel and device pixel ratio.\n\nThe series autoscales to the lowest and highest cell edge of the points on\nscreen. The price line and the last value label, off by default, show the\nmiddle of a column's lowest and highest edge. Options can be changed at\nruntime with `series.applyOptions({ ... })`.\n\nIn the `plugin-examples` collection the types were spelled `HeatMapSeries`,\n`HeatMapData`, `HeatMapSeriesOptions` and `HeatMapCellShader`; the package\nspells them `HeatmapSeries`, `HeatmapData`, `HeatmapSeriesOptions` and\n`HeatmapCellShader`. `HeatmapCell` is unchanged.\n\n## Colors\n\nThe shader is called with the cell's amount and the range of the amounts in\nview, `{ min, max }`: the lowest and the highest amount among the cells of\nthe points on screen. A shader can spread its colors over that range rather\nthan over a maximum worked out in advance, so the colors keep their spread as\nthe chart scrolls.\n\n`createColorScale({ stops, domain?, steps? })` builds such a shader from a\nlist of colors:\n\n```js\nconst shader = createColorScale({\n    // Spread evenly from the low end to the high end.\n    stops: ['rgba(41, 98, 255, 0.1)', '#2962FF', '#F7A600', '#F23645'],\n    // The amounts that take the first and the last stop. Without it, the\n    // range of the amounts in view.\n    domain: [0, 100],\n    // How many colors the scale holds, 2 to 1024. Defaults to 32.\n    steps: 16,\n});\n```\n\nThe stops can be any CSS color the canvas accepts, and are mixed with\npremultiplied alpha, as CSS gradients are. A stop the canvas cannot parse, or\none in a color space other than sRGB such as `oklch()`, is left out; without a\nDOM, as in server-side rendering, only `#rrggbb`, `rgb()` and `rgba()` stops\ncan be read. An amount\nbeyond the domain takes the color at that end; a domain given high end first\nreverses the scale, and one whose ends are not both finite numbers is ignored.\nThe colors are worked out once, so the shader builds no color string while\ndrawing, and the fewer steps there are, the more cells share a fill.\n\nA shader of your own is called for every cell on screen on every paint, so\nkeep it cheap, and return a limited set of colors: cells are filled together\nby color, once per color per paint. A cell whose color the canvas cannot\nparse is not drawn.\n\n## Creating a series\n\nUse `createHeatmapSeries(chart, options?, paneIndex?)`. It adds the series and\nreturns the normal series API, with the plugin's data and options types\nfilled in. Its options type keeps `cellShader` a function, here and in\n`applyOptions`, so an inline shader gets its parameters typed; the library's\n`DeepPartial`, which `chart.addCustomSeries` uses, turns a function option\ninto an object type.\n\nThe `HeatmapSeries` class remains available for\n`chart.addCustomSeries(new HeatmapSeries(), options)`.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `cellShader` | `(amount: number, range: { min: number; max: number }) => string` | green, from faint at `0` to opaque at `100` | Turns a cell's amount into its fill color, given the range of the amounts in view. A value that is not a function falls back to the default. |\n| `cellGap` | `number` | `1` | Space between neighboring cells, in CSS pixels, both between the columns and between the cells of a column. Left out along a side where the cell is not more than three times as long. `0` for none. |\n| `cellBorderWidth` | `number` | `0` | Width of the border drawn inside the edge of every cell, in CSS pixels. Left out along a side where the cell, less the gap, is not more than three times as long. `0` for none. |\n| `cellBorderColor` | `string` | `'rgba(255, 255, 255, 1)'` | Color of the cell border. A color the canvas cannot parse draws no border. |\n\nThe gap and the border are rounded to whole device pixels along each axis.\nWhether a cell is long enough for them is decided before its edges are\nrounded, so cells of one size all get them or all go without.\nA negative width counts as `0`, and one that is not a number as the default.\n`lastValueVisible` and `priceLineVisible` default to `false`.\n\n## Notes\n\n- Only the points on screen are drawn, and of their cells only those on the\n  pane. A cell whose two edges round to the same device pixel is not drawn,\n  which can happen to one under a pixel tall.\n- The series has no `conflationReducer`, so the chart never merges its\n  points: zoomed out to a bar spacing under a device pixel, every column is\n  still worked out, and those that round to no width are skipped.\n- On `lightweight-charts` 5.2 and later the series reports the cell under the\n  pointer through `hitTest`, in the column whose slot holds the pointer and\n  within the series' `hitTestTolerance` (3 px by default) above or below the\n  cell: the crosshair's `hoveredInfo.objectId` is `'cell-<index>'`, the index\n  into that point's `cells`, and `param.seriesData` holds the point to read\n  the cell from. Between a column's lowest and highest edge, holes\n  included, the chart's own fallback reports the series as hovered without\n  an `objectId`, so check `objectId` before reading a cell. Hovering changes\n  nothing in how the series is drawn.\n- On 5.2 and later the chart also draws the hovered series above the others\n  by default. A heatmap is hovered anywhere over the span of its columns, so\n  it then covers a price series drawn on top of it. Create the chart with\n  `hoveredSeriesOnTop: false` to keep the other series on top.\n","isInternal":false,"tokens":2477,"sizeBytes":9339},{"name":"README.md","path":"packages/lwc-plugin-hlc-area-series/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/packages/lwc-plugin-hlc-area-series/README.md","title":"lwc-plugin-hlc-area-series Documentation","category":"plugin-manifest","format":"markdown","content":"# HLC area series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series) for high-low-close data. It draws the high, low, and close\nvalues as three lines. The band between the lines is filled with two colors:\none between high and close, another between close and low. The result reads\nlike a candlestick's range without the visual weight of individual candles.\n\nUse it to show a value together with its range over time. Typical examples: a\ndaily close between its high and low, a forecast with its confidence band, the\nminimum, average, and maximum of a metric, or a mid price between bid and ask.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-hlc-area-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createHLCAreaSeries } from '@tradingview/lwc-plugin-hlc-area-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createHLCAreaSeries(chart, {\n    highLineColor: '#089981',\n    lowLineColor: '#F23645',\n    closeLineColor: '#787B86',\n});\n\nseries.setData([\n    { time: '2024-04-22', high: 104.2, low: 98.7, close: 101.3 },\n    { time: '2024-04-23', high: 105.0, low: 100.1, close: 104.6 },\n    { time: '2024-04-24', high: 106.8, low: 103.2, close: 103.9 },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-hlc-area-series\": \"https://unpkg.com/@tradingview/lwc-plugin-hlc-area-series/dist/hlc-area-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createHLCAreaSeries } from '@tradingview/lwc-plugin-hlc-area-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createHLCAreaSeries(chart, {\n    highLineColor: '#089981',\n    lowLineColor: '#F23645',\n    closeLineColor: '#787B86',\n});\n\nseries.setData([\n    { time: '2024-04-22', high: 104.2, low: 98.7, close: 101.3 },\n    { time: '2024-04-23', high: 105.0, low: 100.1, close: 104.6 },\n    { time: '2024-04-24', high: 106.8, low: 103.2, close: 103.9 },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `createHLCAreaSeries`, then set data with `high`, `low`, and\n`close` values:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createHLCAreaSeries } from '@tradingview/lwc-plugin-hlc-area-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createHLCAreaSeries(chart, {\n    highLineColor: '#089981',\n    lowLineColor: '#F23645',\n    closeLineColor: '#787B86',\n});\n\nseries.setData([\n    { time: '2024-04-22', high: 104.2, low: 98.7, close: 101.3 },\n    { time: '2024-04-23', high: 105.0, low: 100.1, close: 104.6 },\n    { time: '2024-04-24', high: 106.8, low: 103.2, close: 103.9 },\n]);\n```\n\nEach data point is `{ time, high, low, close }`. Points missing any of the three\nvalues are treated as whitespace, and leave a gap. The series' price line and last-value label follow the\n`close` value.\n\nOptions can be changed at runtime with `series.applyOptions({ ... })`.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `highLineColor` | `string` | `'#049981'` | Color of the high line. |\n| `lowLineColor` | `string` | `'#F23645'` | Color of the low line. |\n| `closeLineColor` | `string` | `'#878993'` | Color of the close line. |\n| `highAreaColor` | `string` | `'rgba(4, 153, 129, 0.2)'` | Fill color between the high line and the close line. |\n| `lowAreaColor` | `string` | `'rgba(242, 54, 69, 0.2)'` | Fill color between the close line and the low line. |\n| `highLineWidth` | `LineWidth` | `2` | Width of the high line, in CSS pixels (`1`–`4`). |\n| `lowLineWidth` | `LineWidth` | `2` | Width of the low line, in CSS pixels (`1`–`4`). |\n| `closeLineWidth` | `LineWidth` | `2` | Width of the close line, in CSS pixels (`1`–`4`). |\n| `highLineStyle` | `LineStyle` | `LineStyle.Solid` | Dash pattern of the high line. |\n| `lowLineStyle` | `LineStyle` | `LineStyle.Solid` | Dash pattern of the low line. |\n| `closeLineStyle` | `LineStyle` | `LineStyle.Solid` | Dash pattern of the close line. |\n| `highLineVisible` | `boolean` | `true` | Whether the high line is drawn. |\n| `lowLineVisible` | `boolean` | `true` | Whether the low line is drawn. |\n| `closeLineVisible` | `boolean` | `true` | Whether the close line is drawn. |\n| `areaVisible` | `boolean` | `true` | Whether the two fills between the lines are drawn. |\n| `lineType` | `'simple' \\| 'step'` | `'simple'` | How the lines and the fills get from one point to the next. `'step'` matches the built-in `LineType.WithSteps`. |\n| `highAreaTopColor` | `string` | `''` | Upper stop of a vertical gradient filling the high–close band. |\n| `highAreaBottomColor` | `string` | `''` | Lower stop of the high–close band gradient. |\n| `lowAreaTopColor` | `string` | `''` | Upper stop of a vertical gradient filling the close–low band. |\n| `lowAreaBottomColor` | `string` | `''` | Lower stop of the close–low band gradient. |\n| `hoverPointRadius` | `number` | `4` | Radius, in CSS pixels, of the dots drawn on the high, low and close of the bar under the cursor while the series is hovered. `0` turns the highlight off. |\n\n`areaTopColor` and `areaBottomColor` are deprecated aliases of `highAreaColor`\nand `lowAreaColor`. They still work, and take precedence when both are set.\n\nA band is filled with a gradient only when both stops of its pair are set; while\neither is an empty string the flat `highAreaColor` / `lowAreaColor` is used. The\ngradient runs down the whole pane, like the built-in Area series' `topColor` and\n`bottomColor` without `relativeGradient`.\n\n## Notes\n\n- The price scale autoscales to the full `low`–`high` range, so the band is\n  never clipped.\n- Points missing any of `high`, `low` and `close` are whitespace. The lines and\n  the fills break at a run of whitespace instead of bridging it, and a point\n  whose price falls off the scale is skipped rather than turned into a NaN\n  coordinate.\n- The lines and the fills continue past the first and the last visible point, so\n  they reach the edges of the pane while panning.\n- Line widths follow the library's `LineWidth` type, so `0` is not one of them.\n  Use `highLineVisible` / `lowLineVisible` / `closeLineVisible` to hide a line\n  and `areaVisible` to hide both fills.\n- On Lightweight Charts™ 5.2 and later the series reports the bar under the\n  cursor through `hitTest` and highlights its three values, and from 5.1\n  conflated points are merged as the highest high, the lowest low and the\n  last close.\n\n### Explicit whitespace\n\nUse `createHLCAreaSeries` to retain whitespace passed through `setData` and\n`update`, including historical corrections. Other series' timestamps do not\nbreak the area. The low-level `HLCAreaSeries` view remains available, but\nwithout the factory's gap predicate it draws continuously: the host does not\nprovide whitespace to custom renderers.\n\nUnder time-scale conflation the area is drawn from buckets of several bars, and\na whitespace run narrower than one bucket cannot be resolved at that bar\nspacing: it is absorbed into the bucket rather than breaking the area at every\nbar. Zooming in past the conflation threshold shows the gap again.\n","isInternal":false,"tokens":2197,"sizeBytes":7901},{"name":"README.md","path":"packages/lwc-plugin-image-watermark/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/packages/lwc-plugin-image-watermark/README.md","title":"lwc-plugin-image-watermark Documentation","category":"plugin-manifest","format":"markdown","content":"# Image watermark\n\nAn image drawn behind the chart content, as a\n[series primitive](https://tradingview.github.io/lightweight-charts/docs/plugins/series-primitives)\n(`ImageWatermark`) or as a\n[pane primitive](https://tradingview.github.io/lightweight-charts/docs/plugins/pane-primitives)\n(`ImageWatermarkPane`). The image is placed within the pane — centered by\ndefault, or anchored to a corner — and scaled to fit, to fill, or not at all.\nPosition, size limits, padding, opacity and visibility can all be changed after\nthe watermark has been attached.\n\nThe series primitive belongs to the series it is attached to: it lives in that\nseries' pane and is removed together with the series. The pane primitive needs\nno series at all.\n\nUse it to brand a chart with a logo, or to mark a chart as a preview or draft,\nwithout touching the chart's own rendering.\n\n> **Lightweight Charts™ 5 also ships a built-in image watermark.**\n> [`createImageWatermark(pane, url, options)`](https://tradingview.github.io/lightweight-charts/docs/api/functions/createImageWatermark)\n> is a pane primitive which centers an image and scales it to fit. If that is\n> all you need, the built-in function is the right choice. Use this package for\n> a watermark tied to a specific series rather than to a pane, or for anything\n> the built-in does not offer: corner and fractional positions, `objectFit`,\n> `crossOrigin`, `visible`, `zOrder`, `applyOptions` / `setImage` and an\n> `onError` callback.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-image-watermark\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { ImageWatermark } from '@tradingview/lwc-plugin-image-watermark';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(data);\n\nseries.attachPrimitive(new ImageWatermark('/logo.svg', { alpha: 0.4 }));\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-image-watermark\": \"https://unpkg.com/@tradingview/lwc-plugin-image-watermark/dist/image-watermark.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { ImageWatermark } from '@tradingview/lwc-plugin-image-watermark';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(data);\n\nseries.attachPrimitive(new ImageWatermark('/logo.svg', { alpha: 0.4 }));\n</script>\n```\n\n## Usage\n\n### Behind a series\n\nCreate the watermark with the image URL, then attach it to the series it\nshould follow:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { ImageWatermark } from '@tradingview/lwc-plugin-image-watermark';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(data);\n\nconst watermark = new ImageWatermark('/logo.svg', {\n    maxHeight: 400,\n    maxWidth: 400,\n    padding: 50,\n    alpha: 0.4,\n});\nseries.attachPrimitive(watermark);\n```\n\nTo remove the watermark, detach it from the series:\n\n```js\nseries.detachPrimitive(watermark);\n```\n\n### Behind a pane\n\n`ImageWatermarkPane` takes the same image URL and the same options, and is\nattached to a pane instead of a series. Use it when the watermark should stay\nput while series are added and removed:\n\n```js\nimport { ImageWatermarkPane } from '@tradingview/lwc-plugin-image-watermark';\n\nconst watermark = new ImageWatermarkPane('/logo.svg', { alpha: 0.4 });\nchart.panes()[0].attachPrimitive(watermark);\n\n// later\nchart.panes()[0].detachPrimitive(watermark);\n```\n\n### Changing the watermark\n\nBoth classes have the same methods:\n\n```js\nwatermark.applyOptions({ position: 'bottom-right', alpha: 0.2 });\nwatermark.setImage('/other-logo.svg'); // same as applyOptions({ imageUrl })\nwatermark.options(); // the current options, with the defaults filled in\n```\n\n`applyOptions` merges: an option which is not passed, or is passed as\n`undefined`, is left unchanged.\n\nThe image is loaded when the primitive is attached and drawn once it has\ndecoded; until then nothing is rendered. A new image passed to `setImage` or\n`applyOptions` replaces the current one once it has decoded, so the watermark\ndoes not blink out in between. Any URL the browser can load into an\n`<img>` element works, including SVG and data URLs. Decoded images are cached\nby URL, so detaching and re-attaching a watermark — or using the same image\ntwice — never loads it again.\n\n## Options\n\nOptions are passed as the second constructor argument, which is optional, as\nis every option in it. The type is `ImageWatermarkPluginOptions`, and the\ndefaults are exported as `defaultOptions`.\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `imageUrl` | `string` | `''` | URL of the image. The first constructor argument sets the same option. |\n| `position` | `WatermarkPosition` | `'center'` | Where the image sits in the pane: `'center'`, `'top-left'`, `'top-right'`, `'bottom-left'`, `'bottom-right'`, or `{ x, y }`. |\n| `objectFit` | `WatermarkObjectFit` | `'contain'` | `'contain'` scales the image to fit, `'cover'` scales it to fill and crops the overflow, `'none'` draws it at its natural size. |\n| `maxWidth` | `number` | — (pane width) | Maximum width of the drawing area, in CSS pixels. |\n| `maxHeight` | `number` | — (pane height) | Maximum height of the drawing area, in CSS pixels. |\n| `padding` | `number` | `0` | Minimum distance between the drawing area and the edges of the pane, in CSS pixels. |\n| `alpha` | `number` | `1` | Opacity of the image, from `0` (invisible) to `1` (opaque). |\n| `visible` | `boolean` | `true` | Whether the watermark is drawn at all. |\n| `zOrder` | `'bottom' \\| 'normal' \\| 'top'` | `'bottom'` | Layer the watermark is drawn in. `'bottom'` puts it behind the grid and the series. |\n| `crossOrigin` | `'anonymous' \\| 'use-credentials'` | — | `crossOrigin` attribute of the underlying `<img>` element. |\n| `onError` | `(error, imageUrl) => void` | — | Called when the image cannot be loaded. Nothing else reports the failure. |\n\n### Position and size\n\nThe drawing area is the pane inset by `padding` and limited to `maxWidth` /\n`maxHeight`. `position` places that area within the pane and the image within\nthat area:\n\n- a named anchor — `'center'` or one of the four corners;\n- `{ x, y }`, fractions of the free space from `0` to `1`. `{ x: 0, y: 0 }` is\n  the top-left corner, `{ x: 1, y: 1 }` the bottom-right one, `{ x: 0.5, y: 0 }`\n  the middle of the top edge. Values outside `0`…`1` are clamped.\n\n`objectFit` then decides the scale. With `'contain'` (the default) the image is\nscaled up or down to fit, keeping its aspect ratio; set `maxWidth` /\n`maxHeight` to its natural size if it should never be enlarged. With `'cover'`\nit is scaled to fill the drawing area and the overflow is cropped, and with\n`'none'` it is drawn at its natural size. Nothing is ever drawn outside the\ndrawing area, so `padding` always holds.\n\n## Notes\n\n- The watermark is drawn behind the chart content by default: the grid, the\n  series, and other primitives all appear on top of it. Only the pane\n  background is below it. Pass `zOrder: 'top'` to draw it over everything\n  instead.\n- The image appears only in the pane it belongs to, where the series is drawn.\n  It never covers the price scales or the time scale, and a visible left price\n  scale or a second pane does not move it.\n- A watermark whose image cannot be loaded draws nothing and throws nothing.\n  Pass `onError` to be told about it; the plugin logs nothing itself.\n- `ImageWatermarkOptions` is still exported, as a deprecated alias of\n  `ImageWatermarkPluginOptions`. The plugin option type was renamed because\n  the library exports an `ImageWatermarkOptions` of its own, for the built-in\n  `createImageWatermark`. The alias is kept for compatibility and will be\n  removed in a future major version.\n- The image can be loaded from any origin. However, an image served without\n  CORS headers marks the canvas as \"tainted\", and\n  [`takeScreenshot`](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/IChartApi#takescreenshot)\n  fails on a tainted canvas. If you plan to export the chart as an image, serve\n  the watermark image with CORS headers and set `crossOrigin: 'anonymous'`.\n","isInternal":false,"tokens":2217,"sizeBytes":8820},{"name":"README.md","path":"packages/lwc-plugin-lollipop-series/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/packages/lwc-plugin-lollipop-series/README.md","title":"lwc-plugin-lollipop-series Documentation","category":"plugin-manifest","format":"markdown","content":"# Lollipop series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series)\nthat draws each value as a dot at the end of a stem. The stem runs from a\nbase line, `0` by default, up to a value above it or down to a value below it.\n\nUse it where a histogram would put too much ink on the chart: values that\nswing around a reference, such as daily returns, net flows or a difference\nfrom a target, where the dot marks the value and the stem shows how far it is\nfrom the base.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-lollipop-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createLollipopSeries } from '@tradingview/lwc-plugin-lollipop-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createLollipopSeries(chart, { color: '#2962FF' });\n\nseries.setData([\n    { time: '2024-04-22', value: 4.2 },\n    { time: '2024-04-23', value: -1.8 },\n    { time: '2024-04-24', value: 2.6 },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-lollipop-series\": \"https://unpkg.com/@tradingview/lwc-plugin-lollipop-series/dist/lollipop-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createLollipopSeries } from '@tradingview/lwc-plugin-lollipop-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createLollipopSeries(chart, { color: '#2962FF' });\n\nseries.setData([\n    { time: '2024-04-22', value: 4.2 },\n    { time: '2024-04-23', value: -1.8 },\n    { time: '2024-04-24', value: 2.6 },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `createLollipopSeries`, then set data with a `value` per\npoint:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createLollipopSeries } from '@tradingview/lwc-plugin-lollipop-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createLollipopSeries(chart, {\n    base: 0,\n    lineWidth: 2,\n    markerSize: 8,\n});\n\nseries.setData([\n    { time: '2024-04-22', value: 4.2 },\n    { time: '2024-04-23', value: -1.8, color: '#F23645' },\n    { time: '2024-04-24' },\n    { time: '2024-04-25', value: 2.6 },\n]);\n```\n\nEach data point is `{ time, value }`. A point without a finite `value`,\n`null` included, as JSON sends a missing one, is whitespace: it keeps its\nplace on the time scale and draws nothing. A `color` on a point\noverrides the series `color` for that point's stem and dot.\n\nThe series' price line and last value label follow the last value. Options can\nbe changed at runtime with `series.applyOptions({ ... })`.\n\n## Creating a series\n\nUse `createLollipopSeries(chart, options?, paneIndex?)`. It returns the normal\nseries API, with the plugin's data and options types preserved. It makes `base`\navailable to the series before the first `setData`, so the base line is part\nof the autoscale range from the start, and changing `base` through\n`series.applyOptions` rescales the series without setting the data again. The\nhelper keeps a shallow copy of the input data for that purpose; streaming\nupdates stay incremental.\n\nThe `LollipopSeries` class remains available for\n`chart.addCustomSeries(new LollipopSeries(), options)`. Added that way, the\nseries only learns its options at the first render, so the data set before\nthen is scaled as if `base` were `0`: values around 100 with `base: 100` are\nstretched down to 0 until the data is set again.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`color`, `priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `base` | `number` | `0` | Price the stems are drawn from. It is part of the autoscale range, so the base line always stays in view. |\n| `lineWidth` | `number` | `2` | Width of the stem, in CSS pixels, at most half the bar spacing and at least one device pixel. |\n| `markerSize` | `number` | `8` | Diameter of the dot at the value, in CSS pixels, at most 20 and at most the bar spacing. `0` draws no dots. |\n\nThe standard `color` option colors the stems, the dots and the price line.\n\n## Notes\n\n- Stems and dots shrink with the bar spacing when the chart is zoomed out: a\n  stem is at most half the bar spacing wide, down to one device pixel, and a\n  dot at most as wide as the bar spacing, so neighboring dots can touch but\n  stay apart from the next stem. At a bar spacing of one device pixel the\n  one-pixel stems fill every pixel. Set `timeScale.minBarSpacing` to keep\n  lollipops from getting that small.\n- Autoscale covers the values and the base, not the dots around them, so a\n  dot at the highest or lowest value sticks out by its radius. The 20 px cap\n  on `markerSize` keeps it within the price scale's default margins in a pane\n  at least 100 px tall.\n- Only the points on screen are drawn. The series is never conflated: with\n  `timeScale.enableConflation` on, the chart still draws every point.\n- On `lightweight-charts` 5.2 and later the series reports the lollipop under\n  the pointer through `hitTest`, within the series' `hitTestTolerance` (3 px\n  by default): the crosshair event's `hoveredInfo.objectId` is `bar-<index>`,\n  where `<index>` is the point's position in `series.data()`. The dot is\n  reported as a point and the stem as a range, like a column, so a candle body\n  the pointer is inside wins over a stem the pointer is only near. Elsewhere\n  in a point's slot, between the base and the value, the chart's own fallback\n  still reports the series as hovered, without an `objectId`. Older versions\n  never call `hitTest`.\n","isInternal":false,"tokens":1648,"sizeBytes":6221},{"name":"README.md","path":"packages/lwc-plugin-pretty-histogram-series/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/packages/lwc-plugin-pretty-histogram-series/README.md","title":"lwc-plugin-pretty-histogram-series Documentation","category":"plugin-manifest","format":"markdown","content":"# Pretty histogram series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series) that draws a histogram with rounded bars. Unlike the built-in\nhistogram series, it can round the outer corners of each bar, control the bar\nwidth as a share of the bar spacing, color bars by their sign, draw a border\nand fade the fill into a second color. The result is a softer look that fits\ndashboards and marketing-style charts.\n\nUse it for volume panes, single-value indicators, or any bar chart where the\ndefault square bars look too heavy.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-pretty-histogram-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createPrettyHistogramSeries } from '@tradingview/lwc-plugin-pretty-histogram-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createPrettyHistogramSeries(chart, {\n    color: '#2962FF',\n    widthPercent: 60,\n    radius: 6,\n});\n\nseries.setData([\n    { time: '2024-04-22', value: 12.5 },\n    { time: '2024-04-23', value: -4.1 },\n    { time: '2024-04-24', value: 8.3, color: '#F23645' },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-pretty-histogram-series\": \"https://unpkg.com/@tradingview/lwc-plugin-pretty-histogram-series/dist/pretty-histogram-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createPrettyHistogramSeries } from '@tradingview/lwc-plugin-pretty-histogram-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createPrettyHistogramSeries(chart, {\n    color: '#2962FF',\n    widthPercent: 60,\n    radius: 6,\n});\n\nseries.setData([\n    { time: '2024-04-22', value: 12.5 },\n    { time: '2024-04-23', value: -4.1 },\n    { time: '2024-04-24', value: 8.3, color: '#F23645' },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `addCustomSeries`, then set histogram data:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createPrettyHistogramSeries } from '@tradingview/lwc-plugin-pretty-histogram-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createPrettyHistogramSeries(chart, {\n    color: '#2962FF',\n    widthPercent: 60,\n    radius: 6,\n});\n\nseries.setData([\n    { time: '2024-04-22', value: 12.5 },\n    { time: '2024-04-23', value: -4.1 },\n    { time: '2024-04-24', value: 8.3, color: '#F23645' },\n]);\n```\n\nEach data point is `{ time, value, color? }` — the same shape as the built-in\nhistogram series. A per-point `color` overrides the series `color` for that\nbar. Points without a `value` are treated as whitespace.\n\nOptions can be changed at runtime with `series.applyOptions({ ... })`.\n\n### Two-tone bars\n\nSet `upColor` and `downColor` to color each bar by its sign relative to\n`base`, the way a volume pane usually does:\n\n```js\nseries.applyOptions({\n    base: 0,\n    upColor: '#089981',\n    downColor: '#F23645',\n});\n```\n\nA per-point `color` still wins over both.\n\n### The base line\n\nBars grow from `base` (`0` by default), and the base is always reported to the\nautoscale alongside the values, exactly as the built-in histogram series does.\nBars are therefore never cut off at the edge of the pane, and no custom\n`autoscaleInfoProvider` is needed.\n\n`base` is read when the data is set, so change it before or together with\n`setData` if you also rely on the autoscale following it.\n\n## Creating a series\n\nUse `createPrettyHistogramSeries(chart, options?, paneIndex?)`. It returns the\nnormal series API, with the plugin's data and options types preserved. The helper\nmakes scaling options available before the first `setData` and rebuilds plot\nvalues automatically when those options change through `series.applyOptions`.\nThis keeps autoscaling, last-value labels and crosshair values consistent. The\nhelper retains a shallow copy of the input data, including whitespace, and\nre-ingests it only when a scaling option changes. Streaming updates remain\nincremental.\n\nThe low-level `PrettyHistogramSeries` pane view remains available for integrations\nthat supply their own options getter to its constructor. Passing scaling options\nonly to `chart.addCustomSeries(new PrettyHistogramSeries(), options)` cannot make\nthem available before data ingestion on LWC 5.0; use the creation helper instead.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `color` | `string` | `'#D63864'` | Fill color of the bars, used whenever no more specific color applies. A per-point `color` in the data overrides it. |\n| `upColor` | `string \\| null` | `null` | Fill color of bars at or above `base`. `null` falls back to `color`. |\n| `downColor` | `string \\| null` | `null` | Fill color of bars below `base`. `null` falls back to `color`. |\n| `base` | `number` | `0` | Price the bars grow from. Always included in the autoscale. |\n| `widthPercent` | `number` | `50` | Bar width as a percentage of the bar spacing, `0`–`100`. Ignored when `widthMode` is `'histogram'`. |\n| `widthMode` | `'percent' \\| 'histogram'` | `'percent'` | `'percent'` sizes each bar from `widthPercent`. `'histogram'` uses the full slot with a one-pixel gap, exactly as the built-in histogram series does. |\n| `minColumnWidth` | `number` | `1` | Lower bound for the bar width, in CSS pixels. |\n| `radius` | `number` | `4` | Corner radius of the bar's outer end, in CSS pixels. Positive bars are rounded at the top, negative bars at the bottom. The radius is capped at half the bar width and at the bar height. |\n| `roundInnerCorners` | `boolean` | `false` | Whether the corners at the `base` end are rounded with the same radius. |\n| `borderColor` | `string \\| null` | `null` | Border color of the bars. `null` for no border. |\n| `borderWidth` | `number` | `1` | Border width in CSS pixels. Only drawn when `borderColor` is set. |\n| `gradientColor` | `string \\| null` | `null` | Color the fill fades into at the outer end of each bar. `null` for a flat fill. |\n| `highlightHovered` | `boolean` | `false` | Whether hovering the series fades every bar except the one under the cursor. Requires Lightweight Charts 5.2 or later. |\n\n## Notes\n\n- Bars are anchored at `base` and the base is always part of the autoscale, so\n  the series behaves like the built-in histogram; see\n  [The base line](#the-base-line).\n- Bar widths reproduce the built-in histogram exactly in `'histogram'` width\n  mode and at `widthPercent: 100`: the same pixel grid, the same one-pixel gap,\n  and no alignment carried across a whitespace gap.\n- Flat, borderless bars are drawn in batches: consecutive bars of the same\n  color are filled in one canvas operation. Setting `borderColor`,\n  `gradientColor` or `highlightHovered` paints bar by bar instead.\n- `hitTest`, which reports the hovered bar through the crosshair as\n  `bar-<index>`, is used by Lightweight Charts 5.2 and later, and\n  `conflationReducer` from 5.1. Older versions simply never call them, and\n  `highlightHovered` has no effect before 5.2.\n","isInternal":false,"tokens":2024,"sizeBytes":7745},{"name":"README.md","path":"packages/lwc-plugin-preview-kit/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/packages/lwc-plugin-preview-kit/README.md","title":"lwc-plugin-preview-kit Documentation","category":"plugin-manifest","format":"markdown","content":"# Preview kit\n\nPrivate, never published. Shared layout and controls for the catalog preview\npages of the plugin packages: `src/example/preview.html` and `preview.ts` of\nevery `packages/lwc-plugin-*`, declared as `lwcPlugin.preview` and built to\n`/plugin-previews/<slug>/` by `pnpm plugins:build-demos`.\n\nA preview page is not the plugin's demo. The demo (`lwcPlugin.demo`) is the\npage a developer opens on its own: it carries edge cases, whitespace runs,\nnegative values and every option the plugin has. A preview is what the\ncatalog frames next to the README, so it shows the plugin at its best in a\nshort frame and nothing else.\n\nThree entry points:\n\n- `@tradingview/lwc-plugin-preview-kit/preview.css` — the whole layout. One\n  compact `#controls` row above a `#chart` that fills the rest of the frame.\n  Light and dark, keyed on the root element's `data-theme`. Nothing is\n  restyled after load, so the chart is created at its final size and does not\n  jump.\n- `@tradingview/lwc-plugin-preview-kit/preview-theme` — follows the theme of\n  the docs page that frames the preview, live: toggling the site theme\n  restyles the running preview without reloading it. `?theme=light|dark` in\n  the page URL pins a theme instead (a page opened on its own is light).\n  `themeChart(chart, onTheme?)` themes the chart's background, text, grid,\n  scale borders and crosshair labels now and on every switch; `onTheme` is\n  where a preview recolours anything of its own that would not read on the\n  other background.\n- `@tradingview/lwc-plugin-preview-kit/preview-controls` — `mountControls(defs)`\n  builds the control row from `select`, `checkbox` and `button` declarations,\n  and `addRefreshButton(onRefresh)` adds a \"New data\" button for the previews\n  whose sample data is random. Plain DOM, no framework.\n\nA preview page is therefore two elements and a script:\n\n```html\n<div id=\"controls\"></div>\n<div id=\"chart\"></div>\n<script type=\"module\" src=\"./preview.ts\"></script>\n```\n\nThe page script is a module and can run after the first paint, so\n`src/theme-boot.js` sets the theme before it: `pnpm plugins:build-demos`\ninlines it straight after `<meta charset>` of every built preview page (the\nbuild fails without one), which is why a preview page needs no script of its\nown in its HTML. It applies the same rules as `preview-theme`; change them in\nboth places.\n\nAdd the kit to a package with `@tradingview/lwc-plugin-preview-kit: workspace:*` in\n`devDependencies` — `create-lwc-plugin --workspace` does this for you — and\ndeclare `lwcPlugin.preview` (and `previewHeight`, when 330 px is not enough).\n","isInternal":false,"tokens":649,"sizeBytes":2600},{"name":"README.md","path":"packages/lwc-plugin-rounded-candles-series/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/packages/lwc-plugin-rounded-candles-series/README.md","title":"lwc-plugin-rounded-candles-series Documentation","category":"plugin-manifest","format":"markdown","content":"# Rounded candles series\n\nA [custom candlestick series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series) with rounded candle bodies. It renders the same\nopen-high-low-close data as the built-in candlestick series. Each body is\ndrawn as a rounded rectangle. The corner radius adapts to the bar spacing:\nsharp when zoomed out, soft when zoomed in.\n\nUse it as a drop-in replacement for the built-in candlesticks wherever a\nsofter visual style fits, such as dashboards, embedded widgets, or marketing\npages.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-rounded-candles-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { RoundedCandleSeries } from '@tradingview/lwc-plugin-rounded-candles-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addCustomSeries(new RoundedCandleSeries(), {\n    upColor: '#089981',\n    downColor: '#F23645',\n    wickUpColor: '#089981',\n    wickDownColor: '#F23645',\n});\n\nseries.setData([\n    { time: '2024-04-22', open: 100.2, high: 104.6, low: 99.1, close: 103.8 },\n    { time: '2024-04-23', open: 103.8, high: 105.0, low: 101.4, close: 102.0 },\n    { time: '2024-04-24', open: 102.0, high: 106.1, low: 101.7, close: 105.4 },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-rounded-candles-series\": \"https://unpkg.com/@tradingview/lwc-plugin-rounded-candles-series/dist/rounded-candles-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { RoundedCandleSeries } from '@tradingview/lwc-plugin-rounded-candles-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addCustomSeries(new RoundedCandleSeries(), {\n    upColor: '#089981',\n    downColor: '#F23645',\n    wickUpColor: '#089981',\n    wickDownColor: '#F23645',\n});\n\nseries.setData([\n    { time: '2024-04-22', open: 100.2, high: 104.6, low: 99.1, close: 103.8 },\n    { time: '2024-04-23', open: 103.8, high: 105.0, low: 101.4, close: 102.0 },\n    { time: '2024-04-24', open: 102.0, high: 106.1, low: 101.7, close: 105.4 },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `addCustomSeries`, then set candlestick data:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { RoundedCandleSeries } from '@tradingview/lwc-plugin-rounded-candles-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addCustomSeries(new RoundedCandleSeries(), {\n    upColor: '#089981',\n    downColor: '#F23645',\n    wickUpColor: '#089981',\n    wickDownColor: '#F23645',\n});\n\nseries.setData([\n    { time: '2024-04-22', open: 100.2, high: 104.6, low: 99.1, close: 103.8 },\n    { time: '2024-04-23', open: 103.8, high: 105.0, low: 101.4, close: 102.0 },\n    { time: '2024-04-24', open: 102.0, high: 106.1, low: 101.7, close: 105.4 },\n]);\n```\n\nEach data point is `{ time, open, high, low, close }` — the same shape as the\nbuilt-in candlestick series. Points missing any of the four values are treated\nas whitespace, and leave a gap.\n\nA constant `radius` fixes the corner rounding regardless of zoom:\n\n```js\nseries.applyOptions({ radius: 6 });\n```\n\nOptions can be changed at runtime with `series.applyOptions({ ... })`.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `upColor` | `string` | `'#26a69a'` | Body color of rising candles. |\n| `downColor` | `string` | `'#ef5350'` | Body color of falling candles. |\n| `borderVisible` | `boolean` | `true` | Whether a border is drawn around the body. |\n| `borderUpColor` | `string` | `'#26a69a'` | Border color of rising candles. |\n| `borderDownColor` | `string` | `'#ef5350'` | Border color of falling candles. |\n| `borderColor` | `string` | — | Border color of both directions. Wins over `borderUpColor` / `borderDownColor` while it is set to a non-empty string. |\n| `wickVisible` | `boolean` | `true` | Whether wicks are drawn. |\n| `wickUpColor` | `string` | `'#26a69a'` | Wick color of rising candles. |\n| `wickDownColor` | `string` | `'#ef5350'` | Wick color of falling candles. |\n| `wickColor` | `string` | — | Wick color of both directions. Wins over `wickUpColor` / `wickDownColor` while it is set to a non-empty string. |\n| `wickLineCap` | `'butt' \\| 'round'` | `'butt'` | Shape of the two wick ends. |\n| `radius` | `number \\| ((barSpacing: number) => number)` | `bs => bs < 4 ? 0 : bs / 3` | Corner radius of the candle body, in CSS pixels. Either a constant, or a function of the current bar spacing. Use `0` for square candles. |\n| `upDownMode` | `'openClose' \\| 'previousClose'` | `'openClose'` | How a candle is decided to be rising or falling. `'openClose'` compares `open <= close`, exactly as the built-in candlestick series does. `'previousClose'` compares the close with the previous candle's close and treats the first candle as rising. |\n| `hoverDimOpacity` | `number` | `1` | Opacity of the candles other than the hovered one while the series is hovered. `1` leaves the series unchanged. |\n\nEach data point may also carry `color`, `borderColor` and `wickColor`, which\noverride the corresponding options for that candle only — the same per-item\noverrides the built-in candlestick series supports.\n\n## Notes\n\n- A candle counts as *rising* when `open <= close`, exactly as the built-in\n  candlestick series decides it. `upDownMode: 'previousClose'` restores the\n  behavior this plugin had while it was an example (close compared with the\n  previous close, the first candle always rising).\n- `borderColor` and `wickColor` are resolved at draw time, so clearing them\n  (setting them to an empty string) brings the up/down pair back. The built-in\n  series copies them into the pair once, in `applyOptions`, and cannot be\n  reverted that way.\n- Wicks are drawn above and below the body rather than as one bar behind it, so\n  a translucent body does not show its own wick through itself.\n- On Lightweight Charts™ 5.2 and later the series reports the candle under the\n  cursor through `hitTest`, and from 5.1 conflated candles are merged\n  open-first, close-last with the extremes of both.\n- Rounded corners use `CanvasRenderingContext2D.roundRect`, which every browser\n  the library supports provides.\n","isInternal":false,"tokens":1963,"sizeBytes":6961},{"name":"README.md","path":"packages/lwc-plugin-scatter-series/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/packages/lwc-plugin-scatter-series/README.md","title":"lwc-plugin-scatter-series Documentation","category":"plugin-manifest","format":"markdown","content":"# Scatter series\n\nA scatter and bubble chart for Lightweight Charts™: points placed by two\nnumbers on a numeric X axis, in named groups with their own colors and marker\nshapes, sized by a data value, optionally connected by lines, with baselines\nand accent borders around the plot.\n\nUse it to show how two measures relate across many items, where time is not\nthe horizontal axis: trades by maximum adverse excursion and result, bonds by\nmaturity and yield with the issue size as the bubble, or sectors on a relative\nrotation graph with their recent path as a tail. The plugin draws the chart\ncontent only: titles, legends and tooltips stay with your page, and the series\ntells it which point is hovered and where it is drawn.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.2.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-scatter-series\n```\n\nThen create a scatter chart and add the series to it:\n\n```js\nimport { createScatterChart, createScatterSeries } from '@tradingview/lwc-plugin-scatter-series';\n\nconst chart = createScatterChart(document.getElementById('container'), { autoSize: true });\n\nconst series = createScatterSeries(chart, {\n    groups: [\n        { id: 'win', name: 'Win trades', color: '#089981' },\n        { id: 'loss', name: 'Loss trades', color: '#F23645' },\n    ],\n    baselines: [{ axis: 'y', value: 0 }],\n});\n\nseries.setData([\n    { x: 12, y: 540000, group: 'win', sizeValue: 14 },\n    { x: 31, y: -320000, group: 'loss', sizeValue: 3 },\n    { x: 18, y: 120000, group: 'win', sizeValue: 40 },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-scatter-series\": \"https://unpkg.com/@tradingview/lwc-plugin-scatter-series/dist/scatter-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createScatterChart, createScatterSeries } from '@tradingview/lwc-plugin-scatter-series';\n\nconst series = createScatterSeries(createScatterChart(document.getElementById('container'), { autoSize: true }));\nseries.setData([{ x: 1, y: 2 }, { x: 3, y: 5 }, { x: 4, y: 1 }]);\n</script>\n```\n\n## Usage\n\n`createScatterChart(container, options?)` creates a chart whose horizontal\nscale is a numeric X axis (see [The scatter chart](#the-scatter-chart)), and\n`createScatterSeries(chart, options?, paneIndex?)` adds the series, which\nholds the whole dataset, every group included. Fields of your own travel with\nthe points; give the series their type:\n\n```ts\nimport { createScatterChart, createScatterSeries, type ScatterPoint } from '@tradingview/lwc-plugin-scatter-series';\n\ninterface Bond extends ScatterPoint {\n    title: string;\n}\n\nconst chart = createScatterChart(document.getElementById('container')!, { autoSize: true });\nconst series = createScatterSeries<Bond>(chart, {\n    groups: [\n        { id: 'aaa', name: 'AAA-AA', color: '#089981' },\n        { id: 'hy', name: 'High yield', color: '#FF9800' },\n    ],\n    xRange: { min: 0, max: 30 },\n    xFormatter: (x: number) => `${x}Y`,\n    priceFormat: { type: 'custom', minMove: 0.01, formatter: (y: number) => `${y.toFixed(2)}%` },\n});\n\nseries.setData([\n    { id: 'PEMX1', x: 4.5, y: 3.2, group: 'aaa', sizeValue: 120, title: 'PEMX1' },\n    { id: 'PEMX3', x: 21.7, y: 9.4, group: 'hy', sizeValue: 75, title: 'PEMX3' },\n]);\n```\n\nChange options with `series.applyOptions({ ... })` and replace the points with\n`series.setData(points)`; the chart applies both on its next frame. Every\noption and method is documented in the package's type declarations.\n\n### Points\n\n| Field | Type | Description |\n| --- | --- | --- |\n| `x`, `y` | `number` | Position, in X axis and price scale units. Required. A point is drawn only when both are finite and `x` is within the X range. |\n| `id` | `string` | Reported as the `objectId` when the point is hovered; defaults to its index. Keep it unique. |\n| `group` | `string` | Identifier of the point's group. |\n| `sizeValue` | `number` | A value mapped to the point's size (see [Dynamic size](#dynamic-size)). |\n| `size` | `number` | Size in CSS pixels, stroke included. Overrides `sizeValue`. |\n| `color`, `opacity`, `shape`, `strokeColor`, `strokeWidth`, `hollow` | | Overrides of the group's style (see [Point styles](#point-styles)). |\n\nPoints need no ordering, and may share an X value. Any other field is kept\nand handed back with the point by the hover API.\n\n### Groups\n\nA group is a named set of points sharing a style — what a user calls a\n\"series\" of the scatter chart. Declare groups in `groups`, in drawing order; a\ngroup a point names without it being declared comes after them. `groups` is\nreplaced as a whole by `applyOptions`.\n\n| Field | Default | Description |\n| --- | --- | --- |\n| `id` | — | Identifier points refer to. Required. |\n| `name` | `id` | Display name, for your legend. |\n| `color` | the `palette` entry | Fill color. |\n| `opacity`, `shape`, `pointSize`, `strokeColor`, `strokeWidth`, `hollow` | the series option | Style of the group's points; `opacity` is `1` with `lineVisible`. |\n| `visible` | `true` | Whether the group is drawn, hovered and autoscaled. |\n| `lineVisible` | `false` | Connect the group's points in data order, as a tail. |\n| `lineWidth`, `lineColor`, `lineStyle` | `1`, the group color, solid | The connecting line. |\n\nA hidden group still counts for the automatic X range and size domain, so\nswitching it moves neither; `series.setGroupVisible(id, visible)` switches one\nwithout passing every group again. A connecting line is cut at the plot edge.\n\n### Point styles\n\nA point's style beats its group's, which beats the series options; its size\nis its `size`, else its mapped `sizeValue`, else the `pointSize` of its group,\nelse of the series. Every point has a thin ring, `strokeWidth` wide but at\nmost a quarter of its size, to show where points overlap; a `hollow` point is\nan outline at least 1 px wide and no fill. The ring color is automatic by\ndefault: the chart's background, following theme changes, or the point's own\ncolor when it is hollow.\n\n`strokeColor` is the only style that also takes `null`, on a group or a point,\nand `null` is not the same as leaving it out: left out, the color comes from\nthe group, then the series; `null` asks for the automatic color even when the\ngroup or the series sets one.\n\n```js\nseries.applyOptions({\n    strokeColor: '#131722',\n    groups: [\n        { id: 'aaa', hollow: true, strokeWidth: 2, strokeColor: null }, // outlined in its own color\n        { id: 'bbb', strokeWidth: 2 }, // ringed in #131722\n    ],\n});\n```\n\n### Dynamic size\n\n`sizeValue` is mapped onto `sizeRange` (5–25 px by default): `sizeDomain.min`\nto the smallest size, `sizeDomain.max` to the largest, and values beyond the\ndomain to its ends. An open end of the domain (`null`, the default) is taken\nfrom the points of every group, hidden ones included. When every value is the\nsame, the points are drawn at the middle of the range. When every value lies\npast the one given end, the domain is that end alone and the points take its\nsize: the smallest below a given `min`, the largest above a given `max`.\n`sizeScale: 'area'` grows the area\nrather than the diameter, which is what the eye compares in a bubble chart.\n\n```js\nseries.applyOptions({ sizeRange: { min: 5, max: 50 }, sizeDomain: { min: 0, max: null }, sizeScale: 'area' });\n```\n\nEvery size, stroke included, is clamped to `pointSizeLimits`: 5–50 px by\ndefault (`defaultOptions.pointSizeLimits`), each end within 1–500 px.\n`series.sizeMapping()` returns the mapping as drawn — `domain`, `range`,\n`scale` and `sizeFor(value)` — for a bubble-size legend.\n\n### Baselines and border\n\n`baselines` are reference lines under the points: `{ axis: 'y', value: 0 }`\nis horizontal at a Y value, `axis: 'x'` vertical at an X value, each with an\noptional `color`, `width` and `style`. The price scale and the automatic X\nrange include them. `plotBorder` draws an accent border inside the edges of\nthe plot, on the sides you choose: `{ visible: true, top: false, right: false }`.\n\n### The X axis\n\nThe X axis spans `xRange`. An open end (`null`, the default) is taken from\nevery point and rounded outwards to a nice tick — 1, 2 or 5 × 10ⁿ, about ten\nintervals across; a given end off the axis grid (slots a tenth or a twentieth\nof a tick apart) is moved outwards to it. `series.xDomain()` returns the range\nin use. The labels are evenly spaced nice values, thinned out on narrow charts\nso that none overlap, and formatted with `xFormatter`.\n\nThe ends of the range sit on the plot edges, so a bubble there is cut in half;\n`xMargins` keeps room for it, in pixels. A fixed edge allows no such room, so\nwhile `xMargins` is above 0 the series frees the chart's fixed edges, and fixes\nthem again when the margins return to 0 or the series is removed. An edge the\nhost fixes meanwhile is kept fixed then; one it frees meanwhile cannot be told\nfrom the freed one, so free it again once the margins are 0. For dates, pass\ntimestamps and format them: the ticks are nice numbers of the unit, not\ncalendar boundaries, and next to large offsets such as epoch milliseconds the\nslots stay coarse enough to be distinct numbers. X values beyond ±1e300 cannot\nbe laid out: those points are not drawn, and the series warns once; nor can a\nspan below 1e-98, which is widened, with a warning. Data spanning only a few\nfloating-point steps of its own magnitude, such as `[1e15, 1e15 + 1]`, gets\nan axis of very few slots, since finer ones would not be distinct numbers;\nthe chart keeps neighboring slots at most half the plot width apart (its\ndefault `timeScale.maxBarSpacing`), so such data spans about half the plot.\n\n```js\nseries.applyOptions({\n    xFormatter: x => new Date(x).toLocaleDateString('en-GB', { day: 'numeric', month: 'short', timeZone: 'UTC' }),\n    xMargins: 12,\n});\nseries.setData(trades.map(trade => ({ id: trade.id, x: trade.closedAt, y: trade.pnl }))); // epoch milliseconds\n```\n\n### The Y axis\n\nThe Y axis is the series' price scale: format it with `priceFormat`, and pin\neither end with `yRange` (an open end autoscales, with room for the largest\npoint; ends in the wrong order are swapped, as in `xRange`). Its modes apply as they are — `PriceScaleMode.Logarithmic`, or\n`invertScale` — and the points, hit tests and `pointById` follow; the\npercentage and indexed-to-100 modes mean nothing here, and the series warns\nonce when either is set. For the scale on the left, give the chart\n`leftPriceScale: { visible: true }` and `rightPriceScale: { visible: false }`,\nand the series `priceScaleId: 'left'`.\n\n## The scatter chart\n\n`createScatterChart` is `createChartEx` with a numeric horizontal scale\nbehavior (`ScatterHorzScaleBehavior`) and these defaults\n(`scatterChartDefaults`), which the options you pass override:\n\n- scrolling and zooming off, flag by flag: `handleScroll`'s `mouseWheel`,\n  `pressedMouseMove`, `horzTouchDrag` and `vertTouchDrag`, and `handleScale`'s\n  `mouseWheel`, `pinch`, and `axisPressedMouseMove` and `axisDoubleClickReset`\n  for both axes, so that the X axis spans its range edge to edge;\n- `crosshair.mode: CrosshairMode.Hidden`; hover and the crosshair events keep\n  working;\n- dotted grid lines, and no time or price scale borders;\n- on the time scale: `allowBoldLabels: false`, `uniformDistribution: true`,\n  `lockVisibleTimeRangeOnResize: true`, `shiftVisibleRangeOnNewBar: false`,\n  `rightOffset: 0`, `minBarSpacing: 0.001`, `fixLeftEdge: true` and\n  `fixRightEdge: true`;\n- price `scaleMargins` of 0.05 at the top and the bottom, on both price\n  scales; the series adds room for its largest point.\n\n`scatterChartDefaults` is frozen. A `handleScroll` or `handleScale` object you\npass switches on just the flags it sets; `true` switches them all on. To build\nthe chart yourself, give `createChartEx` both type arguments, which it cannot\ninfer:\n`createChartEx<number, ScatterHorzScaleBehavior>(container, new ScatterHorzScaleBehavior(), scatterChartDefaults)`.\n\nThe series manages the chart's `timeScale.tickMarkMaxCharacterLength`, and\ngives the chart its own value back on `remove()`. A crosshair you show\n(`CrosshairMode.Normal`) snaps its vertical line to the slots of the X axis,\nnot to the points; its magnet modes snap to the extremes of a slot.\n\n### Scrolling and zooming\n\nWith scrolling or zooming switched on (`handleScroll`, `handleScale`), the\nseries keeps the user's zoom through data refreshes, option changes and\nresizes, and labels the part of the axis in view. A new X range is fitted\nagain, as `series.fitXDomain()` does. Zoomed out to the span of the fit or\nfurther, wherever the range sat, the user is back at the fit: a pan at that\nzoom springs back to it, as does the chart's double-click reset of the time\naxis. Keep the fixed edges: they keep the user within the X range, and only at\na fixed edge does the chart move an end label inside the plot. At a free edge\nit centers the label on its value, so the series keeps that end of the range\nfar enough inside for it. To let the user pan past the range, set `xMargins`.\nZoom from code with `chart.timeScale().setVisibleLogicalRange(...)`: a zoom\nset through the `timeScale.barSpacing` and `rightOffset` options looks like the\nchart's double-click reset, so the series fits the range again.\n\n## Hover, tooltips and legends\n\n`subscribeHoveredPointChange(handler)` is the one subscription a tooltip\nneeds. After the chart has painted, at most once a frame, it hands the handler\nthe hovered point — under the pointer, else the one set with\n`setHoveredPoint` — whenever anything about it changes (another point, new\ndata or options, a resize, a rescaled axis), and `null` when there is none any\nmore, the removal of the series included.\n\n```js\nconst tooltip = document.getElementById('tooltip'); // absolutely positioned in the chart container\n\nseries.subscribeHoveredPointChange(info => {\n    if (info === null) {\n        tooltip.style.display = 'none';\n        return;\n    }\n    // Pane coordinates: the plot starts after the left price scale, if it is shown.\n    const left = chart.priceScale('left').width() + info.x;\n    tooltip.textContent = `${info.point.title}: ${info.point.x}, ${info.point.y}`;\n    tooltip.style.display = 'block';\n    tooltip.style.transform = `translate(${left}px, ${info.y - info.radius}px) translate(-50%, -100%)`;\n});\n```\n\nIt gets what `series.pointById(objectId)` returns: your point, its `index`\nand `groupId`, its center `x` and `y` in pane coordinates (CSS pixels from the\ntop-left corner of the plot), its `radius` as drawn, and its resolved style.\nThe chart's crosshair and click events carry the hovered `objectId` in\n`param.hoveredInfo` (with `hoveredInfo.series === series.series()`), but come\nwith pointer moves, and when the series lays the X axis out again, and never\nreport a point set with `setHoveredPoint`: prefer the subscription. To highlight a point from outside\nthe chart, a table row say, call `series.setHoveredPoint(objectId)`, and\n`null` to clear it.\n\nBuild a legend from `series.groups()`, the groups as drawn, with their palette\ncolor, shape, ring and `pointCount` resolved, and switch them with\n`setGroupVisible`:\n\n```js\nfunction renderLegend() {\n    legend.replaceChildren(...series.groups().map(group => {\n        const item = document.createElement('button');\n        item.textContent = `${group.name} (${group.pointCount})`;\n        item.style.cssText = `color: ${group.color}; opacity: ${group.visible ? 1 : 0.4}`;\n        item.onclick = () => { series.setGroupVisible(group.id, !group.visible); renderLegend(); };\n        return item;\n    }));\n}\nrenderLegend();\n```\n\nThe hovered point is drawn on top at `hoveredOpacity`, and can grow\n(`hoveredSizeIncrease`) and get a ring (`hoveredRingWidth`). Of overlapping\npoints the topmost is hovered; over no point, the pointer hovers one within\n`hitTestTolerance` pixels.\n\n## Draw your own overlays\n\nFor anything else — a shaded region, a band, an annotation — attach a\n[series primitive](https://tradingview.github.io/lightweight-charts/docs/plugins/series-primitives)\nto `series.series()`, placed with `series.xToCoordinate(x)` and\n`series.series().priceToCoordinate(y)` in its `updateAllViews`, which the\nchart calls before every paint. This one shades rectangles given in data\nunits under the grid and the points — the quadrants of a relative rotation\ngraph, say:\n\n```ts\nimport type { IPrimitivePaneView, ISeriesPrimitive } from 'lightweight-charts';\nimport type { ScatterSeriesApi } from '@tradingview/lwc-plugin-scatter-series';\n\n/** A rectangle in data units. An open end (`null`) runs to the edge of the pane. */\ninterface ShadedRegion {\n    xMin: number | null;\n    xMax: number | null;\n    yMin: number | null;\n    yMax: number | null;\n    color: string;\n}\n\nfunction regionShading(scatter: ScatterSeriesApi, regions: readonly ShadedRegion[]): ISeriesPrimitive<number> {\n    let boxes: { left: number; right: number; top: number; bottom: number; color: string }[] = [];\n    const view: IPrimitivePaneView = {\n        zOrder: () => 'bottom',\n        renderer: () => ({\n            // Whole device pixels within the pane, so that the edges stay sharp.\n            draw: target => target.useBitmapCoordinateSpace(({ context, bitmapSize, horizontalPixelRatio: h, verticalPixelRatio: v }) => {\n                for (const box of boxes) {\n                    const left = Math.max(0, Math.round(box.left * h));\n                    const right = Math.min(bitmapSize.width, Math.round(box.right * h));\n                    const top = Math.max(0, Math.round(box.top * v));\n                    const bottom = Math.min(bitmapSize.height, Math.round(box.bottom * v));\n                    if (right > left && bottom > top) {\n                        context.fillStyle = box.color;\n                        context.fillRect(left, top, right - left, bottom - top);\n                    }\n                }\n            }),\n        }),\n    };\n    return {\n        attached: ({ requestUpdate }) => requestUpdate(), // attaching does not repaint the chart\n        paneViews: () => [view],\n        updateAllViews: () => {\n            const series = scatter.series();\n            boxes = [];\n            if (!series.options().visible) {\n                return; // the chart draws the primitives of a hidden series too\n            }\n            // An open Y end runs to the top of the pane, or to the bottom of an inverted scale.\n            const up = series.priceScale().options().invertScale ? Infinity : -Infinity;\n            const x = (value: number | null, open: number) => (value === null ? open : scatter.xToCoordinate(value));\n            const y = (value: number | null, open: number) => (value === null ? open : series.priceToCoordinate(value));\n            for (const region of regions) {\n                const left = x(region.xMin, -Infinity);\n                const right = x(region.xMax, Infinity);\n                const low = y(region.yMin, -up);\n                const high = y(region.yMax, up);\n                if (left !== null && right !== null && low !== null && high !== null) {\n                    boxes.push({ left, right, top: Math.min(low, high), bottom: Math.max(low, high), color: region.color });\n                }\n            }\n        },\n    };\n}\n\nseries.series().attachPrimitive(regionShading(series, [\n    { xMin: 100, xMax: null, yMin: 100, yMax: null, color: 'rgba(8, 153, 129, 0.1)' }, // leading\n    { xMin: 100, xMax: null, yMin: null, yMax: 100, color: 'rgba(251, 192, 45, 0.12)' }, // weakening\n    { xMin: null, xMax: 100, yMin: null, yMax: 100, color: 'rgba(242, 54, 69, 0.08)' }, // lagging\n    { xMin: null, xMax: 100, yMin: 100, yMax: null, color: 'rgba(41, 98, 255, 0.08)' }, // improving\n]));\n```\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceFormat`, `priceScaleId`, `visible`, `autoscaleInfoProvider`, …):\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `color` | `'#2962FF'` | Fill color of points with no group, and of groups when `palette` is empty. |\n| `opacity` | `0.65` | Opacity of the points, `0`–`1`. |\n| `pointSize` | `9` | Size of the points in CSS pixels, stroke included. |\n| `pointSizeLimits` | `{ min: 5, max: 50 }` | Smallest and largest size of any point. |\n| `shape` | `'circle'` | `'circle'`, `'square'`, `'diamond'`, `'triangleUp'` or `'triangleDown'`. |\n| `strokeColor`, `strokeWidth` | `null`, `1` | Color (`null`: automatic) and width in CSS pixels (`0`: none) of the ring around every point. |\n| `hollow` | `false` | Draw points as open markers. |\n| `palette` | `DEFAULT_SCATTER_PALETTE` | Colors of the groups which set none, in group order: ten by default. |\n| `groups` | `[]` | The groups, in drawing order. |\n| `sizeRange` | `{ min: 5, max: 25 }` | Sizes `sizeValue` is mapped onto, in CSS pixels. |\n| `sizeDomain` | `{ min: null, max: null }` | Values mapped to the ends of `sizeRange`; `null` takes the end from the data. |\n| `sizeScale` | `'linear'` | Whether the diameter (`'linear'`) or the area (`'area'`) grows with `sizeValue`. |\n| `xRange` | `{ min: null, max: null }` | The X axis range; `null` takes the end from the data. |\n| `xMargins` | `0` | Room between each end of the X range and the plot edge, in CSS pixels. |\n| `xFormatter` | `null` | Formats the X labels; `null` prints the number. |\n| `yRange` | `{ min: null, max: null }` | Pins the ends of the Y axis; `null` autoscales. |\n| `baselines` | `[]` | Reference lines under the points. |\n| `plotBorder` | `visible: false`, `'#9598A1'`, 1 px, solid, every side | Accent border along the edges of the plot (`visible`, `color`, `width`, `style`, `top`, `right`, `bottom`, `left`). |\n| `hoveredOpacity` | `1` | Opacity of the hovered point, drawn on top. |\n| `hoveredSizeIncrease` | `0` | Pixels added to the size of the hovered point. |\n| `hoveredRingWidth`, `hoveredRingGap`, `hoveredRingColor` | `0`, `1`, `null` | Width (`0`: none), distance and color (`null`: the point's) of a ring around the hovered point. |\n| `hitTestTolerance` | `3` | How many pixels outside a point the pointer may be and still hover it. |\n\n`applyOptions` merges nested objects; `groups`, `baselines`, `palette` and\n`xFormatter` are replaced whole. `null` sets an option back to its default: an\nend of a range to automatic, or (from JavaScript) a whole option. An\n`applyOptions` or `setData` call that throws — an `xFormatter` that throws,\nsay — changes nothing. Set `visible` through the scatter series. Keep the\nprice line and last-value label off: the underlying values are X axis slots.\n\n## API\n\n`createScatterSeries` returns a `ScatterSeriesApi`:\n\n| Method | Description |\n| --- | --- |\n| `setData(points)` / `data()` | Replaces / reads the points. The array is copied, the points are not. |\n| `applyOptions(options)` / `options()` | Changes / reads (a copy of) the options. |\n| `series()` | The underlying custom series, for its price scale and Y conversions. |\n| `groups()` | The groups as drawn, resolved, with their point counts, for a legend. |\n| `setGroupVisible(groupId, visible)` | Shows or hides a group, keeping its color and the X axis. |\n| `xDomain()` / `fitXDomain()` | The X axis range in use and its tick step / fits it to the plot again. |\n| `xToCoordinate(x)` / `coordinateToX(coordinate)` | An X value to a horizontal pane coordinate and back, as the points are drawn, or `null`. |\n| `sizeMapping()` | How `sizeValue` maps to sizes, or `null` when no point uses it. |\n| `pointById(objectId)` / `hitTest(x, y)` | Where a point is drawn / the point at a pane coordinate, or `null`. |\n| `hoveredPoint()` / `setHoveredPoint(objectId \\| null)` | Reads / sets the hovered point. |\n| `subscribeHoveredPointChange(handler)` / `unsubscribeHoveredPointChange(handler)` | Follows the hovered point: which point, and where it is drawn. |\n| `remove()` | Removes the series, and gives the chart back the options the series manages. Safe to call twice, or after `chart.remove()`. |\n\n## Notes\n\n- Requires `lightweight-charts` 5.2 or later, for the custom series hit test\n  and the `hoveredInfo` of chart events.\n- One scatter series per chart: it holds every group, and creating a second\n  throws until the first is removed. Other series on a scatter chart are not\n  supported, as their time points break the even spacing of the X axis: use\n  `baselines`, a group's `lineVisible`, or a\n  [primitive](#draw-your-own-overlays).\n- Take the series off with `series.remove()`; one taken off with\n  `chart.removeSeries(series.series())` releases itself right after the next\n  chart event or API call. After `chart.remove()` the API returns `null`.\n- `series.series()` serves the price scale and Y conversions, not data or\n  scatter options: its data is the slot grid of the X axis, and its own\n  `options().hitTestTolerance` is `-Infinity`, which turns the chart's hit test\n  of the slots off (the scatter tolerance is in `series.options()`).\n- A chart and a series from different copies of the package (the standalone\n  build and the main entry point, say) do not mix: `createScatterSeries`\n  throws.\n","isInternal":false,"tokens":6647,"sizeBytes":25403},{"name":"README.md","path":"packages/lwc-plugin-session-highlighting/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/packages/lwc-plugin-session-highlighting/README.md","title":"lwc-plugin-session-highlighting Documentation","category":"plugin-manifest","format":"markdown","content":"# Session highlighting\n\nA [series primitive](https://tradingview.github.io/lightweight-charts/docs/plugins/series-primitives)\nthat shades the background behind each bar of a series. You give it a\nfunction from a bar's time to a color, and every bar of the attached series\ngets a full-height column in that color, as wide as the bar itself. The\ncolumns follow the series as the chart scrolls and zooms.\n\nUse it to show where one trading session ends and the next begins, to tint\npre-market and after-hours bars, to mark weekends or holidays, or to shade any\nother time-based condition behind the data.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-session-highlighting\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart, CandlestickSeries } from 'lightweight-charts';\nimport { SessionHighlighting } from '@tradingview/lwc-plugin-session-highlighting';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(CandlestickSeries);\nseries.setData(data);\n\nseries.attachPrimitive(new SessionHighlighting(time => {\n    const day = new Date(time * 1000).getUTCDay();\n    return day === 0 || day === 6 ? 'rgba(255, 152, 1, 0.2)' : '';\n}));\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-session-highlighting\": \"https://unpkg.com/@tradingview/lwc-plugin-session-highlighting/dist/session-highlighting.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart, CandlestickSeries } from 'lightweight-charts';\nimport { SessionHighlighting } from '@tradingview/lwc-plugin-session-highlighting';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(CandlestickSeries);\nseries.setData(data);\n\nseries.attachPrimitive(new SessionHighlighting(time => {\n    const day = new Date(time * 1000).getUTCDay();\n    return day === 0 || day === 6 ? 'rgba(255, 152, 1, 0.2)' : '';\n}));\n</script>\n```\n\n## Usage\n\n### The highlighter\n\nThe first constructor argument is the highlighter: a function which receives\na bar's time and returns a CSS color. Return an empty string for a bar that\nshould not be shaded. The time comes in whatever form your data uses, so for\nbusiness-day data check for an object:\n\n```js\nimport { isBusinessDay } from 'lightweight-charts';\n\nfunction toDate(time) {\n    if (isBusinessDay(time)) {\n        return new Date(Date.UTC(time.year, time.month - 1, time.day));\n    }\n    return typeof time === 'number' ? new Date(time * 1000) : new Date(time);\n}\n\nconst highlighter = time => {\n    const hour = toDate(time).getUTCHours();\n    if (hour < 9 || hour >= 16) {\n        return 'rgba(120, 123, 134, 0.15)'; // outside the main session\n    }\n    return '';\n};\n\nconst highlighting = new SessionHighlighting(highlighter);\nseries.attachPrimitive(highlighting);\n```\n\nThe highlighter is called once per bar when the series data is set, and once\nfor the last bar when `series.update()` appends or replaces it, so it can do\nreal work per call; `series.pop()` drops the popped bars without calling it.\nKeep it a function of the time alone: a historical update, which is\n`series.update(bar, true)`, re-asks it for the last bar rather than for the\nbar it changed, and one that turns a bar into whitespace, or whitespace into a\nbar, re-asks it for every bar. Translucent colors let the grid and the series show through; the shading\nis drawn behind both by default.\n\nTo remove the shading, detach it from the series:\n\n```js\nseries.detachPrimitive(highlighting);\n```\n\n### Changing the shading\n\n```js\nhighlighting.applyOptions({ zOrder: 'top', visible: false });\nhighlighting.setHighlighter(time => '#F0F3FA'); // recolors every bar\nhighlighting.options(); // the current options, with the defaults filled in\n```\n\n`applyOptions` merges: an option which is not passed, or is passed as\n`undefined`, is left unchanged.\n\n## Options\n\nOptions are passed as the second constructor argument, which is optional, as\nis every option in it. The type is `SessionHighlightingOptions`, and the\ndefaults are exported as `defaultOptions`.\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `visible` | `boolean` | `true` | Whether the shading is drawn at all. |\n| `zOrder` | `'bottom' \\| 'normal' \\| 'top'` | `'bottom'` | Layer the shading is drawn in. `'bottom'` puts it behind the grid and the series. |\n\n## Notes\n\n- Each column is exactly one bar wide, taken from the time scale's bar\n  spacing, so neighboring columns abut with no seams and no overlap at any\n  zoom level or device pixel ratio.\n- Only bars of the attached series are shaded. Whitespace items and gaps in\n  the data get no column, even where another series has a bar at that time.\n- The shading appears only in the pane the series is drawn in, never under\n  the price scales or the time scale. To shade a second pane, attach another\n  `SessionHighlighting` to a series in that pane.\n- Only the bars on screen are drawn, so the cost of a paint is bounded by the\n  width of the chart, not by the length of the history. An incremental\n  `series.update()` or `series.pop()` does read the series data once to find\n  out what changed, which is proportional to the number of bars.\n","isInternal":false,"tokens":1384,"sizeBytes":5626},{"name":"README.md","path":"packages/lwc-plugin-stacked-area-series/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/packages/lwc-plugin-stacked-area-series/README.md","title":"lwc-plugin-stacked-area-series Documentation","category":"plugin-manifest","format":"markdown","content":"# Stacked area series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series) that stacks several values per\ntime point into cumulative\nbands. Each value is drawn as an area on top of the previous one, with a line\nalong its upper edge. The top edge of the stack shows the total.\n\nUse it to show composition over time, when the parts and the whole matter at\nthe same time. Typical examples: portfolio allocation, revenue by segment,\ntraffic by source, or volume by venue.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-stacked-area-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createStackedAreaSeries } from '@tradingview/lwc-plugin-stacked-area-series';\n\nconst chart = createChart(document.getElementById('container'), {\n    rightPriceScale: { scaleMargins: { top: 0.05, bottom: 0.05 } },\n});\nconst series = createStackedAreaSeries(chart, {\n    colors: [\n        { line: '#2962FF', area: 'rgba(41, 98, 255, 0.2)' },\n        { line: '#F23645', area: 'rgba(242, 54, 69, 0.2)' },\n        { line: '#FF9800', area: 'rgba(255, 152, 0, 0.2)' },\n    ],\n    lineWidth: 2,\n});\n\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    { time: '2024-04-23', values: [14, 7, 6] },\n    { time: '2024-04-24', values: [11, 9, 4] },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-stacked-area-series\": \"https://unpkg.com/@tradingview/lwc-plugin-stacked-area-series/dist/stacked-area-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createStackedAreaSeries } from '@tradingview/lwc-plugin-stacked-area-series';\n\nconst chart = createChart(document.getElementById('container'), {\n    rightPriceScale: { scaleMargins: { top: 0.05, bottom: 0.05 } },\n});\nconst series = createStackedAreaSeries(chart, {\n    colors: [\n        { line: '#2962FF', area: 'rgba(41, 98, 255, 0.2)' },\n        { line: '#F23645', area: 'rgba(242, 54, 69, 0.2)' },\n        { line: '#FF9800', area: 'rgba(255, 152, 0, 0.2)' },\n    ],\n    lineWidth: 2,\n});\n\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    { time: '2024-04-23', values: [14, 7, 6] },\n    { time: '2024-04-24', values: [11, 9, 4] },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `createStackedAreaSeries`, then set data with a `values` array per\npoint. The array order is the stacking order: `values[0]` is the bottom band.\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createStackedAreaSeries } from '@tradingview/lwc-plugin-stacked-area-series';\n\nconst chart = createChart(document.getElementById('container'), {\n    rightPriceScale: { scaleMargins: { top: 0.05, bottom: 0.05 } },\n});\nconst series = createStackedAreaSeries(chart, {\n    colors: [\n        { line: '#2962FF', area: 'rgba(41, 98, 255, 0.2)' },\n        { line: '#F23645', area: 'rgba(242, 54, 69, 0.2)' },\n        { line: '#FF9800', area: 'rgba(255, 152, 0, 0.2)' },\n    ],\n    lineWidth: 2,\n});\n\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    { time: '2024-04-23', values: [14, 7, 6] },\n    { time: '2024-04-24', values: [11, 9, 4] },\n]);\n```\n\nEach data point is `{ time, values: number[] }`. Points do not have to carry\nthe same number of values: a point with fewer values is padded with zeroes, so\nits missing bands collapse onto the one below them. Points with an empty or\nmissing `values` array are treated as whitespace. The series' price line and\nlast-value label follow the stack total.\n\nValues are stacked from `base` (`0` by default): a positive value continues\naway from the base, a negative one comes back towards it and past it, so each\nband is a single ribbon between two lines and never folds over itself.\n\nA point may override the colors of its own bands:\n\n```js\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    {\n        time: '2024-04-23',\n        values: [14, 7, 6],\n        colors: [{ line: '#000000', area: 'rgba(0, 0, 0, 0.2)' }],\n    },\n]);\n```\n\nAn override applies to the piece of the band which starts at that point.\n\nOptions can be changed at runtime with `series.applyOptions({ ... })`.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `colors` | `StackedAreaColor[]` | five preset pairs (blue, red, orange, purple, teal); in each pair the area is the line color at 20% opacity | Appearance of each band, in stacking order. If there are more values than entries, the entries repeat. An empty array falls back to this default. |\n| `lineWidth` | `LineWidth` | `2` | Width of the band lines, in CSS pixels (`1`–`4`). |\n| `lineStyle` | `LineStyle` | `LineStyle.Solid` | Style of the band lines. |\n| `lineVisible` | `boolean` | `true` | Whether the band lines are drawn. |\n| `areaVisible` | `boolean` | `true` | Whether the bands are filled. |\n| `base` | `number` | `0` | Price the bands are stacked from. |\n| `lineType` | `'simple' \\| 'step' \\| 'curved'` | `'simple'` | How the points of a band are joined: straight lines, a value held until the next point, or a smooth curve. |\n| `gapHandling` | `'break' \\| 'bridge'` | `'break'` | Whether the bands stop at a whitespace gap and start again after it, or are drawn straight across it. |\n| `percent` | `boolean` | `false` | Scale every point so that its bands total 100 in absolute terms, giving a 100% stacked chart. |\n\nEach entry of `colors` is a `StackedAreaColor`, which may also override the\nseries-wide line options for that band:\n\n| Field | Type | Description |\n| --- | --- | --- |\n| `line` | `string` | Color of the line along the top of the band. |\n| `area` | `string` | Fill color of the band, or the top of its gradient when `areaBottom` is set. |\n| `areaBottom` | `string` (optional) | Bottom color of the band's gradient. |\n| `lineWidth` | `LineWidth` (optional) | Width of this band's line. |\n| `lineStyle` | `LineStyle` (optional) | Style of this band's line. |\n| `lineVisible` | `boolean` (optional) | Whether this band's line is drawn. |\n| `areaVisible` | `boolean` (optional) | Whether this band is filled. |\n\nPer-point overrides, on the data item:\n\n| Field | Type | Description |\n| --- | --- | --- |\n| `colors` | `StackedAreaPointColor[]` | `line`, `area` and `areaBottom` for each band at this point. Anything missing falls back to the series color. |\n\n## Notes\n\n- The price scale autoscales over the whole run of the stack, not just its\n  total, so a point containing negative values stays fully in view. The\n  outermost line sits exactly on the edge of the range; add a small\n  `scaleMargins` on the price scale (as in the example above) if you want\n  breathing room around it.\n- Autoscaling follows `percent` and `base`, so a 100% stack scales to\n  `base`…`base + 100` and not to the raw totals, and changing either option\n  rescales the series. This needs the current options at the moment the library\n  asks for the plot values, which only `createStackedAreaSeries` can provide: a\n  bare `new StackedAreaSeries()` added with `chart.addCustomSeries` autoscales\n  from the raw `values` measured from zero, and needs an\n  `autoscaleInfoProvider` of its own for `percent` or a non-zero `base`.\n- The factory retains explicit whitespace, and `gapHandling` decides whether\n  to break or bridge it. Timestamps from other series do not create gaps.\n- On `lightweight-charts` 5.2 and later the series reports the hovered band\n  through `hitTest` (the `objectId` is the index of the band) and dims the\n  other bands while one is hovered, and from 5.1 conflated points are merged\n  by summing each band. Older versions simply never call those hooks.\n\n### Explicit whitespace\n\nUse `createStackedAreaSeries` to retain whitespace passed through `setData` and\n`update`, including historical corrections. Other series' timestamps do not\nbreak the area. The low-level `StackedAreaSeries` view remains available, but\nwithout the factory's gap predicate it draws continuously: the host does not\nprovide whitespace to custom renderers.\n\nUnder time-scale conflation the area is drawn from buckets of several bars, and\na whitespace run narrower than one bucket cannot be resolved at that bar\nspacing: it is absorbed into the bucket rather than breaking the area at every\nbar. Zooming in past the conflation threshold shows the gap again.\n","isInternal":false,"tokens":2526,"sizeBytes":9018},{"name":"README.md","path":"packages/lwc-plugin-stacked-bars-series/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/packages/lwc-plugin-stacked-bars-series/README.md","title":"lwc-plugin-stacked-bars-series Documentation","category":"plugin-manifest","format":"markdown","content":"# Stacked bars series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series) that stacks several values per\ntime point into one column.\nEach value is a segment drawn on top of the previous one. The column height\nshows the total, and the segments show its composition.\n\nUse it to show composition over time in discrete periods, when a bar reads\nbetter than an area. Typical examples: volume by venue, revenue by product\nline, or trades by side.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-stacked-bars-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createStackedBarsSeries } from '@tradingview/lwc-plugin-stacked-bars-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createStackedBarsSeries(chart, {\n    colors: ['#2962FF', '#F23645', '#FF9800'],\n});\n\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    { time: '2024-04-23', values: [14, 7, 6] },\n    { time: '2024-04-24', values: [11, 9, 4] },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-stacked-bars-series\": \"https://unpkg.com/@tradingview/lwc-plugin-stacked-bars-series/dist/stacked-bars-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createStackedBarsSeries } from '@tradingview/lwc-plugin-stacked-bars-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createStackedBarsSeries(chart, {\n    colors: ['#2962FF', '#F23645', '#FF9800'],\n});\n\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    { time: '2024-04-23', values: [14, 7, 6] },\n    { time: '2024-04-24', values: [11, 9, 4] },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `addCustomSeries`, then set data with a `values` array per\npoint. The array order is the stacking order: `values[0]` is the bottom\nsegment.\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createStackedBarsSeries } from '@tradingview/lwc-plugin-stacked-bars-series';\n\nconst chart = createChart(document.getElementById('container'), {\n    timeScale: { minBarSpacing: 3 },\n});\nconst series = createStackedBarsSeries(chart, {\n    colors: ['#2962FF', '#F23645', '#FF9800'],\n});\n\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    { time: '2024-04-23', values: [14, 7, 6] },\n    { time: '2024-04-24', values: [11, 9, 4] },\n]);\n```\n\nEach data point is `{ time, values: number[] }`. Points with an empty or\nmissing `values` array are treated as whitespace. The series' price line and\nlast-value label follow the column total.\n\nValues are stacked from `base` (`0` by default): a positive value continues\naway from the base, a negative one comes back towards it and past it, so a\nmixed point stays contiguous and never overlaps. Values which are not finite\nare skipped without shifting the segments above them.\n\nA point may override the series colors for its own segments:\n\n```js\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    { time: '2024-04-23', values: [14, 7, 6], colors: ['#000000', undefined, '#BBBBBB'] },\n]);\n```\n\nOptions can be changed at runtime with `series.applyOptions({ ... })`.\n\n## Creating a series\n\nUse `createStackedBarsSeries(chart, options?, paneIndex?)`. It returns the\nnormal series API, with the plugin's data and options types preserved. The helper\nmakes scaling options available before the first `setData` and rebuilds plot\nvalues automatically when those options change through `series.applyOptions`.\nThis keeps autoscaling, last-value labels and crosshair values consistent. The\nhelper retains a shallow copy of the input data, including whitespace, and\nre-ingests it only when a scaling option changes. Streaming updates remain\nincremental.\n\nThe low-level `StackedBarsSeries` pane view remains available for integrations\nthat supply their own options getter to its constructor. Passing scaling options\nonly to `chart.addCustomSeries(new StackedBarsSeries(), options)` cannot make\nthem available before data ingestion on LWC 5.0; use the creation helper instead.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `colors` | `string[]` | `['#2962FF', '#E1575A', '#F28E2C', 'rgb(164, 89, 209)', 'rgb(27, 156, 133)']` | Fill color of each segment, in stacking order. If there are more values than colors, the colors repeat. An empty array falls back to this default. |\n| `base` | `number` | `0` | Price the columns are stacked from. |\n| `columnWidthMode` | `'histogram' \\| 'percent'` | `'histogram'` | `histogram` uses the width the built-in histogram series uses (as wide as the bar spacing allows, with a one pixel gap); `percent` uses a share of the bar spacing, given by `widthPercent`. |\n| `widthPercent` | `number` | `80` | Column width as a percentage of the bar spacing, `0`–`100`. Only used when `columnWidthMode` is `percent`. |\n| `segmentBorderColor` | `string` | `'#FFFFFF'` | Color of the border drawn inside the edge of every segment. |\n| `segmentBorderWidth` | `number` | `0` | Width of the segment border in pixels. `0` draws no border. |\n| `radius` | `number` | `0` | Corner radius of the two ends of a column, in pixels. |\n| `stackOrder` | `'normal' \\| 'reverse'` | `'normal'` | `normal` puts `values[0]` closest to the base; `reverse` puts the last value there. Colors stay with their value. |\n| `percent` | `boolean` | `false` | Scale every point so that its segments total 100 in absolute terms, giving a 100% stacked chart. |\n\nPer-point overrides, on the data item:\n\n| Field | Type | Description |\n| --- | --- | --- |\n| `colors` | `(string \\| undefined)[]` | Fill color of each segment of this point. A missing or `undefined` entry falls back to the series color for that segment. |\n\nThe standard `color` option is not used for the segments; it colors the\nseries' price line.\n\n## Notes\n\n- Column width follows the bar spacing by default, with a small gap between\n  columns. Set `timeScale.minBarSpacing` (as in the example above) to keep\n  columns from collapsing when the user zooms out, or switch to\n  `columnWidthMode: 'percent'` for a fixed share of the slot.\n- The price scale autoscales over the whole run of the stack, not just its\n  total, so a column containing negative values stays fully in view.\n- `createStackedBarsSeries` measures the same ordered, normalized, and offset\n  bands that are drawn. `percent`, nonzero `base`, and `stackOrder: 'reverse'`\n  therefore autoscale without a custom range provider.\n\n- On `lightweight-charts` 5.2 and later the series reports the hovered segment\n  through `hitTest` (the `objectId` is the index of the value within the point)\n  and dims the other segments while one is hovered, and from 5.1 conflated\n  points are merged by summing each band. Older versions simply never call\n  those hooks.\n","isInternal":false,"tokens":2010,"sizeBytes":7573},{"name":"README.md","path":"packages/lwc-plugin-user-price-lines/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/packages/lwc-plugin-user-price-lines/README.md","title":"lwc-plugin-user-price-lines Documentation","category":"plugin-manifest","format":"markdown","content":"# User price lines\n\nA [series primitive](https://tradingview.github.io/lightweight-charts/docs/plugins/series-primitives)\nthat lets the user add price lines to a series. When the pointer comes near\nthe right edge of the pane, a small button with a plus follows it up and down;\nclicking the button adds a price line at that price.\n\nUse it for levels the user marks by hand: support and resistance, entry and\nexit prices, or the price an alert should fire at.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-user-price-lines\n```\n\nThen import the plugin and attach it to a series:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { UserPriceLines } from '@tradingview/lwc-plugin-user-price-lines';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData([\n    { time: '2024-04-22', value: 101.2 },\n    { time: '2024-04-23', value: 102.8 },\n    { time: '2024-04-24', value: 100.9 },\n]);\n\nseries.attachPrimitive(new UserPriceLines({ lineColor: '#F23645' }));\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-user-price-lines\": \"https://unpkg.com/@tradingview/lwc-plugin-user-price-lines/dist/user-price-lines.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { UserPriceLines } from '@tradingview/lwc-plugin-user-price-lines';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData([\n    { time: '2024-04-22', value: 101.2 },\n    { time: '2024-04-23', value: 102.8 },\n    { time: '2024-04-24', value: 100.9 },\n]);\n\nseries.attachPrimitive(new UserPriceLines({ lineColor: '#F23645' }));\n</script>\n```\n\n## Usage\n\nAttach the plugin to the series the lines belong to. The button shows near\nthe right edge of that series' pane, wherever the series has a price, and a\nclick on it adds a price line to the series at the price under the pointer:\n\n```js\nconst lines = new UserPriceLines({ maxLines: 3 });\nseries.attachPrimitive(lines);\n\n// Lines can be added and removed from code as well.\nconst line = lines.addLine(102.5);\nlines.lineAdded().subscribe(added => console.log('added', added.options().price));\nlines.lineRemoved().subscribe(removed => console.log('removed', removed.options().price));\nlines.removeLine(line);\nlines.removeAll();\n```\n\n- `addLine(price)` adds a line with the line options and returns its\n  `IPriceLine`. A click on the button does the same. At `maxLines`, the\n  oldest line is removed first. It throws unless the plugin is attached to a\n  series that is on a chart.\n- `removeLine(line)` removes a line the plugin added and returns `true`; a\n  line it did not add, or one already removed, is left alone and gives\n  `false`. `removeAll()` removes every line the plugin added.\n- `lines()` lists the lines the plugin added that are still on the series,\n  oldest first. A line removed with `series.removePriceLine` is left out.\n- `lineAdded()` and `lineRemoved()` fire with each line the plugin adds and\n  removes. Lines are removed by `removeLine` and `removeAll`, to stay within\n  `maxLines`, and when the plugin is detached.\n\nDetaching the plugin, `series.detachPrimitive(lines)`, stops it listening to\nthe pointer, removes the lines it added and puts the crosshair mode back.\nAttaching it to another series while it is attached moves it there: it is\ndetached from the first series, which removes its lines there.\n`chart.removeSeries` takes the lines away with the series, and the plugin\nlets go of the chart on the next pointer event.\n\n### Crosshair mode\n\nThe button follows the pointer, so the plugin sets the chart's crosshair to\n`CrosshairMode.Normal` while it is attached: in the `Magnet` modes the\ncrosshair would jump between the series' values instead. The mode the chart\nhad is put back when the plugin is detached, unless something changed it\nfrom `Normal` in the meantime, in which case it is left as it is. Pass\n`setCrosshairMode: false` to leave the crosshair mode alone.\n\n### Several instances\n\nWithin a pane, only the instance attached last shows its button and adds\nlines, so a click never adds a line to two series at once. When it is\ndetached, the one attached before it takes over.\n\n## Options\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `lineColor` | `string` | `'#000000'` | Color of the price lines the plugin adds. |\n| `lineWidth` | `LineWidth` | `1` | Width of the price lines, in CSS pixels. |\n| `lineStyle` | `LineStyle` | `LineStyle.Dashed` | Style of the price lines. |\n| `axisLabelVisible` | `boolean` | `true` | Whether the price lines show their price on the price scale. |\n| `buttonColor` | `string` | `''` | Background of the add button. An empty string uses the background of the crosshair's horizontal line label. |\n| `hoverColor` | `string` | `'#777777'` | Background of the add button while the pointer is over it. |\n| `maxLines` | `number` | `Infinity` | The most lines the plugin keeps; adding one more removes the oldest. Rounded down and at least `1`; a value that is not a number means no limit. |\n| `setCrosshairMode` | `boolean` | `true` | Whether the plugin sets the crosshair to `Normal` mode while attached. |\n\nChange them with `lines.applyOptions({ ... })`; `lines.options()` returns\nthem all. The line options apply to the lines added afterwards. Lowering\n`maxLines` removes the oldest lines over the new limit.\n\n## Notes\n\n- The button is reported to the chart's hit test, so the cursor becomes a\n  pointer over it and pointer events report `ADD_BUTTON_ID` as the hovered\n  object (`param.hoveredObjectId`).\n- The button only comes up for the pointer. A crosshair placed with\n  `chart.setCrosshairPosition`, as charts kept in sync do, never shows it.\n- A tap on a touch screen moves no crosshair, so no button is shown and a tap\n  at the edge adds nothing; after a long press has brought the button up,\n  only a tap on the button adds a line. The chart reports no click after a\n  drag, so a drag that starts on the button adds nothing either.\n- The button always sits at the right edge of the pane, which is where the\n  pointer leaves the pane for the right price scale. Clicking a line to remove\n  it, placing the button by the left price scale and rounding prices to the\n  series' price step are not part of this release.\n\n## Migrating from `plugin-examples`\n\nIn the `plugin-examples` collection the plugin was created with\n`new UserPriceLines(chart, series, options)` and taken off with `remove()`.\nBoth still work and are deprecated: pass the options only and attach the\nplugin with `series.attachPrimitive`, and detach it with\n`series.detachPrimitive`. `remove()` now removes the lines the plugin added,\nas detaching does, and does not throw once the chart or the series is gone.\n\nThe options are renamed: `color`, the color of the lines, is `lineColor`, and\n`limitToOne`, which was never read, is `maxLines` (`maxLines: 1` keeps one\nline). The lines can now be removed, and the plugin no longer adds lines for\nclicks in other panes or for two instances at once.\n","isInternal":false,"tokens":1891,"sizeBytes":7563},{"name":"README.md","path":"packages/lwc-plugin-vertical-line/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/packages/lwc-plugin-vertical-line/README.md","title":"lwc-plugin-vertical-line Documentation","category":"plugin-manifest","format":"markdown","content":"# Vertical line\n\nA [series primitive](https://tradingview.github.io/lightweight-charts/docs/plugins/series-primitives)\nthat draws a full-height vertical line at a given time, with an optional label\non the time axis. You attach the line to a series. The line then follows that\nseries' time scale as the user scrolls and zooms.\n\nUse it to mark a moment in time that matters on your chart:\n\n- an event, such as earnings, a news release, or a dividend date;\n- a trade, such as entry and exit points, with a label like `Buy` or `Sell`;\n- a boundary, such as a session open or close, the start of a backtest, or\n  the current bar.\n\nBecause each line is a separate primitive, you can place as many as you need\non the same series, each with its own color, width, and label.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-vertical-line\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { VerticalLine } from '@tradingview/lwc-plugin-vertical-line';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(data);\n\nseries.attachPrimitive(new VerticalLine('2024-04-25'));\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-vertical-line\": \"https://unpkg.com/@tradingview/lwc-plugin-vertical-line/dist/vertical-line.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { VerticalLine } from '@tradingview/lwc-plugin-vertical-line';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(data);\n\nseries.attachPrimitive(new VerticalLine('2024-04-25'));\n</script>\n```\n\n## Usage\n\nCreate a line for a time that exists in your series data, then attach it to that series:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { VerticalLine } from '@tradingview/lwc-plugin-vertical-line';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(data);\n\nconst earningsLine = new VerticalLine('2024-04-25', {\n    color: '#2962FF',\n    width: 2,\n    showLabel: true,\n    labelText: 'Earnings',\n    labelBackgroundColor: '#2962FF',\n    labelTextColor: '#FFFFFF',\n});\nseries.attachPrimitive(earningsLine);\n```\n\nTo remove a line, detach it from the series:\n\n```js\nseries.detachPrimitive(earningsLine);\n```\n\nThe `time` argument accepts any [`Time`](https://tradingview.github.io/lightweight-charts/docs/api/type-aliases/Time)\nvalue supported by the chart (a business day string, a `BusinessDay` object,\nor a UTC timestamp) — use the same format as your series data.\n\nChange a line after it has been created with `applyOptions` and `setTime`:\n\n```js\nearningsLine.applyOptions({ color: '#F23645', labelText: 'Moved' });\nearningsLine.setTime('2024-05-02');\n```\n\n## Options\n\nAll options are optional. Pass them as the second constructor argument.\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `color` | `string` | `'green'` | Color of the line. |\n| `width` | `number` | `3` | Width of the line, in CSS pixels. |\n| `lineStyle` | `LineStyle` | `LineStyle.Solid` | Dash pattern of the line. |\n| `lineVisible` | `boolean` | `true` | Draw the line itself. Set it to `false` for a time-axis label with no line. |\n| `showLabel` | `boolean` | `false` | Show a label at the line's position on the time axis. |\n| `tickVisible` | `boolean` | `true` | Draw the tick mark of the time-axis label. |\n| `labelText` | `string` | `''` | Text of the time-axis label. Overrides `labelFormatter` when set. |\n| `labelFormatter` | `(time) => string` | — | Builds the label text from the line's time. Used only while `labelText` is empty; the default formats the time the way the chart's own time axis does. |\n| `labelBackgroundColor` | `string` | `'green'` | Background color of the label. |\n| `labelTextColor` | `string` | `'white'` | Text color of the label. |\n| `zOrder` | `'bottom' \\| 'normal' \\| 'top'` | `'normal'` | Layer the line is drawn in. |\n| `snap` | `'exact' \\| 'nearest'` | `'exact'` | `'exact'` draws the line only at a time which is a bar of the chart; `'nearest'` places it on the closest bar instead. |\n| `draggable` | `boolean` | `false` | Lets the user drag the line along the time scale. |\n| `hitTestTolerance` | `number` | `4` | Distance from the line, in CSS pixels, still counted as a hit. |\n| `id` | `string` | `'vertical-line'` | Reported as `externalId` for a hit on this line. |\n| `badge` | `Partial<VerticalLineBadgeOptions> & { text }` | — | Text badge drawn on the line. Omit it for no badge. |\n\nThe defaults are exported as `defaultOptions`.\n\n### Badge\n\nA badge is a short caption drawn on the line itself, for text that should stay\nnext to the line rather than sit on the time axis:\n\n```js\nseries.attachPrimitive(new VerticalLine('2024-04-25', {\n    badge: { text: 'Earnings', backgroundColor: '#2962FF' },\n}));\n```\n\n| Badge option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `text` | `string` | `''` | Text of the badge. An empty string hides it. |\n| `color` | `string` | `'white'` | Text color. |\n| `backgroundColor` | `string` | `'green'` | Background color. |\n| `borderColor` | `string` | — | Border color. Leave it out for no border. |\n| `borderWidth` | `number` | `0` | Border width, in CSS pixels. |\n| `borderRadius` | `number` | `4` | Corner radius of the background, in CSS pixels. |\n| `font` | `string` | system sans-serif, 12px | Font, as a CSS `font` shorthand. |\n| `padding` | `number` | `4` | Space between the text and the edge of the background. |\n| `margin` | `number` | `4` | Distance from the line and from the pane edge. |\n| `verticalAlign` | `'top' \\| 'middle' \\| 'bottom'` | `'top'` | Where along the line the badge sits. |\n| `horizontalAlign` | `'left' \\| 'right'` | `'right'` | Which side of the line the badge sits on. |\n\nThe badge defaults are exported as `defaultBadgeOptions`.\n\n### Dragging\n\nWith `draggable: true` the line can be moved along the time scale with the\npointer, and `timeChanged()` reports every new time:\n\n```js\nconst line = new VerticalLine('2024-04-25', { draggable: true });\nseries.attachPrimitive(line);\nline.timeChanged().subscribe(time => console.log(time));\n```\n\nDragging suspends the chart's own scroll and scale handling for the duration of\nthe gesture, so the chart does not pan under the pointer. Only one line per\nchart holds that suspension at a time: where two draggable lines overlap, the\none attached first takes the gesture and the other ignores it, so the chart's\noptions are restored exactly once. Ownership is tracked per loaded copy of this\nmodule, so two bundles of the plugin on the same page each track their own\nowner; load it once per page if you attach overlapping draggable lines.\n\n## Notes\n\n- With the default `snap: 'exact'` the line is drawn only when its time is a\n  bar of the chart's time scale; a time between bars or outside the data draws\n  nothing, and its time-axis label is hidden with it. Use `snap: 'nearest'` to\n  place the line on the closest bar instead.\n- The line spans the full height of the pane the series belongs to. To mark a\n  time across several panes, attach a line to a series in each pane.\n- The label is rendered by the chart's time axis, so it inherits the axis font\n  and is hidden together with the axis if `timeScale.visible` is `false`.\n- `VertLine` and `VertLineOptions` are still exported, as deprecated aliases of\n  `VerticalLine` and `VerticalLineOptions`, and the old\n  `new VertLine(chart, series, time, options)` form of the constructor still\n  works: the chart and the series arguments are ignored. Both are kept for\n  compatibility and will be removed in a future major version.\n","isInternal":false,"tokens":2147,"sizeBytes":8269},{"name":"README.md","path":"packages/lwc-toolkit/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/packages/lwc-toolkit/README.md","title":"lwc-toolkit Documentation","category":"plugin-manifest","format":"markdown","content":"# @tradingview/lwc-toolkit\n\nHelpers for authoring [Lightweight Charts™](https://www.tradingview.com/lightweight-charts/)\nplugins — the pixel-arithmetic, subscription and base-class pieces that every\nplugin ends up needing, so they do not have to be copied into each project.\n\nRequires `lightweight-charts` 5.0 or later as a peer dependency.\n\n```shell\nnpm install --save-dev @tradingview/lwc-toolkit\n```\n\nA dev dependency is usually the right choice: a plugin bundles the handful of\nhelpers it uses into its own output, so the people installing that plugin never\nneed this package themselves. See [Bundling](#bundling) below.\n\n## Usage\n\nEvery helper is imported from its own sub-path. There is no barrel entry point,\nso `@tradingview/lwc-toolkit` on its own does not resolve — import the module\nyou want:\n\n```js\nimport { PluginBase } from '@tradingview/lwc-toolkit/plugin-base';\nimport { positionsBox, positionsLine } from '@tradingview/lwc-toolkit/dimensions/positions';\n```\n\nSub-path exports need a modern module resolver. Set `moduleResolution` to\n`\"bundler\"`, `\"node16\"` or `\"nodenext\"` in `tsconfig.json`; the legacy `\"node\"`\nsetting ignores the `exports` field and will report the imports as unresolved.\n\n## Modules\n\n| Sub-path | Provides |\n| --- | --- |\n| `assertions` | `ensureDefined`, `ensureNotNull` — narrow a value or throw |\n| `axis-label-view` | `AxisLabelView`, `AxisLabelSource` — a price- or time-axis label over a source that may have no coordinate yet |\n| `canvas/markers` | `beginMarker`, `beginMarkerOffset`, `traceMarker`, `traceMarkerOffset`, `markerDistance`, `markerVertices`, `segmentDistance`, `MarkerShape` — circle, square, diamond and triangle markers, one per path (`begin*`, which start the path) or many to a path (`trace*`), the ring around them, and the distance to them as drawn, for hit testing, all from the same vertices |\n| `canvas/round-rect` | `drawRoundRect`, `drawRoundRectWithBorder`, `clampCornerRadius`, `CornerRadii` — rounded rectangles with an inset border |\n| `chart/compat` | `supportsSeriesOrder` — runtime checks for series methods newer than 5.0 (`setSeriesOrder`, 5.0.6) that narrow the series, so that a plugin calls them where the host has them and still supports 5.0 |\n| `chart/interaction-flags` | `canUserMoveTimeScale`, `TIME_SCALE_MOVE_FLAGS` — whether `handleScroll` / `handleScale` let the user scroll or zoom the time scale, by the library's own rule |\n| `chart/lifecycle` | `isChartRemoved`, `isSeriesAttached` — side-effect-free checks for a removed chart and a series taken off the chart |\n| `chart/time-axis-labels` | `timeAxisLabelFont`, `tickMarkPixelsPerCharacter`, `tickMarkMaxLabelWidth`, `tickMarkCharactersForWidth` — the time axis' label font, and `tickMarkMaxCharacterLength` to pixels and back |\n| `closest-index` | `ClosestTimeIndexFinder` — cached binary search for the first index at or after (or last at or before) a time |\n| `custom-series/compat` | `CustomSeriesHitTestResult`, `ConflationContext` — types only: the library's hit test result (5.2) and conflation context (5.1), so a plugin can implement `hitTest` and `conflationReducer` and still support 5.0 |\n| `custom-series/hit-test` | `distanceToRange`, `seriesHitTestTolerance`, `nearestBar`, `nearestVerticalRange`, `createHitTestDataCache` — a renderer's `hitTest`: the series' tolerance, the visible bar nearest the pointer within it by any distance or, for bars that span a vertical range, by the distance to their box, and one `hitTestData` object per hovered item |\n| `custom-series/line-paths` | `buildLinePath`, `buildStepLinePath`, `areaBetween`, `strokeStyledPolyline` — polylines (straight or stepped), the band between two lines, and a line whose style, dash pattern included, changes along its length |\n| `custom-series/options-aware-series` | `createOptionsAwareSeries`, `createWhitespaceSeries`, `OptionsAwareSeries` — retain accepted input, bind price-value builders to current options and refresh stored values when scaling options change |\n| `custom-series/renderer-base` | `CustomSeriesRendererBase`, `CustomSeriesDrawArgs` — a custom series renderer with the data and visible-range guards done, leaving `drawImpl`. A renderer's `hitTest` must return the same `hitTestData` object while the same item stays hovered |\n| `custom-series/stacking` | `cumulativeSum`, `stackLevels`, `stackedPlotValues` — running totals, the band boundaries of a stack drawn from a base, and the autoscale values of a stack that may contain negatives |\n| `custom-series/visible-bars` | `forEachVisibleBar`, `mapVisibleBars`, `extendRange`, `visibleSegments`, `whitespaceGapCheck`, `AcceptedInput`, `barCoordinate`, `getConflationFactor`, `effectiveBarSpacing` — iterate the visible bars only, reach the pane edge, split at whitespace gaps wide enough to see at the current bar spacing, size a conflated bar to the slots it covers |\n| `delegate` | `Delegate`, `ISubscription` — a small subscribe/fire event primitive |\n| `dimensions/candles` | `candlestickWidth` — the body width the chart itself would use at a given bar spacing |\n| `dimensions/columns` | `calculateColumnPositions`, `calculateColumnPositionsInPlace` — evenly spaced column bars with consistent gaps |\n| `dimensions/common` | `BitmapPositionLength` — the `{ position, length }` pair the other dimension helpers return |\n| `dimensions/crosshair-width` | `gridAndCrosshairMediaWidth`, `gridAndCrosshairBitmapWidth` — line widths matching the grid and crosshair |\n| `dimensions/full-width` | `fullBarWidth`, `fullBarWidthAfter` — a bar spanning the whole slot, and one starting where its neighbor ended, so neighbors share an edge |\n| `dimensions/positions` | `positionsBox`, `positionsLine` — pixel-perfect boxes and lines from two coordinates |\n| `dom/media-query` | `subscribeMediaQuery`, `mediaQueryMatches`, `HIGH_CONTRAST_QUERIES`, `REDUCED_MOTION_QUERY` — shared, SSR-safe media query subscriptions |\n| `dom/pane-element` | `paneContentElement`, `chartTableElement` — the pane's canvas wrapper to append DOM overlays to, and the chart table |\n| `line-style` | `setLineStyle`, `getDashPattern`, `LineStyle` — the chart's dash patterns for renderers that receive no drawing utils; takes the library's `LineStyle` too |\n| `min-max-in-range` | `UpperLowerInRange` — cached upper/lower bounds over a range, for autoscaling |\n| `numbers` | `isFiniteNumber`, `finiteOr`, `nonNegativeOr`, `clampOpacity` — checks for numeric options, which the canvas otherwise ignores silently when they are `NaN` |\n| `options/merge` | `mergeOptions`, `cloneOptions`, `freezeOptions`, `isPlainObject`, `isUnsafeKey` — deep merge of partial options (a `null` reset to the default is opt-in), a copy that keeps functions, and frozen defaults |\n| `pane-plugin-base` | `PanePluginBase` — the pane-primitive counterpart of `PluginBase`: chart reference and `requestUpdate` hook |\n| `plugin-base` | `PluginBase` — a series-primitive base class holding the chart and series references and a `requestUpdate` hook |\n| `scheduling/coalesced-task` | `createCoalescedTask`, `CoalescedTask` — work run at most once per microtask (or frame), with `cancel()` for disposal |\n| `simple-clone` | `cloneReadonly` — deep clone that drops readonly-ness, through JSON: functions and `undefined` are dropped (`cloneOptions` in `options/merge` keeps them) |\n| `text/measure` | `textMeasureContext`, `createTextWidthCache` — a shared offscreen context to measure text with, and a bounded cache of widths |\n| `time` | `convertTime`, `convertTimeUTC`, `displayTime`, `formattedDateAndTime` — `Time` to local or UTC timestamps and display strings |\n\nThe dimension helpers exist because canvas drawing has to land on whole device\npixels to look sharp at every device pixel ratio. See\n[Pixel Perfect Rendering](https://tradingview.github.io/lightweight-charts/docs/plugins/pixel-perfect-rendering)\nfor the reasoning.\n\n## Bundling\n\nThe package is ESM only, ships no side effects (`\"sideEffects\": false`) and\nkeeps one module per file, so a bundler drops whatever a plugin does not\nreference. Since each plugin inlines only the helpers it actually uses — a few\nhundred bytes, typically — the usual arrangement is to keep this as a\n`devDependency` and let it disappear into the plugin's own bundle, rather than\nmaking every consumer of the plugin install it.\n\n`lightweight-charts` is a peer dependency and must stay external: the chart and\nseries objects are compared by identity, so a second copy of the library is a\nbug rather than an inefficiency.\n\n## Contributing\n\nThe sources live in the\n[Lightweight Charts™ repository](https://github.com/tradingview/lightweight-charts/tree/master/packages/lwc-toolkit).\n\n```shell\npnpm --filter @tradingview/lwc-toolkit build\n```\n\nOn a fresh checkout, build the library first (`pnpm build:prod` in the\nrepository root) — this package compiles against the `lightweight-charts`\ntypings from the root `dist/`.\n\nConsumers inside the repository use the compiled `dist/` output, so re-run the\nbuild after editing a helper. The `plugin-examples` scripts do this\nautomatically before building.\n\n## License\n\nApache-2.0. See [LICENSE](./LICENSE) and [NOTICE](./NOTICE).\n","isInternal":false,"tokens":2242,"sizeBytes":9238},{"name":"README.md","path":"plugin-examples/src/plugins/accessibility/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/plugin-examples/src/plugins/accessibility/README.md","title":"accessibility Documentation","category":"plugin-manifest","format":"markdown","content":"# Accessibility\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-accessibility`](https://www.npmjs.com/package/@tradingview/lwc-plugin-accessibility).\nIts source lives in [`packages/lwc-plugin-accessibility`](../../../../packages/lwc-plugin-accessibility),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/accessibility/` and `/plugin-previews/accessibility/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","isInternal":false,"tokens":157,"sizeBytes":682},{"name":"README.md","path":"plugin-examples/src/plugins/anchored-text/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/plugin-examples/src/plugins/anchored-text/README.md","title":"anchored-text Documentation","category":"plugin-manifest","format":"markdown","content":"# Anchored text\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-anchored-text`](https://www.npmjs.com/package/@tradingview/lwc-plugin-anchored-text).\nIts source lives in [`packages/lwc-plugin-anchored-text`](../../../../packages/lwc-plugin-anchored-text),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/anchored-text/` and `/plugin-previews/anchored-text/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","isInternal":false,"tokens":171,"sizeBytes":682},{"name":"README.md","path":"plugin-examples/src/plugins/background-shade-series/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/plugin-examples/src/plugins/background-shade-series/README.md","title":"background-shade-series Documentation","category":"plugin-manifest","format":"markdown","content":"# Background shade series\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-background-shade-series`](https://www.npmjs.com/package/@tradingview/lwc-plugin-background-shade-series).\nIts source lives in [`packages/lwc-plugin-background-shade-series`](../../../../packages/lwc-plugin-background-shade-series),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/background-shade-series/` and `/plugin-previews/background-shade-series/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","isInternal":false,"tokens":171,"sizeBytes":752},{"name":"README.md","path":"plugin-examples/src/plugins/box-whisker-series/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/plugin-examples/src/plugins/box-whisker-series/README.md","title":"box-whisker-series Documentation","category":"plugin-manifest","format":"markdown","content":"# Box and whisker series\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-box-whisker-series`](https://www.npmjs.com/package/@tradingview/lwc-plugin-box-whisker-series).\nIts source lives in [`packages/lwc-plugin-box-whisker-series`](../../../../packages/lwc-plugin-box-whisker-series),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/box-whisker-series/` and `/plugin-previews/box-whisker-series/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","isInternal":false,"tokens":181,"sizeBytes":721},{"name":"README.md","path":"plugin-examples/src/plugins/brushable-area-series/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/plugin-examples/src/plugins/brushable-area-series/README.md","title":"brushable-area-series Documentation","category":"plugin-manifest","format":"markdown","content":"# Brushable area series\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-brushable-area-series`](https://www.npmjs.com/package/@tradingview/lwc-plugin-brushable-area-series).\nIts source lives in [`packages/lwc-plugin-brushable-area-series`](../../../../packages/lwc-plugin-brushable-area-series),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/brushable-area-series/` and `/plugin-previews/brushable-area-series/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","isInternal":false,"tokens":178,"sizeBytes":738},{"name":"README.md","path":"plugin-examples/src/plugins/dual-range-histogram-series/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/plugin-examples/src/plugins/dual-range-histogram-series/README.md","title":"dual-range-histogram-series Documentation","category":"plugin-manifest","format":"markdown","content":"# Dual range histogram series\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-dual-range-histogram-series`](https://www.npmjs.com/package/@tradingview/lwc-plugin-dual-range-histogram-series).\nIts source lives in [`packages/lwc-plugin-dual-range-histogram-series`](../../../../packages/lwc-plugin-dual-range-histogram-series),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/dual-range-histogram-series/` and `/plugin-previews/dual-range-histogram-series/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","isInternal":false,"tokens":184,"sizeBytes":780},{"name":"README.md","path":"plugin-examples/src/plugins/grouped-bars-series/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/plugin-examples/src/plugins/grouped-bars-series/README.md","title":"grouped-bars-series Documentation","category":"plugin-manifest","format":"markdown","content":"# Grouped bars series\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-grouped-bars-series`](https://www.npmjs.com/package/@tradingview/lwc-plugin-grouped-bars-series).\nIts source lives in [`packages/lwc-plugin-grouped-bars-series`](../../../../packages/lwc-plugin-grouped-bars-series),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/grouped-bars-series/` and `/plugin-previews/grouped-bars-series/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","isInternal":false,"tokens":172,"sizeBytes":724},{"name":"README.md","path":"plugin-examples/src/plugins/heatmap-series/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/plugin-examples/src/plugins/heatmap-series/README.md","title":"heatmap-series Documentation","category":"plugin-manifest","format":"markdown","content":"# Heatmap series\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-heatmap-series`](https://www.npmjs.com/package/@tradingview/lwc-plugin-heatmap-series).\nIts source lives in [`packages/lwc-plugin-heatmap-series`](../../../../packages/lwc-plugin-heatmap-series),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/heatmap-series/` and `/plugin-previews/heatmap-series/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working. `example/example2.html`, the old\nsecond example, redirects to the same demo, which now holds both data sets.\n","isInternal":false,"tokens":190,"sizeBytes":798},{"name":"README.md","path":"plugin-examples/src/plugins/hlc-area-series/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/plugin-examples/src/plugins/hlc-area-series/README.md","title":"hlc-area-series Documentation","category":"plugin-manifest","format":"markdown","content":"# HLC area series\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-hlc-area-series`](https://www.npmjs.com/package/@tradingview/lwc-plugin-hlc-area-series).\nIts source lives in [`packages/lwc-plugin-hlc-area-series`](../../../../packages/lwc-plugin-hlc-area-series),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/hlc-area-series/` and `/plugin-previews/hlc-area-series/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","isInternal":false,"tokens":172,"sizeBytes":696},{"name":"README.md","path":"plugin-examples/src/plugins/image-watermark/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/plugin-examples/src/plugins/image-watermark/README.md","title":"image-watermark Documentation","category":"plugin-manifest","format":"markdown","content":"# Image watermark\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-image-watermark`](https://www.npmjs.com/package/@tradingview/lwc-plugin-image-watermark).\nIts source lives in [`packages/lwc-plugin-image-watermark`](../../../../packages/lwc-plugin-image-watermark),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/image-watermark/` and `/plugin-previews/image-watermark/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","isInternal":false,"tokens":164,"sizeBytes":696},{"name":"README.md","path":"plugin-examples/src/plugins/lollipop-series/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/plugin-examples/src/plugins/lollipop-series/README.md","title":"lollipop-series Documentation","category":"plugin-manifest","format":"markdown","content":"# Lollipop series\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-lollipop-series`](https://www.npmjs.com/package/@tradingview/lwc-plugin-lollipop-series).\nIts source lives in [`packages/lwc-plugin-lollipop-series`](../../../../packages/lwc-plugin-lollipop-series),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/lollipop-series/` and `/plugin-previews/lollipop-series/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","isInternal":false,"tokens":165,"sizeBytes":696},{"name":"README.md","path":"plugin-examples/src/plugins/pretty-histogram-series/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/plugin-examples/src/plugins/pretty-histogram-series/README.md","title":"pretty-histogram-series Documentation","category":"plugin-manifest","format":"markdown","content":"# Pretty histogram series\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-pretty-histogram-series`](https://www.npmjs.com/package/@tradingview/lwc-plugin-pretty-histogram-series).\nIts source lives in [`packages/lwc-plugin-pretty-histogram-series`](../../../../packages/lwc-plugin-pretty-histogram-series),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/pretty-histogram-series/` and `/plugin-previews/pretty-histogram-series/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","isInternal":false,"tokens":177,"sizeBytes":752},{"name":"README.md","path":"plugin-examples/src/plugins/rounded-candles-series/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/plugin-examples/src/plugins/rounded-candles-series/README.md","title":"rounded-candles-series Documentation","category":"plugin-manifest","format":"markdown","content":"# Rounded candles series\n\nThis plugin has graduated to a published package,\n[`@tradingview/lwc-plugin-rounded-candles-series`](https://www.npmjs.com/package/@tradingview/lwc-plugin-rounded-candles-series).\nIts source lives in [`packages/lwc-plugin-rounded-candles-series`](../../../../packages/lwc-plugin-rounded-candles-series),\nand so do its two pages: the demo (`src/example/index.html`) and the catalog\npreview (`src/example/preview.html`).\n\n`pnpm plugins:build-demos` builds both from the package into the documentation\nsite, at `/plugin-demos/rounded-candles-series/` and `/plugin-previews/rounded-candles-series/`. The\n`example/index.html` left here is a redirect stub to the first of those, so\nlinks to the old gallery URL keep working.\n","isInternal":false,"tokens":173,"sizeBytes":745},{"name":"README.md","path":"plugin-examples/src/plugins/session-highlighting/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/plugin-examples/src/plugins/session-highlighting/README.md","title":"session-highlighting Documentation","category":"plugin-manifest","format":"markdown","content":"<!-- Skill available on-demand via /api/skills/tradingview/lightweight-charts?path=plugin-examples%2Fsrc%2Fplugins%2Fsession-highlighting%2FREADME.md -->","isInternal":false,"tokens":163,"sizeBytes":731},{"name":"README.md","path":"plugin-examples/src/plugins/stacked-area-series/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/plugin-examples/src/plugins/stacked-area-series/README.md","title":"stacked-area-series Documentation","category":"plugin-manifest","format":"markdown","content":"<!-- Skill available on-demand via /api/skills/tradingview/lightweight-charts?path=plugin-examples%2Fsrc%2Fplugins%2Fstacked-area-series%2FREADME.md -->","isInternal":false,"tokens":174,"sizeBytes":724},{"name":"README.md","path":"plugin-examples/src/plugins/stacked-bars-series/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/plugin-examples/src/plugins/stacked-bars-series/README.md","title":"stacked-bars-series Documentation","category":"plugin-manifest","format":"markdown","content":"<!-- Skill available on-demand via /api/skills/tradingview/lightweight-charts?path=plugin-examples%2Fsrc%2Fplugins%2Fstacked-bars-series%2FREADME.md -->","isInternal":false,"tokens":174,"sizeBytes":724},{"name":"README.md","path":"plugin-examples/src/plugins/user-price-lines/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/plugin-examples/src/plugins/user-price-lines/README.md","title":"user-price-lines Documentation","category":"plugin-manifest","format":"markdown","content":"<!-- Skill available on-demand via /api/skills/tradingview/lightweight-charts?path=plugin-examples%2Fsrc%2Fplugins%2Fuser-price-lines%2FREADME.md -->","isInternal":false,"tokens":165,"sizeBytes":703},{"name":"README.md","path":"plugin-examples/src/plugins/vertical-line/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/plugin-examples/src/plugins/vertical-line/README.md","title":"vertical-line Documentation","category":"plugin-manifest","format":"markdown","content":"<!-- Skill available on-demand via /api/skills/tradingview/lightweight-charts?path=plugin-examples%2Fsrc%2Fplugins%2Fvertical-line%2FREADME.md -->","isInternal":false,"tokens":160,"sizeBytes":682},{"name":"README.md","path":"website/plugins/plugin-catalogue/README.md","rawUrl":"https://raw.githubusercontent.com/tradingview/lightweight-charts/HEAD/website/plugins/plugin-catalogue/README.md","title":"plugin-catalogue Documentation","category":"plugin-manifest","format":"markdown","content":"<!-- Skill available on-demand via /api/skills/tradingview/lightweight-charts?path=website%2Fplugins%2Fplugin-catalogue%2FREADME.md -->","isInternal":false,"tokens":1631,"sizeBytes":6962}],"systemPromptSnippet":"<yakaai_skills repo=\"tradingview/lightweight-charts\">\n<!-- File: .github/skills/lightweight-charts-plugin-authoring/references/official-plugins.md (Tokens: ~4431 | Category: anthropic-skill) -->\n# The official plugins, and what each one teaches\n\nUpstream: `packages/lwc-plugin-<name>/`. Published: `@tradingview/lwc-plugin-<name>`,\nwhich ships the README and `dist/` (`.js` + `.d.ts`) but not the source. From\na repository that is not the upstream checkout, read the source on GitHub —\n`https://github.com/tradingview/lightweight-charts/tree/master/packages/lwc-plugin-<name>/src`,\nor the raw file URL under `raw.githubusercontent.com/tradingview/lightweight-charts/master/…` —\nor clone once: `git clone --depth 1 https://github.com/tradingview/lightweight-charts /tmp/lightweight-charts`.\n\nEach package has `src/`, a dev demo (`src/example/index.html`), a catalog\npreview (`src/example/preview.html`), `tests/{unit,graphics,interactions}`, a\nREADME in the catalog's shape and a CHANGELOG. Read the whole `src/` of the\nnearest one before designing; they are small.\n\nEvery preview calls `themeChart` from\n`@tradingview/lwc-plugin-preview-kit/preview-theme` and has been checked in\nboth the light and the dark theme. A new package needs the same: open the\nbuilt preview with `?theme=dark` and make sure nothing is left white or\nunreadable on black. For colors that have to change with the theme, see the\npreviews of `session-highlighting`, `image-watermark`,\n`rounded-candles-series` and `box-whisker-series`.\n\nEvery custom series below ships a `create<Name>Series(chart, options?,\npaneIndex?)` factory as the supported entry point and keeps the\n`<Name>Series` class exported for `chart.addCustomSeries` and composition.\nThe factory is where options-aware autoscale and whitespace detection live.\n\n## Custom series\n\n### `stacked-bars-series` — start here for any custom series\n\nStacked columns from a `values: number[]` per point. The shortest complete\ncustom series: `data.ts`, `options.ts`, `stack.ts` (pure maths, unit-tested),\n`renderer.ts` (extends `CustomSeriesRendererBase`), the view, the factory.\nShows `createOptionsAwareSeries` with `['base', 'percent', 'stackOrder']` as\nthe price options; `stackedPlotValues` for autoscale over negatives;\n`calculateColumnPositions` with `time` so columns either side of a gap are\nnot aligned to each other; `hitTest` returning the hovered segment index;\n`conflationReducer` summing bands.\n\n### `pretty-histogram-series` — one value per point, rounded, pixel-aligned\n\nRounded columns with `widthPercent`/`widthMode`, inner corners, a border and\na gradient. Shows `canvas/round-rect` with clamped radii, `base` reported in\n`priceValueBuilder` so bars never clip at the pane edge, `highlightHovered`\ndimming, a `conflationReducer` that keeps the later value, and the guard for\nan empty visible range.\n\n### `lollipop-series` — markers on stems, sized by the bar spacing\n\nA dot at each value on a stem from `base`, drawn with `beginMarker` from\n`canvas/markers`. Read for: sizes that are options but capped by the bar\nspacing, and the dot also by a fixed maximum that keeps it within the price\nscale's margins in a pane at least 100 px tall, since autoscale only knows the\nvalues (`geometry.ts`, unit-tested); a stem kept at least one device pixel\nwide; centering the dot on the stem as it was snapped to the pixel grid; and a\n`hitTest` built on `custom-series/hit-test`: `nearestVerticalRange` for the\nstems and `nearestBar` with `markerDistance` for the dots, so that each dot is\nmeasured as drawn, reporting the dot as a `'point'` and the stem as a\n`'range'`, since the chart prefers any point hit to a range hit whatever the\ndistance. It has no `conflationReducer`, so it sizes against `barSpacing`, not\n`effectiveBarSpacing`. Its `hover-empty-space` interaction test shows the\nlibrary's own fallback: where the renderer's `hitTest` returns `null`, a\npointer inside a bar's slot between its plot values still reports the series\nas hovered, without an `objectId`.\n\n### `grouped-bars-series` — several values per point, side by side\n\nA group of columns per point from `values[]`, with series and per-point\n`colors`, a `base`, and `columnWidthMode`/`widthPercent` named as in\n`stacked-bars-series`. Read for: one column count for the whole series, the\nmost values any point that draws a column has, so a column is as wide in\nevery group, counted once per data change by keying it on the\n`AcceptedInput` revision that `createOptionsAwareSeries` hands the view, and\nread when the renderer draws or hit tests rather than in the view's `update`,\nwhich the chart calls while `setData` is still running, before the revision\nmoves; groups placed with `calculateColumnPositionsInPlace` in `histogram`\nmode and `positionsLine` in `percent` mode, where they are all the same width\nand never wider than the bar spacing covers; splitting each group into\nwhole-pixel columns that tile it exactly (`splitGroup` in `layout.ts`,\nunit-tested), every column keeping at least a pixel and the tallest drawn\nfirst once they share pixels; values equal to `base`, `null` and non-finite\nvalues skipped like whitespace; and a `hitTest` that measures every column\nwithin reach with `nearestBar`, naming the point and the column in\n`objectId`.\n\n### `stacked-area-series` — bands, gaps and conflation together\n\nCumulative bands from `values[]`, negatives folding back to the base,\n`gapHandling: 'break' | 'bridge'`, `percent` mode, per-band and per-point\ncolors, `lineType` simple/step/curved. Shows `createWhitespaceSeries` with\n`['base', 'percent']`; `visibleSegments` with the `GapCheck` and\n`getConflationFactor(data)` as `minGap`; `extendRange` + `barCoordinate` so\nlines reach the pane edge with correct offscreen coordinates; `stackLevels`;\na `hitTest` that ignores whitespace gaps and unpainted extents. Its\ninteraction tests (`shared-timeline`, `whitespace-hit-test`,\n`conflation-holidays`) are the model for testing gap behavior.\n\n### `hlc-area-series` — two lines with a band between\n\nHigh, low and close lines, two-tone fill, gradients, step mode, hover\nmarkers on the bar under the cursor. Shows `line-paths` (`buildLinePath`,\n`buildStepLinePath`, `areaBetween`), skipping points whose prices fall off\nthe scale rather than drawing to `NaN`, `hitTest` by nearest bar, and a\n`conflationReducer` taking highest high / lowest low / last close.\n\n### `brushable-area-series` — a series plus its own interaction primitive\n\nAn area whose `brushRanges` (logical-index ranges) carry their own styles,\nwith `outsideStyle`, `basePrice` and gradient options; and\n`BrushableAreaInteraction`, a series primitive that turns mouse drag,\none-finger drag and two-finger gestures into a range and reports it through\n`activeRange()` as a `Delegate`. Read this for: matching ranges by *logical\nindex* rather than array index (they differ when another series starts\nearlier), `strokeStyledPolyline` for a line whose style changes mid-way, and\nhow a series and a primitive cooperate without the series knowing about\npointers.\n\n### `dual-range-histogram-series` — fixed pixel height, price-scale coexistence\n\nNested up/down columns of fixed pixel height on the zero line, or `scaleMode:\n'price'` to autoscale like a normal series. Shows the problem of a series that\nis *not* part of the autoscale: `keepPixelSeriesInView(chart, series)` reserves\nroom on the price scale and keeps doing so on resize. Also generic horizontal\nscale support, role-keyed `colors`/`borderRadius`, and `normalize`.\n\n### `background-shade-series` — a series that is only a background\n\nFull-height columns behind each bar, colored by where the bar's value sits\nbetween two colors. Read for: a custom series that stays out of the price\nscale (`priceValueBuilder` returns `[NaN]`, so it never changes the autoscale\nrange, has no last value and is never hovered) and sits on an overlay price\nscale of its own, set in `defaultOptions`, since a series at the bottom of the\norder would otherwise set the number format of a shared axis; columns from\n`fullBarWidthAfter`, each starting where the previous one ends, since two\nedges rounded on their own can leave a seam; shades looked up in a table built when the\ncolors change, so no color string is made while drawing; a per-point `color`\nread from `bar.barColor`, since the chart keeps `color` out of\n`originalData` and merges it with the series `color`, which the package\ntherefore leaves empty; parsing a CSS color\nthrough a scratch canvas of its own (never the chart's context, whose\n`fillStyle` a check would change), and spotting an invalid one; mixing colors\nwith premultiplied alpha; a factory that moves the series behind the others\nwith `setSeriesOrder(0)` where the host has it; and `globalAlpha` set inside\n`save`/`restore`. Its `price-format-kept` interaction test compares two\ncharts, since a price axis never narrows once it has grown.\n\n### `box-whisker-series` — a statistical shape on the candle grid\n\nA box plot per point from named fields (`min`, `q1`, `median`, `q3`, `max`)\nand `outliers`, with the five colors overridable on each point. Read for:\nsizing every part from `candlestickWidth` and the grid line width in bitmap\npixels, with the same parity as the whisker so each part is centered on it;\nthe outliers in the autoscale values, so every dot stays in view; malformed\npoints (a non-finite or `null` number) read as whitespace in `isWhitespace`,\nso they never reach the price scale; a factory that is a typed\n`chart.addCustomSeries`, since no option changes the plot values; and a\n`hitTest` on `nearestBar` that names the part and the point under the pointer\n(`'box-<point>'`, `'outlier-<point>-<index>'`, …) in `objectId`, an outlier\nreported as a `'point'` and the rest as `'range'`. It has no\n`conflationReducer`: merging two box plots has no clear meaning.\n\n### `heatmap-series` — many cells per point, filled by color\n\nA column of `{ low, high, amount }` cells per point, colored by a\n`cellShader(amount, range)` option. Read for: drawing many small shapes per\nframe by collecting them per color and filling one path per color, which a\nshader with few colors (`createColorScale` and its `steps`) makes pay off;\nhanding a function option the range of the values in view, worked out over\nthe visible bars, so colors need no maximum fixed in advance; checking a\ncolor a user function returns on a scratch canvas before drawing with it,\nsince the canvas ignores an invalid fill and would reuse the last one;\ncells rounded to pixels edge by edge, so neighbors share an edge, columns\nfrom `fullBarWidthAfter`, and a gap and a border rounded per axis and left out\nof a cell too small for them; rows off the pane skipped; a function-valued\noption, and a factory options type that keeps it a function where the\nlibrary's `DeepPartial` would not; a cell-level `hitTest` limited to the\ncolumn whose slot holds the pointer, so its `objectId` indexes the point\n`param.seriesData` reports, with no `hitTestData` so a pointer moving within a\ncell repaints nothing (its `hover-stable` interaction test counts fills); and\nseeded sample data shared by the demo, the preview and the unit tests.\n\n### `rounded-candles-series` — a drop-in replacement for a built-in\n\nCandlesticks with rounded bodies. Read for how to *match* the built-in:\nthe same color option set and shorthand semantics, `candlestickWidth` for\nthe body, body and wick aligned on one pixel grid at every DPR,\n`upDownMode`, per-point overrides, `conflationFactor` widening candles under\nconflation, and a `radius` that may be a number or a function of bar spacing.\n\n### `scatter-series` — a numeric X axis instead of time\n\nScatter and bubble charts. `createScatterChart` builds the chart on a custom\nhorizontal scale behavior (`ScatterHorzScaleBehavior`) so that the X axis is a\nplain number, and `createScatterSeries` draws the whole data set as one custom\nseries, in named groups with their own colors, marker shapes and connecting\nlines, with bubble sizes driven by a data value. Read for a custom horizontal\nscale, markers drawn and hit tested through `canvas/markers`, and a host API\nfor the tooltip and legend the plugin leaves to the page: `hoveredInfo.objectId`,\n`pointById`, `subscribeHoveredPointChange`. The one official plugin that needs\n`lightweight-charts` 5.2 (`^5.2.0`).\n\n## Series primitives\n\n### `vertical-line` — the model series primitive\n\nA full-height line at a time, with a time-axis label, a badge on the line,\n`snap: 'exact' | 'nearest'`, dragging with an `ew-resize` cursor. Shows\n`PluginBase`, `AxisLabelView` (and the off-screen coordinate when the time is\nnot on the scale), `positionsLine` for a crisp line, `setLineStyle` for dash\npatterns, `Delegate` for `timeChanged()`, hit-testing with a tolerance, and\ndrag ownership — only one line per chart suspends the chart's own scroll and\nscale handling, and restores it exactly once. Its interaction tests cover\ndrag cancel, disabling during a drag, overlapping lines and pointer scope.\n\n### `user-price-lines` — pointer-driven creation on a series\n\nA button at the right edge of the pane that follows the pointer and adds a\nprice line where it is clicked. Read for: driving a tool from\n`subscribeCrosshairMove` and `subscribeClick`, ignoring events from other\npanes with `param.paneIndex` and asking for a repaint only when the button\nchanges; moves with no `sourceEvent` (the chart's own, after\n`setCrosshairPosition`, on data and time scale changes) never bringing the\nbutton up; a click that only counts on the button where it is shown, so a\ntouch tap away from it adds nothing (the chart reports no click after a\ndrag); the pane's width from `chart.paneSize`, since\n`timeScale().width()` is 0 while the time axis is hidden; a geometric\n`hitTest` for the cursor and `hoveredObjectId` (the chart hit tests before it\nreports the move); setting a chart option (`CrosshairMode.Normal`) while\nattached and putting the old value back on detach only if it is still the one\nset, handed over between instances; one active instance per pane, kept in a\nmodule-level `WeakMap` by chart; letting go of the chart once\n`chart.removeSeries` or `chart.remove` has taken its series away (neither\ncalls `detached`); tracking the lines it created by `id`, since\n`series.priceLines()` returns new objects on every call, and removing them on\ndetach; and a deprecated constructor overload kept from the example. Its\ninteraction tests wait out the chart's double-click window between clicks in\none pane: a second click within 500 ms is otherwise swallowed, and a test\nasserting that it added nothing passes for the wrong reason. Its `price-zero`\ntest builds a scale on which a whole pixel row is at exactly 0.\n\n### `image-watermark` — the same idea as both primitive types\n\n`ImageWatermark` (series primitive) and `ImageWatermarkPane` (pane primitive)\nsharing options and a renderer. Read for: drawing nothing until an image has\ndecoded (and reporting failures through `onError` instead of throwing every\nframe), positioning from the *pane's* size rather than the chart element,\n`objectFit`/`position`/`padding` layout, `zOrder`, a decoded-image cache by\nURL, and `detached()` canceling a pending load.\n\n### `anchored-text` — the smallest two-class primitive\n\n`AnchoredText` (series primitive) and `AnchoredTextPane` (pane primitive)\nsharing one core, with no image to load and no interaction: the shape of\n`image-watermark` reduced to its essentials. Read for: laying text out in the\nmedia coordinate space from `measureText` (`layout.ts` is a pure function the\nunit tests cover for all nine anchors), a renderer that returns `null` while\nthere is nothing to draw, `save`/`restore` around context changes, options\nthat accept a deprecated spelling (`'middle'`) on input and never return it,\nand `mergeOptions` where one option (`lineHeight`) treats an explicit\n`undefined` as a value.\n\n### `session-highlighting` — per-bar background from the series' own data\n\n`SessionHighlighting` shades a full-height column behind every bar with the\ncolor a user function returns for its time. Read for: deriving per-bar state\nfrom `series.data()` in `dataUpdated` and patching only the end of it on an\n`'update'` scope. The scope covers more than append and replace: `pop()` and\nan update that turns the last bar into whitespace shrink the data, and a\nhistorical update can remove a bar from the middle or insert one there, so\nthe bar count decides the case: a shrink is only cut back when the kept last\nentry still names the last bar, and a bar is only appended when it comes after\nthe last entry (both compared by the key `timestampOf` stores for each bar: numbers\npass through unchanged, as the time scale keys them, and business days and\ndate strings become the UTC timestamp of their day, so how the time is written\ndoes not matter); otherwise every bar is recolored. Also read for mapping the\nvisible logical range back to data indices by binary search over `timeToIndex`\n(so other series starting earlier do not shift the slice), `fullBarWidth` from\nthe time scale's `barSpacing` for columns as wide as the bar slots (each edge\nrounded on its own, so neighbors can leave a 1 px seam where an edge falls on\na half pixel; `fullBarWidthAfter` rounds a shared edge once), and\n`zOrder: 'bottom'` for a background.\n\n## Pane primitives\n\n### `accessibility` — DOM overlays and multi-pane lifecycle\n\nA pane primitive per pane plus a chart-level `addAccessibilityPlugin(chart,\noptions)` controller. The reference for anything DOM-based: appending a\nsemantic layer to `paneContentElement(pane)`, following the pane by identity\nthrough reordering (the constructor index is only a pre-build hint; the first\ndraw's canvas resolves the real pane), a single shared ARIA-live region,\n`subscribeMediaQuery` for high contrast, message bundles and localization,\nkeyboard handling on the overlay, and a controller that reconciles panes added\nor removed at runtime. Also the largest test suite of the official plugins; its\n`pane-reorder`, `mismatched-pane-index` and `announce-callback-throws`\ninteraction tests show how to assert on DOM state.\n\n## `plugin-examples/` — breadth, not the standard\n\nUpstream `plugin-examples/src/plugins/` holds unpublished proof-of-concept\nplugins: tooltips and delta tooltips, a rectangle drawing tool, trend lines,\nprice alerts, a volume profile, a partial price line,\nand crosshair highlighting. Good for seeing the shape of an\nidea; they predate the toolkit and skip the tests and README the packages\ncarry, so use the official plugins for *how* and these for *what*. The\ngraduated plugins' folders there are redirect stubs to the packages.\n\n<!-- File: .github/skills/lightweight-charts-plugin-authoring/references/package-contract.md (Tokens: ~1707 | Category: anthropic-skill) -->\n# The plugin package contract\n\nWhat makes a plugin package publishable and catalog-ready. Upstream,\n`pnpm plugins:validate` (`scripts/plugins/validate-metadata.mjs`) enforces all\nof it and fails CI otherwise; a project scaffolded by `create-lwc-plugin`\nalready satisfies every item, so this is mostly a list of what not to break.\nThe catalog on the docs site lists the official packages today; the same\ncontract is what any plugin would need to be listed.\n\nUpstream only: a package under `packages/` also needs its catalog card\nillustration, `website/static/plugin-catalog/assets/previews/<slug>.svg`\n(320×180, TradingView palette colors only). The catalog data README,\n`website/plugins/plugin-catalogue/README.md`, says how to draw it and which\naccent color to pick.\n\n## `package.json`\n\n| Field | Rule | Why |\n| --- | --- | --- |\n| `name` | starts with `lwc-plugin-` (unscoped), or `@tradingview/lwc-plugin-` for an official package | the unscoped remainder is the catalog's URL segment and the entry file name |\n| `version` | valid semver | the release script compares it with npm |\n| `description` | non-empty | shown on the catalog card |\n| `license` | non-empty SPDX id | shown on the detail page |\n| `publishConfig.access` | `\"public\"` | scoped packages default to restricted |\n| `peerDependencies.lightweight-charts` | a valid range, `^5.0.0` unless a 5.1 hook is required | the catalog shows \"works with\"; consumers install the library themselves |\n| `keywords` | includes `lightweight-charts-plugin` | how npm search and the registry find plugins |\n| `files` | `dist` (+ `CHANGELOG.md`, `NOTICE` for official) | ship built output only |\n| `exports` | `.` and `./standalone`, each with `types` + `default` | the standalone build inlines everything but the library, for CDN import maps |\n| `lwcPlugin` | see below | the catalog's curated metadata |\n| `repository.directory` | must equal the package's real path in the repo | the \"source\" link and the catalog read it |\n\n## The `lwcPlugin` block\n\nValidated against `scripts/plugins/lwc-plugin-metadata.schema.json`;\nunknown keys are errors.\n\n| Key | Required | Values |\n| --- | --- | --- |\n| `title` | yes | display name |\n| `category` | yes | `custom-series` \\| `series-primitive` \\| `pane-primitive` |\n| `lifecycle` | yes | `current` \\| `legacy` \\| `deprecated` \\| `experimental` |\n| `origin` | yes | `official` \\| `community` (workspace packages must be `official`) |\n| `demo` | yes | package-relative path of the dev demo page; the file must exist |\n| `author` | no | display name |\n| `preview` | no | package-relative path of the catalog preview page; must exist if declared |\n| `previewHeight` | no | integer ≥ 200, CSS px for the preview frame (default 330); only with `preview` |\n| `tags` | no | search terms |\n\n## Two pages, not one\n\n- **Demo** (`src/example/index.html` + `example.ts`, `lwcPlugin.demo`): the\n  page a developer opens on its own. Put the edge cases here — whitespace\n  runs, negatives, every option as a control. `pnpm dev` serves it; upstream,\n  `pnpm plugins:build-demos` builds it to `/plugin-demos/<slug>/` on the site.\n- **Preview** (`src/example/preview.html` + `preview.ts`, `lwcPlugin.preview`):\n  what the catalog frames next to the README, in a frame ~330 px tall. Show\n  the plugin at its best: clean data, two or three controls, no explanatory\n  text. Official packages build it with the private\n  `@tradingview/lwc-plugin-preview-kit` (layout + `mountControls` /\n  `addRefreshButton`); a standalone project has no preview by default.\n\n  The preview follows the docs site's light or dark theme and switches live\n  when the site theme is toggled. Call `themeChart(chart, onTheme?)` from\n  `@tradingview/lwc-plugin-preview-kit/preview-theme` in the same script run\n  as `createChart`, before anything awaits; it themes the chart's\n  background, text, grid, scales and crosshair labels. Anything the preview\n  colors itself — series and plugin options, a price line color, an image —\n  is your job: recolor it in `onTheme`, which runs right away and again on\n  every switch. Keep a control's current choice in a variable so a theme\n  switch reapplies it, and read `previewTheme()` in the control's handler\n  (see `rounded-candles-series` or `box-whisker-series`). Before you\n  finish, check the built preview in both themes (`?theme=light` and\n  `?theme=dark` on its URL): nothing white or light-only left over, and\n  every line, dot and label readable on black.\n\nNeither page is the plugin's tests. Keep them free of assertions.\n\n## README shape\n\nThe catalog renders the README as the page body (its H1 dropped, since the\npage header shows the title), with the Installation subsections lifted into\nan npm/CDN tab switcher. So:\n\n1. `# <Title>` then a description paragraph.\n2. `## Installation` with `### npm` (install command + import example) and\n   `### CDN` (an import map pointing `lightweight-charts` and the package at\n   their standalone builds, then the same import by name).\n3. `## Usage` with at least one `js`/`ts` code block — the release smoke test\n   compiles the first snippet after `### npm`, so it must be complete and\n   correct.\n4. `## Options`, `## Notes` as needed. Headings become anchors and a table of\n   contents on the site, so keep them descriptive.\n\nIf the series ships a factory, the README's snippets use it, and a line says\nthe plain class draws continuously (no whitespace detection).\n\n## Tests\n\nOfficial packages carry `tests/unit/*.spec.ts` (run by the repo's `pnpm test`),\n`tests/graphics/*.js` (screenshot comparison against the previous build) and\n`tests/interactions/*.js` (async `beforeInteractions(container)` that throws on\na wrong outcome). The e2e runners discover them by folder; a package without\na `tests/<suite>` folder is skipped, never failed.\n\n## CHANGELOG\n\nKeep a Changelog format, one `## <version>` per release. For the **first**\nrelease keep it short: a sentence saying it is the first release (and where\nit came from), an `### Added` list of what the package provides, and\n`### Deprecated` only if it ships a deprecated alias. No `Fixed` or `Changed`\n— nothing has been released to fix or change, and entries written as commit\nsubjects read badly on npm. The release script only checks that an entry for\nthe current version exists.\n\n## Scripts a package is expected to have\n\n`dev` (Vite on the demo page), `build` (`tsc` for declarations, then the\nshared compile producing `dist/<entry>.js` and `dist/<entry>.standalone.js`\nplus bundled `.d.ts`), `typecheck`, and `check-package` (`publint --strict`\nand `@arethetypeswrong/cli`). Upstream adds `plugins:check-compat` (build every\nplugin against the workspace library) and `plugins:smoke` (install the packed\ntarball into a fresh Vite project and compile the README snippet).\n\n<!-- File: .github/skills/lightweight-charts-plugin-authoring/references/toolkit.md (Tokens: ~4128 | Category: anthropic-skill) -->\n# `@tradingview/lwc-toolkit`, module by module\n\nEvery module is its own sub-path export: `@tradingview/lwc-toolkit/<module>`.\nThere is no root import. This file describes the shape and the reason, not\nevery overload: verify signatures against\n`node_modules/@tradingview/lwc-toolkit/dist/<module>.d.ts`, whose doc comments\nare the module's documentation.\n\n\"Read:\" names the official plugin whose source shows the module used for\nreal. Upstream that is `packages/lwc-plugin-<name>/src/<file>`; from any other\nrepository fetch\n`https://raw.githubusercontent.com/tradingview/lightweight-charts/master/packages/lwc-plugin-<name>/src/<file>`\n(the published package ships `dist/` only).\n\n## Custom series\n\n### `custom-series/renderer-base` — `CustomSeriesRendererBase`, `CustomSeriesDrawArgs`, `CanvasRenderingTarget2D`\n\nBase class for a custom series renderer. `update(data, options)` stores what\nthe chart hands over; `draw(target, priceConverter, isHovered, hitTestData)`\nguards against a missing data set or an empty visible range and then calls\nyour `drawImpl(scope, args)` inside `useBitmapCoordinateSpace`. `args` is\n`{ data, options, priceToCoordinate, from, to, isHovered, hitTestData }`,\nwhere `from`/`to` are the visible range clamped to the bars array.\n\nReach for it because the guards are exactly where a hand-written renderer\nthrows when the whole dataset is scrolled off screen. It also re-exports the\n`CanvasRenderingTarget2D` type so the plugin need not depend on `fancy-canvas`.\n\nIf the renderer also implements `hitTest` (called from 5.2), return the *same*\n`hitTestData` object for as long as the same item stays hovered: the chart\ncompares it by reference and repaints the pane on every pointer move when it\nchanges. Keep the last one, or return a primitive such as the item's index.\n\nRead: `stacked-bars-series/src/renderer.ts` (short), `hlc-area-series/src/renderer.ts`.\n\n### `custom-series/visible-bars` — `forEachVisibleBar`, `mapVisibleBars`, `extendRange`, `visibleSegments`, `whitespaceGapCheck`, `barCoordinate`, `getConflationFactor`, `effectiveBarSpacing`, `GapCheck`, `AcceptedInput`\n\n- `forEachVisibleBar(data, fn)` / `mapVisibleBars(data, fn)` visit only\n  `data.visibleRange`; `fn` receives the bar and its *absolute* index into\n  `data.bars`, which is what per-index option lookups use.\n- `extendRange(range, length, by = 1)` widens a range by `by` bars each side,\n  clamped, so a line's first and last segments leave the pane.\n- `visibleSegments(bars, range, isGap?)` splits a range into runs of\n  increasing logical index, breaking where `isGap(left, right)` says so. A\n  jump in logical index alone is **not** a gap — other series can own those\n  indices — so without a predicate the range is one run.\n- `whitespaceGapCheck(readInput, logicalIndex, isWhitespace)` builds that\n  predicate from the series' accepted input. Its `GapCheck(left, right,\n  minGap = 1)` is true when the *contiguous* whitespace between two drawn\n  bars is at least `minGap` logical indices long. Renderers pass\n  `getConflationFactor(data)` as `minGap`.\n- `barCoordinate(bar, anchor, barSpacing)` reconstructs a media `x` for a bar\n  whose own `x` is stale (it was off screen) from a visible anchor bar.\n- `getConflationFactor(data)` is `data.conflationFactor`, or 1 on hosts\n  before 5.1.\n- `effectiveBarSpacing(data)` is `barSpacing` times that factor: the width a\n  conflated column or candle covers. Use it only in a series with a\n  `conflationReducer`. The chart reports the factor to every custom series\n  but conflates only those with a reducer, so a series without one is still\n  drawn one point per bar and sizes against `barSpacing`.\n\nRead: `stacked-area-series/src/renderer.ts` for all of them together.\n\n### `custom-series/hit-test` — `distanceToRange`, `seriesHitTestTolerance`, `nearestBar`, `nearestVerticalRange`, `createHitTestDataCache`\n\nFor a renderer's `hitTest` (called from 5.2).\n\n- `seriesHitTestTolerance(options)` reads the series' `hitTestTolerance`\n  option, in CSS pixels, with the library's default of 3 for an invalid value.\n- `nearestVerticalRange(data, x, y, halfWidth, tolerance, span)` returns\n  `{ index, distance }` for the visible bar whose box — `halfWidth` either\n  side of its `x`, between the two ends `span(bar, index)` returns — is\n  nearest the pointer and within `tolerance`, or `null`. It finds the bars\n  near `x` by binary search. Return `null` from `span` for a bar with\n  nothing to hit.\n- `nearestBar(data, x, reach, tolerance, distance)` is the same search with\n  your own `distance(bar, index)`, for geometry that is not one box per bar:\n  a dot, a ring, a shape. Only the bars whose `x` is within `reach` of the\n  pointer are measured, so make `reach` the widest the geometry gets from a\n  bar's `x`, plus `tolerance`. Measure to the shape itself; picking the bar by\n  a box around it reports the wrong bar where neighboring shapes touch.\n- `distanceToRange(value, a, b)` is the distance to a range, `0` inside it.\n- `createHitTestDataCache()` returns `get(key, create)`, which hands back the\n  same object while the same key is asked for. Use it for an object\n  `hitTestData`, keyed by the `objectId`: the chart compares `hitTestData` by\n  reference and repaints on every pointer move when it changes.\n\nReturn the result typed as `CustomSeriesHitTestResult` from\n`custom-series/compat`, which also has `ConflationContext` for a\n`conflationReducer`'s arguments. Both are types only: the library exports its\nown from 5.2 and 5.1, and importing them would raise the plugin's floor.\n\nRead: `rounded-candles-series/src/renderer.ts` (boxes), `lollipop-series/src/renderer.ts`\n(a stem and a dot).\n\n### `custom-series/options-aware-series` — `createOptionsAwareSeries`, `createWhitespaceSeries`, `OptionsAwareSeries`\n\nFactories that wrap `chart.addCustomSeries` so a series can do two things a\nplain `ICustomSeriesPaneView` cannot:\n\n- **Read options in `priceValueBuilder`.** The chart calls the builder at\n  `setData`, before any `update(data, options)`, so a plain view has only its\n  defaults there. `createOptionsAwareSeries(chart, createView, defaults,\n  options, priceOptions, paneIndex?)` passes `createView` an options getter\n  bound to the real series, and re-ingests the retained data whenever one of\n  `priceOptions` changes through `applyOptions`. Use it whenever an option\n  changes what a value *means* — a base, percent mode, a scale mode. The\n  getter keeps one copy of the options until `applyOptions`, so a builder can\n  call it for every point; `series.options()` deep-copies on every call, so\n  never call that from a builder or a renderer.\n- **Know its own whitespace.** The wrapper retains a copy of the accepted\n  input (the host's `data()` exposes fulfilled points only) as an\n  `AcceptedInput`: a chronological array plus a `revision`, kept sorted\n  incrementally so a streaming `update` is a binary insert.\n  `createWhitespaceSeries(chart, createView, defaults, options,\n  priceOptions?, paneIndex?)` builds on it and hands `createView` a ready\n  `GapCheck` plus the options getter.\n\nThe returned API keeps its identity in chart events; `setData`, `update`,\n`pop` and `applyOptions` are wrapped, everything else is the host's.\n\nRead: `stacked-area-series/src/stacked-area-series.ts` (both concerns),\n`stacked-bars-series/src/stacked-bars-series.ts` (options only).\n\n### `custom-series/stacking` — `cumulativeSum`, `stackLevels`, `stackedPlotValues`\n\nRunning totals of a values array; the band boundaries of a stack drawn from\na `base` (negative values fold back towards it, so bands never overlap); and\n`[min, max, total]` for `priceValueBuilder`, where min and max are taken over\nthe running totals *and* the base so a stack with negatives stays in view.\n\nRead: `stacked-area-series/src/stacked-area-series.ts`, `stacked-bars-series/src/stack.ts`.\n\n### `custom-series/line-paths` — `buildLinePath`, `buildStepLinePath`, `areaBetween`, `strokeStyledPolyline`\n\n`Path2D` builders in bitmap space: a polyline over a bar range with an\naccessor for `y`, its stepped variant, the closed area between two such\nlines (for bands and stacks), and a polyline whose color changes along its\nlength without a visible seam (adjacent runs share their boundary bar). A run\nof `strokeStyledPolyline` may carry a `dashPattern` (`getDashPattern(style,\nlineWidth)`), stroked with `butt` caps; runs without one keep the context's\nown dash and cap.\n\nRead: `hlc-area-series/src/renderer.ts`, `brushable-area-series/src/renderer.ts`.\n\n## Primitives\n\n### `plugin-base` — `PluginBase`\n\nSeries-primitive base: holds `chart` and `series` from `attached`, exposes\n`requestUpdate()`, and throws if `chart` is read before attach. Subclasses\nthat override `attached`/`detached` call `super`.\n\nRead: `vertical-line/src/vertical-line.ts`, `image-watermark/src/image-watermark.ts`.\n\n### `pane-plugin-base` — `PanePluginBase<T>`\n\nThe same for a pane primitive: `chart` and `requestUpdate()`; there is no\nseries. Read: `accessibility/src/pane-primitive.ts`.\n\n### `axis-label-view` — `AxisLabelView`, `AxisLabelSource`, `OFFSCREEN_LABEL_COORDINATE`\n\nAn `ISeriesPrimitiveAxisView` over a source of callbacks (`coordinate`,\n`text`, `textColor`, `backColor`, `visible`, `tickVisible`). Returns the\noff-screen coordinate when the source has none, so the axis draws nothing\nrather than a stray label at 0.\n\nRead: `vertical-line/src/vertical-line.ts`.\n\n### `dom/pane-element` — `paneContentElement`, `chartTableElement`\n\nThe pane's canvas wrapper cell, to append a DOM overlay to, and the chart's\ntable element. Pane widgets reuse rows when panes move, so hold the pane API\nby identity and re-resolve the element on `updateAllViews`.\n\nRead: `accessibility/src/dom/pane-dom.ts`.\n\n### `dom/media-query` — `subscribeMediaQuery`, `mediaQueryMatches`, `HIGH_CONTRAST_QUERIES`, `REDUCED_MOTION_QUERY`\n\nShared, SSR-safe `matchMedia` subscriptions (no `window` at import time).\nRead: `accessibility/src/high-contrast.ts`.\n\n## Pixel-perfect dimensions\n\nAll return bitmap-space `{ position, length }` (`BitmapPositionLength`, from\n`dimensions/common`), computed the way the chart's own renderers do so a\nplugin lines up with built-in series at every device pixel ratio.\n\n| Module | Export | Use |\n| --- | --- | --- |\n| `dimensions/positions` | `positionsLine(centre, pixelRatio, width)`, `positionsBox(a, b, pixelRatio)` | a crisp line of a given CSS width; a box between two coordinates |\n| `dimensions/columns` | `calculateColumnPositions(items, barSpacing, pixelRatio)`, `…InPlace` | evenly spaced columns with the histogram's gap; items may carry `time` (logical index) so a gap is not bridged |\n| `dimensions/candles` | `candlestickWidth(barSpacing, pixelRatio)` | the body width the built-in candlestick uses |\n| `dimensions/full-width` | `fullBarWidth(x, halfSpacing, pixelRatio)`, `fullBarWidthAfter(previousRight, x, halfSpacing, pixelRatio)` | a bar filling its whole slot; neighboring columns that share an edge, with no seam |\n| `dimensions/crosshair-width` | `gridAndCrosshairMediaWidth`, `gridAndCrosshairBitmapWidth` | line widths matching the grid |\n\nRead: `rounded-candles-series/src/renderer.ts`, `pretty-histogram-series/src/renderer.ts`.\n\n## Canvas and style\n\n### `canvas/round-rect` — `drawRoundRect`, `drawRoundRectWithBorder`, `clampCornerRadius`, `CornerRadii`\n\nRounded rectangles in bitmap space, with per-corner radii, radius clamping\nto the rectangle's size, and an inset border that does not shrink the fill.\nRead: `pretty-histogram-series/src/renderer.ts`, `dual-range-histogram-series/src/renderer.ts`.\n\n### `canvas/markers` — `beginMarker`, `beginMarkerOffset`, `traceMarker`, `traceMarkerOffset`, `markerDistance`, `markerVertices`, `segmentDistance`, `MarkerShape`\n\nPoint markers (`circle`, `square`, `diamond`, `triangleUp`, `triangleDown`),\ntwo ways:\n\n- one marker per path (a different color or opacity per point):\n  `beginMarker(ctx, shape, x, y, radius)` calls `ctx.beginPath()` and traces\n  the marker as the path's only subpath, then fill or stroke. A circle is a\n  bare `arc`, which Chromium draws faster, as an exact oval.\n- many markers per path (one style, one `fill()`): `traceMarker(path, shape,\n  x, y, radius)` adds each to a context or `Path2D` as a subpath of its own,\n  so no line joins them. Begin the path yourself.\n\n`traceMarkerOffset(…, offset)` / `beginMarkerOffset(…, offset)` trace the\noutline `offset` outside the marker, with rounded corners, for a hover ring\nor halo of even width;\n`markerDistance(shape, dx, dy, radius, strokeWidth)` is the distance from a\npoint to the marker as drawn, stroke and rounded corners included, `0` inside,\nfor `hitTest`. All three read the same vertices, so a marker is hit where it is\ndrawn. `segmentDistance` is the building block for hovering a polyline.\nRead: `scatter-series/src/renderer.ts`, `scatter-series/src/hit-test.ts`.\n\n### `line-style` — `setLineStyle`, `getDashPattern`, `LineStyle`\n\nThe chart's own dash patterns for a renderer that receives no drawing utils\n(custom series renderers before 5.1, primitives on some hosts). The `LineStyle`\ntype takes the library's enum as well, so an option passes without a cast.\nStroke a dashed style with `ctx.lineCap = 'butt'`, as the chart does: a round\ncap closes the gaps of a dotted line (`strokeStyledPolyline` does it for a\nrun given a `dashPattern`).\nRead: `vertical-line/src/vertical-line.ts`.\n\n## Chart behavior\n\nLibrary rules a plugin otherwise copies from the library's source. Each\nmodule names the source it mirrors; the interaction flags are pinned to it by\na unit test.\n\n| Module | Export | Use |\n| --- | --- | --- |\n| `chart/compat` | `supportsSeriesOrder(series)` | calling `setSeriesOrder` (5.0.6) from a plugin whose floor is 5.0: the guard narrows the series, so the call compiles against the 5.0 typings and is skipped on a host without the method |\n| `chart/interaction-flags` | `canUserMoveTimeScale(chart.options())`, `TIME_SCALE_MOVE_FLAGS` | whether the user can scroll or zoom the time scale; with none of the flags on, the chart treats both edges as fixed |\n| `chart/lifecycle` | `isChartRemoved(chart)`, `isSeriesAttached(chart, series)` | for a plugin with its own API in front of a series: stop writing to a chart the host removed, or a series it took off with `chart.removeSeries`. Read-only; decide outside the chart's event dispatch what to release |\n| `chart/time-axis-labels` | `timeAxisLabelFont`, `tickMarkPixelsPerCharacter`, `tickMarkMaxLabelWidth`, `tickMarkCharactersForWidth` | the time axis' label font, and `timeScale.tickMarkMaxCharacterLength` to pixels and back |\n| `text/measure` | `textMeasureContext()`, `createTextWidthCache()` | measuring labels before painting (layout, overlap avoidance); `null` without a DOM |\n\nRead: `scatter-series/src/x-axis-controller.ts`, and `scatter-series-api.ts` for\nthe lifecycle checks; `background-shade-series/src/background-shade-series.ts`\nfor `supportsSeriesOrder`.\n\n## General\n\n| Module | Export | Use |\n| --- | --- | --- |\n| `assertions` | `ensureDefined`, `ensureNotNull` | narrow or throw, for state that must exist after attach |\n| `delegate` | `Delegate`, `ISubscription` | a small subscribe/fire event; expose the `ISubscription` half publicly |\n| `time` | `convertTime`, `convertTimeUTC`, `displayTime`, `formattedDateAndTime` | `Time` (string, business day, timestamp) to a number or display string |\n| `closest-index` | `ClosestTimeIndexFinder` | cached binary search for the index at or after a time |\n| `min-max-in-range` | `UpperLowerInRange` | cached extremes over a range, for autoscale providers |\n| `simple-clone` | `cloneReadonly` | deep clone that drops readonly-ness, through JSON (functions and `undefined` are lost) |\n| `options/merge` | `mergeOptions`, `cloneOptions`, `freezeOptions` | `applyOptions` with nested options: a partial nested option changes only its keys (a spread replaces the whole object); arrays and functions replace; unsafe keys are skipped; pass `defaults` to make `null` reset a value |\n| `numbers` | `isFiniteNumber`, `finiteOr`, `nonNegativeOr`, `clampOpacity` | numeric options from JavaScript: the canvas ignores a `NaN` width or opacity silently |\n| `scheduling/coalesced-task` | `createCoalescedTask(run, enqueue?)` | `{ schedule, cancel, pending }`: once per microtask (or frame) for a burst of events, never inside the chart's dispatch; `cancel()` on removal |\n\n<!-- File: .github/skills/lightweight-charts-plugin-authoring/SKILL.md (Tokens: ~5766 | Category: anthropic-skill) -->\n---\nname: lightweight-charts-plugin-authoring\ndescription: >-\n  Use when creating, extending, debugging or publishing a Lightweight Charts™\n  plugin — a custom series, a series primitive or a pane primitive — or when\n  turning a chart idea (\"I want the chart to show/draw X\") into a working\n  plugin. Covers choosing the plugin type, scaffolding with create-lwc-plugin,\n  building on @tradingview/lwc-toolkit instead of hand-rolled helpers, which of\n  the official plugin packages to read as the reference implementation,\n  where the docs are, and the autoscale, whitespace, visible-range, hit-test\n  and conflation mistakes every plugin author makes once. Reach for it whenever\n  the user mentions a custom series, primitive, renderer, drawing on the chart\n  canvas, lwc-plugin, plugin-examples, the toolkit, or the plugin catalog —\n  even if they never say the word \"plugin\".\n---\n\n# Writing a Lightweight Charts™ plugin\n\nThis skill is about *authoring* plugins. For questions about using the chart\nitself — series, scales, markers, data, wrappers — use the sibling\n`lightweight-charts` skill; the two are designed to be installed together.\n\n## Where you are, and where the sources are\n\nThis skill is used in two places, and the same question has a different\nanswer in each. Detect which before looking anything up:\n\n```sh\n# upstream checkout of lightweight-charts itself?\ntest -f pnpm-workspace.yaml && test -d packages/lwc-toolkit && echo upstream || echo \"a plugin project or other repo\"\n```\n\n**In a plugin project or any other repository** (the common case):\n\n| Looking for | Where |\n| --- | --- |\n| the library's API | `node_modules/lightweight-charts/dist/typings.d.ts`; if it is not installed, the released typings are hosted at `https://tradingview.github.io/lightweight-charts/lightweight-charts.d.ts` |\n| the toolkit's API | `node_modules/@tradingview/lwc-toolkit/dist/<module>.d.ts` — the `.d.ts` carry the doc comments, so they read as documentation |\n| a reference plugin's **source** | not in `node_modules` (packages ship `dist/` only). Fetch it from GitHub: `https://raw.githubusercontent.com/tradingview/lightweight-charts/master/packages/lwc-plugin-<name>/src/<file>`, or clone once and read locally: `git clone --depth 1 https://github.com/tradingview/lightweight-charts /tmp/lightweight-charts` |\n| the docs | every docs page is served as Markdown by appending `.md` to its URL, e.g. `https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series.md`. `https://tradingview.github.io/lightweight-charts/llms.txt` lists every page; `docs_map.md` beside it lists their headings too |\n\n**In the upstream checkout:** `dist/typings.d.ts` (or `src/`) for the library,\n`packages/lwc-toolkit/src/` for the toolkit, `packages/lwc-plugin-*/src/` for\nthe plugins, `website/docs/plugins/*.md` for the docs, `plugin-examples/` for\nthe proof-of-concept examples.\n\n```sh\n# what version is installed, and does the hook I am about to rely on exist in it?\nnode -p \"require('lightweight-charts/package.json').version\"\nrg -n \"hitTest|conflationReducer|isHovered|ICustomSeriesPaneView|IPrimitivePaneRenderer\" node_modules/lightweight-charts/dist/typings.d.ts\n# the toolkit's custom-series surface\nrg -n \"export (declare )?(function|class|interface|type)\" node_modules/@tradingview/lwc-toolkit/dist/custom-series/*.d.ts\n# a reference implementation, without a checkout\ncurl -fsSL https://raw.githubusercontent.com/tradingview/lightweight-charts/master/packages/lwc-plugin-stacked-bars-series/src/renderer.ts\n```\n\nLocal typings win over the docs when they disagree: the docs describe the\ncurrent release, the typings describe what the user actually has. If a file is\nmissing, say what could not be verified. Never invent an option, a hook or a\ntoolkit export — a plugin that compiles against an imagined API fails the\nuser's typecheck, and one that compiles against an option the chart ignores\nfails silently at runtime.\n\n## From idea to plugin type\n\nThe single most consequential decision, and the one to make first. Ask what\nthe idea *is* rather than how it looks:\n\n| The idea is… | Type | Because |\n| --- | --- | --- |\n| a new way to draw a series' own data (bars, bands, stacks, candles) | **custom series** | it needs its own data, autoscale, price line, last value and time-scale integration |\n| a decoration tied to one series (label, marker, band around it, drawing tool on its data) | **series primitive** | it reads that series' coordinates and is clipped to it |\n| a decoration tied to the pane (watermark, legend, title, an overlay for every series) | **pane primitive** | it spans the pane and outlives any one series |\n| a DOM-based accessibility, tooltip or control layer | **pane primitive** with a DOM overlay | the canvas is not the right medium; append to `paneContentElement(pane)` |\n\nDefault to a primitive. A custom series is the heavier construct — it must\nimplement `priceValueBuilder`, `isWhitespace`, `renderer` and `update`, and\nits renderer is called with the series' plot data. Only choose it when the\nidea *is* a series. A drawing tool that needs pointer handling is still a\nprimitive: it draws in a primitive and reacts through `subscribeClick`,\n`subscribeCrosshairMove` and the coordinate-conversion APIs.\n\nKeep hover and interaction in mind when choosing: primitives get a `hitTest`\nso the chart can report them in crosshair and click events; custom series get\na `hitTest` on their renderer only on Lightweight Charts™ 5.2 and later, which\nis what makes the `isHovered` and `hitTestData` arguments of `draw` report a\nhover.\n\n## Working method\n\nBuild in this order. Each step is the cheapest place to find the previous\nstep's mistakes.\n\n1. **Write down the data item and the options** before any code. The data\n   item decides `isWhitespace` (which fields make a point drawable) and the\n   options decide `defaultOptions`. Both go in their own files\n   (`data.ts`, `options.ts`) because the README, the types and the demo all\n   read them.\n2. **Scaffold** (below). Do not start from a blank file.\n3. **Get the renderer drawing with the sample data** the scaffold generates,\n   visible-range only, before touching options or interaction. A renderer that\n   draws everything, or draws nothing, is easier to fix while it is small.\n4. **Wire the options** through `applyOptions`; re-render with\n   `requestUpdate()`. Check every option does something in the demo page.\n5. **Custom series only: autoscale and whitespace.** `priceValueBuilder`\n   drives the price scale and the last-value label; whitespace decides where\n   the line breaks. Both have traps (checklist below).\n6. **Interaction**: `hitTest`, hover, drag. Keep it separate from drawing.\n7. **Tests**, then the README, then the demo and preview pages. The package\n   contract (`references/package-contract.md`) says what each must contain.\n   The preview must use `themeChart` from the preview kit's `preview-theme`\n   and be checked in both the light and the dark theme.\n\n## Scaffold, don't start blank\n\n```sh\nnpm create lwc-plugin@latest\n```\n\nThe wizard is interactive. It first offers to install this skill (say no if it\nis already installed, or the user quit the wizard to hand over to you), then\nasks for the type, a name, a one-sentence description, a package name, a class\nname, author, license, the minimum library version, tags, whether to keep hint\ncomments, and the target folder. Work those answers out with the user before\nanyone runs it — the type decision above is the one that matters — then have\nthe user run the wizard in their terminal, unless your environment gives you a\nTTY to answer the prompts yourself. It writes a Vite project with:\n\n- `src/<entry>.ts` — the plugin class (and, for a custom series, a factory);\n  `src/options.ts`, `src/data.ts`, and a renderer or view file per type\n- `src/example/index.html` + `example.ts` — the dev demo, `pnpm dev` serves it\n- `package.json` with `dev`, `build`, `typecheck` and `check-package` scripts,\n  a `lightweight-charts` peer range, `@tradingview/lwc-toolkit` as a\n  devDependency, and an `lwcPlugin` block for the catalog\n- a README already in the shape the catalog renders\n\nAnswer yes to \"hint comments\": they are `//*` lines that explain each part of\nthe template and are stripped by the wizard otherwise. Read them, then delete\nthe ones you have acted on. Build against the scaffold's own scripts\n(`pnpm typecheck`, `pnpm build`, `pnpm check-package`) — they are what CI and\nthe release tooling run.\n\n## Build on the toolkit\n\n`@tradingview/lwc-toolkit` is what the official plugins are built from,\nextracted from the helpers every example used to copy by hand. Reaching for\nit is not about saving lines; it is that the helpers encode chart behavior\nthat is easy to get subtly wrong — the exact width the built-in candlestick\nuses at a given bar spacing, pixel-perfect line positions at every device\npixel ratio, the dash patterns of `LineStyle`, how conflation changes a bar's\nlogical stride. Import each helper by sub-path:\n\n```ts\nimport { CustomSeriesRendererBase } from '@tradingview/lwc-toolkit/custom-series/renderer-base';\nimport { visibleSegments, extendRange, barCoordinate } from '@tradingview/lwc-toolkit/custom-series/visible-bars';\nimport { PluginBase } from '@tradingview/lwc-toolkit/plugin-base';\n```\n\nProblem → module, for the common cases. `references/toolkit.md` has the rest,\nwith the shape of each API and the official plugin that uses it.\n\n| You need to… | Use |\n| --- | --- |\n| write a custom series renderer without re-doing the data / range guards | `custom-series/renderer-base` — extend `CustomSeriesRendererBase`, implement `drawImpl(scope, args)` |\n| a series or pane primitive with the chart reference and `requestUpdate()` handled | `plugin-base` (`PluginBase`) / `pane-plugin-base` (`PanePluginBase`) |\n| draw only what is on screen, and reach the pane edge with a line | `custom-series/visible-bars` — `forEachVisibleBar`, `mapVisibleBars`, `extendRange`, `barCoordinate` |\n| size a conflated bar to the slots it covers (only with a `conflationReducer`) | `effectiveBarSpacing` (`custom-series/visible-bars`) |\n| implement `hitTest` or `conflationReducer` and still support 5.0 | `custom-series/compat` (types only) — `CustomSeriesHitTestResult`, `ConflationContext` |\n| call a series method newer than 5.0 (`setSeriesOrder`, 5.0.6) and still support 5.0 | `chart/compat` — `supportsSeriesOrder(series)` narrows the series, so the call stays typed |\n| report the bar under the pointer from `hitTest` | `custom-series/hit-test` — `seriesHitTestTolerance`, `nearestVerticalRange` (boxes), `nearestBar` (any shape), `createHitTestDataCache` |\n| break a line at explicit whitespace, not at other series' timestamps | `createWhitespaceSeries` (`custom-series/options-aware-series`) + `visibleSegments` |\n| read options inside `priceValueBuilder` (autoscale that follows options) | `createOptionsAwareSeries` with the option names that affect plot values |\n| stacked values: band edges and autoscale extremes | `custom-series/stacking` — `stackLevels`, `stackedPlotValues` |\n| columns, candles or lines the same width as the built-ins, pixel-aligned | `dimensions/*` — `calculateColumnPositions`, `candlestickWidth`, `positionsLine`, `positionsBox` |\n| rounded rectangles with an inset border | `canvas/round-rect` |\n| polylines, step lines, the area between two lines, a line whose color changes | `custom-series/line-paths` |\n| a label on the price or time axis | `axis-label-view` (`AxisLabelView`) |\n| a DOM overlay inside the pane | `dom/pane-element` (`paneContentElement`) |\n| a small event, or a `Time` as a timestamp or display string | `delegate`, `time` |\n\nWhen the scaffold's template already imports a toolkit helper, keep it; the\ntemplate is the smallest correct plugin of its type.\n\n## Read the reference implementations\n\nThe official packages are the canonical examples: maintained, tested,\npublished, and built exactly the way this skill describes. Read the one\nnearest your idea *before* designing — most questions (\"how do I get the\nhovered item?\", \"how do I autoscale a stack?\") are answered by a file in\none of them. Upstream they are `packages/lwc-plugin-*/src/`. From any other\nrepository the published `@tradingview/lwc-plugin-*` package gives you the\nREADME and the `dist/*.d.ts`, but not the source — fetch that from GitHub\n(raw URL or a shallow clone, see above); each plugin is a handful of files.\n\n| Building… | Read |\n| --- | --- |\n| any custom series | `stacked-bars-series` (the simplest complete one), then `pretty-histogram-series` |\n| a series with several values per point | `stacked-area-series`, `stacked-bars-series`, `grouped-bars-series` (side by side) |\n| a line/area that must break at gaps, or survive conflation | `hlc-area-series`, `brushable-area-series` |\n| a series with its own pointer interaction | `brushable-area-series` (`BrushableAreaInteraction`) |\n| a replacement for a built-in series | `rounded-candles-series` (matches candlestick options and widths) |\n| a chart whose X axis is a number, not time (scatter, bubble) | `scatter-series` (`ScatterHorzScaleBehavior`, `createScatterChart`) |\n| point markers on a series, hovered by their drawn shape | `lollipop-series` (`canvas/markers` dots, `nearestVerticalRange` and `markerDistance` in `hitTest`), `scatter-series` |\n| a shape built from several values per point, on the candle grid | `box-whisker-series` (named fields, per-point colors, part names in `objectId`) |\n| many colored cells per point, an order book or volume profile | `heatmap-series` (fills batched by color, `createColorScale`, a cell-level `hitTest`) |\n| a fixed-pixel-height overlay series | `dual-range-histogram-series` (`scaleMode`, `keepPixelSeriesInView`) |\n| a series primitive with an axis label and dragging | `vertical-line` |\n| a tool the user clicks to add something to a series | `user-price-lines` (pointer events in its own pane, one active instance per pane, a chart option set and put back) |\n| an image or decoration behind a series or pane | `image-watermark` (both a series and a pane primitive) |\n| a background colored from data, outside the price scale | `background-shade-series` (`[NaN]` plot values, `setSeriesOrder(0)`) |\n| a text label anchored to a pane edge or corner | `anchored-text` (the smallest series + pane pair over one core) |\n| a background derived from each bar of a series | `session-highlighting` (per-bar state from `dataUpdated`, visible-range slice) |\n| a DOM layer on a pane, multi-pane lifecycle | `accessibility` |\n\n`references/official-plugins.md` says what each one demonstrates in detail.\n`plugin-examples/src/plugins/` in the repository\n(`https://github.com/tradingview/lightweight-charts/tree/master/plugin-examples`)\nholds a further set of proof-of-concept plugins — tooltips, drawing tools,\na volume profile, … — good for breadth and ideas, but they are\nunpublished starting points, not the standard to match. The graduated\nplugins' folders there are redirects to the packages.\n\n## Read the documentation in this order\n\nFetch pages as Markdown — append `.md` to the URL — rather than scraping the\nHTML: `https://tradingview.github.io/lightweight-charts/docs/plugins/<page>.md`.\n`https://tradingview.github.io/lightweight-charts/llms.txt` is the index of\nevery page, `docs_map.md` the same with headings, and\n`lightweight-charts.d.ts` beside them the released typings.\n\n1. `intro` — the three plugin types and how they attach.\n2. `series-primitives` or `pane-primitives` — the view/renderer/lifecycle\n   contract for your type: `attached` / `detached`, `updateAllViews`,\n   `paneViews`, `priceAxisViews`, `timeAxisViews`, `hitTest`.\n3. `custom_series` — `ICustomSeriesPaneView`: `priceValueBuilder`,\n   `isWhitespace`, `renderer`, `update`, `defaultOptions`, the 5.1 conflation\n   hooks and the 5.2 `hitTest`.\n4. `canvas-rendering-target` — the `CanvasRenderingTarget2D` you draw on and\n   its two coordinate spaces.\n5. `pixel-perfect-rendering` — why widths and positions go through the\n   `dimensions/*` helpers.\n\nFor anything the pages do not cover, read the typings rather than the\ngenerated API reference — they are complete, and the `.d.ts` is what your code\ncompiles against. The docs describe the current release; when your peer range\nstarts earlier, the typings of the installed version are what you actually\nhave.\n\n## Correctness checklist\n\nEach of these has bitten a shipped plugin. The reasons are here so they can\nbe recognized in a new shape, not just avoided in the old one.\n\n### Drawing\n\n- Draw in `useBitmapCoordinateSpace` for anything that must be crisp (lines,\n  bars, borders) and scale widths by `horizontalPixelRatio` /\n  `verticalPixelRatio`; use `useMediaCoordinateSpace` for text and layout in\n  CSS pixels. Mixing them blurs on HiDPI. The `dimensions/*` helpers return\n  bitmap positions for exactly this reason.\n- `CanvasRenderingTarget2D` comes from `fancy-canvas`, not from the library;\n  the toolkit re-exports the type from `custom-series/renderer-base` so a\n  custom series need not depend on it.\n- Restore anything you set on the context (`save`/`restore`, or reset\n  `globalAlpha`, `lineCap`, dash). The next renderer draws on the same\n  context.\n- A `priceToCoordinate` that returns `null` means the price is off the\n  scale. Skip that point or break the line there; drawing to `NaN` loses the\n  whole path.\n\n### Visible range and coordinates\n\n- Draw `data.visibleRange` only; a series can have a million points. For\n  lines and areas widen the range by one bar with `extendRange` so the first\n  and last segments leave the pane instead of stopping at the edge.\n- Bars outside the visible range may carry stale or missing `x`. Rebuild a\n  coordinate from a visible anchor with `barCoordinate(bar, anchor,\n  barSpacing)` — `bar.time` is the *logical index*, and spacing is per index.\n- `bar.time` (logical index) and the array index `i` differ as soon as another\n  series starts earlier or the data has gaps. Per-index option lookups and\n  brush ranges use the logical index.\n\n### Custom series specifics\n\n- `priceValueBuilder` returns the plot values the chart autoscales on and\n  takes the *last* as the current value (price line, last-value label). For\n  a stack report `[min, max, total]` (`stackedPlotValues`); for a band the\n  extremes; for a single value `[value]`.\n- It runs at `setData`, before any render, so a plain view has no options\n  yet — the chart has not called `update` — and `percent`, `base` or\n  `scaleMode` are ignored on the first ingest. `createOptionsAwareSeries`\n  gives the builder a live options getter and re-ingests when a named option\n  changes; this is why the official series ship a `createXSeries` factory as\n  the supported entry point and keep the class exported for composition.\n- The host hands a custom renderer **no whitespace**: bars simply skip the\n  gap, and a jump in logical index may just be another series' timestamps.\n  Break lines only at the series' own whitespace, from its accepted input:\n  `createWhitespaceSeries` provides a `GapCheck`; pass\n  `getConflationFactor(data)` as its `minGap` so a whitespace run narrower\n  than one conflation bucket is absorbed rather than splitting every bucket\n  into a single-point segment.\n- `conflationReducer` and `conflationFactor` exist from 5.1, and the\n  renderer's `hitTest` from 5.2: series hit testing, which reports a custom\n  series hovered through `isHovered` / `hitTestData` (`draw` arguments since\n  5.0), arrived with it. Implement them as optional extras, keep the peer\n  range at `^5.0.0` unless you need them, and say so in the README.\n- `hitTest` must return the same `hitTestData` object while the same item\n  stays hovered: the chart compares it by reference and repaints the pane on\n  every pointer move when it is a new object.\n- `conflationReducer(a, b)` must return a data item of your own type that\n  makes sense as the merge of two: sum for stacks, high/low/last for OHLC,\n  the later value for a rate.\n\n### Primitives specifics\n\n- `requestUpdate()` after any change the chart cannot see (an option, a new\n  time, a decoded image). The chart does not poll your state.\n- `detached()` must undo everything `attached()` did: listeners, DOM nodes,\n  timers, pending image loads. Attach/detach cycles are common (React\n  effects, pane reordering) and leaks show up as ghost drawings and thrown\n  \"disposed\" errors.\n- A pane primitive is drawn only on the pane it is attached to; a pane index\n  given to a constructor is a hint that can be wrong. Resolve the real pane\n  lazily (the first draw's `context.canvas` is inside it) and hold it by\n  identity — indices shift when panes are added, removed or moved.\n- For DOM overlays, append to `paneContentElement(pane)` and keep the\n  overlay's layout independent of the chart's own table cells.\n\n## Testing\n\nThree layers, each catching something the others cannot. The official\npackages have all three under `tests/`; the scaffold sets up the first.\n\n- **Unit** (`tests/unit/*.spec.ts`, `node:test` + `chai`): pure functions —\n  stacking maths, option merging, data padding, gap detection. Fast, run by\n  the repository's `pnpm test`.\n- **Graphics** (`tests/graphics/*.js`): a page that draws one state; CI\n  compares the screenshot against the previous build's. One case per option\n  worth seeing, plus the edge cases: empty visible range, scrolled off, a\n  whitespace run, conflation, inverted scale.\n- **Interactions** (`tests/interactions/*.js`): a page with an async\n  `beforeInteractions(container)` that drives the chart and throws on a\n  wrong outcome — pixel sampling for \"did it paint\", DOM checks, hit tests.\n  This is where whitespace, update, `pop` and pointer behavior are tested.\n\nRun upstream with `pnpm test`, `pnpm e2e:graphics:plugins` and\n`GREP=\"lwc-plugin-<name>/\" pnpm e2e:interactions`, after `pnpm build:prod`\nand `pnpm --filter \"@tradingview/lwc-plugin-*\" build`.\n\n## Publishing and the catalog\n\nA plugin is publishable when `pnpm plugins:validate` passes upstream, or the\nequivalent by hand: an `lwc-plugin-*` name, `publishConfig.access: public`, a\n`lightweight-charts` peer range, the `lightweight-charts-plugin` keyword, a\ncomplete `lwcPlugin` block, a README with `## Installation` (`### npm` and\n`### CDN` tabs) and `## Usage`, and the demo page it declares. The scaffold\nmeets all of it. The docs site's plugin catalog renders the README and\nframes a preview page built from the package; `references/package-contract.md`\nhas the fields, the pages and the first-release changelog convention (short:\nan `Added` list, no `Fixed` — there is nothing to have fixed yet).\n\nWrite documentation and user-facing text (README, CHANGELOG, the package\n`description`, JSDoc on public API) in American English: color, center,\ncatalog, normalize, not colour, centre, catalogue, normalise. Write comments\nin new code the same way, but don't bulk-fix older plugins.\n\n## Answer contract\n\nWhen helping with a plugin:\n\n1. Name the plugin type and say why in one sentence, or explain what the\n   user's idea would lose in the other type.\n2. Point at the toolkit module and the official plugin you are basing the\n   answer on. Read the plugin's file before quoting its pattern.\n3. Verify every library and toolkit name against the local typings; say what\n   you could not verify.\n4. Produce code that the scaffold's own scripts accept: `pnpm typecheck`,\n   `pnpm build`, and `pnpm dev` showing it in the demo page.\n5. When the change touches autoscale, whitespace, the visible range or\n   hover, name the test that would have caught the regression and write it.\n\n<!-- File: .github/skills/lightweight-charts/SKILL.md (Tokens: ~6968 | Category: anthropic-skill) -->\n---\nname: lightweight-charts\ndescription: >-\n  Use when working with TradingView's lightweight-charts — creating charts,\n  adding series (Line/Area/Bar/Candlestick/Histogram), configuring time and\n  price scales, streaming realtime or historical data, panes, markers,\n  per-bar/per-point colors, tooltips, coordinate conversion, custom plugins or\n  primitives, non-financial horizontal scales, SSR/browser loading, or\n  React/Vue/Web Components wrappers. Covers v5 API conventions and the common\n  time, scale, marker, plugin, and wrapper foot-guns.\n---\n\n# Lightweight Charts skill\n\nWorks the same whether the project is a downstream npm consumer app or an upstream `lightweight-charts` source checkout. Detect which one you are in (below) and resolve every API name from whatever typings are locally available.\n\n## Source lookup order\n\nDo not assume you are inside the upstream source repository.\n\n1. In a consumer app, inspect the installed package first:\n   - `node_modules/lightweight-charts/package.json` for the actual version.\n   - `node_modules/lightweight-charts/dist/typings.d.ts` for the API surface.\n2. In the upstream repo, inspect `dist/typings.d.ts` first, then `src/` if generated output is unavailable.\n3. Use official docs/examples as supporting evidence, but local typings win when they disagree.\n\nVerify before answering (copy-paste):\n\n```sh\nnode -p \"require('./node_modules/lightweight-charts/package.json').version\"\nrg -n \"createSeriesMarkers|addSeries|IPrimitivePaneRenderer|createImageWatermark|createOptionsChart\" node_modules/lightweight-charts/dist/typings.d.ts\n# upstream checkout instead of a consumer app:\nrg -n \"createSeriesMarkers|IPrimitivePaneRenderer|createImageWatermark|createOptionsChart\" dist/typings.d.ts src\n```\n\nIf the relevant file is unavailable, say what could not be verified. Do not invent option names, methods, exports, or wrapper behavior.\n\nIf the user's code imports `from lightweight_charts import ...` (underscore), uses pandas/asyncio, or talks about a Python window wrapper, they are probably using the third-party Python wrapper rather than the TypeScript package. Say that clearly before giving core `lightweight-charts` v5 JavaScript advice.\n\n## Mental model\n\nEight layers, in dependency order. Most bugs come from confusing one for another:\n\n1. **Chart** — `createChart(container, options)` returns an `IChartApi`. One chart per container element.\n2. **Series** — added via `chart.addSeries(SeriesType, options, paneIndex?)`. Each call returns an `ISeriesApi`. v5 requires importing the series type explicitly.\n3. **Scales** — `chart.timeScale()` (`ITimeScaleApi`), `chart.priceScale(id)` (`IPriceScaleApi`). Govern range, ticks, autoscale, visibility.\n4. **Data model** — arrays of `{ time, … }` points. `Time = UTCTimestamp | BusinessDay | string`. `UTCTimestamp` is **seconds**, not milliseconds. Times must be unique and ascending per series.\n5. **Interaction** — `chart.subscribeCrosshairMove`, `chart.subscribeClick`, `timeScale.subscribeVisibleLogicalRangeChange`, etc.\n6. **Layout** — `chart.panes()`, `chart.addPane()`. Adding a series with an out-of-range `paneIndex` auto-creates the pane.\n7. **Extension** — pane primitives, series primitives, custom series, watermarks, custom renderers (canvas via `fancy-canvas`).\n8. **Wrappers** — React/Vue/Web Components/iOS/Android. Lifecycle is the wrapper's responsibility; the core library is framework-agnostic.\n\n## v5 essentials\n\nThe conventions that catch people copying older snippets:\n\n```ts\nimport { createChart, CandlestickSeries, LineSeries } from 'lightweight-charts';\n\nconst chart = createChart(container, { /* ChartOptions */ });\nconst candles = chart.addSeries(CandlestickSeries, { /* options */ });\ncandles.setData([\n    { time: 1700000000, open: 1, high: 2, low: 0.5, close: 1.5 },\n]);\n```\n\nKey v5 changes versus older snippets:\n\n- `chart.addSeries(SeriesType, options, paneIndex?)` replaces `addLineSeries` / `addCandlestickSeries` / …\n- `createSeriesMarkers(series, markers)` replaces `series.setMarkers(...)`. The returned primitive owns `.setMarkers(...)` / `.markers()`.\n- `createTextWatermark(pane, options)` and `createImageWatermark(pane, imageUrl, options)` replace the `watermark` chart option.\n- Series types are tree-shaken — importing them is required for ESM.\n\nIf a snippet calls `addLineSeries` or `series.setMarkers`, it's v4 or older. Confirm the user's version before forwarding it.\n\nWhen the task targets v5, show the v5 API directly — do not hedge by mixing in v4 syntax.\n\n## Triage (problem → API → avoid)\n\n| User asks about | First check | Answer with | Avoid |\n|---|---|---|---|\n| v5 series creation | package version + typings | `chart.addSeries(SeriesType, options)` | `addLineSeries` / `addCandlestickSeries` |\n| markers | `createSeriesMarkers` export | marker primitive + required `color` | `series.setMarkers` |\n| timezone | formatter need vs data semantics | `Intl.DateTimeFormat` in formatters | fake `timeScale.timezone` |\n| realtime updates | last-bar vs full replace | `series.update(point)` | `setData` on every tick |\n| panes | `paneIndex` + `chart.panes()` | v5 pane APIs, `pane.setHeight` | private widget / DOM hacks |\n| per-bar colors | data-point color fields | `color`/`borderColor`/`wickColor` on points | extra series / markers to recolor |\n| plugins | primitive vs custom series | scaffold/examples + public coordinate APIs | invented renderer names |\n\n### v4 → v5 replacement matrix\n\nStale copy-pasted snippets are the most common failure. Map them directly:\n\n| Old or wrong | v5 replacement |\n|---|---|\n| `chart.addLineSeries(options)` | `chart.addSeries(LineSeries, options)` |\n| `chart.addCandlestickSeries(options)` | `chart.addSeries(CandlestickSeries, options)` |\n| `series.setMarkers(markers)` | `createSeriesMarkers(series, markers)` |\n| chart `watermark` option | `createTextWatermark(chart.panes()[0], options)` |\n| `createImageWatermark(pane, options)` | `createImageWatermark(pane, imageUrl, options)` |\n| `IPanePrimitivePaneRenderer` | `IPrimitivePaneRenderer` |\n| `timeScale: { timezone }` | label formatters using `Intl.DateTimeFormat` |\n| `time: Date.now()` (ms) | `time: Math.floor(Date.now() / 1000)` for `UTCTimestamp` |\n\n## Routing map (problem → where to look)\n\nUse local typings first. The repo paths below exist only in the upstream `lightweight-charts` checkout; in a consumer app, translate them to the installed package typings or official docs.\n\n| Task | Canonical sources |\n|---|---|\n| First chart / series | `website/docs/intro.mdx`, `website/tutorials/customization/` |\n| Time / range behavior | `website/docs/time-scale.md`, `website/docs/time-zones.md` |\n| Realtime / history | `website/examples/data/realtime-updates.{mdx,js}`, `website/examples/data/infinite-history.{mdx,js}` |\n| Whitespace / gaps | `website/examples/data/whitespace.{mdx,js}` |\n| Price format / locale | `website/tutorials/customization/price-format.mdx`, `website/examples/styling/custom-locale.{mdx,js}` |\n| Two scales / inverted | `website/examples/price-scales/two-price-scales.{mdx,js}`, `website/examples/price-scales/inverted-price-scale.{mdx,js}` |\n| Panes / price + volume | `website/docs/panes.md`, `website/examples/panes/multiple-panes.{mdx,js}`, `website/examples/price-scales/price-and-volume.{mdx,js}` |\n| Markers / tooltips / legends | `website/examples/markers-and-lines/series-markers.{mdx,js}`, `website/examples/tooltips-and-legends/*-tooltip.{mdx,js}`, `website/examples/tooltips-and-legends/*legend.{mdx,js}` |\n| Crosshair (programmatic) | `website/examples/crosshair/*.{mdx,js}` |\n| Watermarks | `website/examples/styling/*-watermark.{mdx,js}` |\n| Plugins / custom series / primitives | `website/docs/plugins/`, `plugin-examples/src/plugins/` |\n| Coordinate conversion / hit-testing | `dist/typings.d.ts` for `subscribeClick`, `coordinateToPrice`, `timeScale().coordinateToLogical` |\n| Non-time horizontal scales / options chart | `dist/typings.d.ts` for `createOptionsChart`, `createChartEx`, `IHorzScaleBehavior` |\n| Pixel-perfect rendering | `website/docs/plugins/pixel-perfect-rendering/` |\n| React / Vue / Web Components | `website/tutorials/react/`, `website/tutorials/vuejs/`, `website/tutorials/webcomponents/` |\n| SSR / script loading / bundlers | installed package `dist/` files, package `exports`, framework docs for client-only components |\n| iOS / Android wrappers | `website/docs/ios.md`, `website/docs/android.md` |\n| Version migration | `website/docs/migrations/from-v2-to-v3.md`, `from-v3-to-v4.md`, `from-v4-to-v5.md` |\n\nIf these repo paths do not exist in the user's project, do not ask them to create or clone the source tree just to answer a normal usage question. Use `node_modules/lightweight-charts/dist/typings.d.ts` and concise v5 examples.\n\n## Foot-guns (assertions, not categories)\n\n### Time\n\n- **`UTCTimestamp` is in seconds.** Use `Math.floor(Date.now() / 1000)`, never `Date.now()`.\n- **There is no built-in `timeScale.timezone` option.** For display-only timezone conversion, use `timeScale.tickMarkFormatter` for axis labels and `localization.timeFormatter` (or your own tooltip formatter) for crosshair/hover labels. Use `Intl.DateTimeFormat(..., { timeZone })`, Luxon, or date-fns-tz for DST-safe IANA timezone formatting.\n- **Pre-shifting timestamps changes chart semantics.** It can make ticks line up in a chosen timezone, but it also changes where bars sit on the UTC time scale. Prefer formatter-based display unless the user intentionally wants shifted data.\n- **Series data must be strictly ascending by `time`, with unique values.** Duplicates replace silently; out-of-order points are dropped or throw.\n- **One time format per series.** `BusinessDay` (`'YYYY-MM-DD'` string or `{ year, month, day }`) or `UTCTimestamp`, but do not mix within a single series.\n- **Business day strings must be zero-padded `'YYYY-MM-DD'`.** `'2024-1-5'`, `'2024/01/05'` or `'Jan 5 2024'` throw. Pad the string or pass `{ year, month, day }`.\n- **Whitespace points carry `time` only** (no `value` / `open` / …). Use them to create gaps or align overlays; do not set values to `null`.\n- **`setData` replaces the dataset and can reset the visible range. `update(point)` appends if `time > last` and replaces if `time === last`.** `update(point, true)` can update an existing historical point, but it is slower and does not insert missing old points. To prepend older history, build a new array and call `setData` again — there is no prepend method; save and restore the visible logical range to avoid the chart snapping.\n- **`timeScale.setVisibleLogicalRange` is logical (bar indices), not time-based.** Use `setVisibleRange` for time bounds, or `fitContent()` to reset.\n\n### Scales and panes\n\n- **Two visible price scales** requires both assigning series with `priceScaleId: 'right'` / `'left'` and making the left scale visible. Use `chart.applyOptions({ leftPriceScale: { visible: true }, rightPriceScale: { visible: true } })` or `chart.priceScale('left').applyOptions({ visible: true })`.\n- **Overlay series** (`priceScaleId: ''` or any custom id) get an autoscaled, hidden scale by default. Make it visible explicitly if you want axis labels.\n- **`autoscaleInfoProvider` runs on every layout pass.** Keep it cheap; do not allocate per call.\n- **`addSeries(_, _, paneIndex)` creates the pane** if `paneIndex` is one past the current count. Pane order is creation order; sizes are controlled via `chart.panes()[i].setHeight(px)`.\n- **Keep pane references if panes can move.** `const mainPane = chart.panes()[0]` remains the same `IPaneApi`; `mainPane.paneIndex()` gives its current index after `swapPanes` or moves.\n- **Sync separate charts with public time-scale events.** Use `subscribeVisibleLogicalRangeChange` and `setVisibleLogicalRange`; avoid `_private__chartWidget`, `paneWidgets`, or DOM offset hacks.\n- **Price-scale width is readable, not directly settable.** Use `series.priceScale().width()` or `chart.priceScale(id).width()` to measure when aligning adjacent containers.\n\n### Markers and interaction\n\n- **v5 markers are a primitive.** `const m = createSeriesMarkers(series, [...]); m.setMarkers([...])`. `series.setMarkers` does not exist on `ISeriesApi` in v5.\n- **Marker `time` must match an existing data point's `time`** for that series. Misaligned markers are dropped silently.\n- **`subscribeCrosshairMove`** fires with `param.time === undefined` outside the data range. Always null-check before reading.\n- **`param.seriesData.get(series)`** returns `undefined` between bars or before the first bar.\n- **Click/crosshair coordinates need API conversion.** Use `series.coordinateToPrice(y)` / `series.priceToCoordinate(price)` and `chart.timeScale().coordinateToLogical(x)` / `logicalToCoordinate(logical)` / `timeToCoordinate(time)`; do not infer price/time from canvas DOM geometry.\n\n### Plugins and custom rendering\n\n- **Start plugins from the scaffold/examples.** Prefer `npm create lwc-plugin@latest` and `plugin-examples/` before writing a primitive from scratch.\n- **Interactive drawing tools need two parts:** a primitive/custom series for rendering, and chart interaction handlers (`subscribeClick`, `subscribeCrosshairMove`, drag state) that convert coordinates with public APIs.\n- **`CanvasRenderingTarget2D` is imported from `fancy-canvas`,** not from `lightweight-charts`.\n- Use `target.useBitmapCoordinateSpace(scope => …)` for pixel-aligned strokes; use `target.useMediaCoordinateSpace(scope => …)` for CSS-pixel logic. Mixing them causes blur or sub-pixel jitter on HiDPI displays.\n- **`IPanePrimitive` views render across the whole pane; `ISeriesPrimitive` views are clipped to the series.** Pick the right base.\n- **The renderer interface is `IPrimitivePaneRenderer`, not `IPanePrimitivePaneRenderer`.** The view is `IPanePrimitivePaneView` and its `renderer()` returns `IPrimitivePaneRenderer | null` — the names are deliberately asymmetric. There is no `IPanePrimitivePaneRenderer` export; grep `dist/typings.d.ts` if unsure.\n- **`ICustomSeriesPaneView` is heavier than a primitive** — only use it when you need a true series API (data, scales, autoscale). For decorations, use a primitive.\n\n### Wrappers (React/Vue/etc.)\n\n- **Create the chart once** in `useEffect` / `onMounted` and destroy it in cleanup with `chart.remove()`. Recreating on every render duplicates DOM and leaks listeners.\n- **Resize can be automatic in v5** with `autoSize: true` when `ResizeObserver` is available. If you need manual control, subscribe a `ResizeObserver` to the container and call `chart.resize(width, height)` (or `applyOptions({ width, height })`).\n- **Don't drive `setData` from props on every render.** Use `series.update(...)` for incremental changes; only call `setData` when the dataset truly replaces.\n- **`undefined` in `applyOptions` means \"not specified\", not \"reset\".** `{ priceFormatter: custom ? fmt : undefined }` leaves the current formatter in place. To clear a `localization` formatter or `autoscaleInfoProvider`, pass `null`. Other options have no reset value: pass the default explicitly.\n- **Next.js/SSR must be client-only.** Put chart code in a `'use client'` component, create it in `useEffect`, and import that component with `next/dynamic(..., { ssr: false })` from server-rendered pages when needed.\n- **Plain HTML is not npm resolution.** The standalone `.js` build exposes `window.LightweightCharts`; ESM in the browser must import an actual `.mjs` URL or use an import map. `import { createChart } from 'lightweight-charts'` only works when a bundler/runtime resolves the package name.\n\n## Canonical recipes\n\n### Realtime updates\n\n```ts\nimport { createChart, CandlestickSeries } from 'lightweight-charts';\n\nconst chart = createChart(container, {});\nconst series = chart.addSeries(CandlestickSeries, {});\nseries.setData(initialBars); // full history once\n\nws.onmessage = ev => {\n    const bar = JSON.parse(ev.data); // { time, open, high, low, close }\n    series.update(bar); // appends if time > last; replaces if time === last\n};\n```\n\n`update()` only handles the latest bar. To insert in the middle or prepend, rebuild the array and call `setData`.\n\n### Two price scales (left + right)\n\n```ts\nconst right = chart.addSeries(LineSeries, { priceScaleId: 'right' });\nconst left  = chart.addSeries(LineSeries, { priceScaleId: 'left' });\nchart.applyOptions({\n    leftPriceScale: { visible: true },\n    rightPriceScale: { visible: true },\n});\n```\n\n### Volume in its own pane\n\n```ts\nconst price  = chart.addSeries(CandlestickSeries, {}, 0);\nconst volume = chart.addSeries(\n    HistogramSeries,\n    { priceFormat: { type: 'volume' } },\n    1,\n);\nchart.panes()[1].setHeight(120);\n```\n\n### Per-bar / per-point colors\n\nColor individual bars by putting the color on the **data point**, not via a separate API:\n\n```ts\n// Candlesticks: per-point color / borderColor / wickColor override series defaults\ncandles.setData([\n    { time: 1700000000, open: 1, high: 2, low: 0.5, close: 1.5,\n      color: '#26a69a', borderColor: '#26a69a', wickColor: '#26a69a' },\n    { time: 1700003600, open: 1.5, high: 1.8, low: 1.1, close: 1.2,\n      color: '#ef5350', borderColor: '#ef5350', wickColor: '#ef5350' },\n]);\n\n// Histogram (e.g. up/down volume): per-point color\nvolume.setData([\n    { time: 1700000000, value: 100, color: 'rgba(38,166,154,0.5)' },\n    { time: 1700003600, value: 80, color: 'rgba(239,83,80,0.5)' },\n]);\n```\n\nLine/Area points also take a per-point `color`. An omitted point color falls back to the series option. Do not create extra series or use markers to recolor bars.\n\n### Series markers\n\n```ts\nimport { createSeriesMarkers } from 'lightweight-charts';\n\nconst markers = createSeriesMarkers(candles, [\n    { time: 1700000000, position: 'aboveBar', color: '#e53935', shape: 'arrowDown', text: 'Sell' },\n]);\n\nmarkers.setMarkers([\n    { time: 1700003600, position: 'belowBar', color: '#43a047', shape: 'arrowUp', text: 'Buy' },\n]);\n```\n\n`color` is required on every marker (`position`, `shape`, `time` too); `text`, `size`, `id`, `price` are optional. Do not put marker objects into `setData()` points. Do not call `series.setMarkers(...)` in v5.\n\n### Timezone display\n\n```ts\nconst zone = 'America/New_York';\nconst formatTime = (timestamp: number) =>\n    new Intl.DateTimeFormat('en-US', {\n        timeZone: zone,\n        hour: '2-digit',\n        minute: '2-digit',\n        second: '2-digit',\n        hour12: false,\n    }).format(new Date(timestamp * 1000));\n\nchart.applyOptions({\n    timeScale: {\n        timeVisible: true,\n        secondsVisible: true,\n        tickMarkFormatter: (time) =>\n            typeof time === 'number' ? formatTime(time) : String(time),\n    },\n    localization: {\n        timeFormatter: (time) =>\n            typeof time === 'number' ? formatTime(time) : String(time),\n    },\n});\n```\n\nDo not invent `timeScale: { timezone: 'America/New_York' }`. If the user needs exchange-session boundaries to generate in a local timezone, explain the trade-off of shifting source timestamps separately from display formatting.\n\n### Text watermark\n\n```ts\nimport { createTextWatermark } from 'lightweight-charts';\n\ncreateTextWatermark(chart.panes()[0], {\n    horzAlign: 'center',\n    vertAlign: 'center',\n    lines: [{ text: 'DEMO', color: 'rgba(0, 0, 0, 0.25)', fontSize: 48 }],\n});\n```\n\nThe old `watermark` chart option is not the v5 API.\n\n### Whitespace gaps\n\n```ts\nline.setData([\n    { time: '2024-01-01', value: 10 },\n    { time: '2024-01-02' }, // whitespace point: time only\n    { time: '2024-01-03', value: 12 },\n]);\n```\n\nDo not use `value: null`, `undefined`, or `NaN` to create gaps.\n\n### Sync separate charts or panes\n\n```ts\nlet syncing = false;\n\npriceChart.timeScale().subscribeVisibleLogicalRangeChange((range) => {\n    if (!range || syncing) return;\n    syncing = true;\n    indicatorChart.timeScale().setVisibleLogicalRange(range);\n    syncing = false;\n});\n\nindicatorChart.timeScale().subscribeVisibleLogicalRangeChange((range) => {\n    if (!range || syncing) return;\n    syncing = true;\n    priceChart.timeScale().setVisibleLogicalRange(range);\n    syncing = false;\n});\n```\n\nFor v5 panes inside one chart, prefer `chart.addSeries(SeriesType, options, paneIndex)` and `chart.panes()[i].setHeight(px)`. If the original pane can move, keep the `IPaneApi` reference and call `pane.paneIndex()` instead of assuming index `0` forever.\n\n### Coordinate conversion\n\n```ts\nchart.subscribeClick((param) => {\n    if (!param.point || param.time === undefined) return;\n\n    const price = series.coordinateToPrice(param.point.y);\n    const logical = chart.timeScale().coordinateToLogical(param.point.x);\n    if (price === null || logical === null) return;\n\n    // Store { time: param.time, price } or convert logical back later:\n    const x = chart.timeScale().logicalToCoordinate(logical);\n    const y = series.priceToCoordinate(price);\n});\n```\n\nUse the public conversion APIs for drawing tools and annotations. DOM canvas coordinates alone cannot tell you the chart price/time.\n\n### Next.js client-only component\n\n```tsx\n'use client';\n\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport type { ISeriesApi, LineData, Time } from 'lightweight-charts';\nimport { useEffect, useRef } from 'react';\n\nexport function LwcChart({ data }: { data: LineData<Time>[] }) {\n    const ref = useRef<HTMLDivElement | null>(null);\n    const seriesRef = useRef<ISeriesApi<'Line'> | null>(null);\n\n    useEffect(() => {\n        if (!ref.current) return;\n        const chart = createChart(ref.current, { autoSize: true });\n        const series = chart.addSeries(LineSeries);\n        seriesRef.current = series;\n        return () => {\n            seriesRef.current = null;\n            chart.remove();\n        };\n    }, []);\n\n    useEffect(() => {\n        seriesRef.current?.setData(data);\n    }, [data]);\n\n    return <div ref={ref} style={{ width: '100%', height: 320 }} />;\n}\n```\n\nFrom a server-rendered Next.js page, import the component with:\n\n```tsx\nimport dynamic from 'next/dynamic';\n\nconst LwcChart = dynamic(() => import('./LwcChart').then((m) => m.LwcChart), {\n    ssr: false,\n});\n```\n\n### Plain HTML loading\n\nUse the standalone IIFE build when there is no bundler:\n\n```html\n<div id=\"chart\" style=\"width: 600px; height: 300px\"></div>\n<script src=\"https://unpkg.com/lightweight-charts/dist/lightweight-charts.standalone.production.js\"></script>\n<script>\n  const chart = LightweightCharts.createChart(document.getElementById('chart'));\n  const series = chart.addSeries(LightweightCharts.LineSeries);\n</script>\n```\n\nChoose the loading shape by environment:\n\n- **Bundler (Vite/webpack/Next):** bare `import { createChart } from 'lightweight-charts'`. The package `exports` resolve the right ESM/CJS build.\n- **Browser `<script>` (no bundler):** the standalone IIFE build above exposes the `LightweightCharts` global; there is no bare-specifier resolution.\n- **Browser native ESM (`<script type=\"module\">`):** import from a concrete `.mjs` URL (e.g. the standalone `.mjs`) or add an import map; a bare `'lightweight-charts'` specifier will not resolve.\n- **SSR frameworks:** load client-only (see the Next.js recipe above) — never import at module top level in a server component.\n\n### Plugin starter\n\n```sh\nnpm create lwc-plugin@latest\n```\n\nUse the generated project and `plugin-examples/` as the base. Decide the extension type first:\n\n- **Primitive** (`IPanePrimitive` / `ISeriesPrimitive`, attached via `attachPrimitive`) — for drawings, overlays, labels, bands, annotations, hit-testing. This is the default; reach for it unless you need real series behavior.\n- **Custom series** (`ICustomSeriesPaneView`) — only when the extension needs its own data, autoscale, or price/time-scale integration. It is heavier; do not use it for decorations.\n\nFor draggable drawings, attach a primitive with `series.attachPrimitive(...)` or `pane.attachPrimitive(...)`, then manage interaction with `subscribeClick` / `subscribeCrosshairMove` and coordinate conversion APIs. Import renderer-only `CanvasRenderingTarget2D` from `fancy-canvas`. The renderer interface is `IPrimitivePaneRenderer` (not `IPanePrimitivePaneRenderer`).\n\n### Non-financial data\n\n```ts\nimport { createOptionsChart } from 'lightweight-charts';\n\nconst chart = createOptionsChart(container);\n```\n\nDecide first whether the horizontal axis is truly non-time:\n\n- **True custom horizontal scale** (option chains, sensor sweeps by a non-time key): use `createOptionsChart` for a numeric x-axis, or `createChartEx` with a custom `IHorzScaleBehavior` (verify both in local typings).\n- **Just non-financial y units** (temperature, load) on an ordinary time/category axis: keep the normal `createChart` series model and set `priceFormat` / `localization.priceFormatter` so labels match the domain.\n- **Categorical x that is really ordered**: mapping categories to ascending `BusinessDay` strings is simpler than a custom scale — but say that the axis is then date-like, not truly categorical.\n\n### Custom price formatter\n\n```ts\nchart.applyOptions({\n    localization: {\n        priceFormatter: (p: number) => `$${p.toFixed(2)}`,\n    },\n});\n```\n\nFor per-series formatting, set `priceFormat: { type: 'custom', formatter, minMove }` in the series options — the chart-level `priceFormatter` is the fallback.\n\nTo go back to the built-in formatting, pass `null`: `chart.applyOptions({ localization: { priceFormatter: null } })`. Passing `undefined` leaves the current formatter in place.\n\n### Minimal pane primitive\n\n```ts\nimport type {\n    IPanePrimitive,\n    IPanePrimitivePaneView,\n    IPrimitivePaneRenderer,\n    Time,\n} from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D } from 'fancy-canvas';\n\nclass Overlay implements IPanePrimitive<Time> {\n    paneViews(): IPanePrimitivePaneView[] { return [new View()]; }\n}\nclass View implements IPanePrimitivePaneView {\n    renderer(): IPrimitivePaneRenderer { return new Renderer(); }\n}\nclass Renderer implements IPrimitivePaneRenderer {\n    draw(target: CanvasRenderingTarget2D): void {\n        target.useMediaCoordinateSpace(({ context, mediaSize }) => {\n            context.fillStyle = 'rgba(0,0,0,0.05)';\n            context.fillRect(0, 0, mediaSize.width, mediaSize.height);\n        });\n    }\n}\n\nchart.panes()[0].attachPrimitive(new Overlay());\n```\n\nWorking examples live under `plugin-examples/src/plugins/` — copy structure from there before writing one from scratch.\n\n## Worked example\n\n> *\"My chart snaps to the right edge every time new data arrives.\"*\n\n1. **Layers involved:** data model (4) and time scale (3).\n2. **Suspect:** the code calls `series.setData(...)` on every tick instead of `series.update(...)`. `setData` resets the visible range.\n3. **Verify:** ask whether the call path is `setData` or `update`. If `setData`, ask whether the visible logical range is captured before and restored after — the v4-era workaround.\n4. **Fix:** switch to `series.update(bar)` for incremental ticks; reserve `setData` for full-history replacement; only use `chart.timeScale().scrollToRealTime()` if the user explicitly wants follow-the-latest behavior.\n5. **References:** `website/examples/data/realtime-updates.js`, `website/docs/time-scale.md`.\n\n## Code-generation rules\n\n- **Default to v5.** Assume v5 APIs unless the user's installed package or prompt pins an older version. If they're on v4, explain the v5 migration point instead of mixing syntaxes.\n- **Use real option names.** In consumer apps, grep `node_modules/lightweight-charts/dist/typings.d.ts`; in the upstream repo, grep `dist/typings.d.ts` or `src/api/options/`. Many similarly-named options exist across chart/series/scale — confirm which level owns the option.\n- **Minimal snippets.** One feature per code block. Combining markers + watermark + custom pane primitive in one snippet hides which API does what.\n- **Match the user's framework.** A React user wants the `useEffect` lifecycle; a vanilla user does not.\n- **Don't invent.** If an API name does not appear in the installed typings or upstream source, it does not exist.\n\n## Answer contract\n\nWhen answering a lightweight-charts question:\n\n1. Name the relevant v5 API.\n2. Show one minimal snippet, not a mega-demo.\n3. Call out the main foot-gun for that task.\n4. Say what local source was checked (version/typings), or state that it could not be verified.\n\n<!-- File: website/docs/plugins/canvas-rendering-target.md (Tokens: ~1053 | Category: anthropic-skill) -->\n---\nsidebar_label: Canvas rendering target\ntitle: Canvas rendering target\nsidebar_position: 4\n---\n\nThe renderer functions of a plugin — whether it is a custom series or a\nprimitive — receive a `CanvasRenderingTarget2D` target to execute their\ndrawing logic on, using the browser's\n[2D Canvas API](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D).\n`CanvasRenderingTarget2D` comes from the\n[Fancy Canvas](https://github.com/tradingview/fancy-canvas) library; its\ndefinition can be viewed in\n[canvas-rendering-target.d.ts](https://unpkg.com/fancy-canvas/canvas-rendering-target.d.ts)\nwithin the published\n[TypeScript declarations](https://www.npmjs.com/package/fancy-canvas?activeTab=code).\n\n## Using CanvasRenderingTarget2D\n\n`CanvasRenderingTarget2D` provides two rendering scopes which you can use:\n\n- `useMediaCoordinateSpace`\n- `useBitmapCoordinateSpace`\n\n## Difference between bitmap and media\n\nBitmap sizing represents the actual physical pixels on the device's screen,\nwhile media sizing represents the size of a pixel as seen by the operating\nsystem and the browser. The number of physical pixels used to render one media\npixel is referred to as the device pixel ratio.\n\nBitmap sizing gives you more control over the drawn image and lets you keep\nthe graphics crisp and pixel perfect; the cost is that the code multiplies\ncoordinates by the pixel ratio throughout. When you don't need that precision,\nmedia sizing is easier: you don't have to think about the device pixel ratio\nat all.\n\n### Bitmap coordinate space\n\nUse `useBitmapCoordinateSpace` to draw with the actual device pixels as the\ncoordinate sizing. The provided scope (of type\n`BitmapCoordinatesRenderingScope`) contains readonly values for the following:\n\n- `context`\n  ([CanvasRenderingContext2D](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D)).\n  Context which can be used for rendering.\n- `horizontalPixelRatio` (number)\n- `verticalPixelRatio` (number)\n- `bitmapSize` (Size). Height and width of the canvas in bitmap dimensions.\n- `mediaSize` (Size). Height and width of the canvas in media dimensions.\n\n#### Bitmap coordinate space usage\n\n```js title='javascript'\n// target is an instance of CanvasRenderingTarget2D\ntarget.useBitmapCoordinateSpace(scope => {\n    // scope is an instance of BitmapCoordinatesRenderingScope\n\n    // example of drawing a filled rectangle which fills the canvas\n    scope.context.beginPath();\n    scope.context.rect(0, 0, scope.bitmapSize.width, scope.bitmapSize.height);\n    scope.context.fillStyle = 'rgba(100, 200, 50, 0.5)';\n    scope.context.fill();\n});\n```\n\n### Media coordinate space\n\nUse `useMediaCoordinateSpace` to draw with the media dimensions as the\ncoordinate sizing. The provided scope (of type\n`MediaCoordinatesRenderingScope`) contains readonly values for the following:\n\n- `context`\n  ([CanvasRenderingContext2D](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D)).\n  Context which can be used for rendering.\n- `mediaSize` (Size). Height and width of the canvas in media dimensions.\n\n#### Media coordinate space usage\n\n```js title='javascript'\n// target is an instance of CanvasRenderingTarget2D\ntarget.useMediaCoordinateSpace(scope => {\n    // scope is an instance of MediaCoordinatesRenderingScope\n\n    // example of drawing a filled rectangle which fills the canvas\n    scope.context.beginPath();\n    scope.context.rect(0, 0, scope.mediaSize.width, scope.mediaSize.height);\n    scope.context.fillStyle = 'rgba(100, 200, 50, 0.5)';\n    scope.context.fill();\n});\n```\n\n## General tips\n\nIt is recommended that rendering functions save and restore the canvas context\nbefore and after all their rendering logic, so the canvas state is the same as\nwhen the function was called. Wrap the logic in a `try…finally` block so the\ncontext is restored even when an error interrupts the drawing.\n\n**Note** that `useBitmapCoordinateSpace` and `useMediaCoordinateSpace`\nautomatically save and restore the canvas context for the logic defined within\nthem. This tip applies to your additional rendering functions called inside\n`use*CoordinateSpace`.\n\n```js title='javascript'\nfunction myRenderingFunction(scope) {\n    const ctx = scope.context;\n\n    // save the current state of the context to the stack\n    ctx.save();\n\n    try {\n        // example code\n        scope.context.beginPath();\n        scope.context.rect(0, 0, scope.mediaSize.width, scope.mediaSize.height);\n        scope.context.fillStyle = 'rgba(100, 200, 50, 0.5)';\n        scope.context.fill();\n    } finally {\n        // restore the saved context from the stack\n        ctx.restore();\n    }\n}\n\ntarget.useMediaCoordinateSpace(scope => {\n    myRenderingFunction(scope);\n    myOtherRenderingFunction(scope);\n    /* ... */\n});\n```\n\n<!-- File: website/docs/plugins/custom_series.md (Tokens: ~1476 | Category: anthropic-skill) -->\n---\nsidebar_label: Custom series\ntitle: Custom series\nsidebar_position: 3\n---\n\n**Custom series** let you define new types of series with your own data\nstructures and rendering logic. A custom series mirrors the API of the\nbuilt-in series: you add it to the chart once, then manage it with the same\nmethods you already use, such as\n[`setData`](../api/interfaces/ISeriesApi.md#setdata) and\n[`applyOptions`](../api/interfaces/ISeriesApi.md#applyoptions). For primitives\nthat decorate an existing series rather than define a new one, see\n[Series primitives](./series-primitives.mdx).\n\n## Adding a custom series\n\nA custom series is defined by a class implementing the\n[`ICustomSeriesPaneView`](../api/interfaces/ICustomSeriesPaneView.md)\ninterface. Pass an instance of it to the\n[`addCustomSeries`](../api/interfaces/IChartApi.md#addcustomseries) method,\nthen work with the returned series as with any other:\n\n```javascript title='javascript'\nclass MyCustomSeries {\n    /* Class implementing the ICustomSeriesPaneView interface */\n}\n\n// Create an instantiated custom series\nconst customSeriesInstance = new MyCustomSeries();\n\nconst chart = createChart(document.getElementById('container'));\nconst myCustomSeries = chart.addCustomSeries(customSeriesInstance, {\n    // Options for MyCustomSeries\n    customOption: 10,\n});\n\nconst data = [\n    { time: 1642425322, value: 123, customValue: 456 },\n    /* ... more data */\n];\n\nmyCustomSeries.setData(data);\n```\n\nTo remove a custom series, use the standard\n[`removeSeries`](../api/interfaces/IChartApi.md#removeseries) method:\n\n```javascript title='javascript'\nchart.removeSeries(myCustomSeries);\n```\n\nThese series are expected to have a uniform width for each data point, which\nensures that the chart maintains a consistent look and feel across all series\ntypes. The only restriction on the data structure is that it should extend the\n[`CustomData`](../api/interfaces/CustomData.md) interface (have a valid time\nproperty for each data point).\n\n## Defining a custom series\n\nThe [`ICustomSeriesPaneView`](../api/interfaces/ICustomSeriesPaneView.md)\ninterface defines the functionality and structure required of a custom series.\nIt includes the following methods and properties:\n\n### Renderer\n\nThe [`renderer`](../api/interfaces/ICustomSeriesPaneView.md#renderer) method\nreturns the renderer that draws the series data on the main chart pane. The\nrenderer must implement the\n[`ICustomSeriesPaneRenderer`](../api/interfaces/ICustomSeriesPaneRenderer.md)\ninterface.\n\nThe library calls the renderer's\n[`draw`](../api/interfaces/ICustomSeriesPaneRenderer.md#draw) method whenever\nthe chart needs to draw the series.\n\nThe [`PriceToCoordinateConverter`](../api/type-aliases/PriceToCoordinateConverter.md)\nprovided as the 2nd argument to the draw method is a convenience function for\nchanging prices into vertical coordinate values. It is provided since the\nseries' original data will most likely be defined in price values, and the\nrenderer needs to draw with coordinates. The values returned by the converter\nare in media coordinates (unscaled by `devicePixelRatio`).\nSee the [Canvas rendering target](./canvas-rendering-target.md) page for more\ndetails on the `CanvasRenderingTarget2D` provided to the `draw` method.\n\n### Update\n\nThe [`update`](../api/interfaces/ICustomSeriesPaneView.md#update) method is\ncalled with the latest data for the renderer to use during the next paint. It\nreceives two parameters: `data` (described below) and `seriesOptions`, a\nreference to the currently applied options for the series.\n\nThe [`PaneRendererCustomData`](../api/interfaces/PaneRendererCustomData.md)\ninterface provides the data that can be used within the renderer for drawing the\nseries data. It includes the following properties:\n\n- `bars`: list of all the series' items and their x coordinates. See\n  [`CustomBarItemData`](../api/interfaces/CustomBarItemData.md) for more details\n- `barSpacing`: spacing between consecutive bars.\n- `visibleRange`: the current visible range of items on the chart.\n\n### Hit testing\n\nThe renderer can implement the optional\n[`hitTest`](../api/interfaces/ICustomSeriesPaneRenderer.md#hittest) method to\nparticipate directly in hover and click resolution.\n\nReturn `null` when the cursor misses the custom geometry. Return a\n[`CustomSeriesHitTestResult`](../api/interfaces/CustomSeriesHitTestResult.md)\nwhen the cursor hits a custom object. The result can provide:\n\n- `distance`: geometric distance from the cursor to the hit\n- `type`: optional geometric classification such as `point`, `line`, `range`, or `custom`\n- `objectId`: optional object identifier that becomes `hoveredObjectId`\n- `cursorStyle`: optional cursor override\n- `hitTestData`: optional renderer-defined hover data passed back into `draw`\n\nThis hook lets the custom series participate in the same geometry-first\narbitration model as built-in series.\n\nThe `type` field is used for hover arbitration only. Public mouse events still\nreport `hoveredInfo.type` as `custom` for custom-series hits. Use `objectId`\nand `hoveredInfo.objectKind` to distinguish custom sub-objects.\n\n### Price value builder\n\nThe\n[`priceValueBuilder`](../api/interfaces/ICustomSeriesPaneView.md#pricevaluebuilder)\nmethod interprets a data item and returns an array of numbers: the equivalent\nhighest, lowest, and current price values for that item.\n\nThese price values are used by the chart to determine the auto-scaling (to\nensure the items are in view) and the crosshair and price line positions. The\nlargest and smallest values in the array will be used to specify the visible\nrange of the painted item, and the last value will be used for the crosshair and\nprice line position.\n\n### Whitespace\n\nThe\n[`isWhitespace`](../api/interfaces/ICustomSeriesPaneView.md#iswhitespace)\nmethod tells the library which data points should be treated as whitespace:\nreturn `true` for a whitespace item. Whitespace data points are not passed to\nthe renderer or to the `priceValueBuilder`.\n\n### Default options\n\nThe\n[`defaultOptions`](../api/interfaces/ICustomSeriesPaneView.md#defaultoptions)\nproperty provides the default options for the series. The user can override\nthem with the options argument of\n[`addCustomSeries`](../api/interfaces/IChartApi.md#addcustomseries), or later\nvia the [`applyOptions`](../api/interfaces/ISeriesApi.md#applyoptions) method\non the series.\n\n### Destroy\n\nThe [`destroy`](../api/interfaces/ICustomSeriesPaneView.md#destroy) method is\ncalled when the series is removed from the chart. Use it to clean up\neverything that could outlive the series and cause memory leaks: event\nlisteners, timers, and references to other objects.\n\n<!-- File: website/docs/plugins/intro.md (Tokens: ~597 | Category: anthropic-skill) -->\n---\nsidebar_label: Overview\nsidebar_position: 0\n---\n\n# Plugin development\n\n**Plugins** let you extend Lightweight Charts™ with your own functionality: new\nseries types, drawing tools, indicators, watermarks, and other custom elements\nrendered as part of the chart. This section explains how plugins work and how\nto build your own.\n\n:::tip\n\nLooking for a ready-made plugin instead of building one? Browse the\n[plugin catalog](/plugins).\n\n:::\n\n## Choosing a plugin type\n\n| You want to build | Plugin type | Attach with |\n| --- | --- | --- |\n| A drawing tool, annotation, or overlay tied to a series and its scales | [Series primitive](./series-primitives.mdx) | [`ISeriesApi.attachPrimitive`](../api/interfaces/ISeriesApi.md#attachprimitive) |\n| A pane-wide element independent of any series, such as a watermark | [Pane primitive](./pane-primitives.md) | [`IPaneApi.attachPrimitive`](../api/interfaces/IPaneApi.md#attachprimitive) |\n| A new way to draw data: a series with its own data structure and rendering | [Custom series](./custom_series.md) | [`addCustomSeries`](../api/interfaces/IChartApi.md#addcustomseries) |\n\n:::tip\n\nIf your element visualizes its own data, build a custom series;\nif it decorates a series or reacts to its scales, build a series primitive;\nif it belongs to the pane as a whole, build a pane primitive.\nSeries primitives can also render on the price and time scales; pane primitives cannot.\n\n:::\n\n## Development workflow\n\n1. **Scaffold a project.** Run `npm create lwc-plugin@latest` — the\n   [create-lwc-plugin](https://www.npmjs.com/package/create-lwc-plugin)\n   package generates a ready-to-run project for the plugin type you choose.\n   The wizard also offers to install the plugin-authoring\n   [Agent Skill](../ai.md#ai-coding-assistants), which teaches AI coding\n   assistants how to write Lightweight Charts™ plugins.\n2. **Implement the plugin interface.** Follow the article for your plugin type\n   from the table above.\n3. **Render on the canvas.** Draw in the right coordinate space with\n   [Canvas rendering target](./canvas-rendering-target.md), and keep lines\n   crisp with the [Pixel perfect rendering](./pixel-perfect-rendering/index.md)\n   techniques.\n4. **Learn from working code.** The\n   [Plugin examples demo](https://tradingview.github.io/lightweight-charts/plugin-examples)\n   hosts interactive examples of heatmaps, alerts, watermarks, and tooltips;\n   their sources live in the\n   [`plugin-examples`](https://github.com/tradingview/lightweight-charts/tree/master/plugin-examples)\n   folder of the repository.\n\n<!-- File: website/docs/plugins/pane-primitives.md (Tokens: ~590 | Category: anthropic-skill) -->\n---\nsidebar_label: Pane primitives\ntitle: Pane primitives\nsidebar_position: 2\n---\n\n**Pane primitives** are primitives attached to a chart pane rather than to a specific series.\nUse pane primitives for chart-wide elements that are not tied to any series' data, such as watermarks.\nThe library's built-in text and image watermarks are implemented this way.\nFor series-bound primitives, see [Series primitives](./series-primitives.mdx).\n\n## Attaching a primitive\n\nA pane primitive is a class implementing the\n[`IPanePrimitive`](../api/type-aliases/IPanePrimitive.md) interface.\nCreate an instance of your primitive and attach it to a pane with the\n[`attachPrimitive`](../api/interfaces/IPaneApi.md#attachprimitive) method:\n\n```javascript\nclass MyCustomPanePrimitive {\n    /* Class implementing the IPanePrimitive interface */\n}\n\n// Create an instantiated pane primitive\nconst myCustomPanePrimitive = new MyCustomPanePrimitive();\n\nconst chart = createChart(document.getElementById('container'));\n// Get the main pane\nconst mainPane = chart.panes()[0];\n\n// Attach the primitive to the pane\nmainPane.attachPrimitive(myCustomPanePrimitive);\n```\n\nTo remove the primitive from the pane, use the\n[`detachPrimitive`](../api/interfaces/IPaneApi.md#detachprimitive) method:\n\n```javascript\nmainPane.detachPrimitive(myCustomPanePrimitive);\n```\n\n## Key differences from series primitives\n\nPane primitives follow the same model as\n[series primitives](./series-primitives.mdx) — views that return renderers,\nthe `attached` / `detached` lifecycle, `updateAllViews`, and hit testing —\nwith four differences:\n\n- A pane primitive is attached to a pane, so\n  [`paneViews`](../api/interfaces/IPanePrimitiveBase.md#paneviews) is its only\n  view getter: it cannot draw on the price or time scales, or define axis\n  labels.\n- The `attached` method receives\n  [`{ chart, requestUpdate }`](../api/interfaces/PaneAttachedParameter.md)\n  without a series reference.\n- There is no `autoscaleInfo`: a pane primitive is not tied to a price scale.\n- Within each `zOrder` layer, pane primitives are drawn before the series and their primitives, so a pane primitive on `'normal'` sits under the series. Use `'top'` to draw it above the series.\n\n## Implementing a pane primitive\n\nThe `paneViews` method returns the views that draw on the pane. Each view must\nprovide a `renderer()` method returning the renderer that draws on the canvas:\n\n```javascript\nclass MyCustomPanePrimitive {\n    paneViews() {\n        return [\n            {\n                renderer: () => ({\n                    draw: target => {\n                        // Custom drawing logic here\n                    },\n                }),\n            },\n        ];\n    }\n\n    // Other methods as needed...\n}\n```\n\n<!-- File: website/docs/plugins/pixel-perfect-rendering/index.md (Tokens: ~894 | Category: anthropic-skill) -->\n---\nsidebar_position: 0\nsidebar_label: Pixel perfect rendering\npagination_title: Pixel perfect rendering\ntitle: Best practices for pixel perfect rendering in canvas drawings\ndescription: Best practices for pixel perfect rendering in canvas drawings when creating plugins for Lightweight Charts\nkeywords:\n  - plugins\n  - extensions\n  - rendering\n  - canvas\n  - bitmap\n  - media\n  - pixels\npagination_prev: null\n---\n\nTo achieve crisp pixel perfect rendering for your plugins, it is recommended that the canvas drawings are created using bitmap coordinates. The difference between media and bitmap coordinate spaces is discussed on the [Canvas rendering target](../canvas-rendering-target.md) page. **Essentially, all drawing actions should use integer positions and dimensions when on the bitmap coordinate space.**\n\nTo ensure consistency between your plugins and the library's built-in logic for rendering points on the chart, use the following calculation functions.\n\n:::info\n\nVariable names containing `media` refer to positions / dimensions specified using the media coordinate space (such as the x and y coordinates provided by the library to the renderers), and names containing `bitmap` refer to positions / dimensions on the bitmap coordinate space (actual device screen pixels).\n\n:::\n\n## Centered shapes\n\nIf you need to draw a shape which is centered on a position (for example a price or x coordinate) and has a desired width then you could use the `positionsLine` function presented below. This can be used for drawing a horizontal line at a specific price, or a vertical line aligned with the center of a series point.\n\n```typescript\ninterface BitmapPositionLength {\n    /** coordinate for use with a bitmap rendering scope */\n    position: number;\n    /** length for use with a bitmap rendering scope */\n    length: number;\n}\n\nfunction centreOffset(lineBitmapWidth: number): number {\n    return Math.floor(lineBitmapWidth * 0.5);\n}\n\n/**\n * Calculates the bitmap position for an item with a desired length (height or width), and centered according to\n * a position coordinate defined in media sizing.\n * @param positionMedia - position coordinate for the bar (in media coordinates)\n * @param pixelRatio - pixel ratio. Either horizontal for x positions, or vertical for y positions\n * @param desiredWidthMedia - desired width (in media coordinates)\n * @returns Position of the start point and length dimension.\n */\nexport function positionsLine(\n    positionMedia: number,\n    pixelRatio: number,\n    desiredWidthMedia: number = 1,\n    widthIsBitmap?: boolean\n): BitmapPositionLength {\n    const scaledPosition = Math.round(pixelRatio * positionMedia);\n    const lineBitmapWidth = widthIsBitmap\n        ? desiredWidthMedia\n        : Math.round(desiredWidthMedia * pixelRatio);\n    const offset = centreOffset(lineBitmapWidth);\n    const position = scaledPosition - offset;\n    return { position, length: lineBitmapWidth };\n}\n```\n\n## Dual point shapes\n\nIf you need to draw a shape between two coordinates (for example, y coordinates for a high and low price) then you can use the `positionsBox` function as presented below.\n\n```typescript\n/**\n * Determines the bitmap position and length for a dimension of a shape to be drawn.\n * @param position1Media - media coordinate for the first point\n * @param position2Media - media coordinate for the second point\n * @param pixelRatio - pixel ratio for the corresponding axis (vertical or horizontal)\n * @returns Position of the start point and length dimension.\n */\nexport function positionsBox(\n    position1Media: number,\n    position2Media: number,\n    pixelRatio: number\n): BitmapPositionLength {\n    const scaledPosition1 = Math.round(pixelRatio * position1Media);\n    const scaledPosition2 = Math.round(pixelRatio * position2Media);\n    return {\n        position: Math.min(scaledPosition1, scaledPosition2),\n        length: Math.abs(scaledPosition2 - scaledPosition1) + 1,\n    };\n}\n```\n\n## Default widths\n\nRefer to the following pages for functions defining the default widths of shapes drawn by the library:\n\n- [Crosshair and grid lines](./widths/crosshair.md)\n- [Candlesticks](./widths/candlestick.md)\n- [Columns (histogram)](./widths/columns.md)\n- [Full bar width](./widths/full-bar-width.md)\n\n<!-- File: website/docs/plugins/pixel-perfect-rendering/widths/candlestick.md (Tokens: ~646 | Category: anthropic-skill) -->\n---\nsidebar_position: 0\nsidebar_label: Candlesticks\npagination_title: Candlestick Widths\ntitle: Candlestick width calculations\ndescription: Describes the calculation for candlestick body widths\nkeywords:\n  - plugins\n  - extensions\n  - rendering\n  - canvas\n  - bitmap\n  - media\n  - pixels\n  - candlestick\n  - width\n---\n\n:::tip\n\nIt is recommend that you first read the [Pixel Perfect Rendering](../index.md) page.\n\n:::\n\nThe following functions can be used to get the calculated width that the library would use for a candlestick at a specific bar spacing and device pixel ratio.\n\nBelow a bar spacing of 4, the library will attempt to use as large a width as possible without the possibility of overlapping, while above 4 then the width will start to trend towards an 80% width of the available space.\n\n:::warning\n\nIt is expected that candles can overlap slightly at smaller bar spacings (more pronounced on lower resolution devices). This produces a more readable chart. If you need to ensure that bars can never overlap then rather use the widths for [Columns](./columns.md) or the [full bar width](./full-bar-width.md) calculation.\n\n:::\n\n```typescript\nfunction optimalCandlestickWidth(\n    barSpacing: number,\n    pixelRatio: number\n): number {\n    const barSpacingSpecialCaseFrom = 2.5;\n    const barSpacingSpecialCaseTo = 4;\n    const barSpacingSpecialCaseCoeff = 3;\n    if (barSpacing >= barSpacingSpecialCaseFrom && barSpacing <= barSpacingSpecialCaseTo) {\n        return Math.floor(barSpacingSpecialCaseCoeff * pixelRatio);\n    }\n    // coeff should be 1 on small barspacing and go to 0.8 while bar spacing grows\n    const barSpacingReducingCoeff = 0.2;\n    const coeff =\n        1 -\n        (barSpacingReducingCoeff *\n            Math.atan(\n                Math.max(barSpacingSpecialCaseTo, barSpacing) - barSpacingSpecialCaseTo\n            )) /\n            (Math.PI * 0.5);\n    const res = Math.floor(barSpacing * coeff * pixelRatio);\n    const scaledBarSpacing = Math.floor(barSpacing * pixelRatio);\n    const optimal = Math.min(res, scaledBarSpacing);\n    return Math.max(Math.floor(pixelRatio), optimal);\n}\n\n/**\n * Calculates the candlestick width that the library would use for the current\n * bar spacing.\n * @param barSpacing - bar spacing in media coordinates\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @returns The width (in bitmap coordinates) that the chart would use to draw a candle body\n */\nexport function candlestickWidth(\n    barSpacing: number,\n    horizontalPixelRatio: number\n): number {\n    let width = optimalCandlestickWidth(barSpacing, horizontalPixelRatio);\n    if (width >= 2) {\n        const wickWidth = Math.floor(horizontalPixelRatio);\n        if (wickWidth % 2 !== width % 2) {\n            width--;\n        }\n    }\n    return width;\n}\n```\n\n<!-- File: website/docs/plugins/pixel-perfect-rendering/widths/columns.md (Tokens: ~2023 | Category: anthropic-skill) -->\n---\nsidebar_position: 0\nsidebar_label: Columns\npagination_title: Histogram Column Widths\ntitle: Histogram column width calculations\ndescription: Describes the calculation for histogram column widths\nkeywords:\n  - plugins\n  - extensions\n  - rendering\n  - canvas\n  - bitmap\n  - media\n  - pixels\n  - histogram\n  - column\n  - width\n---\n\n:::tip\n\nIt is recommend that you first read the [Pixel Perfect Rendering](../index.md) page.\n\n:::\n\nThe following functions can be used to get the calculated width that the library would use for a histogram column at a specific bar spacing and device pixel ratio.\n\nYou can use the `calculateColumnPositionsInPlace` function instead of the `calculateColumnPositions` function to perform the calculation on an existing array of items without needing to create additional arrays (which is more efficient). It is recommended that you memoize the majority of the calculations below to improve the rendering performance.\n\n```typescript\nconst alignToMinimalWidthLimit = 4;\nconst showSpacingMinimalBarWidth = 1;\n\n/**\n * Spacing gap between columns.\n * @param barSpacingMedia - spacing between bars (media coordinate)\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @returns Spacing gap between columns (in Bitmap coordinates)\n */\nfunction columnSpacing(barSpacingMedia: number, horizontalPixelRatio: number) {\n    return Math.ceil(barSpacingMedia * horizontalPixelRatio) <=\n        showSpacingMinimalBarWidth\n        ? 0\n        : Math.max(1, Math.floor(horizontalPixelRatio));\n}\n\n/**\n * Desired width for columns. This may not be the final width because\n * it may be adjusted later to ensure all columns on screen have a\n * consistent width and gap.\n * @param barSpacingMedia - spacing between bars (media coordinate)\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @param spacing - Spacing gap between columns (in Bitmap coordinates). (optional, provide if you have already calculated it)\n * @returns Desired width for column bars (in Bitmap coordinates)\n */\nfunction desiredColumnWidth(\n    barSpacingMedia: number,\n    horizontalPixelRatio: number,\n    spacing?: number\n) {\n    return (\n        Math.round(barSpacingMedia * horizontalPixelRatio) -\n        (spacing ?? columnSpacing(barSpacingMedia, horizontalPixelRatio))\n    );\n}\n\ninterface ColumnCommon {\n    /** Spacing gap between columns */\n    spacing: number;\n    /** Shift columns left by one pixel */\n    shiftLeft: boolean;\n    /** Half width of a column */\n    columnHalfWidthBitmap: number;\n    /** horizontal pixel ratio */\n    horizontalPixelRatio: number;\n}\n\n/**\n * Calculated values which are common to all the columns on the screen, and\n * are required to calculate the individual positions.\n * @param barSpacingMedia - spacing between bars (media coordinate)\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @returns calculated values for subsequent column calculations\n */\nfunction columnCommon(\n    barSpacingMedia: number,\n    horizontalPixelRatio: number\n): ColumnCommon {\n    const spacing = columnSpacing(barSpacingMedia, horizontalPixelRatio);\n    const columnWidthBitmap = desiredColumnWidth(\n        barSpacingMedia,\n        horizontalPixelRatio,\n        spacing\n    );\n    const shiftLeft = columnWidthBitmap % 2 === 0;\n    const columnHalfWidthBitmap = (columnWidthBitmap - (shiftLeft ? 0 : 1)) / 2;\n    return {\n        spacing,\n        shiftLeft,\n        columnHalfWidthBitmap,\n        horizontalPixelRatio,\n    };\n}\n\ninterface ColumnPosition {\n    left: number;\n    right: number;\n    shiftLeft: boolean;\n}\n\n/**\n * Calculate the position for a column. These values can be later adjusted\n * by a second pass which corrects widths, and shifts columns.\n * @param xMedia - column x position (center) in media coordinates\n * @param columnData - precalculated common values (returned by `columnCommon`)\n * @param previousPosition - result from this function for the previous bar.\n * @returns initial column position\n */\nfunction calculateColumnPosition(\n    xMedia: number,\n    columnData: ColumnCommon,\n    previousPosition: ColumnPosition | undefined\n): ColumnPosition {\n    const xBitmapUnRounded = xMedia * columnData.horizontalPixelRatio;\n    const xBitmap = Math.round(xBitmapUnRounded);\n    const xPositions: ColumnPosition = {\n        left: xBitmap - columnData.columnHalfWidthBitmap,\n        right:\n            xBitmap +\n            columnData.columnHalfWidthBitmap -\n            (columnData.shiftLeft ? 1 : 0),\n        shiftLeft: xBitmap > xBitmapUnRounded,\n    };\n    const expectedAlignmentShift = columnData.spacing + 1;\n    if (previousPosition) {\n        if (xPositions.left - previousPosition.right !== expectedAlignmentShift) {\n            // need to adjust alignment\n            if (previousPosition.shiftLeft) {\n                previousPosition.right = xPositions.left - expectedAlignmentShift;\n            } else {\n                xPositions.left = previousPosition.right + expectedAlignmentShift;\n            }\n        }\n    }\n    return xPositions;\n}\n\nfunction fixPositionsAndReturnSmallestWidth(\n    positions: ColumnPosition[],\n    initialMinWidth: number\n): number {\n    return positions.reduce((smallest: number, position: ColumnPosition) => {\n        if (position.right < position.left) {\n            position.right = position.left;\n        }\n        const width = position.right - position.left + 1;\n        return Math.min(smallest, width);\n    }, initialMinWidth);\n}\n\nfunction fixAlignmentForNarrowColumns(\n    positions: ColumnPosition[],\n    minColumnWidth: number\n) {\n    return positions.map((position: ColumnPosition) => {\n        const width = position.right - position.left + 1;\n        if (width <= minColumnWidth) return position;\n        if (position.shiftLeft) {\n            position.right -= 1;\n        } else {\n            position.left += 1;\n        }\n        return position;\n    });\n}\n\n/**\n * Calculates the column positions and widths for the x positions.\n * This function creates a new array. You may get faster performance using the\n * `calculateColumnPositionsInPlace` function instead\n * @param xMediaPositions - x positions for the bars in media coordinates\n * @param barSpacingMedia - spacing between bars in media coordinates\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @returns Positions for the columns\n */\nexport function calculateColumnPositions(\n    xMediaPositions: number[],\n    barSpacingMedia: number,\n    horizontalPixelRatio: number\n): ColumnPosition[] {\n    const common = columnCommon(barSpacingMedia, horizontalPixelRatio);\n    const positions = new Array<ColumnPosition>(xMediaPositions.length);\n    let previous: ColumnPosition | undefined = undefined;\n    for (let i = 0; i < xMediaPositions.length; i++) {\n        positions[i] = calculateColumnPosition(\n            xMediaPositions[i],\n            common,\n            previous\n        );\n        previous = positions[i];\n    }\n    const initialMinWidth = Math.ceil(barSpacingMedia * horizontalPixelRatio);\n    const minColumnWidth = fixPositionsAndReturnSmallestWidth(\n        positions,\n        initialMinWidth\n    );\n    if (common.spacing > 0 && minColumnWidth < alignToMinimalWidthLimit) {\n        return fixAlignmentForNarrowColumns(positions, minColumnWidth);\n    }\n    return positions;\n}\n\nexport interface ColumnPositionItem {\n    x: number;\n    column?: ColumnPosition;\n}\n\n/**\n * Calculates the column positions and widths for bars using the existing\n * array of items.\n * @param items - bar items which include an `x` property, and will be mutated to contain a column property\n * @param barSpacingMedia - bar spacing in media coordinates\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @param startIndex - start index for visible bars within the items array\n * @param endIndex - end index for visible bars within the items array\n */\nexport function calculateColumnPositionsInPlace(\n    items: ColumnPositionItem[],\n    barSpacingMedia: number,\n    horizontalPixelRatio: number,\n    startIndex: number,\n    endIndex: number\n): void {\n    const common = columnCommon(barSpacingMedia, horizontalPixelRatio);\n    let previous: ColumnPosition | undefined = undefined;\n    for (let i = startIndex; i < Math.min(endIndex, items.length); i++) {\n        items[i].column = calculateColumnPosition(items[i].x, common, previous);\n        previous = items[i].column;\n    }\n    const minColumnWidth = (items as ColumnPositionItem[]).reduce(\n        (smallest: number, item: ColumnPositionItem, index: number) => {\n            if (!item.column || index < startIndex || index > endIndex)\n                return smallest;\n            if (item.column.right < item.column.left) {\n                item.column.right = item.column.left;\n            }\n            const width = item.column.right - item.column.left + 1;\n            return Math.min(smallest, width);\n        },\n        Math.ceil(barSpacingMedia * horizontalPixelRatio)\n    );\n    if (common.spacing > 0 && minColumnWidth < alignToMinimalWidthLimit) {\n        (items as ColumnPositionItem[]).forEach(\n            (item: ColumnPositionItem, index: number) => {\n                if (!item.column || index < startIndex || index > endIndex) return;\n                const width = item.column.right - item.column.left + 1;\n                if (width <= minColumnWidth) return item;\n                if (item.column.shiftLeft) {\n                    item.column.right -= 1;\n                } else {\n                    item.column.left += 1;\n                }\n                return item.column;\n            }\n        );\n    }\n}\n\n```\n\n<!-- File: website/docs/plugins/pixel-perfect-rendering/widths/crosshair.md (Tokens: ~307 | Category: anthropic-skill) -->\n---\nsidebar_position: 0\nsidebar_label: Crosshair\npagination_title: Crosshair Widths\ntitle: Crosshair and grid line width calculations\ndescription: Describes the calculation for the crosshair line and grid line widths\nkeywords:\n  - plugins\n  - extensions\n  - rendering\n  - canvas\n  - bitmap\n  - media\n  - pixels\n  - crosshair\n  - grid\n  - line\n  - width\n---\n\n:::tip\n\nIt is recommend that you first read the [Pixel Perfect Rendering](../index.md) page.\n\n:::\n\nThe following functions can be used to get the calculated width that the library would use for a crosshair or grid line at a specific device pixel ratio.\n\n```typescript\n/**\n * Default grid / crosshair line width in Bitmap sizing\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @returns default grid / crosshair line width in Bitmap sizing\n */\nexport function gridAndCrosshairBitmapWidth(\n    horizontalPixelRatio: number\n): number {\n    return Math.max(1, Math.floor(horizontalPixelRatio));\n}\n\n/**\n * Default grid / crosshair line width in Media sizing\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @returns default grid / crosshair line width in Media sizing\n */\nexport function gridAndCrosshairMediaWidth(\n    horizontalPixelRatio: number\n): number {\n    return (\n        gridAndCrosshairBitmapWidth(horizontalPixelRatio) / horizontalPixelRatio\n    );\n}\n\n```\n\n<!-- File: website/docs/plugins/pixel-perfect-rendering/widths/full-bar-width.md (Tokens: ~451 | Category: anthropic-skill) -->\n---\nsidebar_position: 0\nsidebar_label: Full bar width\npagination_title: Full Bar Width\ntitle: Full bar width calculations\ndescription: Describes the calculation for full bar widths\nkeywords:\n  - plugins\n  - extensions\n  - rendering\n  - canvas\n  - bitmap\n  - media\n  - pixels\n  - histogram\n  - column\n  - width\n---\n\n:::tip\n\nIt is recommend that you first read the [Pixel Perfect Rendering](../index.md) page.\n\n:::\n\nThe following functions can be used to get the calculated width that the library would use for the full width of a bar (data point) at a specific bar spacing and device pixel ratio. This can be used when you would like to use the full width available for each data point on the x axis, and don't want any gaps to be visible.\n\n```typescript\ninterface BitmapPositionLength {\n    /** coordinate for use with a bitmap rendering scope */\n    position: number;\n    /** length for use with a bitmap rendering scope */\n    length: number;\n}\n\n/**\n * Calculates the position and width which will completely full the space for the bar.\n * Useful if you want to draw something that will not have any gaps between surrounding bars.\n * @param xMedia - x coordinate of the bar defined in media sizing\n * @param halfBarSpacingMedia - half the width of the current barSpacing (un-rounded)\n * @param horizontalPixelRatio - horizontal pixel ratio\n * @returns position and width which will completely full the space for the bar\n */\nexport function fullBarWidth(\n    xMedia: number,\n    halfBarSpacingMedia: number,\n    horizontalPixelRatio: number\n): BitmapPositionLength {\n    const fullWidthLeftMedia = xMedia - halfBarSpacingMedia;\n    const fullWidthRightMedia = xMedia + halfBarSpacingMedia;\n    const fullWidthLeftBitmap = Math.round(\n        fullWidthLeftMedia * horizontalPixelRatio\n    );\n    const fullWidthRightBitmap = Math.round(\n        fullWidthRightMedia * horizontalPixelRatio\n    );\n    const fullWidthBitmap = fullWidthRightBitmap - fullWidthLeftBitmap;\n    return {\n        position: fullWidthLeftBitmap,\n        length: fullWidthBitmap,\n    };\n}\n```\n\n<!-- File: packages/create-lwc-plugin/README.md (Tokens: ~838 | Category: plugin-manifest) -->\n# create-lwc-plugin\n\n**create-lwc-plugin** scaffolds a new plugin project for Lightweight Charts™.\nThe wizard asks a few questions and generates a ready-to-run project from a\ntemplate for one of the three plugin types:\n\n- a series primitive\n- a pane primitive\n- a custom series\n\nThe scaffolded project is ready to publish: its `package.json` follows the\nconventions used by the Lightweight Charts™ plugin catalog, so the plugin can\nbe listed there once it is published to npm.\n\n✨ Need some examples for inspiration? Check out the\n[plugin-examples](https://github.com/tradingview/lightweight-charts/tree/master/plugin-examples)\nfolder in the Lightweight Charts™ repo.\n\n## Scaffold your first Lightweight Charts™ plugin\n\nWith npm:\n\n```bash\nnpm create lwc-plugin@latest\n```\n\nWith Yarn:\n\n```bash\nyarn create lwc-plugin\n```\n\nWith pnpm:\n\n```bash\npnpm create lwc-plugin\n```\n\nThe wizard asks for the plugin's name, description, author, license, the minimum\nversion of Lightweight Charts™ it supports, and the tags to list it under. Those\nanswers populate the generated `package.json`, including the `lwcPlugin` block\nread by the plugin catalog.\n\nBefore any of that, the wizard offers to install the\n[plugin-authoring Agent Skill](https://github.com/tradingview/lightweight-charts/blob/master/.github/skills/lightweight-charts-plugin-authoring/SKILL.md)\nfor AI coding assistants such as Claude Code, Codex, and Cursor. The skill helps\nchoose the plugin type, build on `@tradingview/lwc-toolkit`, and pick the right\nofficial plugin as the reference for your idea. It also points to the docs and\nwarns about the autoscale, whitespace, and hit-test mistakes a first plugin\ntends to make.\n\nSay yes, and you have two ways to continue. Carry on with the wizard: the skill\nis installed into the new project when the wizard finishes. Or quit right\nthere: the skill is installed into the current directory, and you hand the rest\nover to your assistant. The assistant knows how to run this wizard with you.\n\nThe skill is installed with the [`skills` CLI](https://github.com/vercel-labs/skills).\nThe CLI asks which assistants to set it up for. You can also run it yourself at\nany time:\n\n```bash\nnpx skills add tradingview/lightweight-charts --skill lightweight-charts-plugin-authoring\n```\n\n## The generated project\n\n### Run locally\n\n```shell\nnpm install\nnpm run dev\n```\n\nVisit `localhost:5173` in the browser.\n\n### Build the plugin\n\n```shell\nnpm run build\n```\n\nThis writes three files into the `dist` folder: the package entry point\n(`<name>.js`), a standalone build for use over a CDN\n(`<name>.standalone.js`) which inlines every dependency except\nLightweight Charts™ itself, and the bundled type declarations (`<name>.d.ts`).\nPlugins are published as ES modules only.\n\n### Publish to npm\n\nThe `package.json` in the project root is the published manifest. Check its\n`description`, `version`, `license` and `lwcPlugin` fields, then publish from\nthe project root:\n\n```shell\nnpm publish\n```\n\nHint: append `--dry-run` to the end of the publish command to see the results of\nthe publish command without actually uploading the package to npm.\n\n## Scaffold an official in-repo plugin\n\nMaintainers working inside the Lightweight Charts™ repository can scaffold a\nworkspace package instead of a standalone project:\n\n```shell\npnpm create lwc-plugin --workspace\n```\n\nWorkspace mode targets `packages/`, scopes the package name to `@tradingview/`,\ndepends on the library and the shared plugin utilities through `workspace:*`,\nseeds a `CHANGELOG.md`, `LICENSE` and `NOTICE`, and marks the plugin as an\nofficial catalog entry.\n\n<!-- File: packages/create-lwc-plugin/template-common/README.md (Tokens: ~992 | Category: plugin-manifest) -->\n# _PLUGINNAME_\n\n_DESCRIPTION_\n\n<!--\nExpand the line above into a short paragraph: what the plugin draws or does, and\nwhen someone would reach for it. This is the first thing a reader sees, both on\nnpm and on the plugin registry page.\n-->\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `_PEERVERSION_` in your\nproject:\n\n```shell\nnpm install _PACKAGENAME_\n```\n\nThen import the plugin and add it to a chart:\n\n```js\n_ATTACH_SNIPPET_\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"_PACKAGENAME_\": \"https://unpkg.com/_PACKAGENAME_/dist/_ENTRYNAME_.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\n_ATTACH_SNIPPET_\n</script>\n```\n\n## Usage\n\n<!-- Describe the plugin's typical usage, and anything a caller has to own. -->\n\n```js\n_USAGE_SNIPPET_\n```\n\n## Options\n\n<!--\nList the options the plugin accepts. Add further tables for any nested option\ngroups. Keep this in sync with the option types in the source.\n-->\n\n| Option | Type | Default | Description |\n| ------ | ---- | ------- | ----------- |\n|        |      |         |             |\n\nThe full typed surface is published with the package — see\n[`dist/_ENTRYNAME_.d.ts`](https://unpkg.com/_PACKAGENAME_/dist/_ENTRYNAME_.d.ts),\nalso browsable from the Code tab on the package's npm page.\n\n## Development\n\nInstall the dependencies and start the example page:\n\n```shell\nnpm install\nnpm run dev\n```\n\nVisit `localhost:5173` in the browser. The example under `src/example/` is the\nplugin's live preview — keep it working, and keep it filling the window so that\nit can be embedded.\n\nBuild the publishable bundles into `dist/`:\n\n```shell\nnpm run build\n```\n\nThis produces the package entry point (`dist/_ENTRYNAME_.js`), the standalone\nbuild used over a CDN (`dist/_ENTRYNAME_.standalone.js`) and the bundled type\ndeclarations (`dist/_ENTRYNAME_.d.ts`).\n\n<!-- EXTERNAL_ONLY -->\n## The plugin toolkit\n\nThis project depends on\n[`@tradingview/lwc-toolkit`](https://www.npmjs.com/package/@tradingview/lwc-toolkit),\na small set of helpers written for plugin authors: pixel-perfect coordinate and\nwidth calculations for candles, columns and full-width bars, crosshair-aligned\nline widths, time conversion, and a `PluginBase` class that keeps the chart and\nseries references wired up for you.\n\nDepending on the starter this project was generated from, the code may already\nuse it — check the imports in `src/`. It is a `devDependency`, bundled into\n`dist/` when the plugin is built, so it never becomes a dependency for anyone\ninstalling the plugin. If none of it is needed, uninstall it; nothing else has\nto change.\n<!-- /EXTERNAL_ONLY -->\n\n<!-- EXTERNAL_ONLY -->\n## Publishing to npm\n\nThe `package.json` in the project root is the published manifest: check the\n`description`, `version`, `license` and `lwcPlugin` fields before releasing.\n\nCheck the packaging before publishing:\n\n```shell\nnpm run check-package\n```\n\nThat runs [publint](https://publint.dev), which checks the manifest, and\n[arethetypeswrong](https://arethetypeswrong.github.io), which resolves every\nentry point the way a consumer's TypeScript would — the check that catches an\n`exports` entry with no `types` alongside it. Two of its rules are ignored\nbecause an ESM-only package is meant to fail them: `node10` predates the\n`exports` field entirely, and `require`-ing an ES module is an error rather\nthan a mistake in the package.\n\nPublish from the project root once the plugin has been built:\n\n```shell\nnpm publish\n```\n\nHint: append `--dry-run` to inspect the result without uploading anything.\n\n## Discoverability\n\nTag the plugin so that others can find it: add the `lightweight-charts-plugin`\ntopic to its GitHub repository, and keep the `lightweight-charts-plugin` keyword\nin `package.json`.\n<!-- /EXTERNAL_ONLY -->\n\n<!-- File: packages/lwc-plugin-accessibility/README.md (Tokens: ~6852 | Category: plugin-manifest) -->\n# Accessibility\n\nA drop-in accessibility layer for a Lightweight Charts™ chart. The plugin is\nbuilt on\n[pane primitives](https://tradingview.github.io/lightweight-charts/docs/plugins/pane-primitives)\nand helps your application meet\n[WCAG 2.1 Level AA](https://www.w3.org/TR/WCAG21/).\n\nCanvas-based charts are opaque to assistive technology. This plugin packages\nthe techniques from the\n[accessibility tutorial](https://tradingview.github.io/lightweight-charts/tutorials/a11y/intro).\nYou get keyboard navigation, screen-reader announcements, and a visible focus\nindicator without any manual wiring.\n\nUse the chart-level helper for normal integration. It attaches one primitive\nper pane. Each pane gets its own labeled, keyboard-focusable semantic layer.\nThe plugin handles every series in a pane, so multi-series and multi-pane\ncharts work out of the box.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-accessibility\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { addAccessibilityPlugin } from '@tradingview/lwc-plugin-accessibility';\n\nconst chart = createChart(document.getElementById('chart'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(myData);\n\nconst accessibility = addAccessibilityPlugin(chart, {\n    chartTitle: 'Apple daily close',\n});\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-accessibility\": \"https://unpkg.com/@tradingview/lwc-plugin-accessibility/dist/accessibility.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { addAccessibilityPlugin } from '@tradingview/lwc-plugin-accessibility';\n\nconst chart = createChart(document.getElementById('chart'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(myData);\n\nconst accessibility = addAccessibilityPlugin(chart, {\n    chartTitle: 'Apple daily close',\n});\n</script>\n```\n\n## Usage\n\nEnable the plugin for every current pane with one chart-level call:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { addAccessibilityPlugin } from '@tradingview/lwc-plugin-accessibility';\n\nconst chart = createChart(document.getElementById('chart'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(myData);\n\nconst accessibility = addAccessibilityPlugin(chart, {\n    chartTitle: 'Apple daily close',\n});\n```\n\n`chartTitle` is optional; without it every pane is announced with\n`messages.defaultChartTitle` (*\"Interactive financial chart\"*), distinguished by\na *\"Pane 2 of 2\"* suffix. For a multi-pane chart, pass a title resolver instead:\n\n```js\naddAccessibilityPlugin(chart, {\n    chartTitle: paneIndex => paneIndex === 0 ? 'Price' : 'Volume',\n});\n```\n\nTo turn it off again, detach the controller – the plugin restores the DOM to\nthe state it found it in:\n\n```js\naccessibility.detach();\n```\n\nCall `accessibility.refresh()` to attach it again (it re-attaches whatever panes\nthe chart has at that moment). Detach before `chart.remove()` where you can; the\nother order is safe too — `detach()` skips panes that are already gone.\n\nIf you need low-level control, you can still attach `AccessibilityPlugin`\ndirectly as a pane primitive. It takes `AccessibilityPaneOptions` and, as a\nsecond constructor argument, the index of the pane you attach it to (only needed\nfor a pane other than the first):\n\n```js\nimport { AccessibilityPlugin } from '@tradingview/lwc-plugin-accessibility';\n\nchart.panes()[1].attachPrimitive(\n    new AccessibilityPlugin({ chartTitle: 'Volume' }, 1)\n);\n```\n\nThat index is only used to find the pane before the layer exists: the first\ntime the chart draws the primitive it reports the pane it is really attached to,\nand the plugin follows that pane from then on, by identity, through reordering.\nAn index that does not match the pane you attached to therefore costs nothing\nbut a frame.\n\nA directly attached primitive keeps its own polite live region and takes a plain\nboolean `announceDataUpdates`; the chart-level `dataUpdates` settings only exist\non the helper.\n\n## What it does\n\n- **Semantic layer.** Each pane gets a labeled, keyboard-focusable overlay\n  (`role=\"application\"`, `aria-label`, `tabindex=\"0\"`), while the pane's table\n  scaffolding is marked presentational and the visual canvases are hidden from\n  assistive technology with `aria-hidden`. Focusable chart internals such as the\n  attribution link are removed from the tab order and hidden from the\n  accessibility tree.\n- **Keyboard navigation.** Users traverse every data point with the left/right\n  arrows and switch between the series in the pane with the up/down arrows. The\n  focused point is always paged into view, so the whole series is reachable by\n  keyboard even when only part of it is on screen.\n- **ARIA-live announcements.** The focused point, series changes, on-demand\n  summaries, the visible range after a zoom, markers on the focused point and\n  the active series' price lines are announced through a per-pane assertive live\n  region. Background\n  data updates go through a single polite live region shared by the whole chart,\n  so simultaneous updates in different panes never talk over each other\n  (`dataUpdates`, see below).\n- **A text alternative.** `T` renders the active series as a real `<table>` over\n  the pane, on demand (see below).\n- **Visible focus indicator.** The focused pane receives an outline, and an\n  optional focus ring is drawn over the active point. The point ring stays\n  aligned with the canvas as you scroll or zoom, and `syncCrosshair` moves the\n  chart's crosshair with it.\n- **Visible shortcuts & high contrast (opt-in).** With `showShortcuts: true`,\n  sighted keyboard users get a \"Press H\" hint on focus and an `H`-toggled\n  on-screen list of the controls. `highContrast` (default `'auto'`, following the\n  OS) restyles the plugin's own focus ring and overlay, and `onHighContrastChange`\n  lets you restyle the chart itself to match — for users who navigate by keyboard\n  or need higher contrast but don't use a screen reader.\n\n### Keyboard map\n\n| Key | Action |\n| --- | --- |\n| `Tab` | Move focus between panes / out of the chart |\n| `←` / `→` | Move to the previous / next data point |\n| `↑` / `↓` | Switch to the previous / next series in the pane |\n| `Page Up` / `Page Down` | Jump by `pageStep` points (default 10): `Page Up` forward in time, `Page Down` back — following the ARIA slider convention that `Page Up` increases the value |\n| `Home` / `End` | Jump to the first / last point |\n| `+` / `-` | Zoom the chart in / out |\n| `Enter` / `Space` | Announce a summary of the active series |\n| `T` | Show / hide the data as a table (see below) |\n| `Esc` | Close the open panel (table or shortcuts) |\n| `H` | Announce the controls, and — when `showShortcuts` is on — show / hide the visible shortcuts panel |\n\nThe letter keys are matched by physical key as well as by character, so `H` and\n`T` also work on non-Latin keyboard layouts. Remap anything with `keyBindings`:\n\n```js\naddAccessibilityPlugin(chart, {\n    keyBindings: {\n        s: 'summary',   // add a key\n        KeyD: 'viewAsTable', // by physical key\n        h: null,        // remove a built-in binding\n    },\n});\n```\n\n## Options\n\nAll options are optional and have sensible defaults. `addAccessibilityPlugin`\ntakes `AccessibilityOptions`, a single `AccessibilityPlugin` takes\n`AccessibilityPaneOptions`; the two differ only in the rows marked *chart-level*\nbelow.\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `chartTitle` | `string` — *chart-level:* `string \\| (paneIndex) => string` | `messages.defaultChartTitle` | Accessible name of the pane region. |\n| `showFocusIndicator` | `boolean` | `true` | Draw a visible focus ring on the active point. |\n| `focusIndicatorColor` | `string` | `'#2962FF'` | Color of the focus ring. |\n| `focusIndicatorSize` | `number` | `14` | Diameter of the focus ring, in CSS pixels. |\n| `dataUpdates` | *chart-level only:* `{ mode: 'active' \\| 'all' \\| 'none'; panes?: (paneIndex) => boolean; debounceMs?: number }` | `{ mode: 'active' }` | Which panes announce data updates, and how they combine (see below). |\n| `announceDataUpdates` | *pane-level only:* `boolean` | `true` | Whether this pane announces data updates. Set for you from `dataUpdates`. |\n| `updateDebounceMs` | *pane-level only:* `number` | `1000` | Window over which data changes are coalesced before being announced. Use `dataUpdates.debounceMs` at chart level. |\n| `updateMaxSeries` | `number` | `3` | Maximum number of changed series listed in one update announcement. |\n| `pageStep` | `number` | `10` | Points to jump with `Page Up` / `Page Down`. |\n| `zoomStep` | `number` | `0.2` | Fraction the visible range grows / shrinks per `+` / `-` keypress. |\n| `minZoomSpan` | `number` | `2` | Smallest visible span, in bars, that zooming in will produce. |\n| `dataScope` | `'all' \\| 'visible'` | `'visible'` | Whether the on-demand summary and data-update announcements describe the visible range or the full data set (see below). |\n| `priceFormatter` | `(value: number) => string` | chart `localization.priceFormatter`, else the active series price formatter | Formats values for announcements. |\n| `timeFormatter` | `(time: Time) => string` | chart `localization.timeFormatter`, else a locale-aware date | Formats times for announcements (uses the chart's `localization.locale`). |\n| `timeFormat` | `'auto' \\| 'date' \\| 'dateTime' \\| 'seconds' \\| 'time'` | `'auto'` | How much of a time the built-in formatter speaks. `'auto'` follows the chart's `timeScale.timeVisible` / `secondsVisible`, so intraday bars are distinguishable. Ignored when a `timeFormatter` is set. |\n| `valueAccessor` | `(point, series) => number \\| undefined` | `value`, else `close` | Reads the announced value out of a data point — needed for custom series (see below). |\n| `rangeAccessor` | `(point, series) => { high, low, open?, close? } \\| undefined` | the point's own `high` / `low` | Reads a point's high / low band, so a custom series is announced like an OHLC one. |\n| `seriesLabel` | `(series, index) => string` | series `title`, else `Series N` | Accessible label for each series. |\n| `keyBindings` | `Record<string, AccessibilityCommand \\| null>` | — | Key → command overrides, merged onto the built-in map. The key is a `KeyboardEvent.key` or `.code`; `null` removes a binding. |\n| `announceOnFocus` | `boolean` | `false` | Announce the visible range when the pane receives focus (an assertive message can interrupt the accessible name, hence off by default). |\n| `focusOnPointerDown` | `boolean` | `false` | Move the keyboard focus into the pane when the user presses a pointer on it. |\n| `syncCrosshair` | `boolean` | `false` | Move the chart's crosshair to the focused point (`chart.setCrosshairPosition`). |\n| `tableMaxRows` | `number` | `200` | Maximum number of rows rendered by the `T` table; the cap is spoken with the caption. |\n| `markers` | `(series) => readonly SeriesMarker<Time>[]` | — | The markers of a series, announced with the point they sit on. The library does not expose a series' markers, so pass the array you gave `createSeriesMarkers`. |\n| `announcePriceLines` | `boolean` | `true` | Append the active series' `priceLines()` to the `Enter` / `Space` summary. |\n| `onAnnounce` | `(message: string) => void` | — | Called with every string this pane announces — for captions, a transcript, or a test. |\n| `onFocusChange` | `(event: AccessibilityFocusEvent) => void` | — | Called whenever the active point or series changes, with the pane, series, point and value. |\n| `onSonify` | `(note: SonificationNote) => void` | — | Called for every focused point with the data a sonification needs. `createToneSonifier()` is a ready-made handler (see below). |\n| `describeChart` | `(context: DescribeChartContext) => string` | built-in summary | Generates the `Enter` / `Space` summary. The context carries `points` (already narrowed to `dataScope`), `series`, `label` and `scope`. |\n| `messages` | `PartialAccessibilityMessages` | English `defaultMessages` | Overrides for the announced text — translate some or all of it (see Localization). |\n| `lang` | `string` | chart `localization.locale` | BCP-47 `lang` set on the announced regions so screen readers use the right voice. |\n| `showShortcuts` | `boolean` | `false` | Show a visible keyboard-shortcuts overlay (focus hint + `H`-toggled panel) for sighted keyboard users (see below). |\n| `highContrast` | `boolean \\| 'auto'` | `'auto'` | High-contrast styling for the plugin's own focus ring / outline / overlay. `'auto'` follows the OS `prefers-contrast` / `forced-colors`; pass a boolean to drive it from your own setting. |\n| `onHighContrastChange` | `(enabled: boolean) => void` | — | Called when the resolved high-contrast state changes (and once on attach), so you can restyle the chart's own series / grid / font to match. |\n\nOptions can be changed at runtime. Use the controller's\n`accessibility.applyOptions({ ... })` for chart-level changes (`chartTitle`,\n`dataUpdates`, `messages`, `lang`, `highContrast`, …): it updates every pane\n**and** the shared update region together. A single primitive also has its own\n`plugin.applyOptions({ ... })` for per-pane tweaks (e.g. `dataScope`), but that\ndoes not reach the chart-level shared update region — use the controller for\n`dataUpdates` / `messages` / `lang`.\n\n### Scoping announcements to the visible range\n\nKeyboard navigation always covers the whole series – the arrow keys page the\nchart so every point is reachable regardless of this setting. `dataScope` only\ncontrols what the *summaries* describe.\n\nBy default (`dataScope: 'visible'`) the on-demand summary (`Enter` / `Space`) and\nthe background data-update announcements describe only the points within the\ncurrent visible range – for example *\"65 data points in view\"*. This is the\nrecommended setting for charts with large data sets because it keeps those\nsummaries focused on what the user is currently inspecting. The update\nannouncement's *\"Latest\"* value is the one exception: it always reports the\nseries' newest bar – the bar the update actually changed – even when that bar\nis outside the visible range.\n\nUse `dataScope: 'all'` when you want the summary and update announcements to\ndescribe the full data set, even if only part of the history is visible.\n\nPer-point announcements always report the absolute position (*\"Point 247 of\n500\"*) so the user knows where they are in the whole series.\n\n### Announcing data updates\n\nWhen a chart streams live data, several panes can update in the same tick. Each\npane keeps its own assertive region for navigation, but all *data-update*\nannouncements go through **one** polite region shared by the whole chart, so the\nupdates never talk over each other.\n\n`dataUpdates` (on `addAccessibilityPlugin`) chooses which panes speak:\n\n```js\naddAccessibilityPlugin(chart, {\n    dataUpdates: { mode: 'active', debounceMs: 1500 },\n});\n```\n\n- `mode: 'active'` (the default): only the **last-focused** pane announces (pane 0\n  until you focus one). Navigating the volume pane, for example, makes its updates\n  the ones you hear; otherwise you hear the main pane.\n- `mode: 'all'`: every pane announces; simultaneous updates are combined into a\n  single message in pane order (*\"Chart data updated. 3 series changed. …\"*).\n- `mode: 'none'`: no update announcements.\n- `panes: (paneIndex) => boolean`: restricts announcements to the panes the\n  predicate accepts, on top of `mode`.\n- `debounceMs`: how long changes are coalesced before being announced (default\n  `1000`). A live feed can tick far faster than a screen reader can speak.\n\nSwitch this at runtime through the controller —\n`accessibility.applyOptions({ dataUpdates: { mode: 'all' } })` — which\nreconfigures the shared region's mode; a per-pane `plugin.applyOptions` cannot\nchange it.\n\nA directly-attached `AccessibilityPlugin` (without the helper) takes a plain\nboolean `announceDataUpdates` with its own `updateDebounceMs`, and uses its own\npolite region.\n\n## View as table\n\nPressing `T` renders the active series into a real `<table>` over the pane —\nthe text alternative WCAG asks for, and the most requested way to read a chart\nwithout navigating it point by point. The rows follow `dataScope`, are capped at\n`tableMaxRows` (the cap is announced), and use OHLC columns whenever the points\ncarry a high / low band. `Esc` (or `T` again) closes it. The table is built only\nwhile it is open, so a 50,000-bar series costs nothing until it is asked for.\nIts column headers and caption come from the `messages` bundle\n(`tableColumns`, `tableCaption`, `tableTruncated`, `tableClose`).\n\n## Custom series\n\nA custom series' data shape is only known to its author, so the plugin cannot\nguess where the value is. Without help every point of a custom series announces\n*\"no value\"* and the focus ring has nowhere to go. Point the plugin at the right\nfield:\n\n```js\naddAccessibilityPlugin(chart, {\n    valueAccessor: point => (point.high + point.low) / 2,\n    // Optional: announce it like an OHLC series and report true extremes.\n    rangeAccessor: point => ({ high: point.high, low: point.low }),\n});\n```\n\nBoth are called for every series in the pane; return `undefined` to fall back to\nthe built-in extraction (`value`, then `close`), so a chart mixing built-in and\ncustom series needs only the custom branch.\n\n## Following along: crosshair, captions and sound\n\n- `syncCrosshair: true` moves the chart's crosshair with the keyboard, so a\n  sighted user can follow a screen-reader user point by point.\n- `onAnnounce` receives every string this pane speaks, in order — mirror it into\n  captions, a transcript, or an assertion in a test.\n- `onFocusChange` reports the pane, series, point index and value whenever the\n  focus moves, for your own status bar or analytics.\n- `onSonify` receives each focused point with its position in the series' value\n  range. `createToneSonifier()` is a ready-made handler that plays a short tone\n  whose pitch follows the value, so holding `→` plays the series:\n\n```js\nimport { addAccessibilityPlugin, createToneSonifier } from '@tradingview/lwc-plugin-accessibility';\n\nconst sonifier = createToneSonifier();\naddAccessibilityPlugin(chart, { onSonify: sonifier });\n// sonifier.dispose() releases the AudioContext.\n```\n\nThe `AudioContext` is created on the first note (after a key press, so the\nbrowser's autoplay policy is satisfied) and reused afterwards.\n\n## Localization\n\nOut of the box the announcements are English, but **numbers and dates follow the\nchart's locale** and **every spoken string is translatable**.\n\n**Numbers and dates** come from the chart's\n[`localization`](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/LocalizationOptions):\ndates use `localization.locale`, the summary's percentage uses it via\n`Intl.NumberFormat`, and if you set `localization.priceFormatter` /\n`localization.timeFormatter` the announcements use those too. So a chart you have\nalready localized (see the\n[Custom locale](https://tradingview.github.io/lightweight-charts/tutorials/demos/custom-locale)\nand [Price format](https://tradingview.github.io/lightweight-charts/tutorials/customization/price-format)\ntutorials) gets localized announcements for free. You can still override per\nplugin with `priceFormatter` / `timeFormatter`.\n\n**Strings** are supplied through the `messages` bundle. Every announced sentence\nis a formatter function (so a translation controls word order and pluralization);\natomic words are plain strings. Pass a partial override — anything you leave out\nstays English:\n\n```js\nimport { addAccessibilityPlugin } from '@tradingview/lwc-plugin-accessibility';\n\naddAccessibilityPlugin(chart, {\n    chartTitle: 'Gráfico de precios',\n    lang: 'es',\n    messages: {\n        ohlc: { close: 'cierre' }, // only some keys — the rest stay English\n        point: ({ position, total, time, label, values }) =>\n            `${label} ${values}, ${time}. Punto ${position} de ${total}.`,\n        help: ({ multiSeries }) =>\n            `Controles de teclado. Las flechas izquierda y derecha se mueven entre los puntos de datos. ${multiSeries ? 'Las flechas arriba y abajo cambian de serie. ' : ''}Intro o Espacio lee un resumen de la serie.`,\n    },\n});\n```\n\n`lang` sets the BCP-47 `lang` attribute on the announced regions so a screen\nreader pronounces them with the right voice; it defaults to\n`localization.locale`. `messages`/`lang` are uniform across panes. To switch\nlanguage at runtime, call `accessibility.applyOptions({ messages, lang })` on the\ncontroller — it updates every pane and the shared update region together.\n\nA complete Spanish bundle ships with the package as `esMessages`, both as a\nready-made translation and as a template for your own:\n\n```js\nimport { addAccessibilityPlugin, esMessages } from '@tradingview/lwc-plugin-accessibility';\n\naddAccessibilityPlugin(chart, { messages: esMessages, lang: 'es' });\n```\n\n`defaultMessages` is the English bundle. It is **frozen and read-only** — write a\ntranslation by passing your own entries through `messages` (they are merged onto\n`defaultMessages`), never by mutating it. `paneLabel` receives `paneIndex` and\n`paneCount` alongside the title, so a translation can keep multi-pane titles\ndistinguishable, and `defaultChartTitle` is the fallback used when `chartTitle`\nis unset.\n\nThe precedence for the overridable pieces:\n\n- **value:** `priceFormatter` → chart `localization.priceFormatter` → series formatter\n- **time:** `timeFormatter` → chart `localization.timeFormatter` → locale-aware date\n- **summary:** `describeChart` (full override) → `messages.summary`\n- **strings:** your `messages` entry → English `defaultMessages`\n\n## Visible shortcuts and high contrast\n\nThese help users who navigate by keyboard, or need higher contrast, but don't use\na screen reader.\n\n**Shortcuts overlay** — set `showShortcuts: true`. While the pane is focused a\nsmall *\"Press H for keyboard shortcuts\"* hint is shown; `H` toggles an on-screen\npanel listing the controls. It is `aria-hidden` (screen-reader\nusers already get the spoken `H` help) and its text comes from the `messages`\nbundle (`shortcutsHint`, `shortcutsTitle`, `shortcuts`), so it localizes with the\nrest. The overlay text is sized in `rem`, so it scales with the page/browser font.\n\n**High contrast** — `highContrast` (`boolean | 'auto'`, default `'auto'`) controls\nthe plugin's *own* visuals (focus ring, focus outline, the overlay). `'auto'`\nfollows the OS `prefers-contrast` / `forced-colors` and updates live; to wire it\nto your own app setting, pass a boolean and keep it in step with\n`accessibility.applyOptions({ highContrast })`.\n\nThe plugin deliberately does **not** restyle the chart's series, grid or font —\nthat's the chart theme's job (see the\n[Readability](https://tradingview.github.io/lightweight-charts/tutorials/a11y/readability)\ntutorial). Instead it calls `onHighContrastChange(enabled)` whenever the state\nchanges (and once on attach) so you can apply your own high-contrast chart theme\nin one place:\n\n```js\naddAccessibilityPlugin(chart, {\n    showShortcuts: true,\n    onHighContrastChange: enabled => {\n        chart.applyOptions({ layout: { textColor: enabled ? '#000' : '#222' } });\n        series.applyOptions({ lineWidth: enabled ? 4 : 2 });\n    },\n});\n```\n\nThe example wires both of these up (the \"Enable high contrast\" and \"Large font\"\nbuttons).\n\n## Performance\n\nThe plugin uses an **active-point-only** strategy: it never mirrors every data\npoint into the DOM. Regardless of whether a series holds 500 or 50,000 bars each\npane adds only a small fixed set of nodes (a semantic overlay, a visually-hidden\ndescription, an assertive live region, a focus ring and — when `showShortcuts` is\non — the shortcuts hint and panel), plus one polite live region shared across the\nwhole chart for data-update announcements.\n\nData stays in sync through one `subscribeDataChanged` listener per series.\nScrolling and zooming reposition the focus ring with coordinate lookups; they\ndo not copy series data. Data-change events invalidate a shared snapshot because\nthey do not distinguish a tail tick from a historical correction or `pop()`.\n\nAn unfocused pane reads data only when its debounced announcement is prepared.\nWith update announcements disabled, it defers the read until keyboard focus\nreturns. Focused navigation refreshes immediately after a data change and shares\nthat snapshot with announcement statistics. Each refresh is proportional to the\nseries length; visible-point counts use binary searches within the snapshot, so\nwhitespace and gaps supplied by other series do not inflate the count.\n\n## CSS class hooks\n\nEvery element the plugin injects carries a stable class name, so you can restyle\nthe layer from your own stylesheet. These names are part of the public API and\nwill not change without a major version:\n\n| Class | Element |\n| --- | --- |\n| `lw-chart-a11y-layer` | The focusable semantic overlay per pane (`role=\"application\"`). |\n| `lw-chart-a11y-description` | Visually hidden pane description (`aria-describedby` target). |\n| `lw-chart-a11y-live-region` | Per-pane assertive region for navigation announcements. |\n| `lw-chart-a11y-status-region` | Per-pane polite region, only present on a directly attached primitive. |\n| `lw-chart-a11y-shared-status-region` | The single chart-level polite region created by `addAccessibilityPlugin`. |\n| `lw-chart-a11y-focus-ring` | The visible focus ring drawn over the active point. |\n| `lw-chart-a11y-shortcuts-hint` | The \"Press H\" hint (`showShortcuts`). |\n| `lw-chart-a11y-shortcuts-panel` | The `H`-toggled shortcuts panel (`showShortcuts`). |\n| `lw-chart-a11y-data-table` | The `T`-toggled table panel. |\n\nThe plugin sets its own geometry and colors inline, so an inline style wins over\na plain rule — use `!important`, or restyle through the options where one exists\n(`focusIndicatorColor`, `focusIndicatorSize`, `highContrast`).\n\n## Notes & limitations\n\n- Built-in series work out of the box: OHLC series announce their open / high /\n  low / close, value series announce their value. A **custom series** needs\n  `valueAccessor` (and optionally `rangeAccessor`), because only its author knows\n  where its value lives.\n- Series **and panes** added or removed at runtime are picked up automatically:\n  the controller reconciles its layers with `chart.panes()` on the next redraw\n  and attaches or detaches only the difference, so the focus of the panes that\n  were already there is never disturbed. `controller.refresh()` forces that check\n  immediately and is rarely needed.\n- The library forces `direction: ltr` on the chart element, so the plugin reads\n  the writing direction from the element you created the chart in: on a\n  right-to-left page its panels sit on the leading (right) side.\n- Series in a pane do not need to share timestamps. Navigation is aligned by\n  *time* on the chart's shared time scale: switching series with the up / down\n  arrows keeps the focused time (the nearest point in the new series is\n  selected and paged into view), and the visible-range scoping follows each\n  series' own data.\n- The plugin provides the semantic layer and keyboard model. Visual contrast and\n  font-scaling (covered in the\n  [Readability](https://tradingview.github.io/lightweight-charts/tutorials/a11y/readability)\n  part of the tutorial) remain the responsibility of your chart theme.\n- The API is typed for a `Time`-based chart (`IChartApi`), not the generic\n  `IChartApiBase<HorzScaleItem>`. The announcements format UTC timestamps and\n  business days and the navigation maps points through the `Time` scale, so every\n  internal path assumes `Time`; a custom horizontal scale is not supported.\n- Always validate with real assistive technology (VoiceOver, NVDA) as part of\n  your own accessibility testing before shipping.\n\n<!-- File: packages/lwc-plugin-anchored-text/README.md (Tokens: ~1848 | Category: plugin-manifest) -->\n# Anchored text\n\nA single line of text anchored to an edge, a corner or the center of a pane,\nas a [series primitive](https://tradingview.github.io/lightweight-charts/docs/plugins/series-primitives)\n(`AnchoredText`) or as a\n[pane primitive](https://tradingview.github.io/lightweight-charts/docs/plugins/pane-primitives)\n(`AnchoredTextPane`). The text keeps its place while the chart scrolls and\nzooms, inset from the pane edges by a margin you choose. The text, its anchor,\nmargins, font, color, layer and visibility can all be changed after the\nprimitive has been attached.\n\nThe series primitive belongs to the series it is attached to: it lives in that\nseries' pane and is removed together with the series. The pane primitive needs\nno series at all.\n\nUse it for a chart title, a symbol or interval label, a data-source credit, or\na \"preview\" or \"draft\" stamp.\n\n> **Lightweight Charts™ 5 also ships a built-in text watermark.**\n> [`createTextWatermark(pane, options)`](https://tradingview.github.io/lightweight-charts/docs/api/functions/createTextWatermark)\n> is a pane primitive which draws one or more lines of text, centered by default\n> and scaled down to fit the pane. If that is all you need, the built-in\n> function is the right choice. Use this package for text tied to a specific\n> series rather than to a pane, or for what the built-in does not offer:\n> margins from the pane edge, a CSS `font` shorthand, `zOrder` and\n> `setText`.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-anchored-text\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { AnchoredText } from '@tradingview/lwc-plugin-anchored-text';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(data);\n\nseries.attachPrimitive(new AnchoredText({ text: 'BTC/USD · 1D' }));\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-anchored-text\": \"https://unpkg.com/@tradingview/lwc-plugin-anchored-text/dist/anchored-text.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { AnchoredText } from '@tradingview/lwc-plugin-anchored-text';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(data);\n\nseries.attachPrimitive(new AnchoredText({ text: 'BTC/USD · 1D' }));\n</script>\n```\n\n## Usage\n\n### On a series\n\nCreate the text, then attach it to the series whose pane it should sit in:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { AnchoredText } from '@tradingview/lwc-plugin-anchored-text';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(data);\n\nconst title = new AnchoredText({\n    text: 'BTC/USD · 1D',\n    horzAlign: 'right',\n    vertAlign: 'top',\n    font: 'bold 16px sans-serif',\n    color: '#2962FF',\n});\nseries.attachPrimitive(title);\n```\n\nTo remove the text, detach it from the series:\n\n```js\nseries.detachPrimitive(title);\n```\n\n### On a pane\n\n`AnchoredTextPane` takes the same options and is attached to a pane instead\nof a series. Use it when the text should stay put while series are added and\nremoved:\n\n```js\nimport { AnchoredTextPane } from '@tradingview/lwc-plugin-anchored-text';\n\nconst title = new AnchoredTextPane({ text: 'Volume', vertAlign: 'bottom' });\nchart.panes()[1].attachPrimitive(title);\n\n// later\nchart.panes()[1].detachPrimitive(title);\n```\n\n### Changing the text\n\nBoth classes have the same methods:\n\n```js\ntitle.applyOptions({ horzAlign: 'center', color: '#787B86' });\ntitle.setText('ETH/USD · 1D'); // same as applyOptions({ text })\ntitle.options(); // the current options, with the defaults filled in\n```\n\n`applyOptions` merges: an option which is not passed, or is passed as\n`undefined`, is left unchanged. The one exception is `lineHeight`: passing\n`lineHeight: undefined` goes back to measuring the height from the font.\n\n## Options\n\nOptions are passed as the constructor argument, which is optional, as is every\noption in it. The type is `AnchoredTextOptions`, and the defaults are exported\nas `defaultOptions`.\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `text` | `string` | `''` | The line of text. An empty string draws nothing. |\n| `horzAlign` | `'left' \\| 'center' \\| 'right'` | `'left'` | Which side of the pane the text is anchored to, or centered. |\n| `vertAlign` | `'top' \\| 'center' \\| 'bottom'` | `'top'` | Which edge of the pane the text is anchored to, or centered. |\n| `horzMargin` | `number` | `20` | Distance from the left or right pane edge, in CSS pixels. Not used when `horzAlign` is `'center'`. |\n| `vertMargin` | `number` | `10` | Distance from the top or bottom pane edge, in CSS pixels. Not used when `vertAlign` is `'center'`. |\n| `font` | `string` | `bold 14px` system sans-serif | Font, as a CSS `font` shorthand. |\n| `lineHeight` | `number` | — (measured) | Height of the text, in CSS pixels. Measured from the font when not set. |\n| `color` | `string` | `'#131722'` | Text color. |\n| `visible` | `boolean` | `true` | Whether the text is drawn at all. |\n| `zOrder` | `'bottom' \\| 'normal' \\| 'top'` | `'normal'` | Layer the text is drawn in. `'normal'` draws it with the series, under the crosshair; `'top'` puts it over everything in the pane, the crosshair included; `'bottom'` puts it behind the series. |\n\n### Alignment and margins\n\nThe text is placed against the anchored edge of its pane, `horzMargin` and\n`vertMargin` away from it. A centered axis ignores its margin. With a\n`lineHeight` the text's baseline sits at the bottom of that height, as it did\nin the `plugin-examples` version; without one the height is that of the font,\nso it does not change with the text, and the baseline sits at the font's\nascent.\n\n## Notes\n\n- The text is drawn on one line, as given. It is neither wrapped nor scaled:\n  text wider than the pane is clipped at the pane edge. The built-in\n  `createTextWatermark` scales its text down to fit, if that is what you need.\n- The text appears only in the pane it belongs to. It never covers the price\n  scales or the time scale, and a visible left price scale or a second pane\n  does not move it.\n- Sizes are in CSS pixels; the text is drawn in the media coordinate space, so\n  it stays sharp at any device pixel ratio.\n- `'middle'` is still accepted as a value of `horzAlign` and `vertAlign`, the\n  spelling used in the `plugin-examples` collection, and is read as `'center'`.\n  It is kept for compatibility and will be removed in a future major version.\n\n<!-- File: packages/lwc-plugin-background-shade-series/README.md (Tokens: ~2089 | Category: plugin-manifest) -->\n# Background shade series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series)\nthat shades the full height of the pane behind each bar. The shade is mixed\nfrom two colors by where the bar's value sits between a low and a high value,\nso the background follows an indicator while the price series stays readable\non top of it.\n\nUse it to show a regime or a reading behind the price: an oscillator, the\nshare of up days, volatility, a sentiment score, or a session's volume\nrelative to normal.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-background-shade-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { createBackgroundShadeSeries } from '@tradingview/lwc-plugin-background-shade-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst line = chart.addSeries(LineSeries);\nline.setData([\n    { time: '2024-04-22', value: 101.2 },\n    { time: '2024-04-23', value: 102.8 },\n    { time: '2024-04-24', value: 100.9 },\n]);\n\nconst shade = createBackgroundShadeSeries(chart, {\n    lowColor: '#F23645',\n    highColor: '#089981',\n    opacity: 0.25,\n});\nshade.setData([\n    { time: '2024-04-22', value: 35 },\n    { time: '2024-04-23', value: 70 },\n    { time: '2024-04-24', value: 20 },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-background-shade-series\": \"https://unpkg.com/@tradingview/lwc-plugin-background-shade-series/dist/background-shade-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { createBackgroundShadeSeries } from '@tradingview/lwc-plugin-background-shade-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst line = chart.addSeries(LineSeries);\nline.setData([\n    { time: '2024-04-22', value: 101.2 },\n    { time: '2024-04-23', value: 102.8 },\n    { time: '2024-04-24', value: 100.9 },\n]);\n\nconst shade = createBackgroundShadeSeries(chart, {\n    lowColor: '#F23645',\n    highColor: '#089981',\n    opacity: 0.25,\n});\nshade.setData([\n    { time: '2024-04-22', value: 35 },\n    { time: '2024-04-23', value: 70 },\n    { time: '2024-04-24', value: 20 },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `createBackgroundShadeSeries`, then set data with a\n`value` per bar:\n\n```js\nconst shade = createBackgroundShadeSeries(chart, {\n    lowColor: 'rgb(50, 50, 255)',\n    highColor: 'rgb(255, 50, 50)',\n    lowValue: 0,\n    highValue: 100,\n    opacity: 0.8,\n});\n\nshade.setData([\n    { time: '2024-04-22', value: 35 },\n    { time: '2024-04-23', value: 120 },\n    { time: '2024-04-24' },\n    { time: '2024-04-25', value: 50, color: '#131722' },\n]);\n```\n\nEach data point is `{ time, value }`:\n\n- A value of `lowValue` gets `lowColor`, a value of `highValue` gets\n  `highColor`, and a value in between a mix of the two. Values beyond the\n  range get the color of the nearer end. `lowValue` may be the larger of the\n  two. With `lowValue` equal to `highValue` the shading becomes a two-color\n  threshold: values below it get `lowColor` and the rest `highColor`.\n- A point without a finite `value`, `null` and `NaN` included, is whitespace\n  and leaves its slot unshaded.\n- A `color` on a point shades that bar with it, whatever its value. A color\n  the canvas does not accept is ignored, and the bar is shaded from its value.\n  The series' own `color` option is not drawn; it is empty by default, and a\n  point whose `color` equals it is shaded from its value.\n\n`lowColor` and `highColor` can be hex, `rgb()`, `rgba()`, `hsl()` or named\ncolors. They are mixed with premultiplied alpha, as CSS gradients are, so a\ntransparent end, `'transparent'` included, fades the other color out. A color\nthat cannot be parsed, or one in another color space such as `oklch()`, falls\nback to the default for that end.\n\nThe series shades the full height of its pane and takes no part in the price\nscale. It sits on a price scale of its own, `'background-shade'`, an overlay\nscale with nothing drawn on it, so it never sets the number format of the\nprice axis; its values never change any autoscale range; and it has no price\nline or last value label. It still draws when it is the only series in the\nchart. It is never reported as hovered, so it does not get in the way of the\nseries on top of it.\n\n## Creating a series\n\nUse `createBackgroundShadeSeries(chart, options?, paneIndex?)`. It adds the\nseries and moves it behind every other series in its pane with\n`series.setSeriesOrder(0)`, so it reads as a background whatever order the\nseries are added in. `setSeriesOrder` arrived in `lightweight-charts` 5.0.6;\non older versions the series keeps the order it was added in, so add it\nbefore the others.\n\nMoving the series to another pane, with `series.moveToPane`, puts it on top\nof that pane's series, as for any series; call `series.setSeriesOrder(0)`\nagain afterwards.\n\nThe `BackgroundShadeSeries` class remains available for\n`chart.addCustomSeries(new BackgroundShadeSeries(), options)`. Added that way,\nit gets the same options, its own price scale included, but is drawn in the\norder it was added: added after the main series, an opaque shade covers it.\nAdd it first, or call `series.setSeriesOrder(0)`.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `lowColor` | `string` | `'rgb(50, 50, 255)'` | Shade of a bar whose value is `lowValue`, or beyond it. |\n| `highColor` | `string` | `'rgb(255, 50, 50)'` | Shade of a bar whose value is `highValue`, or beyond it. |\n| `lowValue` | `number` | `0` | Value shaded with `lowColor`. |\n| `highValue` | `number` | `100` | Value shaded with `highColor`. |\n| `opacity` | `number` | `0.8` | Opacity of the whole shading, `0`–`1`, on top of any alpha in the colors. |\n\n`priceLineVisible` and `lastValueVisible` default to `false`, since the series\nhas no value on the price scale, and `priceScaleId` to `'background-shade'`.\nSetting `priceScaleId` to `'right'` or `'left'` puts the shade on a visible\nscale, where, being the bottom series, it would set that scale's number\nformat; it still never changes the scale's range.\n\n## Notes\n\n- Each bar is shaded across one bar spacing centered on it, in whole device\n  pixels, so the slots of consecutive bars abut with no seam and no overlap at\n  every zoom level and device pixel ratio. Time points that only other series\n  have stay unshaded: daily values over hourly candles, say, shade one slot a\n  day. On `lightweight-charts` 5.1 and later, while the chart conflates data, a\n  conflated bar's column is as wide as the slots it stands for, centered where\n  the chart places the bar, and it keeps the later of the two values it\n  merges.\n- Only the bars on screen are drawn. Their shades come from 256 steps between\n  the two end colors, worked out when the colors change, so no color is\n  mixed while drawing.\n- The shading covers its own pane only. To shade another pane, add a second\n  series to it with the `paneIndex` argument.\n\n<!-- File: packages/lwc-plugin-box-whisker-series/README.md (Tokens: ~2138 | Category: plugin-manifest) -->\n# Box and whisker series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series)\nthat draws a box plot per time point: a box from the first to the third\nquartile split at the median, whiskers out to the `min` and `max` you give,\nand a dot for each outlier you list beyond them. Where the whiskers end is\nyours to decide, such as 1.5 times the interquartile range or the 5th and\n95th percentiles, and the values past them are the outliers.\n\nUse it to show how a distribution changes over time rather than a single\nvalue: intraday price distribution per day, latency percentiles per hour,\nor the spread of forecasts per period.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-box-whisker-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createBoxWhiskerSeries } from '@tradingview/lwc-plugin-box-whisker-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createBoxWhiskerSeries(chart);\n\nseries.setData([\n    { time: '2024-04-22', min: 55, q1: 70, median: 80, q3: 85, max: 95 },\n    { time: '2024-04-23', min: 50, q1: 70, median: 78, q3: 83, max: 90, outliers: [40] },\n    { time: '2024-04-24', min: 58, q1: 68, median: 75, q3: 85, max: 90 },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-box-whisker-series\": \"https://unpkg.com/@tradingview/lwc-plugin-box-whisker-series/dist/box-whisker-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createBoxWhiskerSeries } from '@tradingview/lwc-plugin-box-whisker-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createBoxWhiskerSeries(chart);\n\nseries.setData([\n    { time: '2024-04-22', min: 55, q1: 70, median: 80, q3: 85, max: 95 },\n    { time: '2024-04-23', min: 50, q1: 70, median: 78, q3: 83, max: 90, outliers: [40] },\n    { time: '2024-04-24', min: 58, q1: 68, median: 75, q3: 85, max: 90 },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `createBoxWhiskerSeries`, then set data with five\nnumbers per point:\n\n```js\nconst series = createBoxWhiskerSeries(chart, {\n    whiskerColor: '#131722',\n    lowerBoxColor: '#90BFF9',\n    upperBoxColor: '#2962FF',\n    medianColor: '#FFFFFF',\n    outlierColor: '#F23645',\n});\n\nseries.setData([\n    { time: '2024-04-22', min: 55, q1: 70, median: 80, q3: 85, max: 95 },\n    { time: '2024-04-23', min: 50, q1: 70, median: 78, q3: 83, max: 90, outliers: [40, 100] },\n    { time: '2024-04-24' },\n    { time: '2024-04-25', min: 58, q1: 68, median: 75, q3: 85, max: 90, upperBoxColor: '#F23645' },\n]);\n```\n\nEach data point is `{ time, min, q1, median, q3, max, outliers? }`:\n\n- The whiskers run from `min` to `q1` and from `q3` to `max`, and the box from\n  `q1` to `q3`, split at the `median` into a lower and an upper half.\n- `outliers` holds the values beyond the whiskers, each drawn as a dot. `null`\n  means none, and an outlier which is not a finite number is not drawn.\n- A point without five finite numbers, a missing or `null` one included, is\n  whitespace: it keeps its place on the time scale, is not drawn, and takes\n  no part in the price scale.\n- `whiskerColor`, `lowerBoxColor`, `upperBoxColor`, `medianColor` and\n  `outlierColor` on a point override the series options of the same names\n  for that point.\n\nThe autoscale range covers the lowest and the highest of the five numbers and\nthe outliers, so every dot is in view, and a point whose numbers are not in\norder still fits on the scale.\n\nThe series' price line and last value label follow the median of the last\npoint. Options can be changed at runtime with `series.applyOptions({ ... })`.\n\nIn the `plugin-examples` collection this series was `WhiskerBoxSeries`, with a\n`quartiles` array instead of the five named numbers and `lowerQuartileFill` /\n`upperQuartileFill` for the box colors. The package was never published under\nthose names, so it does not keep them.\n\n## Creating a series\n\nUse `createBoxWhiskerSeries(chart, options?, paneIndex?)`. It adds a\n`BoxWhiskerSeries` with `chart.addCustomSeries` and returns the normal series\nAPI, typed `BoxWhiskerSeriesApi`, with the plugin's data and options types\npreserved. The `BoxWhiskerSeries` class remains available for\n`chart.addCustomSeries(new BoxWhiskerSeries(), options)` too; no option\nchanges the plot values, so both behave the same.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `whiskerColor` | `string` | `'rgba(106, 27, 154, 1)'` | Color of the whiskers and their end caps. |\n| `lowerBoxColor` | `string` | `'rgba(103, 58, 183, 1)'` | Fill of the lower half of the box, from `q1` to the median. |\n| `upperBoxColor` | `string` | `'rgba(233, 30, 99, 1)'` | Fill of the upper half of the box, from the median to `q3`. |\n| `medianColor` | `string` | `'rgba(106, 27, 154, 1)'` | Color of the median line across the box. |\n| `outlierColor` | `string` | `'rgba(149, 152, 161, 1)'` | Color of the outlier dots. |\n\nThe standard `color` option is not used for the box plots; it colors the\nseries' price line.\n\n## Notes\n\n- The box is as wide as a candlestick body at the same bar spacing, and every\n  part is centered on the whisker line in whole device pixels, the way the\n  built-in candlestick centers its body on the wick. The median line spans\n  the slot, each whisker cap is as wide as a candlestick body at half the bar\n  spacing, and outlier dots shrink with the box down to a 1.5 px radius, so\n  they stay visible when the chart is zoomed out.\n- Only the points on screen are drawn. The series is never conflated: with\n  `timeScale.enableConflation` on, the chart still draws every point.\n- On `lightweight-charts` 5.2 and later the series reports the part under the\n  pointer through `hitTest`, within the series' `hitTestTolerance` (3 px by\n  default). The crosshair event's `hoveredInfo.objectId` is `'box-<point>'`,\n  `'median-<point>'`, `'whisker-<point>'` or `'outlier-<point>-<index>'`,\n  where `<point>` is the point's position in `series.data()` and `<index>`\n  the index into its `outliers`. Elsewhere in a point's slot, between its\n  lowest and highest value, the chart's own fallback still reports the series\n  as hovered, without an `objectId`, so check `objectId` before reading it.\n  The median line, drawn over the box, is reported on its own row of pixels.\n  An outlier dot is reported as a point and the box and the lines as ranges,\n  so a candle body the pointer is inside wins over a whisker it is only near.\n  Older versions never call `hitTest`.\n\n<!-- File: packages/lwc-plugin-brushable-area-series/README.md (Tokens: ~2592 | Category: plugin-manifest) -->\n# Brushable area series\n\nAn area series that can style parts of the data differently. You set a base\nstyle for the whole series and any number of *brush ranges*. A brush range is\na span of data points with its own line and fill colors.\n\nThe series itself only draws the styles. Attach the optional\n`BrushableAreaInteraction` primitive, or add your own pointer handling, to turn\nit into a brush selection: the user drags across the chart, the brush range for\nthe selected span is set, and the rest of the series keeps the base style.\nGive `outsideStyle` a semi-transparent style to get the classic effect where\nthe selection stays vivid and the rest looks faded.\n\nUse it for range selection on a sparkline or an overview chart. It also fits\nhighlighting a period, such as a trading session, an event window, or a\nbacktest sample, and comparing segments of one series visually.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-brushable-area-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createBrushableAreaSeries } from '@tradingview/lwc-plugin-brushable-area-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createBrushableAreaSeries(chart, {\n    lineColor: 'rgb(41, 98, 255)',\n    topColor: 'rgba(41, 98, 255, 0.4)',\n    bottomColor: 'rgba(41, 98, 255, 0)',\n    priceLineVisible: false,\n});\nseries.setData(data); // [{ time, value }, ...]\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-brushable-area-series\": \"https://unpkg.com/@tradingview/lwc-plugin-brushable-area-series/dist/brushable-area-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createBrushableAreaSeries } from '@tradingview/lwc-plugin-brushable-area-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createBrushableAreaSeries(chart, {\n    lineColor: 'rgb(41, 98, 255)',\n    topColor: 'rgba(41, 98, 255, 0.4)',\n    bottomColor: 'rgba(41, 98, 255, 0)',\n    priceLineVisible: false,\n});\nseries.setData(data); // [{ time, value }, ...]\n</script>\n```\n\n## Usage\n\nAdd the [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series) with `createBrushableAreaSeries`, set single-value data, then set\n`brushRanges` whenever the selection changes:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createBrushableAreaSeries } from '@tradingview/lwc-plugin-brushable-area-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createBrushableAreaSeries(chart, {\n    lineColor: 'rgb(41, 98, 255)',\n    topColor: 'rgba(41, 98, 255, 0.4)',\n    bottomColor: 'rgba(41, 98, 255, 0)',\n    priceLineVisible: false,\n});\nseries.setData(data); // [{ time, value }, ...]\n\n// Highlight points 40–80 in green and fade everything else.\nseries.applyOptions({\n    brushRanges: [\n        {\n            range: { from: 40, to: 80 },\n            style: {\n                lineColor: '#089981',\n                topColor: 'rgba(8, 153, 129, 0.4)',\n                bottomColor: 'rgba(8, 153, 129, 0)',\n                lineWidth: 3,\n            },\n        },\n    ],\n    outsideStyle: {\n        lineColor: 'rgba(41, 98, 255, 0.2)',\n        topColor: 'rgba(41, 98, 255, 0.05)',\n    },\n});\n\n// Clear the selection: the whole series goes back to the base style.\nseries.applyOptions({ brushRanges: [] });\n```\n\nA range's `style` and `outsideStyle` are both partial: every property left out\nfalls back to the base style set on the series.\n\nRanges are expressed in **logical indices** of the time scale (the position on\nthe chart's own index, shared by every series), not in time and not in the\nseries' own array positions. To turn a pointer position into a logical index,\nuse `chart.timeScale().coordinateToLogical(x)`, where `x` is the pointer's\nhorizontal position within the plot area.\n\nEach data point is `{ time, value }`. Points without a `value` are treated as\nwhitespace, and the line breaks at the gap rather than bridging it.\n\n### Brush selection\n\n`BrushableAreaInteraction` is an optional\n[series primitive](https://tradingview.github.io/lightweight-charts/docs/plugins/series-primitives)\nthat turns a mouse drag, a one-finger drag or a two-finger gesture into a brush\nrange, so the pointer handling does not have to be written again in every\napplication:\n\n```js\nimport {\n    BrushableAreaInteraction,\n} from '@tradingview/lwc-plugin-brushable-area-series';\n\nconst brush = new BrushableAreaInteraction({\n    style: { lineColor: '#089981', topColor: 'rgba(8, 153, 129, 0.4)' },\n    outsideStyle: { lineColor: 'rgba(41, 98, 255, 0.2)' },\n});\nseries.attachPrimitive(brush);\n\nbrush.activeRange().subscribe(range => {\n    // null once the selection is cleared by a click without a drag\n    if (range !== null) {\n        console.log(range.from, range.to, range.fromTime, range.toTime);\n    }\n});\n```\n\n| Interaction option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `style` | `Partial<style>` | green | Style applied to the brushed range. |\n| `outsideStyle` | `Partial<style>` | faded blue | Style applied outside the brushed range. |\n| `applyToSeries` | `boolean` | `true` | Set the series' `brushRanges` as the user drags. Turn it off to only receive `activeRange` events. |\n| `minimumRangeWidth` | `number` | `1` | Smallest drag, in logical indices, that counts as a range. |\n\nThe defaults are exported as `defaultInteractionOptions`. The range reported by\n`activeRange()` carries `from` / `to` as logical indices and `fromTime` /\n`toTime` as the times of the data points at those indices (`null` where the\nseries has no point there). `brush.clear()` removes the selection, and\n`brush.range()` returns the current one.\n\nThe chart's own drag gesture competes with brushing, so a chart using this\nprimitive normally sets `handleScroll: false` and `handleScale: false`.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `lineColor` | `string` | `'rgb(40,98,255)'` | Base line color, used outside brush ranges. |\n| `topColor` | `string` | `'rgba(40,98,255, 0.4)'` | Base fill color at the line (top of the gradient). |\n| `bottomColor` | `string` | `'rgba(40,98,255, 0)'` | Base fill color at the base price (bottom of the gradient). |\n| `lineWidth` | `1 \\| 2 \\| 3 \\| 4` | `2` | Base line width, in CSS pixels. |\n| `lineStyle` | `LineStyle` | `LineStyle.Solid` | Base dash pattern of the line. |\n| `lineVisible` | `boolean` | `true` | Draw the line itself. Set it to `false` for the fill only. |\n| `lineType` | `LineType` | `LineType.Simple` | Shape of the line between two points: straight, stepped or curved. The fill follows the same shape. |\n| `relativeGradient` | `boolean` | `false` | Anchor the far end of the fill gradient to the outermost point in view rather than to the edge of the pane, as `AreaSeries` does. |\n| `invertFilledArea` | `boolean` | `false` | Fill the area above the line, up to the top of the pane, instead of down to `basePrice`. |\n| `basePrice` | `number` | `0` | Price the area is filled down to. |\n| `brushRanges` | `{ range: { from: number; to: number }; style: Partial<style> }[]` | `[]` | Ranges of logical indices rendered in their own style. `from` is inclusive, `to` is exclusive. Set an empty array to clear. |\n| `outsideStyle` | `Partial<style>` | — | Style of the points outside every brush range. Used only while at least one range is set. |\n\n`style` is `{ lineColor, topColor, bottomColor, lineWidth, lineStyle }` — the\nsame five properties as the base style, and each one optional.\n\n## Notes\n\n- A point inside a brush range is drawn with that range's style; if ranges\n  overlap, the **last** matching range wins, so a new selection covers the ones\n  it is dragged over.\n- Each drawn segment takes the style of its right-hand point, and consecutive\n  points sharing a style are drawn as one path, so no seam shows inside a run.\n- The fill is a vertical gradient from `bottomColor` at `basePrice` to\n  `topColor` at the edge of the pane the fill extends towards (or at the\n  outermost point in view with `relativeGradient`). When `basePrice` falls\n  outside the visible price range, the fill reaches the edge of the pane.\n- The line and the fill are drawn one bar past each edge of the visible range,\n  so they leave the pane rather than stopping at the last visible point while\n  the chart is panned.\n- Points whose value falls outside the current price scale, and gaps in the\n  data, break the line rather than being drawn to an invalid coordinate.\n- The examples disable chart scrolling and scaling (`handleScroll`,\n  `handleScale`) so that dragging brushes instead of panning; decide which\n  gesture your chart should own.\n\n### Explicit whitespace\n\nUse `createBrushableAreaSeries` to retain whitespace passed through `setData` and\n`update`, including historical corrections. Other series' timestamps do not\nbreak the area. The low-level `BrushableAreaSeries` view remains available, but\nwithout the factory's gap predicate it draws continuously: the host does not\nprovide whitespace to custom renderers.\n\nUnder time-scale conflation the area is drawn from buckets of several bars, and\na whitespace run narrower than one bucket cannot be resolved at that bar\nspacing: it is absorbed into the bucket rather than breaking the area at every\nbar. Zooming in past the conflation threshold shows the gap again.\n\n<!-- File: packages/lwc-plugin-dual-range-histogram-series/README.md (Tokens: ~2637 | Category: plugin-manifest) -->\n# Dual range histogram series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series) that draws columns above and below a zero line. At each time\npoint it can show up to two nested columns in each direction: an outer range\nin a lighter color and an inner range in a darker color.\n\nBy default the columns are not sized in price units. The series has a fixed\nheight in pixels: the largest value gets the full height, and the other columns\nare scaled relative to it. This makes the series a compact overlay. It sits on\nthe zero line of another series' price scale and does not disturb that scale.\nSet `scaleMode: 'price'` to have the values read as prices and autoscale like\nany other series instead.\n\nUse it to show paired values around a center line. Typical examples: buy and\nsell volume with an inner share of \"aggressive\" orders, bid and ask depth, or\ninflows and outflows with a highlighted component. Any positive and negative\npair with a nested subset fits.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-dual-range-histogram-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createDualRangeHistogramSeries } from '@tradingview/lwc-plugin-dual-range-histogram-series';\n\nconst chart = createChart(document.getElementById('container'));\n\nconst histogram = createDualRangeHistogramSeries(chart, {\n    priceLineVisible: false,\n    lastValueVisible: false,\n});\nhistogram.setData([\n    { time: '2024-04-22', values: [120, 45, -80, -30] },\n    { time: '2024-04-23', values: [90, 60, -110, -20] },\n    { time: '2024-04-24', values: [140, 35, -60, -40] },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-dual-range-histogram-series\": \"https://unpkg.com/@tradingview/lwc-plugin-dual-range-histogram-series/dist/dual-range-histogram-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createDualRangeHistogramSeries } from '@tradingview/lwc-plugin-dual-range-histogram-series';\n\nconst chart = createChart(document.getElementById('container'));\n\nconst histogram = createDualRangeHistogramSeries(chart, {\n    priceLineVisible: false,\n    lastValueVisible: false,\n});\nhistogram.setData([\n    { time: '2024-04-22', values: [120, 45, -80, -30] },\n    { time: '2024-04-23', values: [90, 60, -110, -20] },\n    { time: '2024-04-24', values: [140, 35, -60, -40] },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `addCustomSeries`, then set data with a `values` array per\npoint — positive values draw upward, negative values downward. The array is\n`[upOuter, upInner, downOuter, downInner]`, which is also how the styling\noptions name their columns:\n\n```js\nimport { createChart, BaselineSeries } from 'lightweight-charts';\nimport { createDualRangeHistogramSeries } from '@tradingview/lwc-plugin-dual-range-histogram-series';\n\nconst chart = createChart(document.getElementById('container'), {\n    timeScale: { barSpacing: 21, minBarSpacing: 4 },\n});\n\nconst histogram = createDualRangeHistogramSeries(chart, {\n    priceLineVisible: false,\n    lastValueVisible: false,\n});\nhistogram.setData([\n    { time: '2024-04-22', values: [120, 45, -80, -30] },\n    { time: '2024-04-23', values: [90, 60, -110, -20] },\n    { time: '2024-04-24', values: [140, 35, -60, -40] },\n]);\n\n// A main series sharing the price scale; the histogram sits on its zero line.\nconst baseline = chart.addSeries(BaselineSeries, {\n    baseValue: { type: 'price', price: 0 },\n});\nbaseline.setData(mainData);\n```\n\nEach data point is `{ time, values: number[], colors? }`. Points with an empty\nor missing `values` array are treated as whitespace. A `colors` entry overrides\nthe series color for the column at the same position; an `undefined` entry\nkeeps the series color.\n\nColors and corner radii are set per column:\n\n```js\nhistogram.applyOptions({\n    colors: {\n        upOuter: '#BBDEFB',\n        upInner: '#1565C0',\n        downOuter: '#FFE0B2',\n        downInner: '#EF6C00',\n    },\n    borderRadius: { upOuter: 8, upInner: 4, downOuter: 8, downInner: 4 },\n    borderColor: '#131722',\n    borderWidth: 1,\n});\n```\n\n### Keeping the histogram in view\n\nIn the default `pixels` scale mode the histogram is `maxHeight` pixels tall and\ncentered on `baseValue`. It does not report its values to the price scale, so\nit never distorts the scaling of the main series — but if the base line is\nclose to the top or bottom of the pane, the columns are clipped. Reserve room\nwith `keepPixelSeriesInView`, which sets the price scale's margins and keeps\nthem correct while the chart is resized:\n\n```js\nimport { keepPixelSeriesInView } from '@tradingview/lwc-plugin-dual-range-histogram-series';\n\nconst stop = keepPixelSeriesInView(chart, histogram);\n// … later, before removing the chart:\nstop();\n```\n\nThe helper follows the series' current pane, including pane resizing and moves.\nIt uses a sizing primitive attached to the series; call `stop()` before removing\nthe chart. Calling `stop()` more than once is safe.\n\nPass a height as the third argument to reserve room for something other than\nthe series' own `maxHeight`.\n\n### Scale modes\n\n`scaleMode: 'price'` treats the values as prices measured from `baseValue`, so\nthe columns are autoscaled by the price scale like any other series;\n`maxHeight` and `normalize` are then ignored and no margins need reserving.\n\n`createDualRangeHistogramSeries` keeps the plot values synchronized with\n`scaleMode` and `baseValue`, including changes made through `applyOptions`.\n\nIn `pixels` mode, `normalize` chooses what the heights are scaled against:\n`'visible'` (the default) rescales the columns as you pan, `'all'` keeps their\nrelative heights across the whole data set, and a number fixes the value which\nfills half of `maxHeight`.\n\nOptions can be changed at runtime with `series.applyOptions({ ... })`.\n\n## Creating a series\n\nUse `createDualRangeHistogramSeries(chart, options?, paneIndex?)`. It returns the\nnormal series API, with the plugin's data and options types preserved. The helper\nmakes scaling options available before the first `setData` and rebuilds plot\nvalues automatically when those options change through `series.applyOptions`.\nThis keeps autoscaling, last-value labels and crosshair values consistent. The\nhelper retains a shallow copy of the input data, including whitespace, and\nre-ingests it only when a scaling option changes. Streaming updates remain\nincremental.\n\nThe low-level `DualRangeHistogramSeries` pane view remains available for integrations\nthat supply their own options getter to its constructor. Passing scaling options\nonly to `chart.addCustomSeries(new DualRangeHistogramSeries(), options)` cannot make\nthem available before data ingestion on LWC 5.0; use the creation helper instead.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `colors` | `{ upOuter, upInner, downOuter, downInner }` of `string` | `{ upOuter: '#ACE5DC', upInner: '#42BDA8', downOuter: '#FCCACD', downInner: '#F77C80' }` | Fill color of each column. A per-point `colors` entry overrides it. |\n| `borderRadius` | `{ upOuter, upInner, downOuter, downInner }` of `number` | `{ upOuter: 2, upInner: 0, downOuter: 2, downInner: 0 }` | Corner radius of each column, in CSS pixels, applied to the column's outer end. |\n| `borderColor` | `string \\| null` | `null` | Border color of the columns. `null` for no border. |\n| `borderWidth` | `number` | `1` | Border width in CSS pixels. Only drawn when `borderColor` is set. |\n| `maxHeight` | `number` | `130` | Total height of the histogram in CSS pixels; the largest value reaches half of it above or below the base line. `pixels` scale mode only. |\n| `scaleMode` | `'pixels' \\| 'price'` | `'pixels'` | Whether the column heights are a fixed number of pixels or prices measured from `baseValue`. See [Scale modes](#scale-modes). |\n| `normalize` | `'visible' \\| 'all' \\| number` | `'visible'` | What the heights are scaled against in `pixels` mode: the largest value in the visible range, in the whole data set, or a fixed value. |\n| `gap` | `number` | `0` | Gap between the upward and the downward half, in CSS pixels. |\n| `widthPercent` | `number` | `100` | Column width as a percentage of the bar spacing, `0`–`100`. |\n| `baseValue` | `number` | `0` | Price the columns are centered on. |\n| `highlightHovered` | `boolean` | `false` | Whether hovering the series fades every point except the one under the cursor. Requires Lightweight Charts 5.2 or later. |\n\n## Notes\n\n- Columns are matched to `colors` and `borderRadius` by their **position** in\n  `values`, not by their sign: a negative value in the `upOuter` slot points\n  downwards but is still drawn in the `upOuter` color.\n- Columns for the same point share one width and position; values are drawn in\n  array order, so later (inner) values paint over earlier (outer) ones. Keep\n  inner values smaller than outer ones for the nested look.\n- A point may carry more than four values; the four columns then repeat, so\n  `values[4]` is styled as `upOuter` again.\n- Column widths follow the same pixel grid as the built-in histogram series,\n  and the alignment is not carried across a gap of whitespace.\n- Values which are not finite are skipped, and nothing is drawn when there is\n  no value to scale the columns against (an all-zero data set, say).\n- `hitTest`, which reports the hovered point through the crosshair as\n  `bar-<index>`, is used by Lightweight Charts 5.2 and later, and\n  `conflationReducer` from 5.1. Older versions simply never call them, and\n  `highlightHovered` has no effect before 5.2.\n\n<!-- File: packages/lwc-plugin-grouped-bars-series/README.md (Tokens: ~2187 | Category: plugin-manifest) -->\n# Grouped bars series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series)\nthat draws several values per time point as columns side by side, one group\nof columns per point.\n\nUse it to compare a few quantities period by period, when a stack would hide\nthe smaller ones: revenue by region per quarter, buy and sell volume per day,\nor a forecast next to the actual value.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-grouped-bars-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createGroupedBarsSeries } from '@tradingview/lwc-plugin-grouped-bars-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createGroupedBarsSeries(chart, {\n    colors: ['#2962FF', '#F23645', '#FF9800'],\n});\n\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    { time: '2024-04-23', values: [14, 7, 6] },\n    { time: '2024-04-24', values: [11, 9, 4] },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-grouped-bars-series\": \"https://unpkg.com/@tradingview/lwc-plugin-grouped-bars-series/dist/grouped-bars-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createGroupedBarsSeries } from '@tradingview/lwc-plugin-grouped-bars-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createGroupedBarsSeries(chart, {\n    colors: ['#2962FF', '#F23645', '#FF9800'],\n});\n\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    { time: '2024-04-23', values: [14, 7, 6] },\n    { time: '2024-04-24', values: [11, 9, 4] },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `createGroupedBarsSeries`, then set data with a `values`\narray per point. The array order is the column order: `values[0]` is the\nleftmost column of the group.\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createGroupedBarsSeries } from '@tradingview/lwc-plugin-grouped-bars-series';\n\nconst chart = createChart(document.getElementById('container'), {\n    timeScale: { barSpacing: 18, minBarSpacing: 6 },\n});\nconst series = createGroupedBarsSeries(chart, {\n    colors: ['#2962FF', '#F23645', '#FF9800'],\n    widthPercent: 80,\n});\n\nseries.setData([\n    { time: '2024-04-22', values: [12, 8, 5] },\n    { time: '2024-04-23', values: [14, -7, 6] },\n    { time: '2024-04-24' },\n    { time: '2024-04-25', values: [11, 9, 4], colors: [undefined, '#131722'] },\n]);\n```\n\nEach data point is `{ time, values: (number | null)[] }`. A point with an empty or\nmissing `values` array is whitespace: it keeps its place on the time scale and\ndraws nothing. Columns grow from `base` (`0` by default), up for values above\nit and down for values below it. A `null` value, a number which is not finite,\nand a value equal to `base`, which would draw a column of no height, leave\ntheir column empty and stay out of the autoscale range, and the other columns\nkeep their places; use `null` for a missing value coming from JSON, which has\nno `NaN`. A point none of whose values draws a column is whitespace.\n\nEvery group is split into as many columns as the longest point has values, so\na column is as wide in every group; a point with fewer values leaves its last\ncolumns empty.\n\nA point may override the series colors for its own columns with a `colors`\narray. A missing or `undefined` entry keeps the series color for that column.\n\nThe series' price line and last value label follow the last value of the last\npoint that draws a column. Options can be changed at runtime with\n`series.applyOptions({ ... })`.\n\n## Creating a series\n\nUse `createGroupedBarsSeries(chart, options?, paneIndex?)`. It returns the\nnormal series API, with the plugin's data and options types preserved. It\nmakes `base` available to the series before the first `setData`, so the base\nline is part of the autoscale range from the start, and changing `base`\nthrough `series.applyOptions` rescales the series without setting the data\nagain. The helper keeps a shallow copy of the input data for that purpose,\nand counts the columns once per data change: a streamed `update()` recounts\nthem over all the points once, on the next redraw.\n\nThe `GroupedBarsSeries` class remains available for\n`chart.addCustomSeries(new GroupedBarsSeries(), options)`. Added that way, the\nseries only learns its options at the first render, so the data set before\nthen is read as if `base` were `0` until the data is set again: values around\n100 with `base: 50` are stretched down to 0, and a value of `0`, equal to that\nassumed base, draws nothing. It also counts the columns over all its points\non every redraw, after a scroll, a zoom or a data change.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `colors` | `string[]` | `['#2962FF', '#E1575A', '#F28E2C', 'rgb(164, 89, 209)', 'rgb(27, 156, 133)']` | Fill color of each column, in the order of `values`. If there are more values than colors, the colors repeat. An empty array falls back to this default. |\n| `base` | `number` | `0` | Price the columns are drawn from. It is part of the autoscale range, so the base line always stays in view. |\n| `columnWidthMode` | `'percent' \\| 'histogram'` | `'percent'` | How wide a group is: a share of the bar spacing, given by `widthPercent`, or as wide as the built-in histogram's columns, the whole bar spacing but a one pixel gap. |\n| `widthPercent` | `number` | `80` | Share of the bar spacing that each group fills in `percent` mode, `0`–`100`. The rest is the gap between neighboring groups; at `100` they touch, or are a device pixel apart where the bar spacing covers a fractional number of them. |\n\nPer-point overrides, on the data item:\n\n| Field | Type | Description |\n| --- | --- | --- |\n| `colors` | `(string \\| undefined)[]` | Fill color of each column of this point. A missing or `undefined` entry falls back to the series color for that column. |\n\n`values` is typed `(number | null)[]`.\n\nThe standard `color` option is not used for the columns; it colors the\nseries' price line and last value label.\n\n## Notes\n\n- In `percent` mode every group is the same whole number of device pixels\n  wide. In `histogram` mode groups can differ by a pixel, as the built-in\n  histogram's columns do, to keep the gap between them even. Each group's\n  width is split among its columns so that they abut with no seam and no\n  overlap and differ by at most one pixel, as long as every column gets at\n  least one device pixel. Set `timeScale.minBarSpacing` to keep that when the\n  user zooms out. Below it, every column still gets a pixel and columns share\n  pixels: the tallest are drawn first so that the shorter ones stay visible.\n- Only the points on screen are drawn. The series is never conflated: with\n  `timeScale.enableConflation` on, the chart still draws every point.\n- On `lightweight-charts` 5.2 and later the series reports the column nearest\n  the pointer through `hitTest`, within the series' `hitTestTolerance` (3 px\n  by default): the crosshair event's `hoveredInfo.objectId` is\n  `'column-<point>-<index>'`, where `<point>` is the point's position in\n  `series.data()` and `<index>` the column's index in its `values`. The\n  nearest column can belong to the next point, so read the point from\n  `<point>` rather than from the crosshair's time. Elsewhere in a point's slot,\n  between its lowest and highest value or the base, the chart's own fallback\n  still reports the series as hovered, without an `objectId`. Older versions\n  never call `hitTest`.\n\n<!-- File: packages/lwc-plugin-heatmap-series/README.md (Tokens: ~2477 | Category: plugin-manifest) -->\n# Heatmap series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series)\nthat draws a column of cells per time point, each cell covering a price range\nand colored by an amount.\n\nUse it to show how something is spread over prices through time: the size\nresting at each level of an order book, the volume traded at each price, the\ndensity of a forecast, or any value bucketed by price.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-heatmap-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createColorScale, createHeatmapSeries } from '@tradingview/lwc-plugin-heatmap-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createHeatmapSeries(chart, {\n    cellShader: createColorScale({ stops: ['rgba(41, 98, 255, 0.1)', '#2962FF', '#F23645'] }),\n});\n\nseries.setData([\n    { time: '2024-04-22', cells: [{ low: 100, high: 101, amount: 20 }, { low: 101, high: 102, amount: 80 }] },\n    { time: '2024-04-23', cells: [{ low: 100, high: 101, amount: 60 }, { low: 101, high: 102, amount: 40 }] },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-heatmap-series\": \"https://unpkg.com/@tradingview/lwc-plugin-heatmap-series/dist/heatmap-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createColorScale, createHeatmapSeries } from '@tradingview/lwc-plugin-heatmap-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createHeatmapSeries(chart, {\n    cellShader: createColorScale({ stops: ['rgba(41, 98, 255, 0.1)', '#2962FF', '#F23645'] }),\n});\n\nseries.setData([\n    { time: '2024-04-22', cells: [{ low: 100, high: 101, amount: 20 }, { low: 101, high: 102, amount: 80 }] },\n    { time: '2024-04-23', cells: [{ low: 100, high: 101, amount: 60 }, { low: 101, high: 102, amount: 40 }] },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `createHeatmapSeries`, then set data with a `cells`\narray per point:\n\n```js\nconst series = createHeatmapSeries(chart, {\n    cellShader: (amount, range) => (amount > (range.min + range.max) / 2 ? '#F23645' : '#2962FF'),\n    cellGap: 1,\n});\n\nseries.setData([\n    {\n        time: '2024-04-22',\n        cells: [\n            { low: 100, high: 101, amount: 20 },\n            { low: 101, high: 102, amount: 80 },\n        ],\n    },\n    { time: '2024-04-23' },\n]);\n```\n\nEach data point is `{ time, cells }`, and each cell `{ low, high, amount }`:\n\n- A cell is drawn from `low` to `high` across the point's whole slot, in the\n  color `cellShader(amount, range)` returns. The edges may come in either\n  order, and the cells of a column in any order. Cells are not expected to\n  overlap: cells of the same color are filled together, so where two\n  overlap, which one shows depends on their colors, not on their order.\n- A cell whose `low`, `high` or `amount` is not a finite number is skipped,\n  and so is a `null` cell, as a JSON feed may send.\n- A point with no cell to draw is whitespace, `cells` that is missing or\n  `null` included.\n\nCells whose price edges meet share a pixel edge, and so do neighboring\ncolumns, so with no gap they abut with no seam and no overlap at every zoom\nlevel and device pixel ratio.\n\nThe series autoscales to the lowest and highest cell edge of the points on\nscreen. The price line and the last value label, off by default, show the\nmiddle of a column's lowest and highest edge. Options can be changed at\nruntime with `series.applyOptions({ ... })`.\n\nIn the `plugin-examples` collection the types were spelled `HeatMapSeries`,\n`HeatMapData`, `HeatMapSeriesOptions` and `HeatMapCellShader`; the package\nspells them `HeatmapSeries`, `HeatmapData`, `HeatmapSeriesOptions` and\n`HeatmapCellShader`. `HeatmapCell` is unchanged.\n\n## Colors\n\nThe shader is called with the cell's amount and the range of the amounts in\nview, `{ min, max }`: the lowest and the highest amount among the cells of\nthe points on screen. A shader can spread its colors over that range rather\nthan over a maximum worked out in advance, so the colors keep their spread as\nthe chart scrolls.\n\n`createColorScale({ stops, domain?, steps? })` builds such a shader from a\nlist of colors:\n\n```js\nconst shader = createColorScale({\n    // Spread evenly from the low end to the high end.\n    stops: ['rgba(41, 98, 255, 0.1)', '#2962FF', '#F7A600', '#F23645'],\n    // The amounts that take the first and the last stop. Without it, the\n    // range of the amounts in view.\n    domain: [0, 100],\n    // How many colors the scale holds, 2 to 1024. Defaults to 32.\n    steps: 16,\n});\n```\n\nThe stops can be any CSS color the canvas accepts, and are mixed with\npremultiplied alpha, as CSS gradients are. A stop the canvas cannot parse, or\none in a color space other than sRGB such as `oklch()`, is left out; without a\nDOM, as in server-side rendering, only `#rrggbb`, `rgb()` and `rgba()` stops\ncan be read. An amount\nbeyond the domain takes the color at that end; a domain given high end first\nreverses the scale, and one whose ends are not both finite numbers is ignored.\nThe colors are worked out once, so the shader builds no color string while\ndrawing, and the fewer steps there are, the more cells share a fill.\n\nA shader of your own is called for every cell on screen on every paint, so\nkeep it cheap, and return a limited set of colors: cells are filled together\nby color, once per color per paint. A cell whose color the canvas cannot\nparse is not drawn.\n\n## Creating a series\n\nUse `createHeatmapSeries(chart, options?, paneIndex?)`. It adds the series and\nreturns the normal series API, with the plugin's data and options types\nfilled in. Its options type keeps `cellShader` a function, here and in\n`applyOptions`, so an inline shader gets its parameters typed; the library's\n`DeepPartial`, which `chart.addCustomSeries` uses, turns a function option\ninto an object type.\n\nThe `HeatmapSeries` class remains available for\n`chart.addCustomSeries(new HeatmapSeries(), options)`.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `cellShader` | `(amount: number, range: { min: number; max: number }) => string` | green, from faint at `0` to opaque at `100` | Turns a cell's amount into its fill color, given the range of the amounts in view. A value that is not a function falls back to the default. |\n| `cellGap` | `number` | `1` | Space between neighboring cells, in CSS pixels, both between the columns and between the cells of a column. Left out along a side where the cell is not more than three times as long. `0` for none. |\n| `cellBorderWidth` | `number` | `0` | Width of the border drawn inside the edge of every cell, in CSS pixels. Left out along a side where the cell, less the gap, is not more than three times as long. `0` for none. |\n| `cellBorderColor` | `string` | `'rgba(255, 255, 255, 1)'` | Color of the cell border. A color the canvas cannot parse draws no border. |\n\nThe gap and the border are rounded to whole device pixels along each axis.\nWhether a cell is long enough for them is decided before its edges are\nrounded, so cells of one size all get them or all go without.\nA negative width counts as `0`, and one that is not a number as the default.\n`lastValueVisible` and `priceLineVisible` default to `false`.\n\n## Notes\n\n- Only the points on screen are drawn, and of their cells only those on the\n  pane. A cell whose two edges round to the same device pixel is not drawn,\n  which can happen to one under a pixel tall.\n- The series has no `conflationReducer`, so the chart never merges its\n  points: zoomed out to a bar spacing under a device pixel, every column is\n  still worked out, and those that round to no width are skipped.\n- On `lightweight-charts` 5.2 and later the series reports the cell under the\n  pointer through `hitTest`, in the column whose slot holds the pointer and\n  within the series' `hitTestTolerance` (3 px by default) above or below the\n  cell: the crosshair's `hoveredInfo.objectId` is `'cell-<index>'`, the index\n  into that point's `cells`, and `param.seriesData` holds the point to read\n  the cell from. Between a column's lowest and highest edge, holes\n  included, the chart's own fallback reports the series as hovered without\n  an `objectId`, so check `objectId` before reading a cell. Hovering changes\n  nothing in how the series is drawn.\n- On 5.2 and later the chart also draws the hovered series above the others\n  by default. A heatmap is hovered anywhere over the span of its columns, so\n  it then covers a price series drawn on top of it. Create the chart with\n  `hoveredSeriesOnTop: false` to keep the other series on top.\n\n<!-- File: packages/lwc-plugin-hlc-area-series/README.md (Tokens: ~2197 | Category: plugin-manifest) -->\n# HLC area series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series) for high-low-close data. It draws the high, low, and close\nvalues as three lines. The band between the lines is filled with two colors:\none between high and close, another between close and low. The result reads\nlike a candlestick's range without the visual weight of individual candles.\n\nUse it to show a value together with its range over time. Typical examples: a\ndaily close between its high and low, a forecast with its confidence band, the\nminimum, average, and maximum of a metric, or a mid price between bid and ask.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-hlc-area-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createHLCAreaSeries } from '@tradingview/lwc-plugin-hlc-area-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createHLCAreaSeries(chart, {\n    highLineColor: '#089981',\n    lowLineColor: '#F23645',\n    closeLineColor: '#787B86',\n});\n\nseries.setData([\n    { time: '2024-04-22', high: 104.2, low: 98.7, close: 101.3 },\n    { time: '2024-04-23', high: 105.0, low: 100.1, close: 104.6 },\n    { time: '2024-04-24', high: 106.8, low: 103.2, close: 103.9 },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-hlc-area-series\": \"https://unpkg.com/@tradingview/lwc-plugin-hlc-area-series/dist/hlc-area-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createHLCAreaSeries } from '@tradingview/lwc-plugin-hlc-area-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createHLCAreaSeries(chart, {\n    highLineColor: '#089981',\n    lowLineColor: '#F23645',\n    closeLineColor: '#787B86',\n});\n\nseries.setData([\n    { time: '2024-04-22', high: 104.2, low: 98.7, close: 101.3 },\n    { time: '2024-04-23', high: 105.0, low: 100.1, close: 104.6 },\n    { time: '2024-04-24', high: 106.8, low: 103.2, close: 103.9 },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `createHLCAreaSeries`, then set data with `high`, `low`, and\n`close` values:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createHLCAreaSeries } from '@tradingview/lwc-plugin-hlc-area-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createHLCAreaSeries(chart, {\n    highLineColor: '#089981',\n    lowLineColor: '#F23645',\n    closeLineColor: '#787B86',\n});\n\nseries.setData([\n    { time: '2024-04-22', high: 104.2, low: 98.7, close: 101.3 },\n    { time: '2024-04-23', high: 105.0, low: 100.1, close: 104.6 },\n    { time: '2024-04-24', high: 106.8, low: 103.2, close: 103.9 },\n]);\n```\n\nEach data point is `{ time, high, low, close }`. Points missing any of the three\nvalues are treated as whitespace, and leave a gap. The series' price line and last-value label follow the\n`close` value.\n\nOptions can be changed at runtime with `series.applyOptions({ ... })`.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `highLineColor` | `string` | `'#049981'` | Color of the high line. |\n| `lowLineColor` | `string` | `'#F23645'` | Color of the low line. |\n| `closeLineColor` | `string` | `'#878993'` | Color of the close line. |\n| `highAreaColor` | `string` | `'rgba(4, 153, 129, 0.2)'` | Fill color between the high line and the close line. |\n| `lowAreaColor` | `string` | `'rgba(242, 54, 69, 0.2)'` | Fill color between the close line and the low line. |\n| `highLineWidth` | `LineWidth` | `2` | Width of the high line, in CSS pixels (`1`–`4`). |\n| `lowLineWidth` | `LineWidth` | `2` | Width of the low line, in CSS pixels (`1`–`4`). |\n| `closeLineWidth` | `LineWidth` | `2` | Width of the close line, in CSS pixels (`1`–`4`). |\n| `highLineStyle` | `LineStyle` | `LineStyle.Solid` | Dash pattern of the high line. |\n| `lowLineStyle` | `LineStyle` | `LineStyle.Solid` | Dash pattern of the low line. |\n| `closeLineStyle` | `LineStyle` | `LineStyle.Solid` | Dash pattern of the close line. |\n| `highLineVisible` | `boolean` | `true` | Whether the high line is drawn. |\n| `lowLineVisible` | `boolean` | `true` | Whether the low line is drawn. |\n| `closeLineVisible` | `boolean` | `true` | Whether the close line is drawn. |\n| `areaVisible` | `boolean` | `true` | Whether the two fills between the lines are drawn. |\n| `lineType` | `'simple' \\| 'step'` | `'simple'` | How the lines and the fills get from one point to the next. `'step'` matches the built-in `LineType.WithSteps`. |\n| `highAreaTopColor` | `string` | `''` | Upper stop of a vertical gradient filling the high–close band. |\n| `highAreaBottomColor` | `string` | `''` | Lower stop of the high–close band gradient. |\n| `lowAreaTopColor` | `string` | `''` | Upper stop of a vertical gradient filling the close–low band. |\n| `lowAreaBottomColor` | `string` | `''` | Lower stop of the close–low band gradient. |\n| `hoverPointRadius` | `number` | `4` | Radius, in CSS pixels, of the dots drawn on the high, low and close of the bar under the cursor while the series is hovered. `0` turns the highlight off. |\n\n`areaTopColor` and `areaBottomColor` are deprecated aliases of `highAreaColor`\nand `lowAreaColor`. They still work, and take precedence when both are set.\n\nA band is filled with a gradient only when both stops of its pair are set; while\neither is an empty string the flat `highAreaColor` / `lowAreaColor` is used. The\ngradient runs down the whole pane, like the built-in Area series' `topColor` and\n`bottomColor` without `relativeGradient`.\n\n## Notes\n\n- The price scale autoscales to the full `low`–`high` range, so the band is\n  never clipped.\n- Points missing any of `high`, `low` and `close` are whitespace. The lines and\n  the fills break at a run of whitespace instead of bridging it, and a point\n  whose price falls off the scale is skipped rather than turned into a NaN\n  coordinate.\n- The lines and the fills continue past the first and the last visible point, so\n  they reach the edges of the pane while panning.\n- Line widths follow the library's `LineWidth` type, so `0` is not one of them.\n  Use `highLineVisible` / `lowLineVisible` / `closeLineVisible` to hide a line\n  and `areaVisible` to hide both fills.\n- On Lightweight Charts™ 5.2 and later the series reports the bar under the\n  cursor through `hitTest` and highlights its three values, and from 5.1\n  conflated points are merged as the highest high, the lowest low and the\n  last close.\n\n### Explicit whitespace\n\nUse `createHLCAreaSeries` to retain whitespace passed through `setData` and\n`update`, including historical corrections. Other series' timestamps do not\nbreak the area. The low-level `HLCAreaSeries` view remains available, but\nwithout the factory's gap predicate it draws continuously: the host does not\nprovide whitespace to custom renderers.\n\nUnder time-scale conflation the area is drawn from buckets of several bars, and\na whitespace run narrower than one bucket cannot be resolved at that bar\nspacing: it is absorbed into the bucket rather than breaking the area at every\nbar. Zooming in past the conflation threshold shows the gap again.\n\n<!-- File: packages/lwc-plugin-image-watermark/README.md (Tokens: ~2217 | Category: plugin-manifest) -->\n# Image watermark\n\nAn image drawn behind the chart content, as a\n[series primitive](https://tradingview.github.io/lightweight-charts/docs/plugins/series-primitives)\n(`ImageWatermark`) or as a\n[pane primitive](https://tradingview.github.io/lightweight-charts/docs/plugins/pane-primitives)\n(`ImageWatermarkPane`). The image is placed within the pane — centered by\ndefault, or anchored to a corner — and scaled to fit, to fill, or not at all.\nPosition, size limits, padding, opacity and visibility can all be changed after\nthe watermark has been attached.\n\nThe series primitive belongs to the series it is attached to: it lives in that\nseries' pane and is removed together with the series. The pane primitive needs\nno series at all.\n\nUse it to brand a chart with a logo, or to mark a chart as a preview or draft,\nwithout touching the chart's own rendering.\n\n> **Lightweight Charts™ 5 also ships a built-in image watermark.**\n> [`createImageWatermark(pane, url, options)`](https://tradingview.github.io/lightweight-charts/docs/api/functions/createImageWatermark)\n> is a pane primitive which centers an image and scales it to fit. If that is\n> all you need, the built-in function is the right choice. Use this package for\n> a watermark tied to a specific series rather than to a pane, or for anything\n> the built-in does not offer: corner and fractional positions, `objectFit`,\n> `crossOrigin`, `visible`, `zOrder`, `applyOptions` / `setImage` and an\n> `onError` callback.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-image-watermark\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { ImageWatermark } from '@tradingview/lwc-plugin-image-watermark';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(data);\n\nseries.attachPrimitive(new ImageWatermark('/logo.svg', { alpha: 0.4 }));\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-image-watermark\": \"https://unpkg.com/@tradingview/lwc-plugin-image-watermark/dist/image-watermark.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { ImageWatermark } from '@tradingview/lwc-plugin-image-watermark';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(data);\n\nseries.attachPrimitive(new ImageWatermark('/logo.svg', { alpha: 0.4 }));\n</script>\n```\n\n## Usage\n\n### Behind a series\n\nCreate the watermark with the image URL, then attach it to the series it\nshould follow:\n\n```js\nimport { createChart, LineSeries } from 'lightweight-charts';\nimport { ImageWatermark } from '@tradingview/lwc-plugin-image-watermark';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addSeries(LineSeries);\nseries.setData(data);\n\nconst watermark = new ImageWatermark('/logo.svg', {\n    maxHeight: 400,\n    maxWidth: 400,\n    padding: 50,\n    alpha: 0.4,\n});\nseries.attachPrimitive(watermark);\n```\n\nTo remove the watermark, detach it from the series:\n\n```js\nseries.detachPrimitive(watermark);\n```\n\n### Behind a pane\n\n`ImageWatermarkPane` takes the same image URL and the same options, and is\nattached to a pane instead of a series. Use it when the watermark should stay\nput while series are added and removed:\n\n```js\nimport { ImageWatermarkPane } from '@tradingview/lwc-plugin-image-watermark';\n\nconst watermark = new ImageWatermarkPane('/logo.svg', { alpha: 0.4 });\nchart.panes()[0].attachPrimitive(watermark);\n\n// later\nchart.panes()[0].detachPrimitive(watermark);\n```\n\n### Changing the watermark\n\nBoth classes have the same methods:\n\n```js\nwatermark.applyOptions({ position: 'bottom-right', alpha: 0.2 });\nwatermark.setImage('/other-logo.svg'); // same as applyOptions({ imageUrl })\nwatermark.options(); // the current options, with the defaults filled in\n```\n\n`applyOptions` merges: an option which is not passed, or is passed as\n`undefined`, is left unchanged.\n\nThe image is loaded when the primitive is attached and drawn once it has\ndecoded; until then nothing is rendered. A new image passed to `setImage` or\n`applyOptions` replaces the current one once it has decoded, so the watermark\ndoes not blink out in between. Any URL the browser can load into an\n`<img>` element works, including SVG and data URLs. Decoded images are cached\nby URL, so detaching and re-attaching a watermark — or using the same image\ntwice — never loads it again.\n\n## Options\n\nOptions are passed as the second constructor argument, which is optional, as\nis every option in it. The type is `ImageWatermarkPluginOptions`, and the\ndefaults are exported as `defaultOptions`.\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `imageUrl` | `string` | `''` | URL of the image. The first constructor argument sets the same option. |\n| `position` | `WatermarkPosition` | `'center'` | Where the image sits in the pane: `'center'`, `'top-left'`, `'top-right'`, `'bottom-left'`, `'bottom-right'`, or `{ x, y }`. |\n| `objectFit` | `WatermarkObjectFit` | `'contain'` | `'contain'` scales the image to fit, `'cover'` scales it to fill and crops the overflow, `'none'` draws it at its natural size. |\n| `maxWidth` | `number` | — (pane width) | Maximum width of the drawing area, in CSS pixels. |\n| `maxHeight` | `number` | — (pane height) | Maximum height of the drawing area, in CSS pixels. |\n| `padding` | `number` | `0` | Minimum distance between the drawing area and the edges of the pane, in CSS pixels. |\n| `alpha` | `number` | `1` | Opacity of the image, from `0` (invisible) to `1` (opaque). |\n| `visible` | `boolean` | `true` | Whether the watermark is drawn at all. |\n| `zOrder` | `'bottom' \\| 'normal' \\| 'top'` | `'bottom'` | Layer the watermark is drawn in. `'bottom'` puts it behind the grid and the series. |\n| `crossOrigin` | `'anonymous' \\| 'use-credentials'` | — | `crossOrigin` attribute of the underlying `<img>` element. |\n| `onError` | `(error, imageUrl) => void` | — | Called when the image cannot be loaded. Nothing else reports the failure. |\n\n### Position and size\n\nThe drawing area is the pane inset by `padding` and limited to `maxWidth` /\n`maxHeight`. `position` places that area within the pane and the image within\nthat area:\n\n- a named anchor — `'center'` or one of the four corners;\n- `{ x, y }`, fractions of the free space from `0` to `1`. `{ x: 0, y: 0 }` is\n  the top-left corner, `{ x: 1, y: 1 }` the bottom-right one, `{ x: 0.5, y: 0 }`\n  the middle of the top edge. Values outside `0`…`1` are clamped.\n\n`objectFit` then decides the scale. With `'contain'` (the default) the image is\nscaled up or down to fit, keeping its aspect ratio; set `maxWidth` /\n`maxHeight` to its natural size if it should never be enlarged. With `'cover'`\nit is scaled to fill the drawing area and the overflow is cropped, and with\n`'none'` it is drawn at its natural size. Nothing is ever drawn outside the\ndrawing area, so `padding` always holds.\n\n## Notes\n\n- The watermark is drawn behind the chart content by default: the grid, the\n  series, and other primitives all appear on top of it. Only the pane\n  background is below it. Pass `zOrder: 'top'` to draw it over everything\n  instead.\n- The image appears only in the pane it belongs to, where the series is drawn.\n  It never covers the price scales or the time scale, and a visible left price\n  scale or a second pane does not move it.\n- A watermark whose image cannot be loaded draws nothing and throws nothing.\n  Pass `onError` to be told about it; the plugin logs nothing itself.\n- `ImageWatermarkOptions` is still exported, as a deprecated alias of\n  `ImageWatermarkPluginOptions`. The plugin option type was renamed because\n  the library exports an `ImageWatermarkOptions` of its own, for the built-in\n  `createImageWatermark`. The alias is kept for compatibility and will be\n  removed in a future major version.\n- The image can be loaded from any origin. However, an image served without\n  CORS headers marks the canvas as \"tainted\", and\n  [`takeScreenshot`](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/IChartApi#takescreenshot)\n  fails on a tainted canvas. If you plan to export the chart as an image, serve\n  the watermark image with CORS headers and set `crossOrigin: 'anonymous'`.\n\n<!-- File: packages/lwc-plugin-lollipop-series/README.md (Tokens: ~1648 | Category: plugin-manifest) -->\n# Lollipop series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series)\nthat draws each value as a dot at the end of a stem. The stem runs from a\nbase line, `0` by default, up to a value above it or down to a value below it.\n\nUse it where a histogram would put too much ink on the chart: values that\nswing around a reference, such as daily returns, net flows or a difference\nfrom a target, where the dot marks the value and the stem shows how far it is\nfrom the base.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-lollipop-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createLollipopSeries } from '@tradingview/lwc-plugin-lollipop-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createLollipopSeries(chart, { color: '#2962FF' });\n\nseries.setData([\n    { time: '2024-04-22', value: 4.2 },\n    { time: '2024-04-23', value: -1.8 },\n    { time: '2024-04-24', value: 2.6 },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-lollipop-series\": \"https://unpkg.com/@tradingview/lwc-plugin-lollipop-series/dist/lollipop-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createLollipopSeries } from '@tradingview/lwc-plugin-lollipop-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createLollipopSeries(chart, { color: '#2962FF' });\n\nseries.setData([\n    { time: '2024-04-22', value: 4.2 },\n    { time: '2024-04-23', value: -1.8 },\n    { time: '2024-04-24', value: 2.6 },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `createLollipopSeries`, then set data with a `value` per\npoint:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createLollipopSeries } from '@tradingview/lwc-plugin-lollipop-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createLollipopSeries(chart, {\n    base: 0,\n    lineWidth: 2,\n    markerSize: 8,\n});\n\nseries.setData([\n    { time: '2024-04-22', value: 4.2 },\n    { time: '2024-04-23', value: -1.8, color: '#F23645' },\n    { time: '2024-04-24' },\n    { time: '2024-04-25', value: 2.6 },\n]);\n```\n\nEach data point is `{ time, value }`. A point without a finite `value`,\n`null` included, as JSON sends a missing one, is whitespace: it keeps its\nplace on the time scale and draws nothing. A `color` on a point\noverrides the series `color` for that point's stem and dot.\n\nThe series' price line and last value label follow the last value. Options can\nbe changed at runtime with `series.applyOptions({ ... })`.\n\n## Creating a series\n\nUse `createLollipopSeries(chart, options?, paneIndex?)`. It returns the normal\nseries API, with the plugin's data and options types preserved. It makes `base`\navailable to the series before the first `setData`, so the base line is part\nof the autoscale range from the start, and changing `base` through\n`series.applyOptions` rescales the series without setting the data again. The\nhelper keeps a shallow copy of the input data for that purpose; streaming\nupdates stay incremental.\n\nThe `LollipopSeries` class remains available for\n`chart.addCustomSeries(new LollipopSeries(), options)`. Added that way, the\nseries only learns its options at the first render, so the data set before\nthen is scaled as if `base` were `0`: values around 100 with `base: 100` are\nstretched down to 0 until the data is set again.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`color`, `priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `base` | `number` | `0` | Price the stems are drawn from. It is part of the autoscale range, so the base line always stays in view. |\n| `lineWidth` | `number` | `2` | Width of the stem, in CSS pixels, at most half the bar spacing and at least one device pixel. |\n| `markerSize` | `number` | `8` | Diameter of the dot at the value, in CSS pixels, at most 20 and at most the bar spacing. `0` draws no dots. |\n\nThe standard `color` option colors the stems, the dots and the price line.\n\n## Notes\n\n- Stems and dots shrink with the bar spacing when the chart is zoomed out: a\n  stem is at most half the bar spacing wide, down to one device pixel, and a\n  dot at most as wide as the bar spacing, so neighboring dots can touch but\n  stay apart from the next stem. At a bar spacing of one device pixel the\n  one-pixel stems fill every pixel. Set `timeScale.minBarSpacing` to keep\n  lollipops from getting that small.\n- Autoscale covers the values and the base, not the dots around them, so a\n  dot at the highest or lowest value sticks out by its radius. The 20 px cap\n  on `markerSize` keeps it within the price scale's default margins in a pane\n  at least 100 px tall.\n- Only the points on screen are drawn. The series is never conflated: with\n  `timeScale.enableConflation` on, the chart still draws every point.\n- On `lightweight-charts` 5.2 and later the series reports the lollipop under\n  the pointer through `hitTest`, within the series' `hitTestTolerance` (3 px\n  by default): the crosshair event's `hoveredInfo.objectId` is `bar-<index>`,\n  where `<index>` is the point's position in `series.data()`. The dot is\n  reported as a point and the stem as a range, like a column, so a candle body\n  the pointer is inside wins over a stem the pointer is only near. Elsewhere\n  in a point's slot, between the base and the value, the chart's own fallback\n  still reports the series as hovered, without an `objectId`. Older versions\n  never call `hitTest`.\n\n<!-- File: packages/lwc-plugin-pretty-histogram-series/README.md (Tokens: ~2024 | Category: plugin-manifest) -->\n# Pretty histogram series\n\nA [custom series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series) that draws a histogram with rounded bars. Unlike the built-in\nhistogram series, it can round the outer corners of each bar, control the bar\nwidth as a share of the bar spacing, color bars by their sign, draw a border\nand fade the fill into a second color. The result is a softer look that fits\ndashboards and marketing-style charts.\n\nUse it for volume panes, single-value indicators, or any bar chart where the\ndefault square bars look too heavy.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-pretty-histogram-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createPrettyHistogramSeries } from '@tradingview/lwc-plugin-pretty-histogram-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createPrettyHistogramSeries(chart, {\n    color: '#2962FF',\n    widthPercent: 60,\n    radius: 6,\n});\n\nseries.setData([\n    { time: '2024-04-22', value: 12.5 },\n    { time: '2024-04-23', value: -4.1 },\n    { time: '2024-04-24', value: 8.3, color: '#F23645' },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-pretty-histogram-series\": \"https://unpkg.com/@tradingview/lwc-plugin-pretty-histogram-series/dist/pretty-histogram-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { createPrettyHistogramSeries } from '@tradingview/lwc-plugin-pretty-histogram-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createPrettyHistogramSeries(chart, {\n    color: '#2962FF',\n    widthPercent: 60,\n    radius: 6,\n});\n\nseries.setData([\n    { time: '2024-04-22', value: 12.5 },\n    { time: '2024-04-23', value: -4.1 },\n    { time: '2024-04-24', value: 8.3, color: '#F23645' },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `addCustomSeries`, then set histogram data:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { createPrettyHistogramSeries } from '@tradingview/lwc-plugin-pretty-histogram-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = createPrettyHistogramSeries(chart, {\n    color: '#2962FF',\n    widthPercent: 60,\n    radius: 6,\n});\n\nseries.setData([\n    { time: '2024-04-22', value: 12.5 },\n    { time: '2024-04-23', value: -4.1 },\n    { time: '2024-04-24', value: 8.3, color: '#F23645' },\n]);\n```\n\nEach data point is `{ time, value, color? }` — the same shape as the built-in\nhistogram series. A per-point `color` overrides the series `color` for that\nbar. Points without a `value` are treated as whitespace.\n\nOptions can be changed at runtime with `series.applyOptions({ ... })`.\n\n### Two-tone bars\n\nSet `upColor` and `downColor` to color each bar by its sign relative to\n`base`, the way a volume pane usually does:\n\n```js\nseries.applyOptions({\n    base: 0,\n    upColor: '#089981',\n    downColor: '#F23645',\n});\n```\n\nA per-point `color` still wins over both.\n\n### The base line\n\nBars grow from `base` (`0` by default), and the base is always reported to the\nautoscale alongside the values, exactly as the built-in histogram series does.\nBars are therefore never cut off at the edge of the pane, and no custom\n`autoscaleInfoProvider` is needed.\n\n`base` is read when the data is set, so change it before or together with\n`setData` if you also rely on the autoscale following it.\n\n## Creating a series\n\nUse `createPrettyHistogramSeries(chart, options?, paneIndex?)`. It returns the\nnormal series API, with the plugin's data and options types preserved. The helper\nmakes scaling options available before the first `setData` and rebuilds plot\nvalues automatically when those options change through `series.applyOptions`.\nThis keeps autoscaling, last-value labels and crosshair values consistent. The\nhelper retains a shallow copy of the input data, including whitespace, and\nre-ingests it only when a scaling option changes. Streaming updates remain\nincremental.\n\nThe low-level `PrettyHistogramSeries` pane view remains available for integrations\nthat supply their own options getter to its constructor. Passing scaling options\nonly to `chart.addCustomSeries(new PrettyHistogramSeries(), options)` cannot make\nthem available before data ingestion on LWC 5.0; use the creation helper instead.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `color` | `string` | `'#D63864'` | Fill color of the bars, used whenever no more specific color applies. A per-point `color` in the data overrides it. |\n| `upColor` | `string \\| null` | `null` | Fill color of bars at or above `base`. `null` falls back to `color`. |\n| `downColor` | `string \\| null` | `null` | Fill color of bars below `base`. `null` falls back to `color`. |\n| `base` | `number` | `0` | Price the bars grow from. Always included in the autoscale. |\n| `widthPercent` | `number` | `50` | Bar width as a percentage of the bar spacing, `0`–`100`. Ignored when `widthMode` is `'histogram'`. |\n| `widthMode` | `'percent' \\| 'histogram'` | `'percent'` | `'percent'` sizes each bar from `widthPercent`. `'histogram'` uses the full slot with a one-pixel gap, exactly as the built-in histogram series does. |\n| `minColumnWidth` | `number` | `1` | Lower bound for the bar width, in CSS pixels. |\n| `radius` | `number` | `4` | Corner radius of the bar's outer end, in CSS pixels. Positive bars are rounded at the top, negative bars at the bottom. The radius is capped at half the bar width and at the bar height. |\n| `roundInnerCorners` | `boolean` | `false` | Whether the corners at the `base` end are rounded with the same radius. |\n| `borderColor` | `string \\| null` | `null` | Border color of the bars. `null` for no border. |\n| `borderWidth` | `number` | `1` | Border width in CSS pixels. Only drawn when `borderColor` is set. |\n| `gradientColor` | `string \\| null` | `null` | Color the fill fades into at the outer end of each bar. `null` for a flat fill. |\n| `highlightHovered` | `boolean` | `false` | Whether hovering the series fades every bar except the one under the cursor. Requires Lightweight Charts 5.2 or later. |\n\n## Notes\n\n- Bars are anchored at `base` and the base is always part of the autoscale, so\n  the series behaves like the built-in histogram; see\n  [The base line](#the-base-line).\n- Bar widths reproduce the built-in histogram exactly in `'histogram'` width\n  mode and at `widthPercent: 100`: the same pixel grid, the same one-pixel gap,\n  and no alignment carried across a whitespace gap.\n- Flat, borderless bars are drawn in batches: consecutive bars of the same\n  color are filled in one canvas operation. Setting `borderColor`,\n  `gradientColor` or `highlightHovered` paints bar by bar instead.\n- `hitTest`, which reports the hovered bar through the crosshair as\n  `bar-<index>`, is used by Lightweight Charts 5.2 and later, and\n  `conflationReducer` from 5.1. Older versions simply never call them, and\n  `highlightHovered` has no effect before 5.2.\n\n<!-- File: packages/lwc-plugin-preview-kit/README.md (Tokens: ~649 | Category: plugin-manifest) -->\n# Preview kit\n\nPrivate, never published. Shared layout and controls for the catalog preview\npages of the plugin packages: `src/example/preview.html` and `preview.ts` of\nevery `packages/lwc-plugin-*`, declared as `lwcPlugin.preview` and built to\n`/plugin-previews/<slug>/` by `pnpm plugins:build-demos`.\n\nA preview page is not the plugin's demo. The demo (`lwcPlugin.demo`) is the\npage a developer opens on its own: it carries edge cases, whitespace runs,\nnegative values and every option the plugin has. A preview is what the\ncatalog frames next to the README, so it shows the plugin at its best in a\nshort frame and nothing else.\n\nThree entry points:\n\n- `@tradingview/lwc-plugin-preview-kit/preview.css` — the whole layout. One\n  compact `#controls` row above a `#chart` that fills the rest of the frame.\n  Light and dark, keyed on the root element's `data-theme`. Nothing is\n  restyled after load, so the chart is created at its final size and does not\n  jump.\n- `@tradingview/lwc-plugin-preview-kit/preview-theme` — follows the theme of\n  the docs page that frames the preview, live: toggling the site theme\n  restyles the running preview without reloading it. `?theme=light|dark` in\n  the page URL pins a theme instead (a page opened on its own is light).\n  `themeChart(chart, onTheme?)` themes the chart's background, text, grid,\n  scale borders and crosshair labels now and on every switch; `onTheme` is\n  where a preview recolours anything of its own that would not read on the\n  other background.\n- `@tradingview/lwc-plugin-preview-kit/preview-controls` — `mountControls(defs)`\n  builds the control row from `select`, `checkbox` and `button` declarations,\n  and `addRefreshButton(onRefresh)` adds a \"New data\" button for the previews\n  whose sample data is random. Plain DOM, no framework.\n\nA preview page is therefore two elements and a script:\n\n```html\n<div id=\"controls\"></div>\n<div id=\"chart\"></div>\n<script type=\"module\" src=\"./preview.ts\"></script>\n```\n\nThe page script is a module and can run after the first paint, so\n`src/theme-boot.js` sets the theme before it: `pnpm plugins:build-demos`\ninlines it straight after `<meta charset>` of every built preview page (the\nbuild fails without one), which is why a preview page needs no script of its\nown in its HTML. It applies the same rules as `preview-theme`; change them in\nboth places.\n\nAdd the kit to a package with `@tradingview/lwc-plugin-preview-kit: workspace:*` in\n`devDependencies` — `create-lwc-plugin --workspace` does this for you — and\ndeclare `lwcPlugin.preview` (and `previewHeight`, when 330 px is not enough).\n\n<!-- File: packages/lwc-plugin-rounded-candles-series/README.md (Tokens: ~1963 | Category: plugin-manifest) -->\n# Rounded candles series\n\nA [custom candlestick series](https://tradingview.github.io/lightweight-charts/docs/plugins/custom_series) with rounded candle bodies. It renders the same\nopen-high-low-close data as the built-in candlestick series. Each body is\ndrawn as a rounded rectangle. The corner radius adapts to the bar spacing:\nsharp when zoomed out, soft when zoomed in.\n\nUse it as a drop-in replacement for the built-in candlesticks wherever a\nsofter visual style fits, such as dashboards, embedded widgets, or marketing\npages.\n\n## Installation\n\n### npm\n\nInstall the package. It requires `lightweight-charts` `^5.0.0` in your\nproject:\n\n```shell\nnpm install @tradingview/lwc-plugin-rounded-candles-series\n```\n\nThen import the plugin and add it to a chart:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { RoundedCandleSeries } from '@tradingview/lwc-plugin-rounded-candles-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addCustomSeries(new RoundedCandleSeries(), {\n    upColor: '#089981',\n    downColor: '#F23645',\n    wickUpColor: '#089981',\n    wickDownColor: '#F23645',\n});\n\nseries.setData([\n    { time: '2024-04-22', open: 100.2, high: 104.6, low: 99.1, close: 103.8 },\n    { time: '2024-04-23', open: 103.8, high: 105.0, low: 101.4, close: 102.0 },\n    { time: '2024-04-24', open: 102.0, high: 106.1, low: 101.7, close: 105.4 },\n]);\n```\n\n### CDN\n\nThe plugin is published as ES modules. Map the library and the plugin to their\nCDN builds with an import map:\n\n```html\n<script type=\"importmap\">\n{\n  \"imports\": {\n    \"lightweight-charts\": \"https://unpkg.com/lightweight-charts@^5/dist/lightweight-charts.standalone.production.mjs\",\n    \"@tradingview/lwc-plugin-rounded-candles-series\": \"https://unpkg.com/@tradingview/lwc-plugin-rounded-candles-series/dist/rounded-candles-series.standalone.js\"\n  }\n}\n</script>\n```\n\nThe plugin can then be imported by name, exactly as it is under a bundler:\n\n```html\n<script type=\"module\">\nimport { createChart } from 'lightweight-charts';\nimport { RoundedCandleSeries } from '@tradingview/lwc-plugin-rounded-candles-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addCustomSeries(new RoundedCandleSeries(), {\n    upColor: '#089981',\n    downColor: '#F23645',\n    wickUpColor: '#089981',\n    wickDownColor: '#F23645',\n});\n\nseries.setData([\n    { time: '2024-04-22', open: 100.2, high: 104.6, low: 99.1, close: 103.8 },\n    { time: '2024-04-23', open: 103.8, high: 105.0, low: 101.4, close: 102.0 },\n    { time: '2024-04-24', open: 102.0, high: 106.1, low: 101.7, close: 105.4 },\n]);\n</script>\n```\n\n## Usage\n\nAdd the series with `addCustomSeries`, then set candlestick data:\n\n```js\nimport { createChart } from 'lightweight-charts';\nimport { RoundedCandleSeries } from '@tradingview/lwc-plugin-rounded-candles-series';\n\nconst chart = createChart(document.getElementById('container'));\nconst series = chart.addCustomSeries(new RoundedCandleSeries(), {\n    upColor: '#089981',\n    downColor: '#F23645',\n    wickUpColor: '#089981',\n    wickDownColor: '#F23645',\n});\n\nseries.setData([\n    { time: '2024-04-22', open: 100.2, high: 104.6, low: 99.1, close: 103.8 },\n    { time: '2024-04-23', open: 103.8, high: 105.0, low: 101.4, close: 102.0 },\n    { time: '2024-04-24', open: 102.0, high: 106.1, low: 101.7, close: 105.4 },\n]);\n```\n\nEach data point is `{ time, open, high, low, close }` — the same shape as the\nbuilt-in candlestick series. Points missing any of the four values are treated\nas whitespace, and leave a gap.\n\nA constant `radius` fixes the corner rounding regardless of zoom:\n\n```js\nseries.applyOptions({ radius: 6 });\n```\n\nOptions can be changed at runtime with `series.applyOptions({ ... })`.\n\n## Options\n\nIn addition to the standard\n[series options](https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon)\n(`priceLineVisible`, `lastValueVisible`, `priceFormat`, `autoscaleInfoProvider`, …):\n\n| Option | Type | Default | Description |\n| --- | --- | --- | --- |\n| `upColor` | `string` | `'#26a69a'` | Body color of rising candles. |\n| `downColor` | `string` | `'#ef5350'` | Body color of falling candles. |\n| `borderVisible` | `boolean` | `true` | Whether a border is drawn around the body. |\n| `borderUpColor` | `string` | `'#26a69a'` | Border color of rising candles. |\n| `borderDownColor` | `string` | `'#ef5350'` | Border color of falling candles. |\n| `borderColor` | `string` | — | Border color of both directions. Wins over `borderUpColor` / `borderDownColor` while it is set to a non-empty string. |\n| `wickVisible` | `boolean` | `true` | Whether wicks are drawn. |\n| `wickUpColor` | `string` | `'#26a69a'` | Wick color of rising candles. |\n| `wickDownColor` | `string` | `'#ef5350'` | Wick color of falling candles. |\n| `wickColor` | `string` | — | Wick color of both directions. Wins over `wickUpColor` / `wickDownColor` while it is set to a non-empty string. |\n| `wickLineCap` | `'butt' \\| 'round'` | `'butt'` | Shape of the two wick ends. |\n| `radius` | `number \\| ((barSpacing: number) => number)` | `bs => bs < 4 ? 0 : bs / 3` | Corner radius of the candle body, in CSS pixels. Either a constant, or a function of the current bar spacing. Use `0` for square candles. |\n| `upDownMode` | `'openClose' \\| 'previousClose'` | `'openClose'` | How a candle is decided to be rising or falling. `'openClose'` compares `open <= close`, exactly as the built-in candlestick series does. `'previousClose'` compares the close with the previous candle's close and treats the first candle as rising. |\n| `hoverDimOpacity` | `number` | `1` | Opacity of the candles other than the hovered one while the series is hovered. `1` leaves the series unchanged. |\n\nEach data point may also carry `color`, `borderColor` and `wickColor`, which\noverride the corresponding options for that candle only — the same per-item\noverrides the built-in candlestick series supports.\n\n## Notes\n\n- A candle counts as *rising* when `open <= close`, exactly as the built-in\n  candlestick series decides it. `upDownMode: 'previousClose'` restores the\n  behavior this plugin had while it was an example (close compared with the\n  previous close, the first candle always rising).\n- `borderColor` and `wickColor` are resolved at draw time, so clearing them\n  (setting them to an empty string) brings the up/down pair back. The built-in\n  series copies them into the pair once, in `applyOptions`, and cannot be\n  reverted that way.\n- Wicks are drawn above and below the body rather than as one bar behind it, so\n  a translucent body does not show its own wick through itself.\n- On Lightweight Charts™ 5.2 and later the series reports the candle under the\n  cursor through `hitTest`, and from 5.1 conflated candles are merged\n  open-first, close-last with the extremes of both.\n- Rounded corners use `CanvasRenderingContext2D.roundRect`, which every browser\n  the library supports provides.\n\n<!-- ... +26 more modular skills available via /api/skills/tradingview/lightweight-charts?path={path} -->\n</yakaai_skills>"}