AG Studio Launch Week šŸš€šŸš€šŸš€ 28 Sep - 2 Oct 2026 šŸš€šŸš€šŸš€ Join now

JavaScript ChartsHistogram Series

Version 14.2.0
Enterprise

A Histogram Series shows the frequency distribution of data values, providing a visual representation of the distribution and spread of the data.

Simple Histogram Copy Link

To create a Histogram Series, use the histogram series type and provide an xKey.

{
    series: [
        {
            type: 'histogram',
            xKey: 'age',
            xName: 'Participant Age',
        },
    ],
}

In this configuration:

  • xKey defines the data values to be distributed into bins.
  • The Histogram Series will split the data into around ten identically sized bins, although the exact number will vary to show round values for the bin boundaries.
  • xName configures display names, reflected in the Tooltip Titles.

Bin Customisation Copy Link

Bin Count Copy Link

The approximate number of bins to aim for can be overridden by setting the binCount property.

{
    series: [
        {
            type: 'histogram',
            xKey: 'age',
            binCount: 20,
        },
    ],
}

Irregular Intervals Copy Link

Rather than specifying the number of bins, it is possible to explicitly give the start and end values for each bin.

{
    series: [
        {
            type: 'histogram',
            xKey: 'age',
            areaPlot: true,
            bins: [
                [16, 18],
                [18, 21],
                [21, 25],
                [25, 40],
            ],
        },
    ],
}

In this configuration:

  • The data from the race is split into irregular age categories using the bins.
  • This property takes an array of arrays where each inner array contains the start and end value of a bin.
  • The areaPlot property has been set to true. This visualises the value using the area of the bar rather than its height and is often used for Histogram Series with irregular bin sizes.

If both bins and binCount properties are provided, binCount takes precedence.

2D Histogram Copy Link

To provide Y values as well as X values, specify both xKey and yKey properties.

{
    series: [
        {
            type: 'histogram',
            xKey: 'age',
            xName: 'Participant Age',
            yKey: 'winnings',
            yName: 'Winnings',
        },
    ],
}
  • xKey defines the data values to be distributed into bins along the horizontal axis.
  • yKey defines the values determining the height of each bar along the vertical axis. These are aggregated within each bin.
  • xName and yName configure display names, reflected in the Tooltips.

Aggregation Copy Link

The default aggregation method is sum. Use the aggregation option to change this to count or mean.

{
    series: [
        {
            type: 'histogram',
            xKey: 'age',
            xName: 'Participant Age',
            yKey: 'winnings',
            yName: 'Winnings',
            aggregation: 'sum', //default
        },
    ],
}

Histogram Chart Examples Copy Link

See more Histogram Chart examples in the AG Charts Gallery.

API Reference Copy Link

Properties available on the AgHistogramSeriesOptions interface.

type required 'histogram'
Configuration for Histogram Series.
xKey required DatumKey
The key to use to retrieve x-values from the data.
listeners AgHistogramSeriesListeners
A map of event names to event listeners.
getItemId Function
A callback to provide a stable identifier for each bin, exposed as `itemId` in events and active state. The returned identifier must be unique across all bins in the series. If not supplied, an identifier is generated from the bin boundaries.
id string default: auto-generated value
Primary identifier for the series. This is provided as `seriesId` in user callbacks to differentiate multiple series. Auto-generated ids are subject to future change without warning, if your callbacks need to vary behaviour by series please supply your own unique `id` value.
context ContextDefault
Context object to use in callbacks.
data DatumDefault[]
The data to use when rendering the series. If this is not supplied, data must be set on the chart instead.
visible boolean
Whether to display the series.
cursor string
The cursor to use for hovered markers. This config is identical to the CSS `cursor` property.
nodeClickRange InteractionRange
Range from a node that a click triggers the listener.
showInLegend boolean
Whether to include the series in the legend.
xKeyAxis string default: 'x'
The key of the x-axis to which this series is bound.
yKeyAxis string default: 'y'
The key of the y-axis to which this series is bound.
yKey DatumKey
The key to use to retrieve y-values from the data.
xName string
A human-readable description of the x-values. If supplied, this will be shown in the default tooltip and passed to the tooltip renderer as one of the parameters.
yName string
A human-readable description of the y-values. If supplied, this will be shown in the default tooltip and passed to the tooltip renderer as one of the parameters.
styler Styler
A callback function for adjusting the styles of the whole series based on the highlight or selection state.
itemStyler Styler
A callback function for adjusting the styles of each bin individually, based on its range, frequency and aggregated value.
shadow AgDropShadowOptions
Configuration for the shadow used behind the chart series.
label AgHistogramSeriesLabelOptions
Configuration for the labels shown on bars.
tooltip AgSeriesTooltip
Series-specific tooltip configuration.
highlight AgMultiSeriesHighlightOptions
Configuration for highlighting when a series or legend item is hovered over.
areaPlot boolean
If `true`, the aggregated `yKey` values will be represented using the area of the bar, instead of just the height.
bins [number, number][]
Set the bin sizes explicitly. __Note:__ `bins` is ignored if `binCount` is also supplied.
binCount number
The number of bins to try to split the x-axis into.
aggregation 'count' | 'sum' | 'mean' default: sum
Dictates how the `yKey` values are aggregated within each bin.
showInMiniChart boolean
Whether to include the series in the Mini Chart.
cornerRadius PixelSize
Apply rounded corners to each bar.
fill AgColorType
The colour for filling shapes. A colour string, or an object for a gradient, pattern, or image fill.
fillOpacity Opacity
The opacity of the fill colour.
stroke AgCssColorOrRef
The colour for the stroke.
strokeWidth PixelSize
The width of the stroke in pixels.
strokeOpacity Opacity
The opacity of the stroke colour.
lineDash PixelSize[]
An array specifying the length in pixels of alternating dashes and gaps.
lineDashOffset PixelSize
The initial offset of the dashed line in pixels.