Back to Trending
RepositoryTypeScriptCHSwitzerland
deepentropy

deepentropy/lightweight-charts-drawing

86 TradingView-style drawing tools for lightweight-charts v5: TradingView defaults, labels, hit tests and placement rules (lines, channels, pitchforks, Fibonacci, Gann, patterns, Elliott waves, forecasting, volume profiles, shapes, text)

163stars
54forks
0issues
2views

Featured achievements

The project's latest awards

1
TINIX TRENDING·Topic: gann

#1 Repository of the week

1
TINIX TRENDING·Topic: drawing-tools

#1 Repository of the week

1
TINIX TRENDING·Topic: trendline

#1 Repository of the week

lightweight-charts-drawing

Live Demo

68 drawing tools for TradingView's lightweight-charts library. Includes trend lines, Fibonacci tools, Gann analysis, channels, pitchforks, shapes, annotations, and forecasting tools.

Installation

npm install lightweight-charts-drawing lightweight-charts

Quick Start

import { createChart, CandlestickSeries } from 'lightweight-charts';
import { DrawingManager, TrendLine, FibRetracement } from 'lightweight-charts-drawing';

// Create chart
const chart = createChart(document.getElementById('chart')!, {
  width: 800,
  height: 400,
});

const series = chart.addSeries(CandlestickSeries);
series.setData([/* ... your OHLC data ... */]);

// Set up drawing manager
const manager = new DrawingManager();
manager.attach(chart, series, document.getElementById('chart')!);

// Add a trend line
const trendLine = new TrendLine('tl-1', [
  { time: '2024-01-15', price: 100 },
  { time: '2024-02-15', price: 110 },
], { lineColor: '#2962FF', lineWidth: 2 });

manager.addDrawing(trendLine);

// Add a Fibonacci retracement
const fib = new FibRetracement('fib-1', [
  { time: '2024-01-01', price: 95 },
  { time: '2024-03-01', price: 115 },
]);

manager.addDrawing(fib);

Lightweight-Charts Integration Example

import { createChart, CandlestickSeries, ColorType } from 'lightweight-charts';
import {
  DrawingManager,
  TrendLine,
  HorizontalLine,
  Rectangle,
  TextAnnotation,
  getToolRegistry,
} from 'lightweight-charts-drawing';

// Create chart
const container = document.getElementById('chart')!;
const chart = createChart(container, {
  layout: {
    background: { type: ColorType.Solid, color: '#131722' },
    textColor: '#d1d4dc',
  },
  width: 1000,
  height: 500,
});

const series = chart.addSeries(CandlestickSeries);
series.setData([/* ... OHLC data ... */]);

// Initialize drawing manager
const manager = new DrawingManager();
manager.attach(chart, series, container);

// Listen for events
manager.on('drawing:selected', (event) => {
  console.log('Selected:', event.drawingId);
});

// Add drawings programmatically
const support = new HorizontalLine('support', [
  { time: '2024-01-01' as any, price: 95 },
], { lineColor: '#26a69a', lineWidth: 1 });

manager.addDrawing(support);

// Select, deselect, remove
manager.selectDrawing('support');
manager.deselectAll();
manager.removeDrawing('support');

// Export/import drawings as JSON
const json = manager.exportDrawings();
// manager.importDrawings(json, factory);

// Access the tool registry for all 68 tool definitions
const registry = getToolRegistry();
const allTools = registry.getAllTools();

Available Drawing Tools (68)

Lines

ToolExportAnchors
Trend LineTrendLine2
RayRay2
Info LineInfoLine2
Extended LineExtendedLine2
Trend AngleTrendAngle2
Horizontal LineHorizontalLine1
Horizontal RayHorizontalRay1
Vertical LineVerticalLine1
Cross LineCrossLine1

Channels

ToolExportAnchors
Parallel ChannelParallelChannel3
Regression TrendRegressionTrend2
Flat Top/BottomFlatTopBottom3
Disjoint ChannelDisjointChannel4

Pitchforks

