Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

oakview

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oakview

TradingView-style charting Web Component built on lightweight-charts v5

latest
Source
npmnpm
Version
0.4.2
Version published
Weekly downloads
114
132.65%
Maintainers
1
Weekly downloads
 
Created
Source

OakView

npm version License: MIT

A TradingView-style charting Web Component built on lightweight-charts v5. Drop-in chart with toolbar, drawing tools, and flexible data provider architecture.

Features

  • Simple Integration: <oak-view> - single tag for full-featured charts
  • TradingView UI: Built-in toolbar, symbol search, interval selector, chart types
  • Drawing Tools: 21 professional drawing tools (trend lines, Fibonacci, shapes)
  • Data Agnostic: Bring your own data provider (REST, WebSocket, CSV)
  • Full API Access: Direct access to lightweight-charts v5 API
  • Framework Agnostic: Works with React, Vue, Angular, or vanilla JS
  • Multiple Layouts: Single, dual, triple, or quad pane layouts
  • Theme Support: Light and dark themes

Installation

npm install oakview

Quick Start

<!DOCTYPE html>
<html>
<head>
  <script type="module">
    import 'oakview';
    import { OakViewDataProvider } from 'oakview';

    class MyProvider extends OakViewDataProvider {
      async initialize() { /* Connect to your data source */ }

      async fetchHistorical(symbol, interval) {
        const response = await fetch(`/api/bars/${symbol}/${interval}`);
        const data = await response.json();
        return data.map(bar => ({
          time: bar.timestamp,  // Unix seconds
          open: bar.open,
          high: bar.high,
          low: bar.low,
          close: bar.close,
          volume: bar.volume
        }));
      }
    }

    const chart = document.getElementById('chart');
    const provider = new MyProvider();
    await provider.initialize();
    chart.setDataProvider(provider);
  </script>
</head>
<body>
  <oak-view id="chart" symbol="AAPL" theme="dark"></oak-view>
</body>
</html>

Data Providers

OakView uses a flexible data provider system. Implement these methods:

MethodRequiredDescription
initialize(config)YesConnect to data source
fetchHistorical(symbol, interval)YesLoad OHLCV bars
subscribe(symbol, interval, callback)NoReal-time updates
searchSymbols(query)NoSymbol search
getAvailableIntervals(symbol)NoList timeframes

Example Providers

Data Format

// OHLCV bar format
{
  time: 1700000000,    // Unix timestamp in SECONDS (not milliseconds)
  open: 150.00,
  high: 152.50,
  low: 149.00,
  close: 151.75,
  volume: 1000000      // Optional
}

Important: Time must be in Unix seconds. Data must be sorted ascending (oldest first).

API Reference

<oak-view> Attributes

AttributeTypeDefaultDescription
layout'single' | 'dual' | 'triple' | 'quad''single'Pane layout
symbolstring'SYMBOL'Initial symbol
theme'light' | 'dark''dark'Color theme

Layout Methods

const chart = document.getElementById('chart');

// Set data provider
chart.setDataProvider(provider);

// Get chart pane (0-indexed)
const pane = chart.getChartAt(0);

// Get pane count
const count = chart.getChartCount();

// Change layout
chart.setLayout('dual');

Chart Pane Methods

const pane = chart.getChartAt(0);

// Set OHLCV data
pane.setData(bars);

// Update real-time
pane.updateRealtime(bar);

// Get lightweight-charts instance (full API access)
const lwChart = pane.getChart();

// Get main series
const series = pane.getSeries();

Events

chart.addEventListener('symbol-change', (e) => {
  console.log('Symbol:', e.detail.symbol);
});

chart.addEventListener('interval-change', (e) => {
  console.log('Interval:', e.detail.interval);
});

Direct API Access

Access the underlying lightweight-charts v5 API for advanced features:

const pane = chart.getChartAt(0);

// Get lightweight-charts instance
const lwChart = pane.getChart();
const series = pane.getSeries();

// Add price lines
series.createPriceLine({
  price: 150.00,
  color: '#FF9800',
  title: 'Entry'
});

// Add markers
series.setMarkers([{
  time: 1700000000,
  position: 'belowBar',
  color: '#26a69a',
  shape: 'arrowUp',
  text: 'BUY'
}]);

// Configure time scale
lwChart.timeScale().fitContent();

Drawing Tools

21 professional drawing tools organized by category:

  • Lines: Trend Line, Horizontal, Vertical, Ray, Arrow, Extended Line
  • Fibonacci: Retracement, Parallel Channel
  • Shapes: Rectangle, Circle, Triangle, Price Range
  • Annotations: Text, Callout, Brush, Highlighter, Path
const pane = chart.getChartAt(0);

// Activate tool
pane.setActiveTool('trend-line');

// Add drawing programmatically
pane.addDrawing('horizontal-line', [
  { time: 1700000000, price: 150 }
], { lineColor: '#ef5350' });

// Export/import drawings
const json = pane.exportDrawings();
pane.importDrawings(json);

Development

# Install dependencies
npm install

# Start dev server
npm run dev

# Build for production
npm run build

# Run tests
npm test

Browser Support

  • Chrome/Edge 79+
  • Firefox 63+
  • Safari 13.1+

Tech Stack

License

MIT

Keywords

charts

FAQs

Package last updated on 10 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts