Ultra-simple TradingView Lightweight Charts integration for Jupyter notebooks. No widget infrastructure, no build steps, just works.
lwcharts takes a radically simple approach to displaying charts in Jupyter:
- ✅ No JavaScript build required - Uses inline HTML with CDN-loaded libraries
- ✅ No widget infrastructure - Just pure IPython HTML display
- ✅ Works everywhere - PyCharm, JupyterLab, VS Code, Colab, anywhere Jupyter runs
- ✅ Zero configuration - Install and use immediately
- ✅ Tiny package - Less than 2KB, only depends on IPython
pip install lwchartsThat's it! No additional setup, no extensions to install, no build steps.
from lwcharts import Chart
chart = Chart(chart_type='line', width=800, height=400)
chart.data = [
{'time': '2025-01-01', 'value': 100},
{'time': '2025-01-02', 'value': 110},
{'time': '2025-01-03', 'value': 105},
{'time': '2025-01-04', 'value': 120},
]
chart # Display the chartfrom lwcharts import Chart
chart = Chart(chart_type='candlestick', width=800, height=400)
chart.data = [
{'time': '2025-01-01', 'open': 100, 'high': 110, 'low': 95, 'close': 105},
{'time': '2025-01-02', 'open': 105, 'high': 115, 'low': 100, 'close': 112},
{'time': '2025-01-03', 'open': 112, 'high': 120, 'low': 108, 'close': 115},
]
chartchart = Chart(chart_type='line')
chart.data = [{'time': '2025-01-01', 'value': 100}, ...]chart = Chart(chart_type='area')
chart.data = [{'time': '2025-01-01', 'value': 100}, ...]chart = Chart(chart_type='candlestick')
chart.data = [
{'time': '2025-01-01', 'open': 100, 'high': 110, 'low': 95, 'close': 105},
...
]chart = Chart(chart_type='bar')
chart.data = [
{'time': '2025-01-01', 'open': 100, 'high': 110, 'low': 95, 'close': 105},
...
]chart = Chart(chart_type='histogram')
chart.data = [
{'time': '2025-01-01', 'value': 50000, 'color': '#26a69a'},
...
]chart = Chart(chart_type='line', width=1000, height=600)chart = Chart(chart_type='candlestick')
# Customize appearance
chart.chart_options = {
'layout': {
'background': {'color': '#1e1e1e'},
'textColor': '#d1d4dc',
},
'grid': {
'vertLines': {'color': '#2a2a2a'},
'horzLines': {'color': '#2a2a2a'},
},
}# Customize candlestick colors
chart.series_options = {
'upColor': '#26a69a',
'downColor': '#ef5350',
'wickUpColor': '#26a69a',
'wickDownColor': '#ef5350',
}import pandas as pd
import yfinance as yf
from lwcharts import Chart
# Download stock data
ticker = yf.Ticker('AAPL')
df = ticker.history(period='1mo')
# Convert to lwc format
data = [
{
'time': index.strftime('%Y-%m-%d'),
'open': row['Open'],
'high': row['High'],
'low': row['Low'],
'close': row['Close'],
}
for index, row in df.iterrows()
]
# Display chart
chart = Chart(chart_type='candlestick', width=1000, height=600)
chart.data = data
chartWorks in any Jupyter environment:
| Environment | Status |
|---|---|
| PyCharm Professional | ✅ Works |
| JupyterLab | ✅ Works |
| Jupyter Notebook | ✅ Works |
| VS Code | ✅ Works |
| Google Colab | ✅ Works |
| Kaggle Notebooks | ✅ Works |
| Databricks | ✅ Works |
Chart(
chart_type='line', # 'line', 'area', 'candlestick', 'bar', 'histogram'
width=800, # Chart width in pixels
height=400 # Chart height in pixels
)data(list): Chart data pointschart_type(str): Type of chartwidth(int): Chart width in pixelsheight(int): Chart height in pixelschart_options(dict): Chart configurationseries_options(dict): Series configuration
display(): Explicitly display the chartset_data(data): Set chart dataadd_data_point(point): Add a single data point
Unlike traditional Jupyter widgets that require complex JavaScript builds and widget infrastructure, lwcharts uses a simple approach:
- Creates HTML with embedded JavaScript
- Loads lightweight-charts library from CDN (unpkg.com)
- Generates inline JavaScript to create and populate the chart
- Returns HTML via
_repr_html_()for Jupyter display
This means:
- ✅ No RequireJS/AMD module loading issues
- ✅ No widget registration needed
- ✅ No nbextension installation
- ✅ Works immediately after
pip install
See the examples.ipynb notebook for more usage examples including all chart types and customization options.
- Python 3.7+
- IPython (automatically installed with Jupyter)
- Internet access (to load lightweight-charts from CDN)
For chart options and customization, see the TradingView Lightweight Charts documentation.
Apache License 2.0 - See LICENSE file for details.
Built on TradingView Lightweight Charts
- Open an issue on GitHub
- Check the examples.ipynb notebook
- Read the TradingView docs