Framework:Javascript Data GridAngular Data GridReact Data GridVue Data Grid

React Charts: 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 yKey properties. A minimal 'area' series config would therefore look like this:

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

In the snippet above we are using 'ie' as the yKey to show market share of 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:

series: [{
    ...
    marker: {
        enabled: true
    }
}]

Tooltips will be shown on hover, which in this case show percentage values without a % suffix.

The series are designed to work with all kinds of data and are unaware of the nature of the values. So we additionally provide a tooltipRenderer to add the % suffix. After this change, the tooltips will change like so:

Default Area Tooltip
Before
-->
Custom Area Tooltip
After

The final result can be seen in the example below.

Showing labels on top of data points is also an option with the label config. Labels can be enabled independently of series markers. For example, to show bold labels on top of each data point (and in this case a marker) we would use the following config:

series: [{
    ...
    label: {
        fontWeight: 'bold'
    }
}]

The above config is used in the example below. Feel free to open it in Pluker and experiment with other label options.

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',
        yKey: 'ie'
    },
    {
        type: 'area',
        xKey: 'year',
        yKey: '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 yName to control the text that the legend displays
  • Enable markers
  • Define custom fill and stroke
  • Make the fill translucent using the fillOpacity config

Stacked Area Series

The stacked: true property controls series stacking behaviour. 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', yKey: 'ie', stacked: true },
    { type: 'area', xKey: 'year', yKey: 'firefox', stacked: true },
    { type: 'area', xKey: 'year', yKey: 'safari', stacked: true },
    { type: 'area', xKey: 'year', yKey: 'chrome', stacked: true }
]

This produces the following chart:

Normalized Area Series

Following on from our stacked area series example, if we want 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

Next Up

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