Stacked Column Chart

The Ignite UI for React stacked column chart belongs to a group of category charts and is rendered using a collection of rectangles (IgrStackedFragmentSeries) that are 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. IgrStackedColumnSeries uses the same concepts of data plotting as IgrStackedBarSeries but data points are stacked along vertical line (y-axis) rather than along horizontal line (x-axis). In other words, the stacked column chart is rendered like the stacked bar chart but with 90 degrees counter-clockwise rotation.

Demo

The IgrStackedColumnSeries 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 IgrStackedColumnSeries.

Required Data

The IgrStackedColumnSeries 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 IgrStackedColumnSeries.
  • 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 IgrStackedColumnSeries' IgrSeries collection.

Required Modules

Creation of the IgrStackedColumnSeries requires the following modules:

// axis' modules:
import { IgrCategoryXAxis } from 'igniteui-react-charts';
import { IgrNumericYAxis } from 'igniteui-react-charts';
// series' modules:
import { IgrStackedColumnSeries } 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();

This code demonstrates how to create an instance of the Ignite UI for React data chart with IgrStackedColumnSeries 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} />
  <IgrStackedColumnSeries 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" />
  </IgrStackedColumnSeries>
</IgrDataChart>
const stack = new IgrStackedColumnSeries({ 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);