https://github.com/dsnchz/solid-lightweight-charts
TradingView Lightweight Charts™ as SolidJS components
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.3%) to scientific vocabulary
Keywords
Repository
TradingView Lightweight Charts™ as SolidJS components
Basic Info
Statistics
- Stars: 9
- Watchers: 1
- Forks: 1
- Open Issues: 0
- Releases: 3
Topics
Metadata Files
README.md
@dschz/solid-lightweight-charts
A fully typed SolidJS wrapper around TradingView's Lightweight Charts, providing declarative, reactive charting with support for time series, price, and yield curve data.

📋 Table of Contents
- ✨ Features
- 🎉 What's New in v0.3.0
- 📆 Installation
- 🚀 Quick Usage
- 📏 Chart Sizing & Layout
- 📊 Chart Examples
- 🛠 Playground & Examples
- 📚 Resources
- 📄 License
✨ Features
- ⚡ SolidJS-native reactivity for all chart options and data updates
- 🔀 Multiple chart types with specialized APIs:
TimeChartfor time-based financial dataPriceChartfor numeric-based price dataYieldCurveChartfor rate curves and duration-based data
- 📈 Built-in series support: Line, Area, Candlestick, Bar, Histogram, Baseline
- 🎨 Custom series support with full TypeScript integration across all chart types
- 📍 Series markers with declarative prop support and reactive updates
- 📆 Namespaced APIs (e.g.
<TimeChart.Series />,<PriceChart.Series />) - 📊 Multi-Pane support for advanced multi-series visualization
- 🖼️ Pane/Series primitives for interactive drawings (trend lines, alerts, annotations)
- 🔄 Lifecycle/Event hooks for chart, series data, primitives and markers.
- 🔖 Core API compatibility - access underlying
lightweight-chartsAPIs when needed - 🧹 Automatic cleanup and proper lifecycle management
🎉 What's New in v0.3.0
- Major new features and improvements, including chart event subscription support, default class on chart containers, and improved sizing behavior.
- For a full list of changes and details, see the CHANGELOG.md.
📆 Installation
Install via your favorite package manager:
bash
npm install solid-js lightweight-charts @dschz/solid-lightweight-charts
pnpm install solid-js lightweight-charts @dschz/solid-lightweight-charts
yarn install solid-js lightweight-charts @dschz/solid-lightweight-charts
bun install solid-js lightweight-charts @dschz/solid-lightweight-charts
These are peer dependencies, so they must be installed manually:
solid-jslightweight-charts
🚀 Quick Usage
TimeChart (Time-based Data)
```tsx import { TimeChart } from "@dschz/solid-lightweight-charts";
PriceChart (Numeric X-axis)
```tsx import { PriceChart } from "@dschz/solid-lightweight-charts";
YieldCurveChart (Duration-based)
```tsx import { YieldCurveChart } from "@dschz/solid-lightweight-charts";
📏 Chart Sizing & Layout
Chart components (TimeChart, PriceChart, YieldCurveChart) do not apply any default sizing styles. You have complete control over how your charts are sized.
Understanding the Component Structure
It's important to understand that chart components have two levels of configuration:
```tsx <TimeChart class="h-[400px] w-full" // Applied to container div style={{ border: "1px solid red" }} // Applied to container div autoSize={true} // Passed to Lightweight Charts width={800} // Passed to Lightweight Charts (ignored if autoSize=true) height={400} // Passed to Lightweight Charts (ignored if autoSize=true)
```
Container Level (class, style, id):
- Controls the HTML div that wraps the chart
- Handles sizing, positioning, borders, backgrounds, etc.
- Uses standard CSS/HTML attributes
Chart Level (autoSize, width, height, chart options):
- Passed directly to the underlying Lightweight Charts instance
- Controls chart-specific behavior and rendering
- Uses Lightweight Charts API
How to Size Your Charts
Option 1: CSS Classes (Recommended)
tsx
<TimeChart class="h-[400px] w-full">
<TimeChart.Series type="Line" data={data} />
</TimeChart>
Option 2: Inline Styles
tsx
<TimeChart style={{ height: "400px", width: "100%" }}>
<TimeChart.Series type="Line" data={data} />
</TimeChart>
Option 3: Fixed Dimensions (autoSize=false)
tsx
<TimeChart autoSize={false} width={800} height={400}>
<TimeChart.Series type="Line" data={data} />
</TimeChart>
Understanding autoSize
autoSize: true(default): Chart fills its container div. Thewidthandheightprops are ignored.autoSize: false: Chart uses explicitwidthandheightprops for fixed dimensions.
Key Point: When autoSize={true}, the chart will automatically resize to match whatever size you've given the container div via class or style.
Container Class
All chart containers include the solid-lwc-container class for easy global styling:
css
.solid-lwc-container {
height: 400px;
width: 100%;
}
Common Patterns
Responsive with Tailwind:
tsx
<TimeChart class="h-[400px] w-full md:h-[500px]">
<TimeChart.Series type="Line" data={data} />
</TimeChart>
Fixed size for specific use cases:
tsx
<TimeChart autoSize={false} width={600} height={300}>
<TimeChart.Series type="Line" data={data} />
</TimeChart>
Parent container sizing:
tsx
<div class="h-[400px] w-full">
<TimeChart style={{ height: "100%", width: "100%" }}>
<TimeChart.Series type="Line" data={data} />
</TimeChart>
</div>
Container styling + chart options:
```tsx <TimeChart class="h-[500px] w-full border rounded-lg shadow" rightPriceScale={{ visible: true }} timeScale={{ timeVisible: true }}
``` Important: Charts need explicit dimensions to render. If you see a blank chart, make sure you've provided sizing through CSS classes, inline styles, or fixed dimensions.
📊 Chart Examples
Multiple Panes and Markers
```tsx import { TimeChart } from "@dschz/solid-lightweight-charts";
{/* Secondary pane with volume */}
Custom Series
```tsx import { TimeChart } from "@dschz/solid-lightweight-charts";
// Define your custom pane view const customPaneView = { updateAllViews() { /* implementation / }, paneViews() { / implementation / }, priceValueBuilder(plotRow) { / implementation / }, isWhitespace(data) { / implementation / }, defaultOptions() { / implementation */ }, };
Series Primitives
```tsx import { TimeChart, type SeriesPrimitive } from "@dschz/solid-lightweight-charts"; import type { ISeriesPrimitiveAxisView, IPrimitivePaneView, IPrimitivePaneRenderer, Time, SeriesAttachedParameter, } from "lightweight-charts";
// Trend line primitive with proper TypeScript implementation class TrendLinePrimitive implements SeriesPrimitive<"Line", Time> { private _paneViews: TrendLinePaneView[]; private _point1: { time: Time; value: number }; private _point2: { time: Time; value: number };
constructor(point1: { time: Time; value: number }, point2: { time: Time; value: number }) { this.point1 = point1; this.point2 = point2; this._paneViews = [new TrendLinePaneView(this)]; }
updateAllViews() { this._paneViews.forEach((pv) => pv.update()); }
paneViews() { return this._paneViews; }
attached(param: SeriesAttachedParameter
detached() { // Cleanup when primitive is detached }
getPoint1() { return this.point1; } getPoint2() { return this.point2; } }
class TrendLinePaneView implements IPrimitivePaneView { private _source: TrendLinePrimitive; private _renderer: TrendLinePaneRenderer;
constructor(source: TrendLinePrimitive) { this.source = source; this.renderer = new TrendLinePaneRenderer(); }
update() { this.renderer.setData({ point1: this.source.getPoint1(), point2: this._source.getPoint2(), }); }
renderer() { return this._renderer; }
zOrder() { return "normal" as const; } }
class TrendLinePaneRenderer implements IPrimitivePaneRenderer { private _data: { point1: any; point2: any } | null = null;
setData(data: { point1: any; point2: any } | null) { this._data = data; }
draw(target: any) { if (!this.data) return; // Canvas 2D rendering implementation target.useBitmapCoordinateSpace((scope: any) => { const ctx = scope.context; // Draw trend line using this.data.point1 and this._data.point2 // ... drawing logic }); } }
const trendLine = new TrendLinePrimitive( { time: "2023-01-01" as Time, value: 100 }, { time: "2023-01-10" as Time, value: 120 }, );
Pane Primitives
```tsx import { TimeChart, type PanePrimitive } from "@dschz/solid-lightweight-charts"; import type { IPanePrimitivePaneView, IPrimitivePaneRenderer, PaneAttachedParameter, Time, } from "lightweight-charts";
// Watermark primitive with proper TypeScript implementation class WatermarkPrimitive implements PanePrimitive
constructor(text: string, color = "rgba(128, 128, 128, 0.3)", fontSize = 48) { this.text = text; this.color = color; this.fontSize = fontSize; this.paneViews = [new WatermarkPaneView(this)]; }
updateAllViews() { this._paneViews.forEach((pv) => pv.update()); }
paneViews() { return this._paneViews; }
attached(param: PaneAttachedParameter
detached() { // Cleanup if needed }
getText() { return this.text; } getColor() { return this.color; } getFontSize() { return this._fontSize; } }
class WatermarkPaneView implements IPanePrimitivePaneView { private _source: WatermarkPrimitive; private _renderer: WatermarkPaneRenderer;
constructor(source: WatermarkPrimitive) { this.source = source; this.renderer = new WatermarkPaneRenderer(); }
update() { this.renderer.setData({ text: this.source.getText(), color: this.source.getColor(), fontSize: this.source.getFontSize(), }); }
renderer() { return this._renderer; }
zOrder() { return "bottom" as const; } }
class WatermarkPaneRenderer implements IPrimitivePaneRenderer { private _data: { text: string; color: string; fontSize: number } | null = null;
setData(data: { text: string; color: string; fontSize: number } | null) { this._data = data; }
draw(target: any) { if (!this._data) return;
target.useBitmapCoordinateSpace((scope: any) => {
const ctx = scope.context;
const { width, height } = scope.bitmapSize;
ctx.save();
ctx.font = `${this._data!.fontSize}px Arial`;
ctx.fillStyle = this._data!.color;
ctx.textAlign = "center";
ctx.textBaseline = "middle";
// Draw watermark in center of pane
ctx.fillText(this._data!.text, width / 2, height / 2);
ctx.restore();
});
} }
const watermark = new WatermarkPrimitive("DEMO CHART");
<TimeChart.Series type="Histogram" data={volumeData} />; ```
💡 Complete Examples: For fully working primitive implementations with comprehensive TypeScript types, see the interactive examples in our playground:
SeriesPrimitivesExample.tsx- Trend lines, support/resistance, price alerts, annotationsPanePrimitivesExample.tsx- Watermarks, grid overlays, corner badges
🛠 Playground & Examples
See playground/App.tsx for a complete working showcase with live interactive examples:
Core Chart Types:
- TimeChart with multiple panes (Candlestick+Line, Volume, Area) and series markers
- PriceChart with multiple panes (Line+Area, Histogram) and series markers
- YieldCurveChart with multiple panes (Line, Area) and series markers
Advanced Features (New in v0.2.0):
- Series Primitives Example - Interactive trend lines, support/resistance levels, price alerts, and text annotations
- Pane Primitives Example - Watermarks, custom grid overlays, and corner badges with live updates
- Custom Series Integration - Complete examples with proper TypeScript interfaces
- Dynamic Management - Real-time updates, lifecycle management, and memory optimization
Run the playground locally:
bash
git clone https://github.com/dsnchz/solid-lightweight-charts
cd solid-lightweight-charts
bun install
bun start
📚 Resources
Full documentation and advanced guides coming soon.
📄 License
MIT © Daniel Sanchez
Owner
- Name: dsnchz
- Login: dsnchz
- Kind: organization
- Repositories: 1
- Profile: https://github.com/dsnchz
GitHub Events
Total
- Release event: 6
- Watch event: 5
- Push event: 25
- Create event: 10
Last Year
- Release event: 6
- Watch event: 5
- Push event: 25
- Create event: 10
Packages
- Total packages: 1
-
Total downloads:
- npm 50 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 13
- Total maintainers: 1
npmjs.org: @dschz/solid-lightweight-charts
TradingView Lightweight Charts™ as SolidJS components
- Homepage: https://github.com/dsnchz/solid-lightweight-charts#readme
- License: MIT
-
Latest release: 0.3.3
published 8 months ago