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

Angular ChartsBackground Regions

Version 14.2.0
Enterprise

Background Regions are shaded rectangular areas in a cartesian chart, bounded by value ranges on both the x and y axes. These can denote additional information or thresholds, making them useful for data analysis.

Adding Background Regions Copy Link

Background Regions are defined in the seriesArea.backgroundRegions array.

{
    seriesArea: {
        backgroundRegions: [
            {
                xRange: { start: new Date(2025, 5, 1), end: new Date(2025, 8, 1) },
                yRange: { start: 0, end: 50 },
                label: {
                    text: 'Drought Risk',
                },
            },
        ],
    },
}

In this configuration:

  • xRange and yRange bound the region with start and end values, given in the units of the appropriate axis.
  • label.text adds a label to the region.

Regions are drawn behind the series and above the chart background.

Range Bounds Copy Link

The range boundaries are defined by optional xRange and yRange properties, each containing optional start and end properties. These must be in the units of the appropriate axis.

Omitting a start or an end extends that side of the region along the entire axis domain in that direction. Omitting a range entirely spans the entire axis.

{
    seriesArea: {
        backgroundRegions: [
            {
                xRange: { start: new Date(2025, 5, 1) },
                yRange: { end: 50 },
                label: {
                    text: 'Drought Risk',
                },
            },
        ],
    },
}

In this configuration:

  • "Open Ended" has only one bound defined for each range.
    • xRange has no end, so the region extends to the right edge of the series area.
    • yRange has no start, so it extends to the bottom edge.
  • "Both Bounds" has both start and end defined for xRange and yRange, so the region is bounded on all sides.
  • "Full Width" has no xRange, so it spans the full width of the series area, while yRange is bounded on both sides.
  • Values outside the axis domain are clamped to the edge of the series area.

Labels Copy Link

Use label.position to place a label relative to its region.

{
    seriesArea: {
        backgroundRegions: [
            {
                xRange: { start: new Date(2025, 5, 1), end: new Date(2025, 8, 1) },
                yRange: { start: 20, end: 50 },
                label: {
                    text: 'Drought Risk',
                    position: 'top',
                },
            },
        ],
    },
}

In this example:

  • Use the dropdown to change position.
  • Position names give the edge first, then the alignment along it. top-left sits above the region, aligned left, and left-top sits to its left, aligned top.
  • An inside prefix places the label within the region.
  • xOffset and yOffset move the label from its position by the specified number of pixels.

Multiple Axes Copy Link

On a chart with multiple axes in one direction, use axis to specify the axis that the range is plotted against.

{
    seriesArea: {
        backgroundRegions: [
            {
                xRange: { start: new Date(2025, 0, 1), end: new Date(2025, 4, 1) },
                yRange: { axis: 'rainfall', start: 100 },
                label: {
                    text: 'Heavy Rainfall',
                    position: 'inside-top-left',
                },
            },
        ],
    },
    axes: {
        x: { type: 'unit-time' },
        capacity: { type: 'number', position: 'left' },
        rainfall: { type: 'number', position: 'right' },
    },
}

In this example:

  • yRange.axis is set to 'rainfall', so the range is resolved against that axis rather than the capacity axis.
  • yRange has no end, so the region extends to the top edge of the series area.
  • When axis is omitted in this scenario, the range uses the first axis declared in that direction.

Customisation Copy Link

Regions are styled with fill, fillOpacity, stroke, strokeWidth and strokeOpacity.

Labels are styled with font and fills & border options.

{
    seriesArea: {
        backgroundRegions: [
            {
                fill: '#5090dc',
                fillOpacity: 0.2,
                stroke: { ref: 'foregroundColor', mix: 0.35, ontoColor: '#5090dc' },
                strokeWidth: 2,
                xRange: { start: 14, end: 31 },
                yRange: { start: 27500, end: 63000 },
                label: {
                    text: 'Retail',
                    position: 'top-left',
                    yOffset: -4,
                    color: { ref: 'foregroundColor', mix: 0.35, ontoColor: '#5090dc' },
                    fontSize: 13,
                    fontWeight: 'bold',
                    fill: { ref: 'backgroundColor' },
                    fillOpacity: 0.85,
                    cornerRadius: 4,
                    padding: { top: 4, right: 8, bottom: 4, left: 8 },
                    border: {
                        enabled: true,
                        stroke: { ref: 'foregroundColor', mix: 0.35, ontoColor: '#5090dc' },
                    },
                },
            },
            //... other regions
        ],
    },
}

In this example:

  • Each market segment has a region covering the middle 80% of its deals on each axis, with a fill matching the series colour.
  • Each label is colour-matched to its region, with fill, cornerRadius, padding and border styling the box around the text and color styling the text itself. Colours are set with theme parameters so they adapt to light and dark themes.
  • yOffset lifts each label 4px clear of its region.

API Reference Copy Link

Properties available on the AgSeriesAreaBackgroundRegion interface.

xRange AgSeriesAreaBackgroundRegionRange
The bounds of the region on an x-axis. Omit to span the full width of the series area.
yRange AgSeriesAreaBackgroundRegionRange
The bounds of the region on a y-axis. Omit to span the full height of the series area.
label AgSeriesAreaBackgroundRegionLabel
Configuration for the label displayed with the region.
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.

Properties available on the AgSeriesAreaBackgroundRegionRange interface.

axis string
The key of the axis in the `axes` dictionary that this range applies to.
start AxisValue
The axis value where the region starts. Omit to extend the region to the edge of the series area.
end AxisValue
The axis value where the region ends. Omit to extend the region to the edge of the series area.

Properties available on the AgSeriesAreaBackgroundRegionLabel interface.

fontFamily FontFamilyFull
The font family to use for the label. A single family name, or an array of names used as fallbacks.
position AgSeriesAreaBackgroundRegionLabelPosition
The position of the Background Region label.
rotation Degree
The rotation of the Background Region label in degrees.
text string
The text to show in the label.
xOffset PixelSize default: 0
The horizontal offset in pixels for the label.
yOffset PixelSize default: 0
The vertical offset in pixels for the label.
enabled boolean
Whether the associated elements and properties should be used in the chart.
color AgCssColorOrRef
The colour for text elements. A colour string, or a theme-colour reference object.
fontSize FontSize
The size of the font in pixels for text elements.
fontStyle FontStyle
The style to use for text elements.
fontWeight FontWeight
The font weight to use for text elements.
border BorderOptions
Stroke options for the box border.
cornerRadius PixelSize
Apply rounded corners to the label box.
padding Padding
Distance between the label text and the border. A number applies uniform padding; an object sets each side.
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.