@vecordis/lightweight-plugins
Drawing tools for TradingView Lightweight Charts v5.
pnpm add @vecordis/lightweight-plugins lightweight-chartsDrawing needs a mouse; on a touch screen you can look at the drawings but not make new ones.
Shortcuts
- Delete / Backspace
- delete the selection
- Escape
- cancel, disarm, deselect
- Ctrl+C / Ctrl+V
- copy / paste
- Ctrl+drag
- marquee-select
- Alt+drag
- duplicate while dragging
- Right-click
- cancel the current drawing
Usage
import { createChart, CandlestickSeries } from 'lightweight-charts';
import { DrawingManager } from '@vecordis/lightweight-plugins';
const chart = createChart(container);
const series = chart.addSeries(CandlestickSeries);
series.setData(candles); // times as UTCTimestamp seconds
const drawings = new DrawingManager(chart, series);
drawings.setTool('trend'); // then click twice on the chart
drawings.on('change', () => save(drawings.getDrawings()));
drawings.setDrawings(load()); // restore saved drawings