# Chart.js vs D3.js: source lines of code compared

The Chart.js vs D3.js comparison on OctoCounts shows side-by-side source line counts for chartjs/Chart.js and d3/d3, counted with the same engine and analysis options on the dates shown in the methodology line: files, total lines, code lines, comment lines, blank lines, and per-language totals, pinned to the exact commits listed below.

As of 2026-08-26, chartjs/Chart.js contains 42,350 total lines (31,657 code) across 113 files, while d3/d3 contains 2,512 total lines (871 code) across 8 files as of 2026-08-26. chartjs/Chart.js is about 36x the size of d3/d3 by code lines. Code size is not code quality: a larger count only means more source material, not a better or worse project.

| Metric | [chartjs/Chart.js](https://octocounts.com/github/chartjs/Chart.js) | [d3/d3](https://octocounts.com/github/d3/d3) |
| --- | ---: | ---: |
| Files | 113 | 8 |
| Total lines | 42,350 | 2,512 |
| Code lines | 31,657 | 871 |
| Comment lines | 5,415 | 1,178 |
| Blank lines | 5,278 | 463 |
| Languages counted | 7 | 4 |

Top languages in chartjs/Chart.js: YAML (48.2% of code), JavaScript (35.9% of code), TypeScript (14.9% of code). Top languages in d3/d3: Shell (78.8% of code), JavaScript (10.7% of code), JSON (10.6% of code). JavaScript, JSON, Shell appear in both top language lists; YAML, TypeScript appear only in chartjs/Chart.js's top languages; Markdown appears only in d3/d3's top languages.

Methodology: both counts come from cached OctoCounts reports generated with tokei. chartjs/Chart.js was counted at ref master (commit cb02e1d207bd) on 2026-08-26; d3/d3 was counted at ref main (commit ca958d45217b) on 2026-08-26. See the [counting methodology](https://octocounts.com/docs/methodology) for ignored directories and analysis options.
## About this comparison

chartjs/Chart.js counts the Chart.js repository: a single canvas-based charting library with its test suite, samples, and documentation. d3/d3 counts the D3 repository, which distributes the D3 modules (d3-array, d3-scale, d3-shape, and roughly thirty interdependent packages) as one tree. The comparison is one self-contained charting library versus a modular visualization toolkit, counted on the dates in the methodology line.

The repository boundaries themselves are the main story: Chart.js keeps one library in one tree, while D3's tree aggregates dozens of small modules that are also published individually, so the right total is shaped by packaging decisions as much as by code volume.

The two projects operate at different abstraction layers — Chart.js renders ready-made chart types to a canvas element, while D3 provides primitives for binding data to documents — which the numbers alone cannot show but which matters when reading them side by side.

_A larger toolkit count does not mean more charts out of the box: D3 is lower-level building blocks, Chart.js is higher-level renderers. Neither number measures rendering quality, flexibility, or suitability for a given visualization._

Sources: [chartjs/Chart.js repository](https://github.com/chartjs/Chart.js) · [d3/d3 repository (D3 modules monorepo)](https://github.com/d3/d3). Statements verified 2026-09-16.

Evidence and next steps:

- [chartjs/Chart.js SLOC report](https://octocounts.com/github/chartjs/Chart.js)
- [d3/d3 SLOC report](https://octocounts.com/github/d3/d3)
- [Compare chartjs/Chart.js and d3/d3 interactively](https://octocounts.com/compare?left=https%3A%2F%2Fgithub.com%2Fchartjs%2FChart.js&right=https%3A%2F%2Fgithub.com%2Fd3%2Fd3)

Note: code size is not code quality. OctoCounts only reports reproducible line counts and makes no claim that either project is better.

## Compare FAQ

### Which has more lines of code, chartjs/Chart.js or d3/d3?

chartjs/Chart.js has more code: 31,657 code lines versus 871 for d3/d3, about 36x as much, based on cached OctoCounts reports as of 2026-08-26.

### Does more source lines of code mean more complexity?

Not necessarily. SLOC measures size, not complexity, quality, or maintainability. A larger codebase can mean more features, more generated or vendored code, more verbose language idioms, or more tests — none of which imply the code is harder to work with. Use SLOC to gauge the scale of what you'd be reading or maintaining, not as a quality signal for chartjs/Chart.js, d3/d3, or any repository.

### How is this comparison calculated?

Methodology: both counts come from cached OctoCounts reports generated with tokei. chartjs/Chart.js was counted at ref master (commit cb02e1d207bd) on 2026-08-26; d3/d3 was counted at ref main (commit ca958d45217b) on 2026-08-26. See the counting methodology for ignored directories and analysis options.

### Can I compare a different branch, tag, or commit?

Yes. This page shows the default branch for each repository. Use the interactive comparison tool to pick any public GitHub repository, branch, tag, or commit SHA for both sides and get a fresh side-by-side report.

## Related OctoCounts pages

- [Interactive repository comparison](https://octocounts.com/compare)
- [Recently analyzed repositories](https://octocounts.com/recent)
- [Popular SLOC reports](https://octocounts.com/popular)
- [Trending GitHub repositories](https://octocounts.com/trending)
- [Hall of Monoliths](https://octocounts.com/hall-of-monoliths)
- [Original research: how filtering changes SLOC counts](https://octocounts.com/research)
- [GitHub SLOC counter guide](https://octocounts.com/docs/github-sloc-counter)
- [Counting methodology](https://octocounts.com/docs/methodology)
- [SLOC and code metrics glossary](https://octocounts.com/docs/glossary)
- [OctoCounts API docs](https://octocounts.com/docs/api)
