Skip to content

Histogram ​

How many values fall in each interval, with their density. Good for the shape of a large sample.

The smallest code that works. change the code, then press Run

In your framework

import { Chart } from 'nervure/react';

const spec = {
  type: 'histogram',
  values: [
    37.1, 41.7, 55.3, 31.2, 51, 52.8, 84, 69.5, 51.7, 48.5, 47.8, 32.8, 61.1, 36.4, 56.6, 40,
    50, 39.3, 72.7, 58.7, 33.1, 34.4, 62.4, 52.1, 60.1, 61.2, 46.5, 32.1, 68.6, 41.6, 39.2,
    29.3, 28.7, 58.7, 44.7, 37.2, 36.5, 68.8, 54.4, 67.8, 65.7, 25.3, 46.6, 46.3, 24.6, 49.3,
    55.2, 53.6, 64.9, 46.2, 33.6, 42, 33.3, 70.9, 38, 52.2, 41.3, 60.2, 40.5, 46.3, 73.5, 22.8,
    54.9, 92.9, 61.2, 66.8, 44.8, 29.1, 39.7, 63.1, 53.6, 36.4, 79.3, 57.9, 31.6, 15.4, 70.5,
    41.6, 39.4, 62, 50, 36.4, 52.2, 38.6, 39, 64.6, 56.1, 34.9, 66.2, 59.1, 22.6, 31.9, 66.7,
    40, 82.8, 60.4, 65.5, 58.4, 43.9, 44.7, 42, 33.2, 69, 51, 88.4, 49.2, 58.4, 30.7, 37.4,
    42.5, 39.3, 39.2, 50.1, 48.5, 49.3, 62.7, 57, 42.2, 48.8, 54, 51.3, 40.8, 41, 44.9, 51.9,
    37.6, 37, 51.9, 60.4, 56, 63.2, 39.8, 65.6, 45, 48.3, 15.9, 47.6, 35.3, 52.7, 58.5, 69.4,
    51, 54.2, 56.3, 55, 40.9, 60.7, 41.8, 54.1, 59.6, 66.1, 30, 31.5, 53.9, 28.4, 51.4, 47.1,
    61.3, 52.9, 38.8, 46.1, 61, 55.5, 70.2, 58, 20.3, 51.2, 44.4, 49.2, 42.7, 72.4, 44.1, 48,
    67.3, 50.9, 69.5, 46.5, 38.4, 63.5, 65.3, 35.5, 42.6, 48.1, 45.6, 47.6, 56.2, 69.3, 59.2,
    47.1, 47.9, 24.1, 72.6, 14, 48.4, 43.2, 50.3, 64.4, 43.2, 54.7, 36.8, 38.9, 64.6, 39.9,
    65.6, 59.2, 29.5, 29.5, 43.2, 50.8, 40.8, 89.9, 42.2, 57.6, 48.6, 75.5, 57.7, 44.4, 57.1,
    27.9, 55.9, 42.6, 45.1, 60.9, 48, 53.3, 38.4, 57.3, 57.1, 49.6, 57, 58.9, 44.1, 62.5, 40.5,
    45.6, 33.6, 19.7, 48.4, 52.1, 56.9, 63.5, 76.9, 48, 50.8, 33.3, 53.4, 56.7, 36.1, 29.4,
    32.8, 55.5, 47.1, 92.6, 53.7, 58.2, 43.7, 36, 46.4, 34.5, 53.5, 48.7, 66.5, 56.2, 68.3,
    80.7, 56.1, 63.7, 61.2, 51.7, 58.4, 54.7, 42.1, 42.6, 45.9, 58.9, 37.2, 63.6, 32.1, 37.2,
    77.3, 49.8, 29.9, 52.7, 37, 63.8, 52.5, 56, 52.7, 48.9, 46.4, 38.9, 57.3, 50.5, 78.3, 56.6,
    66.5, 50.8, 25.3, 36.2, 47,
  ],
  curve: true,
};

export default function Example() {
  return <Chart spec={spec} style={{ height: 340 }} />;
}

Or import this chart alone: what each import weighs.

Options

Beside the fields shared by every chart (title, format, heading, export…), type histogram takes:

interface HistogramSpec extends Base {
  type: 'histogram';
  values: number[];
  bins?: number;
  color?: string;
  /** Draws the density too. */ curve?: boolean;
}

Style it

  • Colours: theme.palette, chart.setColor(name, colour), or --nervure-palette in your CSS. More
  • Marks: [data-series="name"], parts: [data-part="axes"], legend, series. What you change is kept in exports.
  • Movement: animation: false draws at once. More
  • Files: chart.download('png'), svg, csv. More

Close to it