How locupleto/streamlit-lightweight-charts-v5 works
Purpose and public entry point
This repository packages a Streamlit custom component that renders TradingView Lightweight Charts v5 from Python, emphasizing multi-pane financial/technical-analysis layouts. Python callers invoke lightweight_charts_v5_component from lightweight_charts_v5/__init__.py; the component accepts chart/series specifications and returns through Streamlit’s component bridge.
Python-to-frontend component boundary
The package root registers or exposes the Streamlit component and is the sole intended Python API boundary: lightweight_charts_v5/__init__.py. Chart configuration, data points, dimensions, and options cross from Streamlit’s Python runtime into the bundled browser frontend as serializable component arguments. The frontend owns chart construction and browser-side rendering.
Browser rendering application
The Vite/React application is the rendering runtime. lightweight_charts_v5/frontend/src/index.tsx boots the Streamlit component frontend, while lightweight_charts_v5/frontend/src/LightweightChartsComponent.tsx translates supplied chart definitions into Lightweight Charts instances, series, panes, sizing, and chart lifecycle updates. lightweight_charts_v5/frontend/index.html is the Vite browser entry document.
Chart composition model
The central data flow is: caller builds charts[] → each chart supplies chart-level options, a series collection, and height → React creates/configures corresponding Lightweight Charts structures. Series payloads use Lightweight Charts-compatible records (for example time/value or OHLC data), leaving indicator calculation and market-data acquisition outside the library. Multi-pane support is driven by the v5 chart configuration handled in lightweight_charts_v5/frontend/src/LightweightChartsComponent.tsx.
Specialized visual overlays
Browser-side plugins encapsulate non-core rendering layers that sit on chart data/scales rather than the Python API:
• Ichimoku cloud with span fills and regime coloring: lightweight_charts_v5/frontend/src/plugins/IchimokuCloudPlugin.ts
• Static support/resistance-style rectangles: lightweight_charts_v5/frontend/src/plugins/StaticRectanglePlugin.ts
These are integrated by the main React chart component, keeping custom canvas/chart primitives separate from generic series setup.
Demo applications and external data
Streamlit applications under demo/ are executable integration examples rather than library runtime dependencies. Main entry points are demo/minimal_demo.py and demo/chart_demo.py; standalone specialized examples include demo/volume_profile_demo.py and demo/ichimoku_demo.py. Demos obtain market data through Yahoo Finance via yfinance, then transform it into component-compatible chart payloads. Streamlit is the host runtime; TradingView Lightweight Charts is the browser charting dependency.
Delivery and verification
Python packaging/dependencies are defined by pyproject.toml and requirements.txt; the frontend’s Node/Vite dependency graph is in lightweight_charts_v5/frontend/package.json. CI and release automation run through .github/workflows/ci.yml and .github/workflows/release.yml. Browser-level component rendering is exercised through the Streamlit smoke application at e2e/smoke_app.py and its end-to-end checks.
Main entry points: __init__.py Component API · LightweightChartsComponent.tsx Chart renderer · index.tsx Frontend bootstrap · minimal_demo.py Minimal demo
Components 18
Python / Streamlit
- Component API · Sole public Python boundary for chart specifications.
lightweight_charts_v5/__init__.py - Streamlit bridge · Serializable arguments cross into the browser frontend.
Browser renderer
- Vite document
lightweight_charts_v5/frontend/index.html - Frontend bootstrap
lightweight_charts_v5/frontend/src/index.tsx - Chart renderer · Creates, updates, sizes, and disposes multi-pane chart instances.
lightweight_charts_v5/frontend/src/LightweightChartsComponent.tsx - Lightweight Charts v5 · Provides chart, pane, scale, and series primitives.
- Ichimoku cloud overlay · Draws span fills and regime coloring.
lightweight_charts_v5/frontend/src/plugins/IchimokuCloudPlugin.ts - Static rectangle overlay · Draws support/resistance-style rectangles.
lightweight_charts_v5/frontend/src/plugins/StaticRectanglePlugin.ts
Demo applications
- Minimal demo
demo/minimal_demo.py - Chart demo
demo/chart_demo.py - Specialized demos · Volume profile and Ichimoku examples.
demo/ichimoku_demo.py - Yahoo Finance · Demo market-data provider via yfinance.
Build & verification
- Python packaging
pyproject.toml - Frontend dependencies
lightweight_charts_v5/frontend/package.json - CI workflow
.github/workflows/ci.yml - Release workflow
.github/workflows/release.yml - Smoke app · Exercises browser-level component rendering.
e2e/smoke_app.py
Other components
- Chart specifications · charts[] contains options, series, data, and heights.
Connections 20
- Minimal demo → Yahoo Finance: fetches market data
- Chart demo → Yahoo Finance: fetches market data
- Specialized demos → Yahoo Finance: fetches market data
- Minimal demo → Component API: invokes
- Chart demo → Component API: invokes
- Specialized demos → Component API: invokes
- Component API → Chart specifications: accepts
- Component API → Streamlit bridge: registers / sends arguments
- Streamlit bridge → Frontend bootstrap: delivers component arguments
- Vite document → Frontend bootstrap: loads
- Frontend bootstrap → Chart renderer: mounts
- Chart specifications → Chart renderer: drives chart options and series
- Chart renderer → Lightweight Charts v5: creates charts, panes, and series
- Chart renderer → Ichimoku cloud overlay: integrates
- Chart renderer → Static rectangle overlay: integrates
- Python packaging → Component API: packages
- Frontend dependencies → Frontend bootstrap: supplies Vite/React runtime
- CI workflow → Smoke app: runs E2E checks
- Release workflow → Python packaging: publishes
- Smoke app → Component API: exercises