Stacked step area Chart in React Chart component
7 Feb 20247 minutes to read
Stacked step area
To render the Stacked step area series, use the series type
as a StackingStepArea
and inject the StackingStepAreaSeries
module using the Chart.Inject(StackingStepAreaSeries)
method.
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.ts';
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.ts';
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"));
Series customization
The following properties can be used to customize the stacked step area
series.
- fill – Specifies the color of the area series.
- opacity – Specifies the opacity of fill.
- dashArray – Specifies the dashes of series.
- step – Specifies the position of the step for 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.ts';
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" dashArray="5" border= opacity={0.7} step='Center'>
</SeriesDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y1' name='India' type='StackingStepArea' fill="green" dashArray="5" border= opacity={0.7} 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.ts';
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' dashArray="5" border= opacity={0.7} step='Center'>
</SeriesDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y1' name='India' type='StackingStepArea' fill='green' dashArray="5" border= opacity={0.7} step='Center'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));