Step Line Chart in React Chart
17 Aug 202624 minutes to read
Step line
Follow these steps to render a step line series, which connects data points with horizontal and vertical lines to create a staircase effect. Use this for visualizing data that changes at distinct points rather than transitioning continuously.
-
Set the series type: Set the series
typetoStepLinein the series configuration. -
Inject the StepLineSeries module: Add
StepLineSeriesto theservicesarray of theInjectcomponent insideChartComponent. This registers the functionality required to render a step line series.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, Category, Tooltip, DataLabel, StepLineSeries } from '@syncfusion/ej2-react-charts';
import { steplineData } from './datasource';
function App() {
const marker = { visible: true, width: 10, height: 10, border: { width: 2, color: '#F8AB1D' } };
return <ChartComponent id='charts'>
<Inject services={[StepLineSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={steplineData} xName='x' yName='y' width={2} name='India' type='StepLine' 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 { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, StepLineSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { steplineData } from './datasource';
function App() {
const marker = { visible: true, width: 10, height: 10, border: { width: 2, color: '#F8AB1D' } };
return <ChartComponent id='charts'>
<Inject services={[StepLineSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={steplineData} xName='x' yName='y' width={2} name='India' type='StepLine'
marker={marker}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let steplineData = [
{ x: 2006, y: 378 },
{ x: 2007, y: 416 },
{ x: 2008, y: 404 },
{ x: 2009, y: 390 },
{ x: 2010, y: 376 },
{ x: 2011, y: 365 }
];export let steplineData: Object[] = [
{ x: 2006, y: 378 },
{ x: 2007, y: 416 },
{ x: 2008, y: 404 },
{ x: 2009, y: 390 },
{ x: 2010, y: 376 },
{ x: 2011, y: 365 }
];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, Category, Tooltip, DataLabel, StepLineSeries } from '@syncfusion/ej2-react-charts';
import { steplineData } from './datasource';
function App() {
const marker = { visible: true, width: 10, height: 10, border: { width: 2, color: '#F8AB1D' } };
return <ChartComponent id='charts'>
<Inject services={[StepLineSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={steplineData} xName='x' yName='y' width={2} name='India' type='StepLine' 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 { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, StepLineSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { steplineData } from './datasource';
function App() {
const marker = { visible: true, width: 10, height: 10, border: { width: 2, color: '#F8AB1D' } };
return <ChartComponent id='charts'>
<Inject services={[StepLineSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={steplineData} xName='x' yName='y' width={2} name='India' type='StepLine'
marker={marker}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let steplineData = [
{ x: 2006, y: 378 },
{ x: 2007, y: 416 },
{ x: 2008, y: 404 },
{ x: 2009, y: 390 },
{ x: 2010, y: 376 },
{ x: 2011, y: 365 }
];export let steplineData: Object[] = [
{ x: 2006, y: 378 },
{ x: 2007, y: 416 },
{ x: 2008, y: 404 },
{ x: 2009, y: 390 },
{ x: 2010, y: 376 },
{ x: 2011, y: 365 }
];Series customization
Customize the step line 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). |
dashArray |
string | '' |
Pattern of dashes and gaps in the series line (e.g., "5,5"). |
width |
number | 1 |
Stroke width of the series line, in pixels. |
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, Category, Tooltip, DataLabel, StepLineSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const marker = { visible: true, width: 10, height: 10, border: { width: 2, color: '#F8AB1D' } };
return <ChartComponent id='charts'>
<Inject services={[StepLineSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' fill='green' type='StepLine' 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 { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, StepLineSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const marker = { visible: true, width: 10, height: 10, border: { width: 2, color: '#F8AB1D' } };
return <ChartComponent id='charts'>
<Inject services={[StepLineSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' fill='green'
type='StepLine' marker={marker}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let data = [
{ x: 2005, y: 28 },
{ x: 2006, y: 25 },
{ x: 2007, y: 26 },
{ x: 2008, y: 27 },
{ x: 2009, y: 32 },
{ x: 2010, y: 35 },
{ x: 2011, y: 30 }
];export let data: Object[] = [
{ x: 2005, y: 28 },
{ x: 2006, y: 25 },
{ x: 2007, y: 26 },
{ x: 2008, y: 27 },
{ x: 2009, y: 32 },
{ x: 2010, y: 35 },
{ x: 2011, y: 30 }
];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, Category, Tooltip, DataLabel, StepLineSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const marker = { visible: true, width: 10, height: 10, border: { width: 2, color: '#F8AB1D' } };
return <ChartComponent id='charts'>
<Inject services={[StepLineSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' fill='url(#gradient)' type='StepLine' 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 { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, StepLineSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const marker = { visible: true, width: 10, height: 10, border: { width: 2, color: '#F8AB1D' } };
return <ChartComponent id='charts'>
<Inject services={[StepLineSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' fill='url(#gradient)'
type='StepLine' marker={marker}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let data = [
{ x: 2005, y: 28 },
{ x: 2006, y: 25 },
{ x: 2007, y: 26 },
{ x: 2008, y: 27 },
{ x: 2009, y: 32 },
{ x: 2010, y: 35 },
{ x: 2011, y: 30 }
];export let data: Object[] = [
{ x: 2005, y: 28 },
{ x: 2006, y: 25 },
{ x: 2007, y: 26 },
{ x: 2008, y: 27 },
{ x: 2009, y: 32 },
{ x: 2010, y: 35 },
{ x: 2011, y: 30 }
];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, Category, Tooltip, DataLabel, StepLineSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const marker = { visible: true, width: 10, height: 10, border: { width: 2, color: '#F8AB1D' } };
return <ChartComponent id='charts'>
<Inject services={[StepLineSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' opacity={0.5} type='StepLine' 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 { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, StepLineSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const marker = { visible: true, width: 10, height: 10, border: { width: 2, color: '#F8AB1D' } };
return <ChartComponent id='charts'>
<Inject services={[StepLineSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' opacity={0.5}
type='StepLine' marker={marker}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let data = [
{ x: 2005, y: 28 },
{ x: 2006, y: 25 },
{ x: 2007, y: 26 },
{ x: 2008, y: 27 },
{ x: 2009, y: 32 },
{ x: 2010, y: 35 },
{ x: 2011, y: 30 }
];export let data: Object[] = [
{ x: 2005, y: 28 },
{ x: 2006, y: 25 },
{ x: 2007, y: 26 },
{ x: 2008, y: 27 },
{ x: 2009, y: 32 },
{ x: 2010, y: 35 },
{ x: 2011, y: 30 }
];Dash array
The dashArray property determines the pattern of dashes and gaps in the series line.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, Category, Tooltip, DataLabel, StepLineSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const marker = { visible: true, width: 10, height: 10, border: { width: 2, color: '#F8AB1D' } };
return <ChartComponent id='charts'>
<Inject services={[StepLineSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' dashArray='5' type='StepLine' 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 { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, StepLineSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const marker = { visible: true, width: 10, height: 10, border: { width: 2, color: '#F8AB1D' } };
return <ChartComponent id='charts'>
<Inject services={[StepLineSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' dashArray='5'
type='StepLine' marker={marker}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let data = [
{ x: 2005, y: 28 },
{ x: 2006, y: 25 },
{ x: 2007, y: 26 },
{ x: 2008, y: 27 },
{ x: 2009, y: 32 },
{ x: 2010, y: 35 },
{ x: 2011, y: 30 }
];export let data: Object[] = [
{ x: 2005, y: 28 },
{ x: 2006, y: 25 },
{ x: 2007, y: 26 },
{ x: 2008, y: 27 },
{ x: 2009, y: 32 },
{ x: 2010, y: 35 },
{ x: 2011, y: 30 }
];Width
The width property specifies the stroke width of the series line, in pixels.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, Category, Tooltip, DataLabel, StepLineSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const marker = { visible: true, width: 10, height: 10, border: { width: 2, color: '#F8AB1D' } };
return <ChartComponent id='charts'>
<Inject services={[StepLineSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' width={5} type='StepLine' 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 { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, StepLineSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const marker = { visible: true, width: 10, height: 10, border: { width: 2, color: '#F8AB1D' } };
return <ChartComponent id='charts'>
<Inject services={[StepLineSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' width={5}
type='StepLine' marker={marker}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let data = [
{ x: 2005, y: 28 },
{ x: 2006, y: 25 },
{ x: 2007, y: 26 },
{ x: 2008, y: 27 },
{ x: 2009, y: 32 },
{ x: 2010, y: 35 },
{ x: 2011, y: 30 }
];export let data: Object[] = [
{ x: 2005, y: 28 },
{ x: 2006, y: 25 },
{ x: 2007, y: 26 },
{ x: 2008, y: 27 },
{ x: 2009, y: 32 },
{ x: 2010, y: 35 },
{ x: 2011, y: 30 }
];Step
Use the step property to change the position of the steps in a step line series. Valid values are Left, Center, and Right.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, Category, Tooltip, DataLabel, StepLineSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const marker = { visible: true, width: 10, height: 10, border: { width: 2, color: '#F8AB1D' } };
return <ChartComponent id='charts'>
<Inject services={[StepLineSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' step='Center' type='StepLine' 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 { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, StepLineSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const marker = { visible: true, width: 10, height: 10, border: { width: 2, color: '#F8AB1D' } };
return <ChartComponent id='charts'>
<Inject services={[StepLineSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' step='Center'
type='StepLine' marker={marker}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let data = [
{ x: 2005, y: 28 },
{ x: 2006, y: 25 },
{ x: 2007, y: 26 },
{ x: 2008, y: 27 },
{ x: 2009, y: 32 },
{ x: 2010, y: 35 },
{ x: 2011, y: 30 }
];export let data: Object[] = [
{ x: 2005, y: 28 },
{ x: 2006, y: 25 },
{ x: 2007, y: 26 },
{ x: 2008, y: 27 },
{ x: 2009, y: 32 },
{ x: 2010, y: 35 },
{ x: 2011, y: 30 }
];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, StepLineSeries}
from'@syncfusion/ej2-react-charts';
import { stepData } from "../datasource";
function App() {
return <ChartComponent id='charts'
title = 'CO2 - Intensity Analysis'
primaryXAxis={{
minimum: 2004,
maximum: 2013,
interval: 1,
title: 'Year'
}}
primaryYAxis= {{
minimum: 330,
maximum: 450,
interval: 30,
title: 'Intensity (g/kWh)'
}}
>
<Inject services={[StepLineSeries, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepData} type='StepLine' xName='x' noRisers={true} yName='y' width={4}>
</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, StepLineSeries}
from'@syncfusion/ej2-react-charts';
import { stepData } from "../datasource";
function App() {
return <ChartComponent id='charts'
title = 'CO2 - Intensity Analysis'
primaryXAxis={{
minimum: 2004,
maximum: 2013,
interval: 1,
title: 'Year'
}}
primaryYAxis= {{
minimum: 330,
maximum: 450,
interval: 30,
title: 'Intensity (g/kWh)'
}}
>
<Inject services={[StepLineSeries, Legend]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={stepData} type='StepLine' xName='x' noRisers={true} yName='y' width={4}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let stepData: Object[] = [
{ x: 2005, y: 370 },
{ x: 2006, y: 378 },
{ x: 2007, y: 416 },
{ x: 2008, y: 404 },
{ x: 2009, y: 390 },
{ x: 2010, y: 376 },
{ x: 2011, y: 365 },
{ x: 2012, y: 350 }
];Empty points
Data points with null or undefined values are considered empty. By default (mode: 'Gap'), empty points leave a gap in the series; 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, Category, Tooltip, DataLabel, StepLineSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const marker = { visible: true, width: 10, height: 10, border: { width: 2, color: '#F8AB1D' } };
const emptyPoint = { mode: 'Gap' };
return <ChartComponent id='charts'>
<Inject services={[StepLineSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' type='StepLine' 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 { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, StepLineSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const marker = { visible: true, width: 10, height: 10, border: { width: 2, color: '#F8AB1D' } };
const emptyPoint: object = { mode: 'Gap' };
return <ChartComponent id='charts'>
<Inject services={[StepLineSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' emptyPointSettings={emptyPoint}
type='StepLine' marker={marker}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let data = [
{ x: 2005, y: 370 },
{ x: 2006, y: 378 },
{ x: 2007, y: 416 },
{ x: 2008, y: 404 },
{ x: 2009, y: undefined },
{ x: 2010, y: 376 },
{ x: 2011, y: 365 },
{ x: 2012, y: 350 }
];export let data: Object[] = [
{ x: 2005, y: 370 },
{ x: 2006, y: 378 },
{ x: 2007, y: 416 },
{ x: 2008, y: 404 },
{ x: 2009, y: undefined },
{ x: 2010, y: 376 },
{ x: 2011, y: 365 },
{ x: 2012, y: 350 }
];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, Category, Tooltip, DataLabel, StepLineSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const marker = { visible: true, width: 10, height: 10, border: { width: 2, color: '#F8AB1D' } };
const emptyPoint = { mode: 'Average', fill: 'red' };
return <ChartComponent id='charts'>
<Inject services={[StepLineSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' type='StepLine' 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 { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, StepLineSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const marker = { visible: true, width: 10, height: 10, border: { width: 2, color: '#F8AB1D' } };
const emptyPoint: object = { mode: 'Average', fill: 'red' };
return <ChartComponent id='charts'>
<Inject services={[StepLineSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' emptyPointSettings={emptyPoint}
type='StepLine' marker={marker}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let data = [
{ x: 2005, y: 370 },
{ x: 2006, y: 378 },
{ x: 2007, y: 416 },
{ x: 2008, y: 404 },
{ x: 2009, y: undefined },
{ x: 2010, y: 376 },
{ x: 2011, y: 365 },
{ x: 2012, y: 350 }
];export let data: Object[] = [
{ x: 2005, y: 370 },
{ x: 2006, y: 378 },
{ x: 2007, y: 416 },
{ x: 2008, y: 404 },
{ x: 2009, y: undefined },
{ x: 2010, y: 376 },
{ x: 2011, y: 365 },
{ x: 2012, y: 350 }
];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, Category, Tooltip, DataLabel, StepLineSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const marker = { visible: true, width: 10, height: 10, border: { width: 2, color: '#F8AB1D' } };
const emptyPoint = { mode: 'Average', fill: 'red', border: {width: 2, color: 'green'} };
return <ChartComponent id='charts'>
<Inject services={[StepLineSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' type='StepLine' 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 { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, StepLineSeries, Selection}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const marker = { visible: true, width: 10, height: 10, border: { width: 2, color: '#F8AB1D' } };
const emptyPoint: object = { mode: 'Average', fill: 'red', border: {width: 2, color: 'green'} };
return <ChartComponent id='charts'>
<Inject services={[StepLineSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' emptyPointSettings={emptyPoint}
type='StepLine' marker={marker}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let data = [
{ x: 2005, y: 370 },
{ x: 2006, y: 378 },
{ x: 2007, y: 416 },
{ x: 2008, y: 404 },
{ x: 2009, y: undefined },
{ x: 2010, y: 376 },
{ x: 2011, y: 365 },
{ x: 2012, y: 350 }
];export let data: Object[] = [
{ x: 2005, y: 370 },
{ x: 2006, y: 378 },
{ x: 2007, y: 416 },
{ x: 2008, y: 404 },
{ x: 2009, y: undefined },
{ x: 2010, y: 376 },
{ x: 2011, y: 365 },
{ x: 2012, y: 350 }
];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 step line series, use it to vary per-series fill between renders.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, Category, Tooltip, DataLabel, StepLineSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const marker = { visible: true, width: 10, height: 10, border: { width: 2, color: '#F8AB1D' } };
const seriesRender = (args) => {
args.fill = '#ff6347';
};
return <ChartComponent id='charts' seriesRender={seriesRender}>
<Inject services={[StepLineSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' type='StepLine' 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 { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, StepLineSeries, ISeriesRenderEventArgs}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const marker = { visible: true, width: 10, height: 10, border: { width: 2, color: '#F8AB1D' } };
const seriesRender = (args: ISeriesRenderEventArgs) => {
args.fill = '#ff6347';
};
return <ChartComponent id='charts' seriesRender={seriesRender}>
<Inject services={[StepLineSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y'
type='StepLine' marker={marker}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let data = [
{ x: 2005, y: 28 },
{ x: 2006, y: 25 },
{ x: 2007, y: 26 },
{ x: 2008, y: 27 },
{ x: 2009, y: 32 },
{ x: 2010, y: 35 },
{ x: 2011, y: 30 }
];export let data: Object[] = [
{ x: 2005, y: 28 },
{ x: 2006, y: 25 },
{ x: 2007, y: 26 },
{ x: 2008, y: 27 },
{ x: 2009, y: 32 },
{ x: 2010, y: 35 },
{ x: 2011, y: 30 }
];Point render
The pointRender event fires before each data point is drawn, letting you customize per-point marker shape, border, or fill. For a step line series, use it to highlight specific points or apply conditional formatting along the stepped boundary.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, Category, Tooltip, DataLabel, StepLineSeries } from '@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const marker = { visible: true, width: 10, height: 10, border: { width: 2, color: '#F8AB1D' } };
const pointRender = (args) => {
if (args.point.index % 2 !== 0) {
args.fill = '#ff6347';
}
else {
args.fill = '#009cb8';
}
};
return <ChartComponent id='charts' pointRender={pointRender}>
<Inject services={[StepLineSeries, Legend, Tooltip, DataLabel, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y' type='StepLine' 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 { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject,
Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, StepLineSeries, IPointRenderEventArgs}
from'@syncfusion/ej2-react-charts';
import { data } from './datasource';
function App() {
const marker = { visible: true, width: 10, height: 10, border: { width: 2, color: '#F8AB1D' } };
const pointRender = (args: IPointRenderEventArgs) => {
if (args.point.index % 2 !== 0) {
args.fill = '#ff6347';
}
else {
args.fill = '#009cb8';
}
};
return <ChartComponent id='charts' pointRender={pointRender}>
<Inject services={[StepLineSeries, Legend, Tooltip, DataLabel, Category]} />
<SeriesCollectionDirective>
<SeriesDirective dataSource={data} xName='x' yName='y'
type='StepLine' marker={marker}>
</SeriesDirective>
</SeriesCollectionDirective>
</ChartComponent>
};
export default App;
ReactDOM.render(<App />, document.getElementById("charts"));export let data = [
{ x: 2005, y: 28 },
{ x: 2006, y: 25 },
{ x: 2007, y: 26 },
{ x: 2008, y: 27 },
{ x: 2009, y: 32 },
{ x: 2010, y: 35 },
{ x: 2011, y: 30 }
];export let data: Object[] = [
{ x: 2005, y: 28 },
{ x: 2006, y: 25 },
{ x: 2007, y: 26 },
{ x: 2008, y: 27 },
{ x: 2009, y: 32 },
{ x: 2010, y: 35 },
{ x: 2011, y: 30 }
];