Strip lines in TypeScript Charts
Strip lines highlight ranges, thresholds, dates, or categories in the Chart area. Add horizontal strip lines to a vertical axis and vertical strip lines to a horizontal axis. To use strip line features, inject the StripLine module using Chart.Inject(StripLine) method.
Horizontal strip lines
Add entries to the axis stripLines collection on the vertical axis to render horizontal strip lines. Set visible to true for each strip line. The default value is false.
Multiple strip lines can be added to the same axis to highlight different value ranges.
import { Chart, Category, ColumnSeries, LineSeries, DataLabel, StripLine } from '@syncfusion/ej2-charts';
Chart.Inject(ColumnSeries, Category, LineSeries, DataLabel, StripLine);
let chartData: Object[] = [{x: 1, y: 20},{x: 2, y: 22},{x: 3, y: 0},{x: 4, y: 12},{x: 5, y: 5},
{x: 6, y: 15},{x: 7, y: 6},{x: 8, y: 12},{x: 9, y: 20},{x: 10, y: 7}];
let chart: Chart = new Chart({
primaryYAxis: {
stripLines:[
{ start: 15, end: 22 },
{ start: 8, end: 15 },
{ start: 0, end: 8 }]
},
series:[{
dataSource: chartData,
xName: 'x', yName: 'y', type: 'Column'
}],
}, '#element');<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>Vertical strip lines
Add entries to the axis stripLines collection on the horizontal axis to render vertical strip lines. Set visible to true for each strip line.
Vertical strip lines can highlight categories, dates, milestones, or intervals along the horizontal axis.
import { Chart, Category, ColumnSeries, LineSeries, DataLabel, StripLine } from '@syncfusion/ej2-charts';
import { stripData } from './datasource.ts';
Chart.Inject(ColumnSeries, Category, LineSeries, DataLabel, StripLine);
let chart: Chart = new Chart({
primaryXAxis: {
stripLines:[
{start: 0, end: 5 },
{start: 5, end: 10 },
]
},
series:[{
dataSource: stripData,
xName: 'x', yName: 'y',
type: 'Column'}],
},'#element');<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>Customize a strip line
Range configuration
Use the following properties to define the strip-line range:
-
start: Specifies the starting axis value. -
end: Specifies the ending axis value. -
startFromAxis: Starts the strip line from the axis origin when set totrue. The default value isfalse. -
size: Specifies the strip-line width or height when the range is defined from the axis origin. -
sizeType: Specifies howsizeis interpreted. The default value isAuto.
Appearance and z-order
Use the following properties to customize strip-line appearance:
-
color: Specifies the strip-line color. -
opacity: Specifies transparency from0to1. -
border: Configures border color and width. -
dashArray: Specifies a dashed pattern. -
imageUrl: Displays an image as the strip-line background. -
zIndex: Set toBehindto render the strip line behind the series orOverto render it over the series.
import {
Chart,
ColumnSeries,
StripLine
} from '@syncfusion/ej2-charts';
Chart.Inject(ColumnSeries, StripLine);
let chart: Chart = new Chart({
primaryXAxis: {
title: 'Overs',
minimum: 0,
maximum: 10,
interval: 1,
stripLines: [{
visible: true,
startFromAxis: true,
size: 4,
sizeType: 'Auto',
color: '#4CAF50',
opacity: 0.3,
border: {
color: '#1B5E20',
width: 2
},
dashArray: '5,3',
zIndex: 'Behind',
text: 'Powerplay',
textStyle: {
color: '#1B5E20',
size: '14px',
fontFamily: 'Segoe UI',
fontWeight: '600'
},
horizontalAlignment: 'Middle',
verticalAlignment: 'Middle',
rotation: 0
}]
},
primaryYAxis: {
title: 'Runs',
minimum: 0,
maximum: 40,
interval: 10
},
series: [{
dataSource: [
{ x: 1, y: 20 },
{ x: 2, y: 22 },
{ x: 3, y: 0 },
{ x: 4, y: 12 },
{ x: 5, y: 5 },
{ x: 6, y: 15 },
{ x: 7, y: 6 },
{ x: 8, y: 12 },
{ x: 9, y: 34 },
{ x: 10, y: 7 }
],
xName: 'x',
yName: 'y',
type: 'Column',
marker: {
dataLabel: {
visible: true
}
}
}],
title: 'India vs Australia, First Match'
}, '#element');
chart.appendTo('#element');<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>Customize strip-line text
Use text to display a label within the strip line.
-
textStyle: Customizes the label font. -
rotation: Rotates the label by the specified angle. -
horizontalAlignment: Aligns the label horizontally usingStart,Middle, orEnd. The default value isMiddle. -
verticalAlignment: Aligns the label vertically using the supported axis-label positions. The default value isMiddle.
import { Chart, ColumnSeries, LineSeries, StripLine } from '@syncfusion/ej2-charts';
import { stripData } from './datasource.ts';
Chart.Inject(ColumnSeries, LineSeries, StripLine);
let chart: Chart = new Chart({
primaryXAxis: {
stripLines:[
{ startFromAxis: true, size: 4, zIndex: 'Behind', opacity: 0.5, text: 'Good', verticalAlignment: 'Middle', horizontalAlignment: 'Middle', rotation: 90, textStyle: { size: '15px' }},
{ start: 5, end: 8, verticalAlignment: 'Start', horizontalAlignment: 'End', rotation: 45, text: 'Poor'}
]
},
series:[{
dataSource: stripData,
xName: 'x', yName: 'y',
type: 'Column',
}],
},'#element');<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Animation</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>Troubleshooting
- If a strip line is not displayed, verify that
visibleis set totrue. - If a strip line is outside the Chart area, verify that
start,end, orsizefalls within the corresponding axis range. - If a strip line covers the series unexpectedly, set
zIndextoBehind. - If an origin-based strip line is not rendered as expected, use
startFromAxiswith a validsizeandsizeType. - If a segmented strip line is not displayed, verify that
segmentAxisNamematches an existing axis name and that the segment range is valid.