← 返回列表
全部 Skill›商业 Business›lightweight-charts-react-components

lightweight-charts-react-components

作者 @github · 语言 en
lightweight-charts-react-components recipes for TradingView lightweight-charts in React. Candlestick, line, and area series; volume and indicator panes; realtime WebSocket updates; infinite history on scroll; crosshair OHLC legends and tooltips; trade markers and price lines; synchronized charts; numeric options and yield-curve axes. Use when adding or fixing a financial or trading chart in a React app, or when the user mentions lightweight-charts, TradingView charts in React, or this package.
商业 Business金融与投资通用执行命令访问网络待翻译
最近源活动
—
检测 SKILL.md 语言
en
星标 ★
41,524
分支 Fork
0
安装选项
提示
指令
使用 AI 助手安装
将下面的提示复制到你正在使用的 AI 助手中。
下载完整 Skill 目录(含全部配套文件)。 下载压缩包 ↓
SKILL.md 原文预览

lightweight-charts-react-components guide

Quick Start

Let the components manage chart and series creation and cleanup. Import components

and ref types from lightweight-charts-react-components; import native data, option,

and event types from lightweight-charts.

  1. Check versions against the compatibility table below. Read declared ranges

from the app's package.json, then the installed versions from the version

field of node_modules/<package>/package.json for

lightweight-charts-react-components, lightweight-charts, react, and

react-dom. If the library is not installed, follow

Installation. Ensure chart rendering runs in the browser,

within the app's client boundary.

  1. For a basic static chart, start from the minimal chart below. Otherwise, read the

reference matching the requested behavior. Adapt its feed and UI; preserve its

data contract, component nesting, and API readiness handling.

  1. Choose one data owner: pass the complete dataset through data for React-owned

updates, or use reactive={false} and the series API for frequent ticks.

Installation

Install the wrapper together with its lightweight-charts peer dependency, using

the project's package manager. React and React DOM must already be installed.

npm install lightweight-charts-react-components lightweight-charts

Minimal chart

import type { LineData, UTCTimestamp } from "lightweight-charts";
import {
  Chart,
  LineSeries,
  TimeScale,
  TimeScaleFitContentTrigger,
} from "lightweight-charts-react-components";

// Data must be sorted ascending by time with unique times (UTC seconds here).
export function SimpleLineChart({ data }: { data: LineData<UTCTimestamp>[] }) {
  return (
    // autoSize follows the container, which needs a nonzero height.
    <Chart
      options={{ autoSize: true }}
      containerProps={{ style: { height: 300, width: "100%" } }}
    >
      <LineSeries data={data} />
      <TimeScale>
        <TimeScaleFitContentTrigger deps={[]} />
      </TimeScale>
    </Chart>
  );
}

Examples and snippets (reference files)

Read the reference matching the user's outcome. Each contains a complete TypeScript

recipe, data and integration contracts, reasons for the architecture, failure modes,

and acceptance checks. Combine references when a task spans several outcomes; do

not load every reference for a simple chart.

| User request | Reference |

| ------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------- |

| WebSocket candles, updating the current bar, stale history, excessive chart renders | Market data and live updates |

| Older history on scroll, viewport jumps, symbol/interval changes, late API responses | History and range selection |

| Candles plus volume, moving averages, oscillator panes, independent price scales | Price, volume, and indicators |

| OHLC legend, hover details, missing data, tooltip positioning | Hover legends and tooltips |

| Executions and signals, stop/target levels, click-to-place price lines | Trade markers and price levels |

| Compare assets with different prices, fixed-baseline returns, toggle comparisons | Performance comparison |

| Separate charts that share scrolling, zooming, and a crosshair | Synchronized charts |

| Trading-session shading, pane backgrounds, custom drawing that follows zoom | Session overlays and primitives |

| Options strikes, yield maturities, choosing a numeric or custom horizontal axis | Numeric axes and chart types |

If no reference matches the request, tell the user that the skill has no recipe

for it. Then build the solution from the public components and the upstream

lightweight-charts API, applying the Quick Start rules and the edge cases below.

Skill compatibility

The recipes are verified against the reference versions below. These are the

tested baseline, not the latest available releases.

If an installed version differs from the reference version, compare it with the

compatibility range. Inside the range, recipes apply as written. Outside it,

tell the user about the mismatch before writing code, because breaking API

changes can affect the recipes, and verify every API the recipe uses against

the installed package.

| Dependency or environment | Reference version | Compatibility range and checks

评论
Ggithub
github
github/awesome-copilot
查看 GitHub 仓库 查看作者的其他 Skill
来源信息
作者@github
所属大类商业 Business / 金融与投资
国内可用性通用
最近源活动—
风险提示执行命令、访问网络
提示:风险标签为程序静态扫描结果,仅作提示,不代表安全认证。安装前请阅读 SKILL.md 及其引用的脚本、权限,自行判断是否可信。