Repository navigation
v1.0.0
Essential Links
The first release of chartjs-chart-histogram, a histogram chart type for Chart.js 4.0.1 and later.
Features
- The
histogramchart type. Give it raw values: it bins them and draws each bar on its bin's true edges, on a linear axis. - Bins. The
sqrt,sturges,rice,scott,fd,doaneandautorules, with numpy's edges, checked against numpy's output on 27 datasets. Also a count,binWidthandbinStart,domain, explicit edges, a function,closed: 'right', andmaxBinsas a safety cap. - What the bars show.
stat: 'count','relative','percent'or'density', forward or reversecumulative, andweights, given as an array or as a key of object data. - Several datasets. Overlays, shared edges with
binGroup(stacking works on them),sourceto bin another dataset's values, pre-binned{x0, x1, y}records, and line datasets on the same axis. - Interaction. A
'bin'interaction mode that selects the bin under the pointer, tooltips with range labels ([10, 20),≤ 20when cumulative) in the chart's locale, andbinEdgeTicksto put ticks on the edges. - Events and helpers.
onBinsComputedandgetBins(), and warnings with codes, each logged once per chart. - Headless binning.
computeBins()fromchartjs-chart-histogram/core, with no Chart.js and no DOM. - Packaging. ES modules, CommonJS and a UMD bundle that registers itself, with types for TypeScript 4.7 and later. No runtime dependencies.
Tested with
Chart.js 4.0.1, 4.4.0 and 4.6.2; Node.js 22, 24 and 26; Chromium, Firefox and WebKit; chartjs-plugin-zoom, chartjs-plugin-datalabels and chartjs-plugin-annotation; react-chartjs-2 and vue-chartjs; node-canvas for server-side rendering.