Step area in React Chart component
14 Dec 202424 minutes to read
Step area
To render a step area series in your chart, you need to follow a few steps to configure it correctly. Here’s a concise guide on how to do this:
-
Set the series type: Define the series
type
asStepArea
in your chart configuration. This indicates that the data should be represented as a step area chart, which connects data points with vertical and horizontal lines, creating a step like appearance. -
Inject the StepAreaSeries module: Inject
StepAreaSeries
module into theservices
. This step is essential, as it ensures that the necessary functionalities for rendering step area series are available in your chart.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, StepAreaSeries } 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={[StepAreaSeries, Legend]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StepArea'>
</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, StepAreaSeries}
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={[StepAreaSeries, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StepArea'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let stepAreaData = [
{ x: 1, y: 7 }, { x: 2, y: 1 },
{ x: 3, y: 1 }, { x: 4, y: 14 },
{ x: 5, y: 1 }, { x: 6, y: 10 },
{ x: 7, y: 8 }, { x: 8, y: 6 },
{ x: 9, y: 10 }, { x: 10, y: 10 },
{ x: 11, y: 16 }, { x: 12, y: 6 },
{ x: 13, y: 14 }, { x: 14, y: 7 },
{ x: 15, y: 5 }, { x: 16, y: 2 },
{ x: 17, y: 14 }, { x: 18, y: 7 },
{ x: 19, y: 7 }, { x: 20, y: 10 }
];
export let stepAreaData: Object[] = [
{ x: 1, y: 7 }, { x: 2, y: 1 },
{ x: 3, y: 1 }, { x: 4, y: 14 },
{ x: 5, y: 1 }, { x: 6, y: 10 },
{ x: 7, y: 8 }, { x: 8, y: 6 },
{ x: 9, y: 10 }, { x: 10, y: 10 },
{ x: 11, y: 16 }, { x: 12, y: 6 },
{ x: 13, y: 14 }, { x: 14, y: 7 },
{ x: 15, y: 5 }, { x: 16, y: 2 },
{ x: 17, y: 14 }, { x: 18, y: 7 },
{ x: 19, y: 7 }, { x: 20, y: 10 }
];
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.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, StepAreaSeries } 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={[StepAreaSeries, Legend]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StepArea'>
</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, StepAreaSeries}
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={[StepAreaSeries, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StepArea'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let stepAreaData = [
{ x: 1, y: 7 }, { x: 2, y: 1 },
{ x: 3, y: 1 }, { x: 4, y: 14 },
{ x: 5, y: 1 }, { x: 6, y: 10 },
{ x: 7, y: 8 }, { x: 8, y: 6 },
{ x: 9, y: 10 }, { x: 10, y: 10 },
{ x: 11, y: 16 }, { x: 12, y: 6 },
{ x: 13, y: 14 }, { x: 14, y: 7 },
{ x: 15, y: 5 }, { x: 16, y: 2 },
{ x: 17, y: 14 }, { x: 18, y: 7 },
{ x: 19, y: 7 }, { x: 20, y: 10 }
];
export let stepAreaData: Object[] = [
{ x: 1, y: 7 }, { x: 2, y: 1 },
{ x: 3, y: 1 }, { x: 4, y: 14 },
{ x: 5, y: 1 }, { x: 6, y: 10 },
{ x: 7, y: 8 }, { x: 8, y: 6 },
{ x: 9, y: 10 }, { x: 10, y: 10 },
{ x: 11, y: 16 }, { x: 12, y: 6 },
{ x: 13, y: 14 }, { x: 14, y: 7 },
{ x: 15, y: 5 }, { x: 16, y: 2 },
{ x: 17, y: 14 }, { x: 18, y: 7 },
{ x: 19, y: 7 }, { x: 20, y: 10 }
];
Series customization
The following properties can be used to customize the step area
series.
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, StepAreaSeries } 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={[StepAreaSeries, Legend]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StepArea' fill= 'yellow'>
</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, StepAreaSeries}
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={[StepAreaSeries, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' type='StepArea' fill= 'yellow'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let stepAreaData = [
{ x: 1, y: 7 }, { x: 2, y: 1 },
{ x: 3, y: 1 }, { x: 4, y: 14 },
{ x: 5, y: 1 }, { x: 6, y: 10 },
{ x: 7, y: 8 }, { x: 8, y: 6 },
{ x: 9, y: 10 }, { x: 10, y: 10 },
{ x: 11, y: 16 }, { x: 12, y: 6 },
{ x: 13, y: 14 }, { x: 14, y: 7 },
{ x: 15, y: 5 }, { x: 16, y: 2 },
{ x: 17, y: 14 }, { x: 18, y: 7 },
{ x: 19, y: 7 }, { x: 20, y: 10 }
];
export let stepAreaData: Object[] = [
{ x: 1, y: 7 }, { x: 2, y: 1 },
{ x: 3, y: 1 }, { x: 4, y: 14 },
{ x: 5, y: 1 }, { x: 6, y: 10 },
{ x: 7, y: 8 }, { x: 8, y: 6 },
{ x: 9, y: 10 }, { x: 10, y: 10 },
{ x: 11, y: 16 }, { x: 12, y: 6 },
{ x: 13, y: 14 }, { x: 14, y: 7 },
{ x: 15, y: 5 }, { x: 16, y: 2 },
{ x: 17, y: 14 }, { x: 18, y: 7 },
{ x: 19, y: 7 }, { x: 20, y: 10 }
];
The fill property can be used to apply a gradient color to the step area series. By configuring this property with gradient values, you can create a visually appealing effect in which the color transitions smoothly from one shade to another.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, StepAreaSeries } 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={[StepAreaSeries, Legend]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StepArea' fill='url(#gradient)'>
</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, StepAreaSeries}
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={[StepAreaSeries, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' type='StepArea' fill='url(#gradient)'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let stepAreaData = [
{ x: 1, y: 7 }, { x: 2, y: 1 },
{ x: 3, y: 1 }, { x: 4, y: 14 },
{ x: 5, y: 1 }, { x: 6, y: 10 },
{ x: 7, y: 8 }, { x: 8, y: 6 },
{ x: 9, y: 10 }, { x: 10, y: 10 },
{ x: 11, y: 16 }, { x: 12, y: 6 },
{ x: 13, y: 14 }, { x: 14, y: 7 },
{ x: 15, y: 5 }, { x: 16, y: 2 },
{ x: 17, y: 14 }, { x: 18, y: 7 },
{ x: 19, y: 7 }, { x: 20, y: 10 }
];
export let stepAreaData: Object[] = [
{ x: 1, y: 7 }, { x: 2, y: 1 },
{ x: 3, y: 1 }, { x: 4, y: 14 },
{ x: 5, y: 1 }, { x: 6, y: 10 },
{ x: 7, y: 8 }, { x: 8, y: 6 },
{ x: 9, y: 10 }, { x: 10, y: 10 },
{ x: 11, y: 16 }, { x: 12, y: 6 },
{ x: 13, y: 14 }, { x: 14, y: 7 },
{ x: 15, y: 5 }, { x: 16, y: 2 },
{ x: 17, y: 14 }, { x: 18, y: 7 },
{ x: 19, y: 7 }, { x: 20, y: 10 }
];
Opacity
The opacity property specifies the transparency level of the fill. Adjusting this property allows you to control how opaque or transparent the fill color of the series appears.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, StepAreaSeries } 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={[StepAreaSeries, Legend]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StepArea' 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, StepAreaSeries}
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={[StepAreaSeries, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' type='StepArea' opacity={0.5}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let stepAreaData = [
{ x: 1, y: 7 }, { x: 2, y: 1 },
{ x: 3, y: 1 }, { x: 4, y: 14 },
{ x: 5, y: 1 }, { x: 6, y: 10 },
{ x: 7, y: 8 }, { x: 8, y: 6 },
{ x: 9, y: 10 }, { x: 10, y: 10 },
{ x: 11, y: 16 }, { x: 12, y: 6 },
{ x: 13, y: 14 }, { x: 14, y: 7 },
{ x: 15, y: 5 }, { x: 16, y: 2 },
{ x: 17, y: 14 }, { x: 18, y: 7 },
{ x: 19, y: 7 }, { x: 20, y: 10 }
];
export let stepAreaData: Object[] = [
{ x: 1, y: 7 }, { x: 2, y: 1 },
{ x: 3, y: 1 }, { x: 4, y: 14 },
{ x: 5, y: 1 }, { x: 6, y: 10 },
{ x: 7, y: 8 }, { x: 8, y: 6 },
{ x: 9, y: 10 }, { x: 10, y: 10 },
{ x: 11, y: 16 }, { x: 12, y: 6 },
{ x: 13, y: 14 }, { x: 14, y: 7 },
{ x: 15, y: 5 }, { x: 16, y: 2 },
{ x: 17, y: 14 }, { x: 18, y: 7 },
{ x: 19, y: 7 }, { x: 20, y: 10 }
];
Border
Use the border property to customize the width, color and dasharray of the series border.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Tooltip, StepAreaSeries } from '@syncfusion/ej2-react-charts';
import { stepAreaData } from './datasource';
function App() {
const primaryxAxis = { title: 'Overs' };
const primaryyAxis = { title: 'Runs' };
const tooltip = { enable: true };
const border = { width: 2, color: '#FFA500', dashArray: '5,5' };
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
tooltip={tooltip}
title='England - Run Rate'>
<Inject services={[StepAreaSeries, Tooltip]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' type='StepArea' border={border}>
</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, TooltipSettingsModel, Tooltip, StepAreaSeries } from '@syncfusion/ej2-react-charts';
import { stepAreaData } from './datasource';
function App() {
const primaryxAxis: AxisModel = { title: 'Overs' };
const primaryyAxis: AxisModel = { title: 'Runs' };
const tooltip: TooltipSettingsModel = { enable: true };
const border: BorderModel = { width: 2, color: '#FFA500', dashArray: '5,5' };
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
tooltip={tooltip}
title='England - Run Rate'>
<Inject services={[StepAreaSeries, Tooltip]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' type='StepArea' border={border}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let stepAreaData = [
{ x: 1, y: 7 }, { x: 2, y: 1 },
{ x: 3, y: 1 }, { x: 4, y: 14 },
{ x: 5, y: 1 }, { x: 6, y: 10 },
{ x: 7, y: 8 }, { x: 8, y: 6 },
{ x: 9, y: 10 }, { x: 10, y: 10 },
{ x: 11, y: 16 }, { x: 12, y: 6 },
{ x: 13, y: 14 }, { x: 14, y: 7 },
{ x: 15, y: 5 }, { x: 16, y: 2 },
{ x: 17, y: 14 }, { x: 18, y: 7 },
{ x: 19, y: 7 }, { x: 20, y: 10 }
];
export let stepAreaData: Object[] = [
{ x: 1, y: 7 }, { x: 2, y: 1 },
{ x: 3, y: 1 }, { x: 4, y: 14 },
{ x: 5, y: 1 }, { x: 6, y: 10 },
{ x: 7, y: 8 }, { x: 8, y: 6 },
{ x: 9, y: 10 }, { x: 10, y: 10 },
{ x: 11, y: 16 }, { x: 12, y: 6 },
{ x: 13, y: 14 }, { x: 14, y: 7 },
{ x: 15, y: 5 }, { x: 16, y: 2 },
{ x: 17, y: 14 }, { x: 18, y: 7 },
{ x: 19, y: 7 }, { x: 20, y: 10 }
];
Step
Use the step
property to change the position of the steps in a step area series.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, StepAreaSeries } 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={[StepAreaSeries, Legend]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StepArea' 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, StepAreaSeries}
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={[StepAreaSeries, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' type='StepArea' step='Center'>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let stepAreaData = [
{ x: 1, y: 7 }, { x: 2, y: 1 },
{ x: 3, y: 1 }, { x: 4, y: 14 },
{ x: 5, y: 1 }, { x: 6, y: 10 },
{ x: 7, y: 8 }, { x: 8, y: 6 },
{ x: 9, y: 10 }, { x: 10, y: 10 },
{ x: 11, y: 16 }, { x: 12, y: 6 },
{ x: 13, y: 14 }, { x: 14, y: 7 },
{ x: 15, y: 5 }, { x: 16, y: 2 },
{ x: 17, y: 14 }, { x: 18, y: 7 },
{ x: 19, y: 7 }, { x: 20, y: 10 }
];
export let stepAreaData: Object[] = [
{ x: 1, y: 7 }, { x: 2, y: 1 },
{ x: 3, y: 1 }, { x: 4, y: 14 },
{ x: 5, y: 1 }, { x: 6, y: 10 },
{ x: 7, y: 8 }, { x: 8, y: 6 },
{ x: 9, y: 10 }, { x: 10, y: 10 },
{ x: 11, y: 16 }, { x: 12, y: 6 },
{ x: 13, y: 14 }, { x: 14, y: 7 },
{ x: 15, y: 5 }, { x: 16, y: 2 },
{ x: 17, y: 14 }, { x: 18, y: 7 },
{ x: 19, y: 7 }, { x: 20, y: 10 }
];
No risers
You can eliminate the vertical lines between points by using the ‘noRisers’property in a series. This approach 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, StepAreaSeries}
from'@syncfusion/ej2-react-charts';
import { stepData } from "../datasource";
function App() {
return <ChartComponent id='charts'
primaryXAxis=
primaryYAxis=
title = 'England - Run Rate'>
<Inject services={[StepAreaSeries, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepData} xName='x' yName='y' type='StepArea' name='England' opacity= {0.1} border= 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, StepAreaSeries}
from'@syncfusion/ej2-react-charts';
import { stepData } 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 = 'England - Run Rate'>
<Inject services={[StepAreaSeries, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepData} xName='x' yName='y' type='StepArea' name='England' opacity= {0.1} border= noRisers={true}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let stepData: Object[] = [
{ x: 1, y: 7 }, { x: 2, y: 1 },
{ x: 3, y: 1 }, { x: 4, y: 14 },
{ x: 5, y: 1 }, { x: 6, y: 10 },
{ x: 7, y: 8 }, { x: 8, y: 6 },
{ x: 9, y: 10 }, { x: 10, y: 10 },
{ x: 11, y: 16 }, { x: 12, y: 6 },
{ x: 13, y: 14 }, { x: 14, y: 7 },
{ x: 15, y: 5 }, { x: 16, y: 2 },
{ x: 17, y: 14 }, { x: 18, y: 7 },
{ x: 19, y: 7 }, { x: 20, y: 10 }
];
Empty points
Data points with null
or undefined
values are considered empty. Empty data points are ignored and not plotted on the chart.
Mode
Use the mode
property to define how empty or missing data points are handled in the series. The default mode for empty points is Gap
.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, StepAreaSeries } 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'};
const marker = {visible: true};
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Annual Temperature Comparison'>
<Inject services={[StepAreaSeries, Legend]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StepArea' emptyPointSettings={emptyPoint} 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,
Legend, StepAreaSeries}
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'};
const marker: object = {visible: true};
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Annual Temperature Comparison'>
<Inject services={[StepAreaSeries, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' type='StepArea' emptyPointSettings={emptyPoint} marker={marker}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let stepAreaData = [
{ x: 1, y: 7 }, { x: 2, y: 1 },
{ x: 3, y: 1 }, { x: 4, y: 14 },
{ x: 5, y: null }, { x: 6, y: 10 },
{ x: 7, y: 8 }, { x: 8, y: 6 },
{ x: 9, y: 10 }, { x: 10, y: 10 },
{ x: 11, y: 16 }, { x: 12, y: 6 },
{ x: 13, y: 14 }, { x: 14, y: undefined },
{ x: 15, y: 5 }, { x: 16, y: 2 },
{ x: 17, y: 14 }, { x: 18, y: 7 },
{ x: 19, y: 7 }, { x: 20, y: 10 }
];
export let stepAreaData: Object[] = [
{ x: 1, y: 7 }, { x: 2, y: 1 },
{ x: 3, y: 1 }, { x: 4, y: 14 },
{ x: 5, y: null }, { x: 6, y: 10 },
{ x: 7, y: 8 }, { x: 8, y: 6 },
{ x: 9, y: 10 }, { x: 10, y: 10 },
{ x: 11, y: 16 }, { x: 12, y: 6 },
{ x: 13, y: 14 }, { x: 14, y: undefined },
{ x: 15, y: 5 }, { x: 16, y: 2 },
{ x: 17, y: 14 }, { x: 18, y: 7 },
{ x: 19, y: 7 }, { x: 20, y: 10 }
];
Fill
Use the fill
property to customize the fill color of empty points in the series.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, StepAreaSeries } 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'};
const marker = {visible: true};
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Annual Temperature Comparison'>
<Inject services={[StepAreaSeries, Legend]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StepArea' emptyPointSettings={emptyPoint} 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,
Legend, StepAreaSeries}
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'};
const marker: object = {visible: true};
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Annual Temperature Comparison'>
<Inject services={[StepAreaSeries, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' type='StepArea' emptyPointSettings={emptyPoint} marker={marker}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let stepAreaData = [
{ x: 1, y: 7 }, { x: 2, y: 1 },
{ x: 3, y: 1 }, { x: 4, y: 14 },
{ x: 5, y: null }, { x: 6, y: 10 },
{ x: 7, y: 8 }, { x: 8, y: 6 },
{ x: 9, y: 10 }, { x: 10, y: 10 },
{ x: 11, y: 16 }, { x: 12, y: 6 },
{ x: 13, y: 14 }, { x: 14, y: undefined },
{ x: 15, y: 5 }, { x: 16, y: 2 },
{ x: 17, y: 14 }, { x: 18, y: 7 },
{ x: 19, y: 7 }, { x: 20, y: 10 }
];
export let stepAreaData: Object[] = [
{ x: 1, y: 7 }, { x: 2, y: 1 },
{ x: 3, y: 1 }, { x: 4, y: 14 },
{ x: 5, y: null }, { x: 6, y: 10 },
{ x: 7, y: 8 }, { x: 8, y: 6 },
{ x: 9, y: 10 }, { x: 10, y: 10 },
{ x: 11, y: 16 }, { x: 12, y: 6 },
{ x: 13, y: 14 }, { x: 14, y: undefined },
{ x: 15, y: 5 }, { x: 16, y: 2 },
{ x: 17, y: 14 }, { x: 18, y: 7 },
{ x: 19, y: 7 }, { x: 20, y: 10 }
];
Border
Use the border
property to customize the width and color of the border for empty points.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, StepAreaSeries } 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'};
const marker = {visible: true};
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Annual Temperature Comparison'>
<Inject services={[StepAreaSeries, Legend]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StepArea' emptyPointSettings={emptyPoint} 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,
Legend, StepAreaSeries}
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'};
const marker: object = {visible: true};
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Annual Temperature Comparison'>
<Inject services={[StepAreaSeries, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' type='StepArea' emptyPointSettings={emptyPoint} marker={marker}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let stepAreaData = [
{ x: 1, y: 7 }, { x: 2, y: 1 },
{ x: 3, y: 1 }, { x: 4, y: 14 },
{ x: 5, y: null }, { x: 6, y: 10 },
{ x: 7, y: 8 }, { x: 8, y: 6 },
{ x: 9, y: 10 }, { x: 10, y: 10 },
{ x: 11, y: 16 }, { x: 12, y: 6 },
{ x: 13, y: 14 }, { x: 14, y: undefined },
{ x: 15, y: 5 }, { x: 16, y: 2 },
{ x: 17, y: 14 }, { x: 18, y: 7 },
{ x: 19, y: 7 }, { x: 20, y: 10 }
];
export let stepAreaData: Object[] = [
{ x: 1, y: 7 }, { x: 2, y: 1 },
{ x: 3, y: 1 }, { x: 4, y: 14 },
{ x: 5, y: null }, { x: 6, y: 10 },
{ x: 7, y: 8 }, { x: 8, y: 6 },
{ x: 9, y: 10 }, { x: 10, y: 10 },
{ x: 11, y: 16 }, { x: 12, y: 6 },
{ x: 13, y: 14 }, { x: 14, y: undefined },
{ x: 15, y: 5 }, { x: 16, y: 2 },
{ x: 17, y: 14 }, { x: 18, y: 7 },
{ x: 19, y: 7 }, { x: 20, y: 10 }
];
Events
Series render
The seriesRender
event allows you to customize series properties, such as data, fill, and name, before they are rendered on the chart.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, StepAreaSeries } from '@syncfusion/ej2-react-charts';
import { stepAreaData } from './datasource';
function App() {
const primaryxAxis = { valueType: 'Double', title: 'Overs' };
const primaryyAxis = { title: 'Runs' };
const seriesRender = (args) => {
args.fill = '#ff6347';
};
const marker = {visible: true};
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Annual Temperature Comparison' seriesRender={seriesRender}>
<Inject services={[StepAreaSeries, Legend]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StepArea' 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,
Legend, StepAreaSeries, 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) => {
args.fill = '#ff6347';
};
const marker: object = {visible: true};
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Annual Temperature Comparison'
seriesRender={seriesRender}>
<Inject services={[StepAreaSeries, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' type='StepArea' marker={marker}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let stepAreaData = [
{ x: 1, y: 7 }, { x: 2, y: 1 },
{ x: 3, y: 1 }, { x: 4, y: 14 },
{ x: 5, y: 1 }, { x: 6, y: 10 },
{ x: 7, y: 8 }, { x: 8, y: 6 },
{ x: 9, y: 10 }, { x: 10, y: 10 },
{ x: 11, y: 16 }, { x: 12, y: 6 },
{ x: 13, y: 14 }, { x: 14, y: 7 },
{ x: 15, y: 5 }, { x: 16, y: 2 },
{ x: 17, y: 14 }, { x: 18, y: 7 },
{ x: 19, y: 7 }, { x: 20, y: 10 }
];
export let stepAreaData: Object[] = [
{ x: 1, y: 7 }, { x: 2, y: 1 },
{ x: 3, y: 1 }, { x: 4, y: 14 },
{ x: 5, y: 1 }, { x: 6, y: 10 },
{ x: 7, y: 8 }, { x: 8, y: 6 },
{ x: 9, y: 10 }, { x: 10, y: 10 },
{ x: 11, y: 16 }, { x: 12, y: 6 },
{ x: 13, y: 14 }, { x: 14, y: 7 },
{ x: 15, y: 5 }, { x: 16, y: 2 },
{ x: 17, y: 14 }, { x: 18, y: 7 },
{ x: 19, y: 7 }, { x: 20, y: 10 }
];
Point render
The pointRender
event allows you to customize each data point before it is rendered on the chart.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, StepAreaSeries } 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.y <= 8) {
args.fill = '#ff6347';
}
else {
args.fill = '#009cb8';
}
};
const marker = {visible: true};
return <ChartComponent id='charts' primaryXAxis={primaryxAxis} primaryYAxis={primaryyAxis} title='Annual Temperature Comparison' pointRender={pointRender}>
<Inject services={[StepAreaSeries, Legend]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' name='England' type='StepArea' 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,
Legend, StepAreaSeries, 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.y <= 8) {
args.fill = '#ff6347';
}
else {
args.fill = '#009cb8';
}
};
const marker: object = {visible: true};
return <ChartComponent id='charts'
primaryXAxis={primaryxAxis}
primaryYAxis={primaryyAxis}
title='Annual Temperature Comparison'
pointRender={pointRender}>
<Inject services={[StepAreaSeries, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepAreaData} xName='x' yName='y' type='StepArea' marker={marker}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));
export let stepAreaData = [
{ x: 1, y: 7 }, { x: 2, y: 1 },
{ x: 3, y: 1 }, { x: 4, y: 14 },
{ x: 5, y: 1 }, { x: 6, y: 10 },
{ x: 7, y: 8 }, { x: 8, y: 6 },
{ x: 9, y: 10 }, { x: 10, y: 10 },
{ x: 11, y: 16 }, { x: 12, y: 6 },
{ x: 13, y: 14 }, { x: 14, y: 7 },
{ x: 15, y: 5 }, { x: 16, y: 2 },
{ x: 17, y: 14 }, { x: 18, y: 7 },
{ x: 19, y: 7 }, { x: 20, y: 10 }
];
export let stepAreaData: Object[] = [
{ x: 1, y: 7 }, { x: 2, y: 1 },
{ x: 3, y: 1 }, { x: 4, y: 14 },
{ x: 5, y: 1 }, { x: 6, y: 10 },
{ x: 7, y: 8 }, { x: 8, y: 6 },
{ x: 9, y: 10 }, { x: 10, y: 10 },
{ x: 11, y: 16 }, { x: 12, y: 6 },
{ x: 13, y: 14 }, { x: 14, y: 7 },
{ x: 15, y: 5 }, { x: 16, y: 2 },
{ x: 17, y: 14 }, { x: 18, y: 7 },
{ x: 19, y: 7 }, { x: 20, y: 10 }
];