Numbers
histogram
Bounded equal-width bins for numeric distributions.
Use it in your component
Standalone component
import { Component } from '@angular/core';
import { JsonPipe } from '@angular/common';
import { HistogramPipe } from 'extra-pipe';
@Component({
standalone: true,
imports: [HistogramPipe, JsonPipe],
template: `{{ [0,1,2,3] | histogram: 2 | json }}`,
})
export class ExampleComponent {
}
Template
{{ [0,1,2,3] | histogram: 2 | json }}
Try it live.
The output below runs the packed library. Edit data, not code.
Use double quotes for text, or a number, array, object or null.
Ordered parameters: bins. Locale is controlled separately.
This pipe has no locale override.
Live template data
readonly value = [
0,
1,
2,
3
] as const;
readonly parameter0 = 2;
{{ value | histogram: parameter0 | json }}
Rendered output
[
{
"lower": 0,
"upper": 1.5,
"count": 2
},
{
"lower": 1.5,
"upper": 3,
"count": 2
}
]