Area Series

Area series are line series with the area under the line filled, placing more emphasis on the magnitude of the change. Area series additionally support stacking to show the total value and the way individual values relate to the whole.

Single Area Series

To create a simple area chart we need to use series type 'area'. We also have to provide the xKey and at least one yKey.

Since 'area' series can be stacked on top of each other, they can have multiple yKeys, with one key for each stack level.

A minimal 'area' series config would therefore look like this:

series: [{ type: 'area', xKey: 'year', yKeys: ['ie'] }]

In the snippet above we are using 'ie' as the only yKey, to show market share of just this internet browser. Using this simple series config produces the following chart:

Even though area series support markers, they are turned off by default for this series type, as this stylisation is the most common.

To enable area markers, all we need to do is add this to the series config:

marker: { enabled: true }

When markers are enabled, the tooltips will be shown on hover. In this case the values shown are percentage values, however there is no % suffix because the series don't know about the nature of the data (as it is designed to work with all kinds of data). So for the purposes of this example we additionally provide a tooltipRenderer to add the % suffix. After this change, the tooltips will change like so:

Before  Default Area Tooltip --> After  Custom Area Tooltip

The final result can be seen in the example below.

Multiple Area Series

It is possible to use more than one 'area' series in a single chart. For example, if we want one series to show the magnitude of change in market share of Internet Explorer and the other series the change in market share of Chrome, we could use the following series config:

series: [ { type: 'area', xKey: 'year', yKeys: ['ie'] }, { type: 'area', xKey: 'year', yKeys: ['chrome'] } ]
Since multiple area series can overlap, it is a good idea to make the fill translucent, for example using fillOpacity: 0.7.

Note that in the example below we also:

  • Use yNames to control the text that the legend displays
  • Enable markers
  • Define custom fills and strokes
  • Make the fill translucent using the fillOpacity config

Stacked Area Series

If we want the areas to be stacked on top of each other, instead of creating a new 'area' series per stack level, we simply have to use multiple yKeys. For example, to have a stacked area chart that shows changes in market share for the most popular internet browsers we could use a config like this:

series: [{ type: 'area', xKey: 'year', yKeys: ['ie', 'firefox', 'safari', 'chrome'] }]

This produces the following chart:

Normalized Area Series

Going back to our stacked area series example, if we wanted to normalize the totals so that for any given year stack levels always added up to a certain value, for example 100%, we could add the following to our series config:

normalizedTo: 100
It's possible to use any non-zero value to normalize to.

API Reference

xKey
Required
The key to use to retrieve x-values from the data.
xNameA human-readable description of the x-values.
yKeys
Required
The keys to use to retrieve y-values from the data.
yNamesHuman-readable descriptions of the y-values.
data
Required
The data to use when rendering the series. If this is not supplied, data must be set on the chart instead.
visibleWhether or not to display the series.
Default: true
showInLegendWhether or not to include the series in the legend.
Default: true
tooltipEnabledWhether or not to show tooltips when the series are hovered over.
Default: true
tooltipRendererFunction used to create the content for tooltips.function(params: IParams): string; interface IParams { datum: any; title?: string; color?: string; xKey: string; xName?: string; yKey: string; yName?: string; }
normalizedToThe number to normalise the area stacks to. For example, if normalizedTo is set to 100, the stacks will all be scaled proportionally so that their total height is always 100.
fillsThe colours to cycle through for the fills of the areas.
Default: ['#f3622d', '#fba71b', '#57b757', '#41a9c9', '#4258c9', '#9a42c8', '#c84164', '#888888']
fillOpacityThe opacity of the fill for the areas.
Default: 1
strokesThe colours to cycle through for the strokes of the areas.
Default: ['#aa4520', '#b07513', '#3d803d', '#2d768d', '#2e3e8d', '#6c2e8c', '#8c2d46', '#5f5f5f']
strokeOpacityThe opacity of the stroke for the areas.
Default: 1
strokeWidthThe width in pixels of the stroke for the areas.
Default: 1
markerConfiguration for the markers used in the series. See marker for more details about this configuration object.
highlightStyleConfiguration for the highlighting used when the markers are hovered over. See highlightStyle for more details about this configuration object.
shadowConfiguration for the shadow used behind the chart series. See shadow for more details about this configuration object.

marker

Configuration for the markers used in the series.

enabledWhether or not to show markers.
Default: false
shapeThe shape to use for the markers. You can also supply a custom marker by providing a Marker subclass.
Default: 'circle'
Options: 'circle' | 'cross' | 'diamond' | 'plus' | 'square' | 'triangle'
sizeThe size in pixels of the markers.
Default: 8
minSizeFor series where the size of the marker is determined by the data, this determines the smallest size a marker can be in pixels.
Default: 12
fillThe colour to use for marker fills. If this is not specified, the markers will take their fill from the series.
strokeThe colour to use for marker strokes. If this is not specified, the markers will take their stroke from the series.
strokeWidthThe width in pixels of the marker stroke. If this is not specified, the markers will take their stroke width from the series.
formatterFunction used to return formatting for individual markers, based on the supplied information. If the current marker is highlighted, the highlighted property will be set to true; make sure to check this if you want to differentiate between the highlighted and un-highlighted states.function(params: IParams): IReturn; interface IParams { datum: any; fill: string; stroke: string; strokeWidth: number; size: number; highlighted: boolean; xKey: string; yKey: string; } interface IReturn { fill: string; stroke: string; strokeWidth: number; size: number; }

highlightStyle

Configuration for the highlighting used when the markers are hovered over.

fillThe fill colour of the markers when hovered over.
Default: 'yellow'
strokeThe colour of the stroke around the markers when hovered over.

shadow

Configuration for the shadow used behind the chart series.

enabledWhether or not the shadow is visible.
Default: true
colorThe colour of the shadow.
Default: 'rgba(0, 0, 0, 0.5)'
xOffsetThe horizontal offset in pixels for the shadow.
Default: 0
yOffsetThe vertical offset in pixels for the shadow.
Default: 0
blurThe radius of the shadow's blur, given in pixels.
Default: 5

Next Up

Continue to the next section to learn about scatter and bubble series.