ToolExportAnchors
Andrews PitchforkAndrewsPitchfork3
Schiff PitchforkSchiffPitchfork3
Modified Schiff PitchforkModifiedSchiffPitchfork3
Inside PitchforkInsidePitchfork3

Fibonacci

ToolExportAnchors
Fib RetracementFibRetracement2
Fib ExtensionFibExtension3
Fib ChannelFibChannel3
Fib Time ZoneFibTimeZone2
Fib Speed FanFibSpeedFan2
Fib Time ExtensionFibTimeExtension3
Fib CirclesFibCircles2
Fib SpiralFibSpiral2
Fib ArcsFibArcs2
Fib WedgeFibWedge3
PitchfanPitchfan3

Gann

ToolExportAnchors
Gann BoxGannBox2
Gann FanGannFan2
Gann Square FixedGannSquareFixed1
Gann SquareGannSquare2

Forecasting & Measurement

ToolExportAnchors
Long PositionLongPosition3
Short PositionShortPosition3
ForecastForecast2
Bars PatternBarsPattern3
ProjectionProjection3
Price RangePriceRange2
Date RangeDateRange2
Date & Price RangeDatePriceRange2

Shapes

ToolExportAnchors
RectangleRectangle2
Rotated RectangleRotatedRectangle3
CircleCircle2
TriangleTriangle3
EllipseEllipse2
ArcArc3
PathPath2+
PolylinePolyline2+
CurveCurve4
Double CurveDoubleCurve3

Annotations

ToolExportAnchors
TextTextAnnotation1
CalloutCallout2
Anchored TextAnchoredText2
NoteNote1
Price NotePriceNote1
Price LabelPriceLabel1
Flag MarkFlagMark1
PinPin1
CommentComment1
SignpostSignpost1
TableTable1
BrushBrush2+
HighlighterHighlighter2+
ArrowArrow2
Arrow MarkerArrowMarker1
Arrow Mark UpArrowMarkUp1
Arrow Mark DownArrowMarkDown1

Architecture

Each drawing tool follows a two-class pattern:

  • Tool class (e.g. TrendLine) - extends Drawing, holds anchors/state, implements hit testing and geometry computation
  • Pane view (e.g. TrendLinePaneView) - implements IPrimitivePaneView from lightweight-charts, handles canvas rendering

The DrawingManager orchestrates lifecycle, selection, drag-editing, and event emission.

License

MIT

Similar Projects

Discover other similar projects and AI models.

RepositoryTypeScript
chenglou/pretext

Fast, accurate & comprehensive text measurement & layout

51.1k
Nov 25, 2026
RepositoryTypeScript
tradingview/lightweight-charts

Performant financial charts built with HTML5 canvas

18.0k
Nov 27, 2026
RepositoryTypeScript
LuxAlgo/PineTS

Run Pine Script® anywhere. PineTS is LuxAlgo's open-source Pine Script® runtime for Node.js and the browser.

1.0k
Nov 13, 2026
RepositoryTypeScript
deepentropy/lightweight-charts-indicators

1,713 technical analysis indicators for the lightweight-charts library: 117 standard, 1,551 community ports and 45 candlestick patterns, with a renderer for plots, drawings and tables

352
Dec 1, 2026
RepositoryTypeScript
tysonwu/dash-tradingview

Tradingview Lightweight Charts wrapper for Plotly Dash apps

181
Aug 24, 2026
RepositoryTypeScript
rohanbeingsocial/candlekit-charts

Tree-shakeable financial charting toolkit over lightweight-charts: candlestick/OHLC/line/area/volume, drawing tools, pluggable indicators, measurement, and deterministic replay. Framework-agnostic core + React bindings.

66
Oct 20, 2026
RepositoryTypeScript
n8n-io/n8n

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

212.9k
Dec 2, 2026
RepositoryTypeScript
microsoft/vscode

Visual Studio Code

195.9k
Nov 30, 2026
RepositoryTypeScript
excalidraw/excalidraw

Virtual whiteboard for sketching hand-drawn like diagrams

136.5k
Nov 28, 2026