on GitHub

Histogram

The distribution of one numeric column. x is binned and counted in the browser. Control the resolution with bins or binwidth.

Loading…
<Histogram data="db.iris" x="petal_length" bins={20} />

Split by group

A hue column colors the bars per category; stacked stacks those groups within each bin instead of overlaying them.

Loading…
<Histogram
  data="db.iris"
  x="petal_length"
  hue="species"
  bins={20}
  stacked
  legend="bottom"
/>

Props

PropTypeNotes
data / queryrelation | SQLSource rows; a relation, or full SQL. Mutually exclusive.
xcolumnThe numeric column to bin.
bins / binwidthnumberBin count, or a fixed bin width. Pick one.
binrange[number, number]Clamp binning to a range.
stat"count" | "frequency" | "density" | "probability"What the bar height measures.
huecolumnColor bars by a category.
stackedboolStack hue groups within each bin.
xFormat / valueFormatd3-format specHow the axis and bar values render.
legend"top" | "bottom" | "left" | "right" | "none"Legend placement.

Expressions in query and filters values support {{binding}} interpolation against the surrounding BindingProvider.

Installation

Histogram ships in @n6k.io/ui/components. Nothing to install. Register the namespace once in src/app/mdx-components.tsx and the tag resolves in both .mdx and page.py pages:

import * as n6k from "@n6k.io/ui/components";

export function useMDXComponents(components: MDXComponents): MDXComponents {
  return {
    ...n6k, // Histogram, and every other n6k component
    ...components,
  } as unknown as MDXComponents;
}