Comparative bar in Angular Bullet chart component
20 Sep 20226 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 { Component } from '@angular/core';
import { AnimationModel } from '@syncfusion/ej2-charts';
@Component({
selector: 'app-container',
template: `<ejs-bulletchart targetField='target' [minimum]='minimum' [maximum]='maximum'
[interval]='interval' [dataSource]='data' [animation]='animation' [tooltip]='tooltip'>
<e-bullet-range-collection>
<e-bullet-range end='35' color='#ebebeb'></e-bullet-range>
<e-bullet-range end='70' color='#d8d8d8'></e-bullet-range>
<e-bullet-range end='100' color='#7f7f7f'></e-bullet-range>
</e-bullet-range-collection>
</ejs-bulletchart>`
})
export class AppComponent {
public minimum: number = 0;
public maximum: number = 100;
public interval: number = 20;
public data: Object[] = [
{ value: 55, target: 75 }
];
public animation: AnimationModel = { enable: false };
public tooltip: Object = { enable: false };
}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { BulletChartModule} from '@syncfusion/ej2-angular-charts';
/**
* Module
*/
@NgModule({
imports: [
BrowserModule, BulletChartModule
],
declarations: [AppComponent],
bootstrap: [AppComponent],
providers: [ ]
})
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);
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 { Component } from '@angular/core';
import { AnimationModel } from '@syncfusion/ej2-charts';
@Component({
selector: 'app-container',
template: `<ejs-bulletchart targetField='target' [minimum]='minimum' [maximum]='maximum'
[interval]='interval' [dataSource]='data' [animation]='animation' [targetTypes]='targetTypes' [tooltip]='tooltip'>
<e-bullet-range-collection>
<e-bullet-range end='35' color='#ebebeb'></e-bullet-range>
<e-bullet-range end='70' color='#d8d8d8'></e-bullet-range>
<e-bullet-range end='100' color='#7f7f7f'></e-bullet-range>
</e-bullet-range-collection>
</ejs-bulletchart>`
})
export class AppComponent {
public minimum: number = 0;
public maximum: number = 100;
public interval: number = 20;
public data: Object[] = [
{ value: 55, target: 75 }
];
public targetTypes: string[] = ['Circle'];
public animation: AnimationModel = { enable: false };
public tooltip: Object = { enable: false };
}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { BulletChartModule} from '@syncfusion/ej2-angular-charts';
/**
* Module
*/
@NgModule({
imports: [
BrowserModule, BulletChartModule
],
declarations: [AppComponent],
bootstrap: [AppComponent],
providers: [ ]
})
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);
Target Bar Customization
The following properties can be used to customize the Target Bar.
-
targetColor
- Specifies the fill color of Target Bar. -
targetWidth
- Specifies the width of Target Bar.
import { Component } from '@angular/core';
import { AnimationModel } from '@syncfusion/ej2-charts';
@Component({
selector: 'app-container',
template: `<ejs-bulletchart targetField='target' [minimum]='minimum' [maximum]='maximum'
[interval]='interval' [dataSource]='data' [animation]='animation' targetColor='red' targetWidth=15 [tooltip]='tooltip'>
<e-bullet-range-collection>
<e-bullet-range end='35' color='#ebebeb'></e-bullet-range>
<e-bullet-range end='70' color='#d8d8d8'></e-bullet-range>
<e-bullet-range end='100' color='#7f7f7f'></e-bullet-range>
</e-bullet-range-collection>
</ejs-bulletchart>`
})
export class AppComponent {
public minimum: number = 0;
public maximum: number = 100;
public interval: number = 20;
public data: Object[] = [
{ value: 55, target: 75 }
];
public animation: AnimationModel = { enable: false };
public tooltip: Object = { enable: false };
}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { BulletChartModule} from '@syncfusion/ej2-angular-charts';
/**
* Module
*/
@NgModule({
imports: [
BrowserModule, BulletChartModule
],
declarations: [AppComponent],
bootstrap: [AppComponent],
providers: [ ]
})
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);