Stacked Spline Area Chart

The Ignite UI for React stacked spline area chart belongs to a group of category charts and is rendered using a collection of points connected by smooth curves of spline segments (IgrStackedFragmentSeries) with the area below the spline filled in and stacked on top of each other. Each stacked fragment in the collection represents one visual element in each stack. Each stack can contain both positive and negative values. All positive values are grouped on the positive side of the y-axis, and all negative values are grouped on the negative side of the y-axis.

Demo

The IgrStackedSplineAreaSeries has its own IgrSeries collection in which you can place the IgrStackedFragmentSeries elements. These fragments are what make up the actual rendering of the chart and are the elements that accept the valueMemberPath.

Required Axes

The React data chart component provides various types of axes but only the following types of axes can be used with IgrStackedSplineAreaSeries.

Required Data

The IgrStackedSplineAreaSeries has the following data requirements:

  • The data source must be an array or a list of data items.
  • The data source must contain at least one data item otherwise the chart will not render the IgrStackedSplineAreaSeries.
  • All data items must contain at least one data column (string or date time) which should be mapped to the Label property of the category axis (e.g. IgrCategoryXAxis).
  • All data items must contain at least one numeric data column which should be mapped using the ValueMemberPath property of the IgrStackedFragmentSeries to be added to the IgrStackedSplineAreaSeries' IgrSeries collection.

Required Modules

Creation of the IgrStackedSplineAreaSeries requires the following modules:

// axis' modules:
import { IgrCategoryXAxis } from 'igniteui-react-charts';
import { IgrNumericYAxis } from 'igniteui-react-charts';
// series' modules:
import { IgrStackedSplineAreaSeries } from 'igniteui-react-charts';
// data chart's modules:
import { IgrDataChart } from 'igniteui-react-charts';
import { IgrDataChartCoreModule } from 'igniteui-react-charts';
import { IgrDataChartCategoryModule } from 'igniteui-react-charts';
import { IgrDataChartStackedModule } from 'igniteui-react-charts';
import { IgrColumnFragmentModule } from 'igniteui-react-charts' ;

// registering data chart's modules:
IgrDataChartCoreModule.register();
IgrDataChartCategoryModule.register();
IgrDataChartStackedModule.register();
IgrColumnFragmentModule.register();

Code Example

This code demonstrates how to create an instance of the Ignite UI for React data chart with IgrStackedSplineAreaSeries and bind it to a data source.

<IgrDataChart width="100%"
  height="100%"
  dataSource={this.data} >

  <IgrCategoryXAxis name="xAxis" label="Country" />
  <IgrNumericYAxis name="yAxis" minimumValue={0} />
  <IgrStackedSplineAreaSeries name="series" xAxisName="xAxis" yAxisName="yAxis">
    <IgrStackedFragmentSeries name="coal" valueMemberPath="Coal" title="Coal" />
    <IgrStackedFragmentSeries name="hydro" valueMemberPath="Hydro" title="Hydro" />
    <IgrStackedFragmentSeries name="nuclear" valueMemberPath="Nuclear" title="Nuclear" />
    <IgrStackedFragmentSeries name="gas" valueMemberPath="Gas" title="Gas" />
    <IgrStackedFragmentSeries name="oil" valueMemberPath="Oil" title="Oil" />
  </IgrStackedSplineAreaSeries>
</IgrDataChart>
const stack = new IgrStackedSplineAreaSeries({ name: "series" });
stack.xAxisName = "xAxis";
stack.yAxisName = "yAxis";

const propertyNames: string[] = ["Coal", "Hydro", "Nuclear", "Gas", "Oil"];
for (const propertyName of propertyNames) {
    const fragment = new IgrStackedFragmentSeries();
    fragment.valueMemberPath = propertyName;
    fragment.title = propertyName;
    stack.series.add(fragment);
}

const yAxis = new IgrNumericYAxis({ name: "yAxis" });
const xAxis = new IgrCategoryXAxis({ name: "xAxis" });
xAxis.label = "Country";

this.chart = new IgrDataChart({ name: "chart" });
this.chart.dataSource = SampleCategoryData.create();
this.chart.axes.add(yAxis);
this.chart.axes.add(xAxis);
this.chart.series.add(stack);