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 under the rules and on the dates stated below: files, total lines, code lines, comment lines, blank lines, and per-language totals, pinned to the exact commits listed below.

This page compares the source lines of code (SLOC) of chartjs/Chart.js and d3/d3 using cached OctoCounts reports. Code size is not code quality: a larger count only means more source material, not a better or worse project.

As of 2026-10-24, chartjs/Chart.js contains 42,398 total lines (31,692 code) across 113 files, while d3/d3 contains 6,044 total lines (3,652 code) across 11 files as of 2026-11-03. These reports use different engines or counting rules; no like-for-like size ratio is stated. Code size is not code quality: a larger count only means more source material, not a better or worse project.

Metricchartjs/Chart.jsd3/d3
Files11311
Total lines42,3986,044
Code lines31,6923,652
Comment lines5,4221,178
Blank lines5,2841,214
Languages counted75

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: YAML (75.2% of code), Shell (18.8% of code), JavaScript (3.4% of code). YAML, JavaScript, JSON, Shell appear in both top language lists; TypeScript appears 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 71d44219e79e) on 2026-10-24; d3/d3 was counted at ref main (commit db118c93a429) on 2026-11-03. See the counting methodology for ignored directories and analysis options.

These reports use different engines or counting rules; do not interpret their ratio as a like-for-like comparison. chartjs/Chart.js: tokei-14.0.0, policy directories-v1; docs excluded, tests excluded, generated excluded. Excluded directory names: .cache, .generated, .git, .next, __tests__, build, dist, doc, docs, documentation, fixtures, gen, generated, node_modules, target, test, tests, vendor. Ignored languages: none. Repository declarations: off. Exclusions are rule-based; they do not prove that every test, document or generated file was removed. d3/d3: tokei-15.0.0, policy directories-v1; docs excluded, tests excluded, generated excluded. Excluded directory names: .cache, .generated, .git, .next, __tests__, build, dist, doc, docs, documentation, fixtures, gen, generated, node_modules, target, test, tests, vendor. Ignored languages: none. Repository declarations: off. Exclusions are rule-based; they do not prove that every test, document or generated file was removed.

About this comparison

Background observations recorded on 2026-09-16; language descriptions here are historical context, not claims about the current filtered shares. Use this page's measured language breakdown for current counts. Repository layout before counting filters: chartjs/Chart.js is the Chart.js repository: a single canvas-based charting library with its test suite, samples, and documentation. d3/d3 is 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 · d3/d3 repository (D3 modules monorepo). Statements verified 2026-09-16.

Evidence and next steps:

Saved reports remain subject to cache cleanup and replacement. Export their JSON for durable citation; live report URLs can change.

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?

As of 2026-10-24, chartjs/Chart.js contains 42,398 total lines (31,692 code) across 113 files, while d3/d3 contains 6,044 total lines (3,652 code) across 11 files as of 2026-11-03. These reports use different engines or counting rules; no like-for-like size ratio is stated. Code size is not code quality: a larger count only means more source material, not a better or worse project.

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 71d44219e79e) on 2026-10-24; d3/d3 was counted at ref main (commit db118c93a429) on 2026-11-03. 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.