How dc.js Relates to Crossfilter and d3
Updated
dc.js is a charting library that sits on top of two other libraries: it uses Crossfilter for fast multi-dimensional filtering and aggregation, and d3 for rendering charts as SVG. In practice, you write one Crossfilter instance to hold your data, hand its dimensions and groups to dc.js charts, and dc.js uses d3 to draw them. The payoff is that charts become reactive: interacting with one chart filters the others automatically.
The three layers and what each one does
| Layer | Role | What you write |
|---|---|---|
| Crossfilter | Indexes records and computes filtered aggregations across many dimensions at once | Dimensions and groups over your dataset |
| d3 | Renders charts in CSS-friendly SVG | Usually nothing directly — dc.js calls it |
| dc.js | Provides chart components and wires them together so they stay in sync | Chart definitions bound to dimensions and groups |
The dc.js documentation describes it as "a javascript charting library with native crossfilter support, allowing highly efficient exploration on large multi-dimensional datasets," and notes that it "leverages d3 to render charts in CSS-friendly SVG format."
Why the split matters
Crossfilter is the engine. It maintains your records and, for each dimension you define, keeps a group that can be aggregated under the current filter state. That is what makes filtering across many dimensions efficient — you are not re-scanning the raw array on every interaction.
d3 is the renderer. dc.js does not draw pixels itself; it produces SVG through d3, which is why the output is styleable with CSS and scales cleanly.
dc.js is the coordination layer. It exposes ready-made chart types (bar, line, pie, bubble, choropleth, and more) and connects them so that a brush or click on one chart updates the Crossfilter state and every dependent chart re-renders. The docs call the charts "data driven and reactive" and say they "provide instant feedback to user interaction."
What this means for a decision to adopt it
- You get interactivity for free. Because the charts share one Crossfilter instance, cross-chart filtering is the default behavior rather than something you build. The Nasdaq 100 example on the site demonstrates this: selecting a time range zooms the other charts, and a "Reset All" control clears the filters.
- You are committing to the d3/Crossfilter stack. dc.js is a layer over both, not a replacement. If you want a charting library with no d3 dependency or a different data model, this is not it.
- It targets in-browser exploration. The docs position it for "data visualization and analysis in the browser and on mobile devices," which is the scenario where instant cross-filtering pays off most.
- It is aimed at being approachable. The site calls it "an easy yet powerful javascript library," and the annotated Nasdaq source is offered as the starting point for learning the pattern.
A concrete mental model
Picture the Nasdaq example: one Crossfilter holds ~27 years of index records. Dimensions are defined for day of week, quarter, and date range; groups aggregate gain/loss or fluctuation. Each dc.js chart is bound to one of those groups. When you drag a range on the time chart, Crossfilter recomputes the filtered groups, and every chart bound to them redraws via d3 — no manual re-querying or re-binding on your part.
Where to go next
The site points to the annotated source of the Nasdaq example, the API reference, the FAQ and wiki, and community examples (including a US venture capital choropleth and Canadian city crime stats). For questions and support it directs users to Stack Overflow or the user group, and bug reports to GitHub Issues — and it recommends forking the blank jsFiddle or bl.ock to get help faster with a working example.