Contents
- Types of target bar
- Target bar customization
Having trouble getting help?
Contact Support
Contact Support
Comparative bar in EJ2 TypeScript Bullet chart control
29 Dec 20238 minutes to read
The line marker that runs perpendicular to the orientation of the graph is known as the Comparative Measure and it is used as a target marker to compare against the feature measure value. This is also called as the Target Bar in the Bullet Chart. To display the target bar, the targetField
should be mapped to the appropriate field from the datasource.
import { BulletChart, BulletTooltip } from '@syncfusion/ej2-charts';
BulletChart.Inject(BulletTooltip);
let chart: BulletChart = new BulletChart({
title: 'Sales Rate',
dataSource: [
{ value: 55, target: 75, category: 'Year 1' },
],
animation: { enable: false },
targetField: 'target',
ranges: [ { end: 35 },
{ end: 50 },
{ end: 100 }
],
minimum: 0, maximum: 100, interval: 20
}, '#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>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>
Types of target bar
The shape of the target bar can be customized using the targetTypes
property and it supports Circle, Cross, and Rect shapes. The default type of the target bar is Rect.
import { BulletChart, BulletTooltip } from '@syncfusion/ej2-charts';
BulletChart.Inject(BulletTooltip);
let chart: BulletChart = new BulletChart({
title: 'Sales Rate',
dataSource: [
{ value: 55, target: 75, category: 'Year 1' },
],
animation: { enable: false },
targetField: 'target',
targetTypes: ['Circle'],
ranges: [ { end: 35 },
{ end: 50 },
{ end: 100 }
],
minimum: 0, maximum: 100, interval: 20
}, '#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>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>
Target bar customization
The following properties can be used to customize the target bar. Also, you can bind the color for the target bar from dataSource
for the bullet chart.
-
targetColor
- Specifies the fill color of target bar. -
targetWidth
- Specifies the width of target bar.
import { BulletChart, BulletTooltip } from '@syncfusion/ej2-charts';
BulletChart.Inject(BulletTooltip);
let chart: BulletChart = new BulletChart({
title: 'Sales Rate',
dataSource: [
{ value: 55, target: 75, category: 'Year 1', color: 'red' },
],
animation: { enable: false },
targetField: 'target',
targetColor: 'color',
targetWidth: 15,
ranges: [
{ end: 35 },
{ end: 50 },
{ end: 100 }
],
minimum: 0, maximum: 100, interval: 20
}, '#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>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container'>
<div id='element'></div>
</div>
</body>
</html>