Skip to content

Warnings ​

The plugin never throws on bad options or data. It falls back to a valid setting and prints a warning to the console, such as:

chartjs-chart-histogram: dataset 0: bins must be a positive number, a rule name, a function or an edge array, got -3; 'auto' is used. (invalid-bins)

In a chart, each code is printed once per chart, not on every update. computeBins and computeDensity report every warning through their onWarn option, or through console.warn without it.

CodeWhenWhat happens
invalid-binsbins is not a positive number, a rule name, a function or an array'auto' is used
invalid-edgesbins is an array with fewer than two distinct finite numbersThe array is ignored
duplicate-edgesbins repeats an edgeThe repeats are ignored
invalid-bin-widthbinWidth is not a positive finite numberIt is ignored
callback-failedA bins function threw, or returned something other than a positive number'auto' is used
max-binsThe bins asked for exceed maxBinsThe count is capped at maxBins
precisionBins would be narrower than the floating-point resolution of the valuesFewer bins are used
domain-swappeddomain has its larger bound firstThe bounds are swapped
invalid-optionAnother option has an invalid value, such as stat: 'sum'Its default is used
invalid-weightsA weight is missing, negative or not finite, or weights is not an arrayThose values are left out; a weights that is not an array is ignored
invalid-prebinnedA pre-binned record overlaps the one before itThe record is left out
density-degenerateA density curve has fewer than two distinct values, a bandwidth out of range, or a pre-binned sourceNo curve is drawn
unequal-widthsstat: 'count' on bins of different widthsA hint: bar areas are not proportional to counts; stat: 'density' is usually meant
source-missingsource names no other dataset (for a density dataset, no histogram dataset)The histogram or the curve is empty
group-optionsA dataset of a binGroup sets binning options of its own that differ from the first dataset'sThe first dataset's options are used
density-scaleThe source of a density curve is cumulative, or has bins of different widths with a stat other than 'density'No curve is drawn: no single factor scales it to the bars

The last four come from the chart only; computeBins and computeDensity do not raise them.

Released under the MIT License.