django-d3-bridge¶
Declarative D3.js visualizations for Django.
Write Python, render D3.js — no JavaScript required.
What is django-d3-bridge?¶
django-d3-bridge is a Python package that lets you create D3.js visualizations entirely from Python. You declare your chart in a Django view, pass it to the template, and the package generates pure D3.js code — fully interactive, animated, and responsive.
from d3_bridge import BarChart
chart = BarChart(
data=Product.objects.values("name", "sales"),
x="name", y="sales",
title="Sales by Product",
theme="bootstrap",
)
That's it. No JavaScript to write.
19 Chart Types¶
| Category | Charts |
|---|---|
| Basic | Bar, Line, Area, Pie, Donut, Scatter |
| Geographic | Choropleth Map, Bubble Map |
| Network | Force Graph, Sankey, Chord Diagram |
| Hierarchy | Tree, Treemap, Circle Packing, Sunburst, Dendrogram |
| Statistical | Contour Plot, Density Plot, Voronoi Diagram |
All 19 types share the same API pattern: declare in Python, render in template.
3 Data Modes¶
Data comes from a Django QuerySet, evaluated at each page load.
Chart auto-refreshes via HTTP fetch at a configurable interval. No WebSocket needed.
Key Features¶
- Pure D3.js output — no abstraction layer at runtime, inspectable in DevTools
- Django-native — works with QuerySets, GeoQuerySets, template tags
- Zero JS dependencies beyond D3.js v7
- Bootstrap-aware — charts adapt to
col-*grid, inherit fonts - 4 built-in themes — default, dark, bootstrap, terraf
- 7 color palettes — tableau10, warm, cool, earth, sahel, ocean, categorical8
- Responsive — auto-resize on container change
- Animated — smooth D3 transitions on load
- Tooltips — interactive tooltips on all chart types
- Escape hatch — inject custom D3.js when you need full control