chartjs-adapter-date-fns

Lets Chart.js parse, format, and calculate time-scale dates using date-fns instead of its default date engine.

Library
npm
v3.0.0
122stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
40/100Fair
Development Activity0
Maintenance20
Community60
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
66/100Good
Architecture78
Code Quality72
Innovation68
Learning Curve45

chartjs-adapter-date-fns is a lightweight adapter that plugs date-fns into Chart.js’s time-scale axis system. Once imported alongside Chart.js and date-fns, it overrides Chart.js’s built-in _adapters._date object with implementations backed by date-fns’s parse, format, arithmetic, and boundary functions, covering everything from millisecond-level formatting to week, quarter, and year rollups.

Chart.js only ships a generic date-adapter interface and leaves the actual date engine to consumers, so teams already using date-fns elsewhere in their app can standardize on one date library instead of pulling in Moment.js or Luxon just to satisfy Chart.js’s time-scale requirements. The adapter itself has no configuration API beyond a side-effect import; locale support is handled entirely through Chart.js’s own adapters.date.locale scale option.

What You Get

  • A full override of Chart.js’s _date adapter (parse, format, add, diff, startOf, endOf) backed entirely by date-fns
  • Sensible default format strings for every Chart.js time unit, from millisecond up to year
  • Locale support by passing any date-fns locale object through the scale’s adapters.date.locale option
  • Both ESM and minified UMD bundle builds, plus a jsDelivr/unpkg CDN distribution

Common Use Cases

  • Rendering a time-series line or bar chart where the x-axis needs to auto-format ticks from milliseconds up to years
  • Standardizing on date-fns across an app that already avoids Moment.js or Luxon, including for Chart.js’s time scale
  • Localizing chart axis labels and tooltips using a specific date-fns locale (e.g. de, ja, fr)
  • Formatting dashboard time-series data (metrics, logs, financial data) with fine-grained per-unit tick formats

Under The Hood

Architecture The entire package is a single ~114-line src/index.js file that imports Chart.js’s internal _adapters registry and a set of date-fns functions, then calls _adapters._date.override({...}) once with an object literal implementing the seven-method Chart.js date-adapter contract (formats, parse, format, add, diff, startOf, endOf). There is no internal layering, class hierarchy, or caching beyond the format map and per-unit switch statements — Chart.js’s time scale calls straight into these methods with primitive timestamps and unit strings, and each method delegates directly to the matching date-fns function. This is a minimal, direct-delegation integration: if Chart.js ever changed the shape of its _adapters._date contract, the whole file would need to change in lockstep since there’s no compatibility shim.

Tech Stack The package declares zero runtime dependencies — only peerDependencies on chart.js (>=2.8.0) and date-fns (>=2.0.0) — plus a dev toolchain of Rollup 3 (with node-resolve and terser plugins) for producing ESM, CommonJS, and minified UMD bundle outputs, Karma 6 with Jasmine and Chrome/Firefox launchers for real-browser test execution, and ESLint 8 with the shared eslint-config-chartjs ruleset. It ships three distribution targets for different consumption paths: an ESM build, a CommonJS build via package exports, and a minified UMD bundle served from jsDelivr/unpkg for CDN use. There is no server, database, or build-time codegen — this is a pure browser-side plugin.

Code Quality Tests run in real browsers (not headless mocks) via Karma, driving actual Chart.js and date-fns behavior end-to-end across a single Jasmine spec file that exercises the adapter’s format presets and parse/format round-tripping. CI runs a GitHub Actions matrix across Ubuntu and Windows, reporting coverage to Coveralls for both Chrome and Firefox runs, and a separate workflow automates npm publishing on GitHub release — comprehensive process infrastructure for a small package, even though the test suite itself covers a limited set of scenarios. There are no TypeScript definitions in this package (consumers rely on Chart.js’s own types for the adapter shape) and error handling is minimal — malformed format strings would surface as uncaught date-fns exceptions rather than adapter-level validation.

API Design The entire integration surface is a single side-effect import (import 'chartjs-adapter-date-fns') — there is nothing to instantiate or configure directly; Chart.js’s time scale auto-detects the registered adapter. The only consumer-facing configuration point, locale selection, reuses an option Chart.js already exposes (adapters.date.locale) rather than inventing a new one, and peerDependencies correctly use version floors instead of exact pins to avoid duplicate-install conflicts. The README documents install, CDN usage, and locale configuration with runnable snippets. The main ergonomic wart is that importing the module mutates global Chart.js state as a side effect with no exported API signaling that — a new consumer has to read the README to understand what the bare import actually does.

Used by 11 apps in this directory

Python
56%
Other

authentik

Authentication · Security

25,385

The self-hosted Identity Provider that replaces Okta, Auth0, and Entra ID with a unified SSO platform supporting SAML, OAuth2/OIDC, LDAP, RADIUS, and WebAuthn.

View details
92
Repo Health
81
Technical
66
Dependency
Built with
Python56%
TypeScript34%
Updated yesterday
JavaScript
99%
Other

ChartBrew

Analytics · Databases

4,054

Open-source reporting platform to build live dashboards from SQL, NoSQL, APIs, and SaaS tools with an AI assistant that creates charts from natural language.

View details
90
Repo Health
83
Technical
64
Dependency
Built with
JavaScript99%
Updated 4 days ago
Go
73%
Other

Flipt

Devops · Developer Tools

4,888

Git-native feature flag platform that stores, versions, and deploys feature toggles directly in your own Git repositories with no external database required.

View details
90
Repo Health
83
Technical
69
Dependency
Built with
Go73%
TypeScript26%
Updated yesterday
Go
91%
Apache 2.0

Gatus

Monitoring · Devops

12,009

Developer-oriented health dashboard with active endpoint probing, multi-protocol checks, and 40+ alerting integrations so you know about failures before your users do.

View details
78
Repo Health
84
Technical
75
Dependency
Built with
Go91%
Updated 1 weeks ago
TypeScript
76%
AGPL 3.0

Ghostfolio

Invoicing Finance

9,252

Track your stocks, ETFs, and crypto with a privacy-first, self-hostable wealth management platform built for data-driven investors.

View details
93
Repo Health
79
Technical
67
Dependency
Built with
TypeScript76%
HTML21%
Updated yesterday
Rust
71%
Apache 2.0

Rivet

AI Agents · Developer Tools

6,116

Stateful actors as a primitive for AI agents, real-time collaboration, and durable execution — with in-memory state, WebSockets, queues, and scheduling built in.

View details
86
Repo Health
81
Technical
65
Dependency
Built with
Rust71%
TypeScript25%
Updated yesterday
TypeScript
50%
Other

SigNoz

Monitoring · Analytics

32,028

Self-host your entire observability stack — logs, metrics, traces, and LLM monitoring — in one OpenTelemetry-native platform, without the Datadog bill.

View details
92
Repo Health
83
Technical
67
Dependency
Built with
TypeScript50%
Go39%
Updated today
Rust
71%
MIT

Trieve

AI Development · Search · Developer Tools

2,717

All-in-one self-hostable platform for hybrid search, RAG, recommendations, and analytics built on Rust and Qdrant.

View details
43
Repo Health
74
Technical
64
Dependency
Built with
Rust71%
Updated 7 months ago
TypeScript
98%
MIT

Umami

Analytics

38,642

Privacy-first web analytics that respects your users — self-hosted, cookieless, and GDPR compliant out of the box.

View details
95
Repo Health
83
Technical
70
Dependency
Built with
TypeScript98%
Updated yesterday

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search