Stacked Step Area Chart in React Chart
20 Aug 202624 minutes to read
Stacked step area
Follow these steps to render a stacked step area series, which combines a stacked area chart with a step area chart — data points are connected with vertical and horizontal lines, producing a step-like appearance.
-
Set the series type: Set the series
typetoStackingStepAreain the series configuration. -
Inject the StackingStepAreaSeries module: Add
StackingStepAreaSeriesto theservicesarray of theInjectcomponent insideChartComponent. This registers the functionality required to render a stacked step area series.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, StackingStepAreaSeries } from '@syncfusion/ej2-react-charts';
import { stepAreaData } from './datasource';
function App() {
const primaryxAxis = { valueType: 'Double', title: 'Overs' };
const primaryyAxis = { title: 'Runs' };
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Annual Temperature Comparison'>
<Inject services={[StackingStepAreaSeries, Legend]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StackingStepArea'>
</SeriesDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y1' name='India' type='StackingStepArea'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import * as React from "react";
import * as ReactDOM from "react-dom";
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, StackingStepAreaSeries}
from'@syncfusion/ej2-react-charts';
import { stepAreaData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { valueType: 'Double', title: 'Overs' };
const primaryyAxis: AxisModel = { title: 'Runs' };
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Annual Temperature Comparison'>
<Inject services={[StackingStepAreaSeries, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StackingStepArea'>
</SeriesDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y1' name='India' type='StackingStepArea' >
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let stepAreaData = [
{ x: 1, y: 7, y1: 10 }, { x: 2, y: 1, y1: 5 },
{ x: 3, y: 1, y1: 7 }, { x: 4, y: 14, y1: 12 },
{ x: 5, y: 1, y1: 4 }, { x: 6, y: 10, y1: 15 },
{ x: 7, y: 8, y1: 12 }, { x: 8, y: 6, y1: 10 },
{ x: 9, y: 10, y1: 14 }, { x: 10, y: 10, y1: 15 },
{ x: 11, y: 16, y1: 18 }, { x: 12, y: 6, y1: 10 },
{ x: 13, y: 14, y1: 18 }, { x: 14, y: 7, y1: 11 },
{ x: 15, y: 5, y1: 9 }, { x: 16, y: 2, y1: 5 },
{ x: 17, y: 14, y1: 18 }, { x: 18, y: 7, y1: 11 },
{ x: 19, y: 7, y1: 10 }, { x: 20, y: 10, y1: 14 }
];export let stepAreaData: Object[] = [
{ x: 1, y: 7, y1: 10 }, { x: 2, y: 1, y1: 5 },
{ x: 3, y: 1, y1: 7 }, { x: 4, y: 14, y1: 12 },
{ x: 5, y: 1, y1: 4 }, { x: 6, y: 10, y1: 15 },
{ x: 7, y: 8, y1: 12 }, { x: 8, y: 6, y1: 10 },
{ x: 9, y: 10, y1: 14 }, { x: 10, y: 10, y1: 15 },
{ x: 11, y: 16, y1: 18 }, { x: 12, y: 6, y1: 10 },
{ x: 13, y: 14, y1: 18 }, { x: 14, y: 7, y1: 11 },
{ x: 15, y: 5, y1: 9 }, { x: 16, y: 2, y1: 5 },
{ x: 17, y: 14, y1: 18 }, { x: 18, y: 7, y1: 11 },
{ x: 19, y: 7, y1: 10 }, { x: 20, y: 10, y1: 14 }
];Binding data with series
You can bind data to the chart using the dataSource property within the series configuration. This allows you to connect a JSON dataset or remote data to your chart. To display the data correctly, map the fields from the data to the chart series xName and yName properties. The example below uses the same StackingStepArea configuration shown above with a typical JSON dataset and the xName/yName mapping applied.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, StackingStepAreaSeries } from '@syncfusion/ej2-react-charts';
import { stepAreaData } from './datasource';
function App() {
const primaryxAxis = { valueType: 'Double', title: 'Overs' };
const primaryyAxis = { title: 'Runs' };
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Annual Temperature Comparison'>
<Inject services={[StackingStepAreaSeries, Legend]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StackingStepArea'>
</SeriesDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y1' name='India' type='StackingStepArea'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import * as React from "react";
import * as ReactDOM from "react-dom";
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, StackingStepAreaSeries}
from'@syncfusion/ej2-react-charts';
import { stepAreaData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { valueType: 'Double', title: 'Overs' };
const primaryyAxis: AxisModel = { title: 'Runs' };
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Annual Temperature Comparison'>
<Inject services={[StackingStepAreaSeries, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StackingStepArea'>
</SeriesDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y1' name='India' type='StackingStepArea' >
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let stepAreaData = [
{ x: 1, y: 7, y1: 10 }, { x: 2, y: 1, y1: 5 },
{ x: 3, y: 1, y1: 7 }, { x: 4, y: 14, y1: 12 },
{ x: 5, y: 1, y1: 4 }, { x: 6, y: 10, y1: 15 },
{ x: 7, y: 8, y1: 12 }, { x: 8, y: 6, y1: 10 },
{ x: 9, y: 10, y1: 14 }, { x: 10, y: 10, y1: 15 },
{ x: 11, y: 16, y1: 18 }, { x: 12, y: 6, y1: 10 },
{ x: 13, y: 14, y1: 18 }, { x: 14, y: 7, y1: 11 },
{ x: 15, y: 5, y1: 9 }, { x: 16, y: 2, y1: 5 },
{ x: 17, y: 14, y1: 18 }, { x: 18, y: 7, y1: 11 },
{ x: 19, y: 7, y1: 10 }, { x: 20, y: 10, y1: 14 }
];export let stepAreaData: Object[] = [
{ x: 1, y: 7, y1: 10 }, { x: 2, y: 1, y1: 5 },
{ x: 3, y: 1, y1: 7 }, { x: 4, y: 14, y1: 12 },
{ x: 5, y: 1, y1: 4 }, { x: 6, y: 10, y1: 15 },
{ x: 7, y: 8, y1: 12 }, { x: 8, y: 6, y1: 10 },
{ x: 9, y: 10, y1: 14 }, { x: 10, y: 10, y1: 15 },
{ x: 11, y: 16, y1: 18 }, { x: 12, y: 6, y1: 10 },
{ x: 13, y: 14, y1: 18 }, { x: 14, y: 7, y1: 11 },
{ x: 15, y: 5, y1: 9 }, { x: 16, y: 2, y1: 5 },
{ x: 17, y: 14, y1: 18 }, { x: 18, y: 7, y1: 11 },
{ x: 19, y: 7, y1: 10 }, { x: 20, y: 10, y1: 14 }
];Series customization
Customize the stacked step area series appearance with the following properties. Defaults are taken from the standard Series model.
| Property | Type | Default | Description |
|---|---|---|---|
fill |
string | null |
Color applied to the series. Accepts a CSS color or a gradient reference. |
opacity |
number | 1 |
Transparency of the fill (0 to 1). |
border |
BorderModel |
null |
Border settings: width, color, and dashArray. |
step |
StepPosition |
Left |
Position of the steps relative to the data points. |
noRisers |
boolean | false |
When true, hides the vertical risers between data points. |
Solid fill
The fill property determines the color applied to the series.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, StackingStepAreaSeries } from '@syncfusion/ej2-react-charts';
import { stepAreaData } from './datasource';
function App() {
const primaryxAxis = { valueType: 'Double', title: 'Overs' };
const primaryyAxis = { title: 'Runs' };
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Annual Temperature Comparison'>
<Inject services={[StackingStepAreaSeries, Legend]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StackingStepArea' fill="red">
</SeriesDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y1' name='India' type='StackingStepArea' fill="green">
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import * as React from "react";
import * as ReactDOM from "react-dom";
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, StackingStepAreaSeries}
from'@syncfusion/ej2-react-charts';
import { stepAreaData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { valueType: 'Double', title: 'Overs' };
const primaryyAxis: AxisModel = { title: 'Runs' };
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Annual Temperature Comparison'>
<Inject services={[StackingStepAreaSeries, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StackingStepArea' fill='red'>
</SeriesDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y1' name='India' type='StackingStepArea' fill='green'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let stepAreaData = [
{ x: 1, y: 7, y1: 10 }, { x: 2, y: 1, y1: 5 },
{ x: 3, y: 1, y1: 7 }, { x: 4, y: 14, y1: 12 },
{ x: 5, y: 1, y1: 4 }, { x: 6, y: 10, y1: 15 },
{ x: 7, y: 8, y1: 12 }, { x: 8, y: 6, y1: 10 },
{ x: 9, y: 10, y1: 14 }, { x: 10, y: 10, y1: 15 },
{ x: 11, y: 16, y1: 18 }, { x: 12, y: 6, y1: 10 },
{ x: 13, y: 14, y1: 18 }, { x: 14, y: 7, y1: 11 },
{ x: 15, y: 5, y1: 9 }, { x: 16, y: 2, y1: 5 },
{ x: 17, y: 14, y1: 18 }, { x: 18, y: 7, y1: 11 },
{ x: 19, y: 7, y1: 10 }, { x: 20, y: 10, y1: 14 }
];export let stepAreaData: Object[] = [
{ x: 1, y: 7, y1: 10 }, { x: 2, y: 1, y1: 5 },
{ x: 3, y: 1, y1: 7 }, { x: 4, y: 14, y1: 12 },
{ x: 5, y: 1, y1: 4 }, { x: 6, y: 10, y1: 15 },
{ x: 7, y: 8, y1: 12 }, { x: 8, y: 6, y1: 10 },
{ x: 9, y: 10, y1: 14 }, { x: 10, y: 10, y1: 15 },
{ x: 11, y: 16, y1: 18 }, { x: 12, y: 6, y1: 10 },
{ x: 13, y: 14, y1: 18 }, { x: 14, y: 7, y1: 11 },
{ x: 15, y: 5, y1: 9 }, { x: 16, y: 2, y1: 5 },
{ x: 17, y: 14, y1: 18 }, { x: 18, y: 7, y1: 11 },
{ x: 19, y: 7, y1: 10 }, { x: 20, y: 10, y1: 14 }
];Gradient fill
The fill property can be set to a CSS gradient reference such as url(#gradient) to apply a gradient color that transitions across the series. Define the gradient in an SVG <defs> block and reference it from the fill prop.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, StackingStepAreaSeries } from '@syncfusion/ej2-react-charts';
import { stepAreaData } from './datasource';
function App() {
const primaryxAxis = { valueType: 'Double', title: 'Overs' };
const primaryyAxis = { title: 'Runs' };
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Annual Temperature Comparison'>
<Inject services={[StackingStepAreaSeries, Legend]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StackingStepArea' fill="url(#gradient1)">
</SeriesDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y1' name='India' type='StackingStepArea' fill="url(#gradient2)">
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import * as React from "react";
import * as ReactDOM from "react-dom";
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, StackingStepAreaSeries}
from'@syncfusion/ej2-react-charts';
import { stepAreaData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { valueType: 'Double', title: 'Overs' };
const primaryyAxis: AxisModel = { title: 'Runs' };
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Annual Temperature Comparison'>
<Inject services={[StackingStepAreaSeries, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StackingStepArea' fill='url(#gradient1)'>
</SeriesDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y1' name='India' type='StackingStepArea' fill='url(#gradient2)'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let stepAreaData = [
{ x: 1, y: 7, y1: 10 }, { x: 2, y: 1, y1: 5 },
{ x: 3, y: 1, y1: 7 }, { x: 4, y: 14, y1: 12 },
{ x: 5, y: 1, y1: 4 }, { x: 6, y: 10, y1: 15 },
{ x: 7, y: 8, y1: 12 }, { x: 8, y: 6, y1: 10 },
{ x: 9, y: 10, y1: 14 }, { x: 10, y: 10, y1: 15 },
{ x: 11, y: 16, y1: 18 }, { x: 12, y: 6, y1: 10 },
{ x: 13, y: 14, y1: 18 }, { x: 14, y: 7, y1: 11 },
{ x: 15, y: 5, y1: 9 }, { x: 16, y: 2, y1: 5 },
{ x: 17, y: 14, y1: 18 }, { x: 18, y: 7, y1: 11 },
{ x: 19, y: 7, y1: 10 }, { x: 20, y: 10, y1: 14 }
];export let stepAreaData: Object[] = [
{ x: 1, y: 7, y1: 10 }, { x: 2, y: 1, y1: 5 },
{ x: 3, y: 1, y1: 7 }, { x: 4, y: 14, y1: 12 },
{ x: 5, y: 1, y1: 4 }, { x: 6, y: 10, y1: 15 },
{ x: 7, y: 8, y1: 12 }, { x: 8, y: 6, y1: 10 },
{ x: 9, y: 10, y1: 14 }, { x: 10, y: 10, y1: 15 },
{ x: 11, y: 16, y1: 18 }, { x: 12, y: 6, y1: 10 },
{ x: 13, y: 14, y1: 18 }, { x: 14, y: 7, y1: 11 },
{ x: 15, y: 5, y1: 9 }, { x: 16, y: 2, y1: 5 },
{ x: 17, y: 14, y1: 18 }, { x: 18, y: 7, y1: 11 },
{ x: 19, y: 7, y1: 10 }, { x: 20, y: 10, y1: 14 }
];Opacity
The opacity property controls the transparency of the fill (0 to 1) and affects how the series blends with background or overlapping series.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, StackingStepAreaSeries } from '@syncfusion/ej2-react-charts';
import { stepAreaData } from './datasource';
function App() {
const primaryxAxis = { valueType: 'Double', title: 'Overs' };
const primaryyAxis = { title: 'Runs' };
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Annual Temperature Comparison'>
<Inject services={[StackingStepAreaSeries, Legend]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StackingStepArea' opacity={0.5}>
</SeriesDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y1' name='India' type='StackingStepArea' opacity={0.5}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import * as React from "react";
import * as ReactDOM from "react-dom";
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, StackingStepAreaSeries}
from'@syncfusion/ej2-react-charts';
import { stepAreaData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { valueType: 'Double', title: 'Overs' };
const primaryyAxis: AxisModel = { title: 'Runs' };
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Annual Temperature Comparison'>
<Inject services={[StackingStepAreaSeries, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StackingStepArea' opacity={0.5}>
</SeriesDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y1' name='India' type='StackingStepArea' opacity={0.5}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let stepAreaData = [
{ x: 1, y: 7, y1: 10 }, { x: 2, y: 1, y1: 5 },
{ x: 3, y: 1, y1: 7 }, { x: 4, y: 14, y1: 12 },
{ x: 5, y: 1, y1: 4 }, { x: 6, y: 10, y1: 15 },
{ x: 7, y: 8, y1: 12 }, { x: 8, y: 6, y1: 10 },
{ x: 9, y: 10, y1: 14 }, { x: 10, y: 10, y1: 15 },
{ x: 11, y: 16, y1: 18 }, { x: 12, y: 6, y1: 10 },
{ x: 13, y: 14, y1: 18 }, { x: 14, y: 7, y1: 11 },
{ x: 15, y: 5, y1: 9 }, { x: 16, y: 2, y1: 5 },
{ x: 17, y: 14, y1: 18 }, { x: 18, y: 7, y1: 11 },
{ x: 19, y: 7, y1: 10 }, { x: 20, y: 10, y1: 14 }
];export let stepAreaData: Object[] = [
{ x: 1, y: 7, y1: 10 }, { x: 2, y: 1, y1: 5 },
{ x: 3, y: 1, y1: 7 }, { x: 4, y: 14, y1: 12 },
{ x: 5, y: 1, y1: 4 }, { x: 6, y: 10, y1: 15 },
{ x: 7, y: 8, y1: 12 }, { x: 8, y: 6, y1: 10 },
{ x: 9, y: 10, y1: 14 }, { x: 10, y: 10, y1: 15 },
{ x: 11, y: 16, y1: 18 }, { x: 12, y: 6, y1: 10 },
{ x: 13, y: 14, y1: 18 }, { x: 14, y: 7, y1: 11 },
{ x: 15, y: 5, y1: 9 }, { x: 16, y: 2, y1: 5 },
{ x: 17, y: 14, y1: 18 }, { x: 18, y: 7, y1: 11 },
{ x: 19, y: 7, y1: 10 }, { x: 20, y: 10, y1: 14 }
];Border
Use the border property to configure the border width, color, and dashArray of the stacked step area series.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, StackingStepAreaSeries } from '@syncfusion/ej2-react-charts';
import { stepAreaData } from './datasource';
function App() {
const primaryxAxis = {
title: 'Years',
edgeLabelPlacement: 'Shift',
majorTickLines: { width: 0 }
};
const primaryyAxis = {
title: 'Spend in Billions',
minimum: 0,
maximum: 4,
interval: 1,
labelFormat: '{value}B',
majorTickLines: { width: 0 }
};
const border = { width: 2, color: '#ff4251', dashArray: '5,5' };
const border1 = { width: 2, color: '#4C4C4C', dashArray: '5,5' };
const border2 = { width: 2, color: '#794F1B', dashArray: '5,5' };
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Trend in Sales of Ethical Produce'>
<Inject services={[StackingStepAreaSeries, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='Organic' type='StackingStepArea' border={border}>
</SeriesDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y1' name='Fair-trade' type='StackingStepArea' border={border1}>
</SeriesDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y2' name='Fair-trade' type='StackingStepArea' border={border2}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, AxisModel, BorderModel, Legend, StackingStepAreaSeries } from '@syncfusion/ej2-react-charts';
import { stepAreaData } from './datasource';
function App() {
const primaryxAxis: AxisModel = {
title: 'Years',
edgeLabelPlacement: 'Shift',
majorTickLines: { width: 0 }
};
const primaryyAxis: AxisModel = {
title: 'Spend in Billions',
minimum: 0,
maximum: 4,
interval: 1,
labelFormat: '{value}B',
majorTickLines: { width: 0 }
};
const border: BorderModel = { width: 2, color: '#ff4251', dashArray: '5,5' };
const border1: BorderModel = { width: 2, color: '#4C4C4C', dashArray: '5,5' };
const border2: BorderModel = { width: 2, color: '#794F1B', dashArray: '5,5' };
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Trend in Sales of Ethical Produce'>
<Inject services={[StackingStepAreaSeries, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='Organic' type='StackingStepArea' border={border}>
</SeriesDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y1' name='Fair-trade' type='StackingStepArea' border={border1}>
</SeriesDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y2' name='Fair-trade' type='StackingStepArea' border={border2}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let stepAreaData = [
{ x: 2000, y: 0.61, y1: 0.03, y2: 0.48},
{ x: 2001, y: 0.81, y1: 0.05, y2: 0.53 },
{ x: 2002, y: 0.91, y1: 0.06, y2: 0.57 },
{ x: 2003, y: 1, y1: 0.09, y2: 0.61 },
{ x: 2004, y: 1.19, y1: 0.14, y2: 0.63 },
{ x: 2005, y: 1.47, y1: 0.20, y2: 0.64 },
{ x: 2006, y: 1.74, y1: 0.29, y2: 0.66 },
{ x: 2007, y: 1.98, y1: 0.46, y2: 0.76 },
{ x: 2008, y: 1.99, y1: 0.64, y2: 0.77 },
{ x: 2009, y: 1.70, y1: 0.75, y2: 0.55 }
];export let stepAreaData: Object[] = [
{ x: 2000, y: 0.61, y1: 0.03, y2: 0.48},
{ x: 2001, y: 0.81, y1: 0.05, y2: 0.53 },
{ x: 2002, y: 0.91, y1: 0.06, y2: 0.57 },
{ x: 2003, y: 1, y1: 0.09, y2: 0.61 },
{ x: 2004, y: 1.19, y1: 0.14, y2: 0.63 },
{ x: 2005, y: 1.47, y1: 0.20, y2: 0.64 },
{ x: 2006, y: 1.74, y1: 0.29, y2: 0.66 },
{ x: 2007, y: 1.98, y1: 0.46, y2: 0.76 },
{ x: 2008, y: 1.99, y1: 0.64, y2: 0.77 },
{ x: 2009, y: 1.70, y1: 0.75, y2: 0.55 }
];Step
Use the step property to change the position of the steps in a stacked step area series. Valid values are Left(default), Center, and Right.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, StackingStepAreaSeries } from '@syncfusion/ej2-react-charts';
import { stepAreaData } from './datasource';
function App() {
const primaryxAxis = { valueType: 'Double', title: 'Overs' };
const primaryyAxis = { title: 'Runs' };
const border = { width: 2, color: 'red'};
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Annual Temperature Comparison'>
<Inject services={[StackingStepAreaSeries, Legend]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StackingStepArea' step='Center'>
</SeriesDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y1' name='India' type='StackingStepArea' step='Center'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import * as React from "react";
import * as ReactDOM from "react-dom";
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, StackingStepAreaSeries}
from'@syncfusion/ej2-react-charts';
import { stepAreaData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { valueType: 'Double', title: 'Overs' };
const primaryyAxis: AxisModel = { title: 'Runs' };
const border: object = { width: 2, color: 'red'};
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Annual Temperature Comparison'>
<Inject services={[StackingStepAreaSeries, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StackingStepArea' step='Center'>
</SeriesDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y1' name='India' type='StackingStepArea' step='Center'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let stepAreaData = [
{ x: 1, y: 7, y1: 10 }, { x: 2, y: 1, y1: 5 },
{ x: 3, y: 1, y1: 7 }, { x: 4, y: 14, y1: 12 },
{ x: 5, y: 1, y1: 4 }, { x: 6, y: 10, y1: 15 },
{ x: 7, y: 8, y1: 12 }, { x: 8, y: 6, y1: 10 },
{ x: 9, y: 10, y1: 14 }, { x: 10, y: 10, y1: 15 },
{ x: 11, y: 16, y1: 18 }, { x: 12, y: 6, y1: 10 },
{ x: 13, y: 14, y1: 18 }, { x: 14, y: 7, y1: 11 },
{ x: 15, y: 5, y1: 9 }, { x: 16, y: 2, y1: 5 },
{ x: 17, y: 14, y1: 18 }, { x: 18, y: 7, y1: 11 },
{ x: 19, y: 7, y1: 10 }, { x: 20, y: 10, y1: 14 }
];export let stepAreaData: Object[] = [
{ x: 1, y: 7, y1: 10 }, { x: 2, y: 1, y1: 5 },
{ x: 3, y: 1, y1: 7 }, { x: 4, y: 14, y1: 12 },
{ x: 5, y: 1, y1: 4 }, { x: 6, y: 10, y1: 15 },
{ x: 7, y: 8, y1: 12 }, { x: 8, y: 6, y1: 10 },
{ x: 9, y: 10, y1: 14 }, { x: 10, y: 10, y1: 15 },
{ x: 11, y: 16, y1: 18 }, { x: 12, y: 6, y1: 10 },
{ x: 13, y: 14, y1: 18 }, { x: 14, y: 7, y1: 11 },
{ x: 15, y: 5, y1: 9 }, { x: 16, y: 2, y1: 5 },
{ x: 17, y: 14, y1: 18 }, { x: 18, y: 7, y1: 11 },
{ x: 19, y: 7, y1: 10 }, { x: 20, y: 10, y1: 14 }
];No risers
You can eliminate the vertical lines between points by setting the noRisers property on a series to true. This is useful for highlighting trends without the distraction of risers.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, StackingStepAreaSeries}
from'@syncfusion/ej2-react-charts';
import { percentData } from "../datasource";
function App() {
return <ChartComponent id="charts" primaryXAxis={{
title: 'Years',
edgeLabelPlacement: 'Shift',
majorTickLines: { width: 0 }
}}
primaryYAxis={
{
title: 'Spend in Billions',
minimum: 0,
maximum: 4,
interval: 1,
labelFormat: '{value}B',
majorTickLines: { width: 0 }
}}
title = 'Annual Temperature Comparison' >
<Inject services={[StackingStepAreaSeries, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource = {percentData} type='StackingStepArea' xName='x' yName='y' name='Organic' opacity= {0.1} border= {{width:1.5}} noRisers={true}>
</SeriesDirective>
<SeriesDirective dataSource = {percentData} type='StackingStepArea' xName='x' yName='y2' name='Others' opacity= {0.1} border= {{width:1.5}} noRisers={true}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import * as React from "react";
import * as ReactDOM from "react-dom";
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, StackingStepAreaSeries}
from'@syncfusion/ej2-react-charts';
import { percentData } from "../datasource";
function App() {
return <ChartComponent id="charts" primaryXAxis={{
title: 'Years',
edgeLabelPlacement: 'Shift',
majorTickLines: { width: 0 }
}}
primaryYAxis={
{
title: 'Spend in Billions',
minimum: 0,
maximum: 4,
interval: 1,
labelFormat: '{value}B',
majorTickLines: { width: 0 }
}}
title = 'Annual Temperature Comparison' >
<Inject services={[StackingStepAreaSeries, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource = {percentData} type='StackingStepArea' xName='x' yName='y' name='Organic' opacity= {0.1} border= {{width:1.5}} noRisers={true}>
</SeriesDirective>
<SeriesDirective dataSource = {percentData} type='StackingStepArea' xName='x' yName='y2' name='Others' opacity= {0.1} border= {{width:1.5}} noRisers={true}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let percentData: Object[] = [
{ x: 2000, y: 0.61, y1: 0.03, y2: 0.48},
{ x: 2001, y: 0.81, y1: 0.05, y2: 0.53 },
{ x: 2002, y: 0.91, y1: 0.06, y2: 0.57 },
{ x: 2003, y: 1, y1: 0.09, y2: 0.61 },
{ x: 2004, y: 1.19, y1: 0.14, y2: 0.63 },
{ x: 2005, y: 1.47, y1: 0.20, y2: 0.64 },
{ x: 2006, y: 1.74, y1: 0.29, y2: 0.66 },
{ x: 2007, y: 1.98, y1: 0.46, y2: 0.76 },
{ x: 2008, y: 1.99, y1: 0.64, y2: 0.77 },
{ x: 2009, y: 1.70, y1: 0.75, y2: 0.55 }
];Empty points
Data points with null or undefined values are considered empty. By default (mode: 'Gap'), empty points leave a gap in the stack; the mode property on emptyPointSettings lets you change how they are handled.
Mode
Use the mode property to control handling of empty points. Available modes: Gap, Drop, Zero, Average. The default mode is Gap.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, StackingStepAreaSeries } from '@syncfusion/ej2-react-charts';
import { stepAreaData } from './datasource';
function App() {
const primaryxAxis = { valueType: 'Double', title: 'Overs' };
const primaryyAxis = { title: 'Runs' };
const emptyPoint = { mode: 'Gap' };
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Annual Temperature Comparison'>
<Inject services={[StackingStepAreaSeries, Legend]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StackingStepArea' emptyPointSettings={emptyPoint}>
</SeriesDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y1' name='India' type='StackingStepArea'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import * as React from "react";
import * as ReactDOM from "react-dom";
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, StackingStepAreaSeries}
from'@syncfusion/ej2-react-charts';
import { stepAreaData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { valueType: 'Double', title: 'Overs' };
const primaryyAxis: AxisModel = { title: 'Runs' };
const emptyPoint: object = { mode: 'Gap' };
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Annual Temperature Comparison'>
<Inject services={[StackingStepAreaSeries, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StackingStepArea' emptyPointSettings={emptyPoint}>
</SeriesDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y1' name='India' type='StackingStepArea'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let stepAreaData = [
{ x: 1, y: 7, y1: 10 }, { x: 2, y: 1, y1: 5 },
{ x: 3, y: 1, y1: 7 }, { x: 4, y: 14, y1: 12 },
{ x: 5, y: 1, y1: 4 }, { x: 6, y: 10, y1: 15 },
{ x: 7, y: 8, y1: 12 }, { x: 8, y: 6, y1: 10 },
{ x: 9, y: null, y1: 14 }, { x: 10, y: null, y1: 15 },
{ x: 11, y: 16, y1: 18 }, { x: 12, y: 6, y1: 10 },
{ x: 13, y: 14, y1: 18 }, { x: 14, y: 7, y1: 11 },
{ x: 15, y: 5, y1: 9 }, { x: 16, y: 2, y1: 5 },
{ x: 17, y: 14, y1: 18 }, { x: 18, y: 7, y1: 11 },
{ x: 19, y: 7, y1: 10 }, { x: 20, y: 10, y1: 14 }
];export let stepAreaData: Object[] = [
{ x: 1, y: 7, y1: 10 }, { x: 2, y: 1, y1: 5 },
{ x: 3, y: 1, y1: 7 }, { x: 4, y: 14, y1: 12 },
{ x: 5, y: 1, y1: 4 }, { x: 6, y: 10, y1: 15 },
{ x: 7, y: 8, y1: 12 }, { x: 8, y: 6, y1: 10 },
{ x: 9, y: null, y1: 14 }, { x: 10, y: null, y1: 15 },
{ x: 11, y: 16, y1: 18 }, { x: 12, y: 6, y1: 10 },
{ x: 13, y: 14, y1: 18 }, { x: 14, y: 7, y1: 11 },
{ x: 15, y: 5, y1: 9 }, { x: 16, y: 2, y1: 5 },
{ x: 17, y: 14, y1: 18 }, { x: 18, y: 7, y1: 11 },
{ x: 19, y: 7, y1: 10 }, { x: 20, y: 10, y1: 14 }
];Fill
Use the fill property to set the fill color for empty points.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, StackingStepAreaSeries } from '@syncfusion/ej2-react-charts';
import { stepAreaData } from './datasource';
function App() {
const primaryxAxis = { valueType: 'Double', title: 'Overs' };
const primaryyAxis = { title: 'Runs' };
const emptyPoint = { mode: 'Average', fill: 'red' };
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Annual Temperature Comparison'>
<Inject services={[StackingStepAreaSeries, Legend]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StackingStepArea' marker={{visible: true}} emptyPointSettings={emptyPoint}>
</SeriesDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y1' name='India' type='StackingStepArea'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import * as React from "react";
import * as ReactDOM from "react-dom";
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, StackingStepAreaSeries}
from'@syncfusion/ej2-react-charts';
import { stepAreaData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { valueType: 'Double', title: 'Overs' };
const primaryyAxis: AxisModel = { title: 'Runs' };
const emptyPoint: object = { mode: 'Average', fill: 'red' };
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Annual Temperature Comparison'>
<Inject services={[StackingStepAreaSeries, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StackingStepArea' marker={{visible: true}} emptyPointSettings={emptyPoint}>
</SeriesDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y1' name='India' type='StackingStepArea'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let stepAreaData = [
{ x: 1, y: 7, y1: 10 }, { x: 2, y: 1, y1: 5 },
{ x: 3, y: 1, y1: 7 }, { x: 4, y: 14, y1: 12 },
{ x: 5, y: 1, y1: 4 }, { x: 6, y: 10, y1: 15 },
{ x: 7, y: 8, y1: 12 }, { x: 8, y: 6, y1: 10 },
{ x: 9, y: null, y1: 14 }, { x: 10, y: null, y1: 15 },
{ x: 11, y: 16, y1: 18 }, { x: 12, y: 6, y1: 10 },
{ x: 13, y: 14, y1: 18 }, { x: 14, y: 7, y1: 11 },
{ x: 15, y: 5, y1: 9 }, { x: 16, y: 2, y1: 5 },
{ x: 17, y: 14, y1: 18 }, { x: 18, y: 7, y1: 11 },
{ x: 19, y: 7, y1: 10 }, { x: 20, y: 10, y1: 14 }
];export let stepAreaData: Object[] = [
{ x: 1, y: 7, y1: 10 }, { x: 2, y: 1, y1: 5 },
{ x: 3, y: 1, y1: 7 }, { x: 4, y: 14, y1: 12 },
{ x: 5, y: 1, y1: 4 }, { x: 6, y: 10, y1: 15 },
{ x: 7, y: 8, y1: 12 }, { x: 8, y: 6, y1: 10 },
{ x: 9, y: null, y1: 14 }, { x: 10, y: null, y1: 15 },
{ x: 11, y: 16, y1: 18 }, { x: 12, y: 6, y1: 10 },
{ x: 13, y: 14, y1: 18 }, { x: 14, y: 7, y1: 11 },
{ x: 15, y: 5, y1: 9 }, { x: 16, y: 2, y1: 5 },
{ x: 17, y: 14, y1: 18 }, { x: 18, y: 7, y1: 11 },
{ x: 19, y: 7, y1: 10 }, { x: 20, y: 10, y1: 14 }
];Border
Use the border property to customize the border width and color for empty points.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, StackingStepAreaSeries } from '@syncfusion/ej2-react-charts';
import { stepAreaData } from './datasource';
function App() {
const primaryxAxis = { valueType: 'Double', title: 'Overs' };
const primaryyAxis = { title: 'Runs' };
const emptyPoint = { mode: 'Average', fill: 'red', border: {width: 1.5, fill: 'green'} };
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Annual Temperature Comparison'>
<Inject services={[StackingStepAreaSeries, Legend]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StackingStepArea' marker={{visible: true}} emptyPointSettings={emptyPoint}>
</SeriesDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y1' name='India' type='StackingStepArea'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import * as React from "react";
import * as ReactDOM from "react-dom";
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, StackingStepAreaSeries}
from'@syncfusion/ej2-react-charts';
import { stepAreaData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { valueType: 'Double', title: 'Overs' };
const primaryyAxis: AxisModel = { title: 'Runs' };
const emptyPoint: object = { mode: 'Average', fill: 'red', border: {width: 1.5, fill: 'green'} };
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Annual Temperature Comparison'>
<Inject services={[StackingStepAreaSeries, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StackingStepArea' marker={{visible: true}} emptyPointSettings={emptyPoint}>
</SeriesDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y1' name='India' type='StackingStepArea'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let stepAreaData = [
{ x: 1, y: 7, y1: 10 }, { x: 2, y: 1, y1: 5 },
{ x: 3, y: 1, y1: 7 }, { x: 4, y: 14, y1: 12 },
{ x: 5, y: 1, y1: 4 }, { x: 6, y: 10, y1: 15 },
{ x: 7, y: 8, y1: 12 }, { x: 8, y: 6, y1: 10 },
{ x: 9, y: null, y1: 14 }, { x: 10, y: null, y1: 15 },
{ x: 11, y: 16, y1: 18 }, { x: 12, y: 6, y1: 10 },
{ x: 13, y: 14, y1: 18 }, { x: 14, y: 7, y1: 11 },
{ x: 15, y: 5, y1: 9 }, { x: 16, y: 2, y1: 5 },
{ x: 17, y: 14, y1: 18 }, { x: 18, y: 7, y1: 11 },
{ x: 19, y: 7, y1: 10 }, { x: 20, y: 10, y1: 14 }
];export let stepAreaData: Object[] = [
{ x: 1, y: 7, y1: 10 }, { x: 2, y: 1, y1: 5 },
{ x: 3, y: 1, y1: 7 }, { x: 4, y: 14, y1: 12 },
{ x: 5, y: 1, y1: 4 }, { x: 6, y: 10, y1: 15 },
{ x: 7, y: 8, y1: 12 }, { x: 8, y: 6, y1: 10 },
{ x: 9, y: null, y1: 14 }, { x: 10, y: null, y1: 15 },
{ x: 11, y: 16, y1: 18 }, { x: 12, y: 6, y1: 10 },
{ x: 13, y: 14, y1: 18 }, { x: 14, y: 7, y1: 11 },
{ x: 15, y: 5, y1: 9 }, { x: 16, y: 2, y1: 5 },
{ x: 17, y: 14, y1: 18 }, { x: 18, y: 7, y1: 11 },
{ x: 19, y: 7, y1: 10 }, { x: 20, y: 10, y1: 14 }
];Stack labels
The stack labels in stacked charts display cumulative total values for stack segments as inline data labels. If a stacked point has negative values, the stack labels are displayed below the point. Stack labels are independent of the dataLabel settings within each series.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, StackingStepAreaSeries, DataLabel } from '@syncfusion/ej2-react-charts';
import { stepAreaData } from './datasource';
function App() {
const primaryxAxis = { valueType: 'Double', title: 'Overs' };
const primaryyAxis = { title: 'Runs' };
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Annual Temperature Comparison'
stackLabels={{ visible: true }}
>
<Inject services={[StackingStepAreaSeries, Legend, DataLabel]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StackingStepArea' marker={{ dataLabel: { visible: true } }}>
</SeriesDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y1' name='India' type='StackingStepArea' marker={{ dataLabel: { visible: true } }}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import * as React from "react";
import * as ReactDOM from "react-dom";
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, StackingStepAreaSeries, DataLabel}
from'@syncfusion/ej2-react-charts';
import { stepAreaData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { valueType: 'Double', title: 'Overs' };
const primaryyAxis: AxisModel = { title: 'Runs' };
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Annual Temperature Comparison'
stackLabels={{ visible: true }}
>
<Inject services={[StackingStepAreaSeries, Legend, DataLabel]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StackingStepArea' marker={{ dataLabel: { visible: true } }}>
</SeriesDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y1' name='India' type='StackingStepArea' marker={{ dataLabel: { visible: true } }}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let stepAreaData = [
{ x: 1, y: 7, y1: 10 }, { x: 2, y: 1, y1: 5 },
{ x: 3, y: 1, y1: 7 }, { x: 4, y: 14, y1: 12 },
{ x: 5, y: 1, y1: 4 }, { x: 6, y: 10, y1: 15 },
{ x: 7, y: 8, y1: 12 }, { x: 8, y: 6, y1: 10 },
{ x: 9, y: 10, y1: 14 }, { x: 10, y: 10, y1: 15 },
{ x: 11, y: 16, y1: 18 }, { x: 12, y: 6, y1: 10 },
{ x: 13, y: 14, y1: 18 }, { x: 14, y: 7, y1: 11 },
{ x: 15, y: 5, y1: 9 }, { x: 16, y: 2, y1: 5 },
{ x: 17, y: 14, y1: 18 }, { x: 18, y: 7, y1: 11 },
{ x: 19, y: 7, y1: 10 }, { x: 20, y: 10, y1: 14 }
];export let stepAreaData: Object[] = [
{ x: 1, y: 7, y1: 10 }, { x: 2, y: 1, y1: 5 },
{ x: 3, y: 1, y1: 7 }, { x: 4, y: 14, y1: 12 },
{ x: 5, y: 1, y1: 4 }, { x: 6, y: 10, y1: 15 },
{ x: 7, y: 8, y1: 12 }, { x: 8, y: 6, y1: 10 },
{ x: 9, y: 10, y1: 14 }, { x: 10, y: 10, y1: 15 },
{ x: 11, y: 16, y1: 18 }, { x: 12, y: 6, y1: 10 },
{ x: 13, y: 14, y1: 18 }, { x: 14, y: 7, y1: 11 },
{ x: 15, y: 5, y1: 9 }, { x: 16, y: 2, y1: 5 },
{ x: 17, y: 14, y1: 18 }, { x: 18, y: 7, y1: 11 },
{ x: 19, y: 7, y1: 10 }, { x: 20, y: 10, y1: 14 }
];Stack labels customization
Stack labels have various properties for customization to enhance the visual based on your requirements:
| Property | Type | Default | Description |
|---|---|---|---|
visible |
boolean | false |
Specifies whether stack labels are visible. Setting to true displays the labels. |
fill |
string | transparent |
Background color of the stack labels. Accepts valid CSS color strings (hex, RGBA, etc.). |
format |
string | null |
Format string for the label text. Supports placeholders such as {value}. |
angle |
number | 0 |
Rotation angle for stack labels in degrees. |
rx |
number | 5 |
Rounded corner radius along the X-axis for the stack label background. |
ry |
number | 5 |
Rounded corner radius along the Y-axis for the stack label background. |
margin |
MarginModel |
null |
Margin around the stack label (left, right, top, bottom). |
border |
BorderModel |
null |
Border appearance of the stack label. |
font |
StackLabelsFontModel |
null |
Font customization (size, color, fontStyle, fontWeight, fontFamily). |
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, StackingStepAreaSeries, DataLabel } from '@syncfusion/ej2-react-charts';
import { stepAreaData } from './datasource';
function App() {
const primaryxAxis = { valueType: 'Double', title: 'Overs' };
const primaryyAxis = { title: 'Runs' };
const stackLabels = { visible: true, fill: 'rgba(0, 123, 255, 0.5)', format: '{value}', angle: 45, rx: 10, ry: 10, margin: { left: 10, right: 10, top: 10, bottom: 10 }, border: { width: 2, color: '#000' }, font: { size: '14px', color: '#fff', weight: 'bold', family: 'Arial', textAlignment: 'Left' } };
const marker = { dataLabel: { visible: true } };
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Annual Temperature Comparison'
stackLabels={stackLabels}
>
<Inject services={[StackingStepAreaSeries, Legend, DataLabel]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StackingStepArea' marker={marker}>
</SeriesDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y1' name='India' type='StackingStepArea' marker={marker}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import * as React from "react";
import * as ReactDOM from "react-dom";
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, DataLabel
Legend, StackingStepAreaSeries}
from'@syncfusion/ej2-react-charts';
import { stepAreaData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { valueType: 'Double', title: 'Overs' };
const primaryyAxis: AxisModel = { title: 'Runs' };
const stackLabels: Object = { visible: true, fill: 'rgba(0, 123, 255, 0.5)', format: '{value}', angle: 45, rx: 10, ry: 10, margin: { left: 10, right: 10, top: 10, bottom: 10 }, border: { width: 2, color: '#000' }, font: { size: '14px', color: '#fff', weight: 'bold', family: 'Arial', textAlignment: 'Left' } };
const marker: Object = { dataLabel: { visible: true } };
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Annual Temperature Comparison'
stackLabels={stackLabels}
>
<Inject services={[StackingStepAreaSeries, Legend, DataLabel]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StackingStepArea' marker={marker}>
</SeriesDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y1' name='India' type='StackingStepArea' marker={marker}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let stepAreaData = [
{ x: 1, y: 7, y1: 10 }, { x: 2, y: 1, y1: 5 },
{ x: 3, y: 1, y1: 7 }, { x: 4, y: 14, y1: 12 },
{ x: 5, y: 1, y1: 4 }, { x: 6, y: 10, y1: 15 },
{ x: 7, y: 8, y1: 12 }, { x: 8, y: 6, y1: 10 },
{ x: 9, y: 10, y1: 14 }, { x: 10, y: 10, y1: 15 },
{ x: 11, y: 16, y1: 18 }, { x: 12, y: 6, y1: 10 },
{ x: 13, y: 14, y1: 18 }, { x: 14, y: 7, y1: 11 },
{ x: 15, y: 5, y1: 9 }, { x: 16, y: 2, y1: 5 },
{ x: 17, y: 14, y1: 18 }, { x: 18, y: 7, y1: 11 },
{ x: 19, y: 7, y1: 10 }, { x: 20, y: 10, y1: 14 }
];export let stepAreaData: Object[] = [
{ x: 1, y: 7, y1: 10 }, { x: 2, y: 1, y1: 5 },
{ x: 3, y: 1, y1: 7 }, { x: 4, y: 14, y1: 12 },
{ x: 5, y: 1, y1: 4 }, { x: 6, y: 10, y1: 15 },
{ x: 7, y: 8, y1: 12 }, { x: 8, y: 6, y1: 10 },
{ x: 9, y: 10, y1: 14 }, { x: 10, y: 10, y1: 15 },
{ x: 11, y: 16, y1: 18 }, { x: 12, y: 6, y1: 10 },
{ x: 13, y: 14, y1: 18 }, { x: 14, y: 7, y1: 11 },
{ x: 15, y: 5, y1: 9 }, { x: 16, y: 2, y1: 5 },
{ x: 17, y: 14, y1: 18 }, { x: 18, y: 7, y1: 11 },
{ x: 19, y: 7, y1: 10 }, { x: 20, y: 10, y1: 14 }
];Events
Series render
The seriesRender event fires before each series is rendered and lets you modify series properties such as data, fill, or name. For a stacked step area series, use it to vary per-series fill or to swap data sources between renders.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, StackingStepAreaSeries } from '@syncfusion/ej2-react-charts';
import { stepAreaData } from './datasource';
function App() {
const primaryxAxis = { valueType: 'Double', title: 'Overs' };
const primaryyAxis = { title: 'Runs' };
const seriesRender = (args) => {
if (args.series.index === 0) {
args.fill = '#ff4251';
}
else if (args.series.index === 1) {
args.fill = '#4C4C4C';
}
else if (args.series.index === 2) {
args.fill = '#794F1B';
}
};
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Annual Temperature Comparison' seriesRender={seriesRender}>
<Inject services={[StackingStepAreaSeries, Legend]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StackingStepArea' marker={{visible: true}}>
</SeriesDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y1' name='India' type='StackingStepArea'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import * as React from "react";
import * as ReactDOM from "react-dom";
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, StackingStepAreaSeries, ISeriesRenderEventArgs}
from'@syncfusion/ej2-react-charts';
import { stepAreaData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { valueType: 'Double', title: 'Overs' };
const primaryyAxis: AxisModel = { title: 'Runs' };
const seriesRender = (args: ISeriesRenderEventArgs) => {
if (args.series.index === 0) {
args.fill = '#ff4251';
}
else if (args.series.index === 1) {
args.fill = '#4C4C4C';
}
else if (args.series.index === 2) {
args.fill = '#794F1B';
}
};
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Annual Temperature Comparison'
seriesRender={seriesRender}>
<Inject services={[StackingStepAreaSeries, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StackingStepArea' marker={{visible: true}}>
</SeriesDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y1' name='India' type='StackingStepArea'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let stepAreaData = [
{ x: 1, y: 7, y1: 10 }, { x: 2, y: 1, y1: 5 },
{ x: 3, y: 1, y1: 7 }, { x: 4, y: 14, y1: 12 },
{ x: 5, y: 1, y1: 4 }, { x: 6, y: 10, y1: 15 },
{ x: 7, y: 8, y1: 12 }, { x: 8, y: 6, y1: 10 },
{ x: 9, y: 10, y1: 14 }, { x: 10, y: 10, y1: 15 },
{ x: 11, y: 16, y1: 18 }, { x: 12, y: 6, y1: 10 },
{ x: 13, y: 14, y1: 18 }, { x: 14, y: 7, y1: 11 },
{ x: 15, y: 5, y1: 9 }, { x: 16, y: 2, y1: 5 },
{ x: 17, y: 14, y1: 18 }, { x: 18, y: 7, y1: 11 },
{ x: 19, y: 7, y1: 10 }, { x: 20, y: 10, y1: 14 }
];export let stepAreaData: Object[] = [
{ x: 1, y: 7, y1: 10 }, { x: 2, y: 1, y1: 5 },
{ x: 3, y: 1, y1: 7 }, { x: 4, y: 14, y1: 12 },
{ x: 5, y: 1, y1: 4 }, { x: 6, y: 10, y1: 15 },
{ x: 7, y: 8, y1: 12 }, { x: 8, y: 6, y1: 10 },
{ x: 9, y: 10, y1: 14 }, { x: 10, y: 10, y1: 15 },
{ x: 11, y: 16, y1: 18 }, { x: 12, y: 6, y1: 10 },
{ x: 13, y: 14, y1: 18 }, { x: 14, y: 7, y1: 11 },
{ x: 15, y: 5, y1: 9 }, { x: 16, y: 2, y1: 5 },
{ x: 17, y: 14, y1: 18 }, { x: 18, y: 7, y1: 11 },
{ x: 19, y: 7, y1: 10 }, { x: 20, y: 10, y1: 14 }
];Point render
The pointRender event fires before each data point is drawn, letting you customize per-point marker shape, border, or fill. For a stacked step area series, use it to highlight specific points or apply conditional formatting.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, StackingStepAreaSeries } from '@syncfusion/ej2-react-charts';
import { stepAreaData } from './datasource';
function App() {
const primaryxAxis = { valueType: 'Double', title: 'Overs' };
const primaryyAxis = { title: 'Runs' };
const pointRender = (args) => {
if (args.point.index % 2 !== 0) {
args.fill = '#ff6347';
}
else {
args.fill = '#009cb8';
}
};
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Annual Temperature Comparison' pointRender={pointRender}>
<Inject services={[StackingStepAreaSeries, Legend]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StackingStepArea' marker={{visible: true}}>
</SeriesDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y1' name='India' type='StackingStepArea'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>;
}
;
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));import * as React from "react";
import * as ReactDOM from "react-dom";
import { AxisModel, ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, StackingStepAreaSeries, IPointRenderEventArgs}
from'@syncfusion/ej2-react-charts';
import { stepAreaData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { valueType: 'Double', title: 'Overs' };
const primaryyAxis: AxisModel = { title: 'Runs' };
const pointRender = (args: IPointRenderEventArgs) => {
if (args.point.index % 2 !== 0) {
args.fill = '#ff6347';
}
else {
args.fill = '#009cb8';
}
};
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Annual Temperature Comparison'
pointRender={pointRender}>
<Inject services={[StackingStepAreaSeries, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StackingStepArea' marker={{visible: true}}>
</SeriesDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y1' name='India' type='StackingStepArea'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let stepAreaData = [
{ x: 1, y: 7, y1: 10 }, { x: 2, y: 1, y1: 5 },
{ x: 3, y: 1, y1: 7 }, { x: 4, y: 14, y1: 12 },
{ x: 5, y: 1, y1: 4 }, { x: 6, y: 10, y1: 15 },
{ x: 7, y: 8, y1: 12 }, { x: 8, y: 6, y1: 10 },
{ x: 9, y: 10, y1: 14 }, { x: 10, y: 10, y1: 15 },
{ x: 11, y: 16, y1: 18 }, { x: 12, y: 6, y1: 10 },
{ x: 13, y: 14, y1: 18 }, { x: 14, y: 7, y1: 11 },
{ x: 15, y: 5, y1: 9 }, { x: 16, y: 2, y1: 5 },
{ x: 17, y: 14, y1: 18 }, { x: 18, y: 7, y1: 11 },
{ x: 19, y: 7, y1: 10 }, { x: 20, y: 10, y1: 14 }
];export let stepAreaData: Object[] = [
{ x: 1, y: 7, y1: 10 }, { x: 2, y: 1, y1: 5 },
{ x: 3, y: 1, y1: 7 }, { x: 4, y: 14, y1: 12 },
{ x: 5, y: 1, y1: 4 }, { x: 6, y: 10, y1: 15 },
{ x: 7, y: 8, y1: 12 }, { x: 8, y: 6, y1: 10 },
{ x: 9, y: 10, y1: 14 }, { x: 10, y: 10, y1: 15 },
{ x: 11, y: 16, y1: 18 }, { x: 12, y: 6, y1: 10 },
{ x: 13, y: 14, y1: 18 }, { x: 14, y: 7, y1: 11 },
{ x: 15, y: 5, y1: 9 }, { x: 16, y: 2, y1: 5 },
{ x: 17, y: 14, y1: 18 }, { x: 18, y: 7, y1: 11 },
{ x: 19, y: 7, y1: 10 }, { x: 20, y: 10, y1: 14 }
];