Create interactive histogram visualizations with 'data-ui'. The histogram will perform the calculations in 'JavaScript' if the data is raw. If you would like more control over the calculation, then you can pass pre-binned values with help from hist_to_binned_data. dui_histogram works well as a full-featured visualization or can also be used as a 'sparkline` in smaller contexts.

dui_histogram(
  rawData = NULL,
  binCount = NULL,
  binType = NULL,
  binValues = NULL,
  cumulative = NULL,
  horizontal = NULL,
  limits = NULL,
  margin = NULL,
  normalized = NULL,
  renderTooltip = NULL,
  valueAccessor = NULL,
  onMouseMove = NULL,
  onMouseLeave = NULL,
  tooltipData = NULL,
  ariaLabel = NULL,
  components = NULL,
  width = 600,
  height = 400,
  elementId = NULL
)

Arguments

binCount

numeric specifying the approximate number of bins to calculate.

binType

character one of 'numeric'(default) or 'categorical'.

binValues

numeric vector of the bin or break values to override the automatic calculations.

cumulative

logical to specify whether or not the histogram will display cumulative sums of the counts.

horizontal

logical with TRUE meaning the chart will be in horizontal layout.

limits

numeric vector of length two to give a range for which values will be ignored if they are outside of the range.

margin

list of the form list(top =, right =, bottom =, left=) that will specify the margins for the 'sparkline' chart.

normalized

logical specifying whether or not to the values will be calculated as a percent of total.

renderTooltip

htmlwidget::JS function that will provide the 'React' element to render when a user moves their mouse over the visualization. The function should follow the signature ({ event, data, datum, color }) =>. If the function returns a falsy value then nothing will be rendered.

valueAccessor

htmlwidgets::JS function to let the chart know where to look for the y value in the data. An example would look like (d) => d.yval where yval is the property containing the value.

onMouseMove, onMouseLeave

htmlwidgets::JS function to run on mouse events.

tooltipData

currently not supported.

ariaLabel

character accessibility label for the chart

components

list of children (series or reference lines) to include in the histogram. Multiple components should be wrapped in list such as components = list(dui_densityseries, dui_barseries()).

width, height

numeric valid 'css' size unit. For height, this should always be numeric, but width might be something like '100%' or '50vw'.

elementId

character valid 'css' identifier for the htmlwidget container.

Value

react htmlwidget