chartjs-plugin-datalabels

Highly customizable Chart.js plugin for displaying and styling data labels on any chart type.

Library
npm
v2.2.0
920stars
MIT License

Repository Health

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

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
73/100Good
Architecture78
Code Quality75
Innovation65
Learning Curve75

chartjs-plugin-datalabels renders data labels directly on Chart.js data elements — bars, points, arcs, and more — with per-dataset and per-label overrides for color, alignment, anchor, rotation, and formatting. It plugs into Chart.js’s plugin system via a single Chart.register call and works with any chart type Chart.js supports, from pie and doughnut charts to complex mixed and stacked bar charts.

Rather than drawing labels as a fixed overlay, the plugin computes label geometry per element (arcs use angle/radius math, bars and points use dimension-aware positioning) and resolves collisions against a hitbox model to keep dense charts readable. Options can be scriptable functions evaluated per data point, letting label content, color, and visibility respond to the underlying data at render time.

What You Get

  • Per-dataset and per-label datalabel configuration overriding global defaults
  • Automatic label positioning with anchor/align/offset controls plus a collision-aware hitbox layout pass
  • Scriptable options (functions evaluated per data point) for dynamic label content, color, and formatting
  • Built-in TypeScript type definitions that extend Chart.js’s own plugin option types
  • Label click/enter/leave event listeners for interactive labels

Common Use Cases

  • Displaying exact values or percentages on pie/doughnut slices without a separate legend
  • Highlighting key data points on line/bar charts (totals, thresholds, outliers)
  • Building dashboards where every chart needs consistent label formatting across chart types
  • Conditionally showing/hiding labels based on data density to avoid overlap
  • Adding interactive labels that respond to click/hover events

Under The Hood

Architecture plugin.js is the Chart.js plugin entry point — it registers lifecycle hooks into Chart.js’s plugin API that call configure() to merge per-chart, per-dataset, and per-label option objects (global defaults from defaults.js merged with each dataset’s datalabels overrides), then builds a Label instance (label.js) per data element that computes text content and a geometry box. layout.js runs a general layout/collision pass across all active labels using hitbox.js’s box model to keep labels within their allowed positioning area and reduce overlap. positioners.js resolves Chart.js-specific anchor points per element type (arc, point, bar). Data flows from Chart.js’s render loop through the plugin’s draw hook, into configure(), into per-element Label objects, through layout() for final positioning, and out to each Label’s own canvas draw call. Because every consumer’s per-dataset overrides and the merge() calls in plugin.js assume the option shape defined in defaults.js, changing that shape would ripple through the whole configuration-resolution pipeline.

Tech Stack A plain JavaScript library with no runtime framework — ES modules with a single peerDependency on chart.js (>=3.0.0, developed against ^4.0.0). Built with Rollup (commonjs/node-resolve/terser plugins) into UMD and ESM bundles. Type definitions are hand-authored under types/ and checked separately via a dedicated TypeScript test project. Linting runs through ESLint with eslint-config-chartjs. The documentation site is built with VuePress from the docs/ directory and deployed to Netlify. There is no server or database component — it is purely a browser-side canvas-rendering plugin.

Code Quality Tests live under test/specs (54 spec files) and run through Karma + Jasmine against a real Firefox instance rather than a DOM-mocking harness, with coverage collected via karma-coverage and rollup-plugin-istanbul instrumentation. Type correctness is verified independently by compiling a types/test project against the shipped .d.ts files. Naming is consistent camelCase throughout src/, and error handling favors defensive early returns appropriate for a rendering-only library with little I/O. A GitHub Actions workflow and ESLint config are both present. The codebase is compact (137 total commits) with low recent commit activity and open issues in the double digits, suggesting a stable but lightly maintained project rather than an actively evolving one.

What Makes It Unique Most chart-labeling approaches fall back to static image annotation, a manually-positioned DOM overlay, or a second SVG layer synced by hand. This plugin instead reads label geometry directly from Chart.js’s own internal element models (arc angle/radius, bar/point bounding boxes) and hooks into Chart.js’s plugin lifecycle so labels automatically re-lay-out on every re-render and animation frame, with no manual DOM synchronization required. Its collision-avoidance layout pass, which re-flows overlapping label boxes across the whole chart rather than always drawing at a fixed anchor, is a meaningfully non-trivial layout algorithm relative to simpler labeling plugins — though architecturally it remains a conventional “plugin extends host library” design rather than a novel rendering technique.

Used by 14 apps in this directory

Go
54%
Apache 2.0

Authgear

Authentication

2,028

Open-source, self-hostable authentication platform with passkeys, biometric login, SSO, MFA, and GraphQL admin API — a full Auth0/Clerk/Firebase alternative for SaaS and mobile apps.

View details
88
Repo Health
81
Technical
68
Dependency
Built with
Go54%
HTML25%
TypeScript18%
Updated 3 days ago
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
Ruby
60%
GPL 2.0

Discourse

Community

47,793

Open-source community platform with dynamic trust levels, real-time chat, and a powerful plugin architecture for self-hosted forums.

View details
89
Repo Health
89
Technical
67
Dependency
Built with
Ruby60%
JavaScript32%
Updated today
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
PHP
85%
Other

Invoice Ninja

Invoicing Finance · Project Management

10,060

Self-hostable invoicing, time-tracking, and multi-gateway payment platform for freelancers and small businesses, with built-in e-invoicing compliance for EU and global standards.

View details
97
Repo Health
83
Technical
62
Dependency
Built with
PHP85%
XSLT10%
Updated 2 days ago
Scala
62%
AGPL 3.0

lila (Lichess)

Community

18,710

The forever-free, ad-free, open-source chess server powering millions of real-time games, AI analysis, puzzles, and tournaments worldwide.

View details
89
Repo Health
80
Technical
75
Dependency
Built with
Scala62%
TypeScript27%
Updated yesterday
TypeScript
72%
Apache 2.0

Litlyx

Analytics

1,740

Cookie-free, AI-powered web analytics you can self-host in 30 seconds with Docker.

View details
45
Repo Health
51
Technical
72
Dependency
Built with
TypeScript72%
Vue26%
Updated 9 months ago
Ruby
79%
GPL 3.0

OpenProject

Project Management · Productivity · Collaboration

16,035

The open source project management platform that unifies Gantt charts, agile boards, time tracking, and team collaboration under full self-hosted control.

View details
96
Repo Health
79
Technical
69
Dependency
Built with
Ruby79%
TypeScript12%
Updated yesterday
JavaScript
63%
AGPL 3.0

overleaf

Collaboration · Productivity

18,090

Open-source, real-time collaborative LaTeX editor with sandboxed compilation and full TeXLive support for self-hosted academic and research teams.

View details
82
Repo Health
80
Technical
62
Dependency
Built with
JavaScript63%
TypeScript29%
Updated 1 months ago

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