Skip to content

Histogram

Summarize one measure in deterministic numeric bins.

Chart ID: histogram. Independent import: @revolist/charts/histogram.

Loading chart…

Read the frequency or aggregate within numeric bins. Bin placement uses the selected numeric values; an independently bound Y measure can supply sums or means instead of counts.

Use one category per row and one or more numeric series. Values are finite numbers or explicit nulls; the row mapper does not group or aggregate repeated keys.

The roles below describe the chart's data contract. Generic category/value roles resolve from the dataset; explicitly bind specialized numeric roles as shown in the complete example.

Data roleField count
category1 or more
value1 or more
series1–2

Download the complete sample data and settings (JSON). See Data & Configuration for mapping, null values, updates and lifecycle rules.

Install the package using the installation guide, give the host an explicit height, and call createHistogramChart after the host mounts. This factory fixes the chart type to histogram.

<div id="chart" style="width: 100%; height: 450px;"></div>
Complete runnable TypeScript example with sample data
import { createHistogramChart } from '@revolist/charts/histogram';
const container = document.getElementById('chart')!;
const chart = await createHistogramChart({
container,
"dataset": {
"revision": 0,
"source": "client",
"categories": [
{
"id": "preview-category-0",
"label": "12",
"path": [
"12"
],
"labels": [
"12"
],
"depth": 1,
"kind": "leaf"
},
{
"id": "preview-category-1",
"label": "18",
"path": [
"18"
],
"labels": [
"18"
],
"depth": 1,
"kind": "leaf"
},
{
"id": "preview-category-2",
"label": "23",
"path": [
"23"
],
"labels": [
"23"
],
"depth": 1,
"kind": "leaf"
},
{
"id": "preview-category-3",
"label": "27",
"path": [
"27"
],
"labels": [
"27"
],
"depth": 1,
"kind": "leaf"
},
{
"id": "preview-category-4",
"label": "31",
"path": [
"31"
],
"labels": [
"31"
],
"depth": 1,
"kind": "leaf"
},
{
"id": "preview-category-5",
"label": "35",
"path": [
"35"
],
"labels": [
"35"
],
"depth": 1,
"kind": "leaf"
},
{
"id": "preview-category-6",
"label": "42",
"path": [
"42"
],
"labels": [
"42"
],
"depth": 1,
"kind": "leaf"
},
{
"id": "preview-category-7",
"label": "48",
"path": [
"48"
],
"labels": [
"48"
],
"depth": 1,
"kind": "leaf"
}
],
"series": [
{
"id": "preview-series-0",
"label": "Value",
"columnPath": [
"Value"
],
"labels": [
"Value"
],
"kind": "leaf",
"prop": "preview-0"
}
],
"values": [
[
12
],
[
18
],
[
23
],
[
27
],
[
31
],
[
35
],
[
42
],
[
48
]
],
"analyticalFrame": {
"derived": {
"distributions": [
{
"kind": "samples",
"categoryId": "preview-category-0",
"seriesId": "preview-series-0",
"samples": [
8,
12,
14,
18,
19,
23,
27,
31,
48
]
},
{
"kind": "samples",
"categoryId": "preview-category-1",
"seriesId": "preview-series-0",
"samples": [
10,
14,
16,
20,
21,
25,
29,
33,
50
]
},
{
"kind": "samples",
"categoryId": "preview-category-2",
"seriesId": "preview-series-0",
"samples": [
12,
16,
18,
22,
23,
27,
31,
35,
52
]
},
{
"kind": "samples",
"categoryId": "preview-category-3",
"seriesId": "preview-series-0",
"samples": [
14,
18,
20,
24,
25,
29,
33,
37,
54
]
},
{
"kind": "samples",
"categoryId": "preview-category-4",
"seriesId": "preview-series-0",
"samples": [
16,
20,
22,
26,
27,
31,
35,
39,
56
]
},
{
"kind": "samples",
"categoryId": "preview-category-5",
"seriesId": "preview-series-0",
"samples": [
18,
22,
24,
28,
29,
33,
37,
41,
58
]
},
{
"kind": "samples",
"categoryId": "preview-category-6",
"seriesId": "preview-series-0",
"samples": [
20,
24,
26,
30,
31,
35,
39,
43,
60
]
},
{
"kind": "samples",
"categoryId": "preview-category-7",
"seriesId": "preview-series-0",
"samples": [
22,
26,
28,
32,
33,
37,
41,
45,
62
]
}
]
},
"fields": [
{
"id": "pivot:category",
"label": "pivot:category",
"role": "dimension",
"semanticType": "category"
},
{
"id": "pivot:series",
"label": "pivot:series",
"role": "dimension",
"semanticType": "category"
},
{
"id": "preview-series-0",
"label": "Value",
"role": "measure",
"semanticType": "number",
"sourceField": "preview-0"
}
],
"observations": [
{
"id": "[\"preview-category-0\",\"preview-series-0\"]",
"dimensions": {
"pivot:category": {
"value": "12",
"label": "12",
"path": [
"12"
],
"labels": [
"12"
]
},
"pivot:series": {
"value": "Value",
"label": "Value",
"path": [
"Value"
],
"labels": [
"Value"
]
}
},
"measures": {
"preview-series-0": 12
}
},
{
"id": "[\"preview-category-1\",\"preview-series-0\"]",
"dimensions": {
"pivot:category": {
"value": "18",
"label": "18",
"path": [
"18"
],
"labels": [
"18"
]
},
"pivot:series": {
"value": "Value",
"label": "Value",
"path": [
"Value"
],
"labels": [
"Value"
]
}
},
"measures": {
"preview-series-0": 18
}
},
{
"id": "[\"preview-category-2\",\"preview-series-0\"]",
"dimensions": {
"pivot:category": {
"value": "23",
"label": "23",
"path": [
"23"
],
"labels": [
"23"
]
},
"pivot:series": {
"value": "Value",
"label": "Value",
"path": [
"Value"
],
"labels": [
"Value"
]
}
},
"measures": {
"preview-series-0": 23
}
},
{
"id": "[\"preview-category-3\",\"preview-series-0\"]",
"dimensions": {
"pivot:category": {
"value": "27",
"label": "27",
"path": [
"27"
],
"labels": [
"27"
]
},
"pivot:series": {
"value": "Value",
"label": "Value",
"path": [
"Value"
],
"labels": [
"Value"
]
}
},
"measures": {
"preview-series-0": 27
}
},
{
"id": "[\"preview-category-4\",\"preview-series-0\"]",
"dimensions": {
"pivot:category": {
"value": "31",
"label": "31",
"path": [
"31"
],
"labels": [
"31"
]
},
"pivot:series": {
"value": "Value",
"label": "Value",
"path": [
"Value"
],
"labels": [
"Value"
]
}
},
"measures": {
"preview-series-0": 31
}
},
{
"id": "[\"preview-category-5\",\"preview-series-0\"]",
"dimensions": {
"pivot:category": {
"value": "35",
"label": "35",
"path": [
"35"
],
"labels": [
"35"
]
},
"pivot:series": {
"value": "Value",
"label": "Value",
"path": [
"Value"
],
"labels": [
"Value"
]
}
},
"measures": {
"preview-series-0": 35
}
},
{
"id": "[\"preview-category-6\",\"preview-series-0\"]",
"dimensions": {
"pivot:category": {
"value": "42",
"label": "42",
"path": [
"42"
],
"labels": [
"42"
]
},
"pivot:series": {
"value": "Value",
"label": "Value",
"path": [
"Value"
],
"labels": [
"Value"
]
}
},
"measures": {
"preview-series-0": 42
}
},
{
"id": "[\"preview-category-7\",\"preview-series-0\"]",
"dimensions": {
"pivot:category": {
"value": "48",
"label": "48",
"path": [
"48"
],
"labels": [
"48"
]
},
"pivot:series": {
"value": "Value",
"label": "Value",
"path": [
"Value"
],
"labels": [
"Value"
]
}
},
"measures": {
"preview-series-0": 48
}
}
],
"matrixCells": [
{
"categoryId": "preview-category-0",
"seriesId": "preview-series-0",
"observationId": "[\"preview-category-0\",\"preview-series-0\"]",
"measureFieldId": "preview-series-0"
},
{
"categoryId": "preview-category-1",
"seriesId": "preview-series-0",
"observationId": "[\"preview-category-1\",\"preview-series-0\"]",
"measureFieldId": "preview-series-0"
},
{
"categoryId": "preview-category-2",
"seriesId": "preview-series-0",
"observationId": "[\"preview-category-2\",\"preview-series-0\"]",
"measureFieldId": "preview-series-0"
},
{
"categoryId": "preview-category-3",
"seriesId": "preview-series-0",
"observationId": "[\"preview-category-3\",\"preview-series-0\"]",
"measureFieldId": "preview-series-0"
},
{
"categoryId": "preview-category-4",
"seriesId": "preview-series-0",
"observationId": "[\"preview-category-4\",\"preview-series-0\"]",
"measureFieldId": "preview-series-0"
},
{
"categoryId": "preview-category-5",
"seriesId": "preview-series-0",
"observationId": "[\"preview-category-5\",\"preview-series-0\"]",
"measureFieldId": "preview-series-0"
},
{
"categoryId": "preview-category-6",
"seriesId": "preview-series-0",
"observationId": "[\"preview-category-6\",\"preview-series-0\"]",
"measureFieldId": "preview-series-0"
},
{
"categoryId": "preview-category-7",
"seriesId": "preview-series-0",
"observationId": "[\"preview-category-7\",\"preview-series-0\"]",
"measureFieldId": "preview-series-0"
}
]
}
},
"bindings": {},
"presentation": {
"dataLabels": false
}
});
// When the host unmounts:
// chart.destroy();

Await updates before reading a snapshot or exporting. Call chart.destroy() when the host unmounts. See the live catalog to interact with this type.

Set these fields in chartOptions. The option schema validates supported keys, ranges and choices; updating chartOptions replaces that authored object.

OptionDefaultAccepted values
showGridLinestruetrue or false
markOpacity10.2 to 1; step 0.05
binCount00 to 256; step 1
histogramAggregationcountcount, sum, mean

Titles, legends, theme and labels belong to presentation or the corresponding top-level setting. Axis, color, navigation and interaction support depends on the selected chart; see Data & Configuration.

Charts overview · Installation · Data & Configuration