Histograms

API

Extends the base chart options. All options below are optional.

NameTypeDefaultDescription
binCountnumber-Specifies the amount of bins. If not specified, d3 will try to define its own thresholds.

Examples

Difference in UFO Sighting and Reporting Dates (in months)

Semi-real data about the reported differences between the supposed sighting of a UFO and the date it was reported.

new HistogramChart({
  data: ufoData.map((date) => date / 30).sort(),
  width: 600,
  height: 200,
  binCount: 150,
  target: '#my-div',
  brush: 'x',
  yAxis: {
    extendedTicks: true
  },
  tooltipFunction: (bar) => `${bar.time} months, volume ${bar.count}`
})