Articles in this section
Category / Section

How to get started easily with Syncfusion Angular 11 Linear Gauge?

2 mins read

The Essential JS 2 Linear Gauge is used to visually represent a value within a range of values. This value can vary dynamically during presentation and enabling animation effects. Its feature sets include features such as pointer, axes, ranges, and annotations. This KB article explains how to easily integrate Syncfusion Angular Linear Gauge in Angular 11 Application and how to enable its commonly used features using services.

Prerequisites

 

Before starting, you need the following items to create Angular Linear Gauge in Angular 11 application:

Installation and application Creation

 

  1. Install Angular CLI using the following command.

 

npm install @angular/cli@11.2.3

 

Note:

If you would like to follow and run the application in Angular 4 or Angular 5 or Angular 6, you need to replace the CLI command version number with corresponding Angular version number

 

npm install -g @angular/cli@<CLI VERSION>

 

 

  1. Create an Angular 11 application using Angular CLI.

 

ng new angular11-app

cd angular11-app

 

  1. Serve the Angular 11 using following command.

 

ng serve --open

 

Angular_app

 

Integration of Angular Linear Gauge

 

  1. After running the Angular 11 application successfully, configure the Angular Linear Gauge in this application. Install Angular Linear Gauge and EJ2 package using the following command.

 

npm install @syncfusion/ej2-angular-lineargauge –save

npm install @syncfusion/ej2 --save

 

The --save command instructs the NPM to include the Linear Gauge package inside the dependencies section of the package.json.

  1. Import LinearGaugeModule from the installed package in app/app.module.ts.

 

import { BrowserModule } from '@angular/platform-browser';

import { NgModule } from '@angular/core';

import { LinerGaugeModule } from '@syncfusion/ej2-angular-lineargauge;

import { AppComponent } from './app.component';

 

@NgModule({

     declarations: [

    AppComponent

     ],

     imports: [

  BrowserModule,

  LinearGaugeModule

     ],

     providers: [],

     bootstrap: [AppComponent]

})

export class AppModule { }

  1. Refer to the css file for Angular Linear Gauge in style.css.

 

Import “../node_modules/@syncfusion/ej2/material.css”

 

  1. Add the Angular Linear Gauge component in app.component.html.

 

<ejs-lineargauge></ejs-lineargauge>

 

  1. Now add the axes, major ticks, minor ticks, and pointer in app.component.ts.

 

 

public Axes: Object[] = [{

    pointers: [{

        value: 10,

        height: 15,

        width: 15,

        placement: 'Near',

        offset: -50,

        markerType: 'Triangle'

    }],

    majorTicks: {

        color: '#9E9E9E',

        interval: 10

    },

    minorTicks: {

       color: '#9E9E9E',

        interval: 2

    },

    labelStyle: {

      offset: 48

    }

}];

 

 

  1. After adding the properties, define the Linear Gauge properties in app.component.html.

 

<ejs-lineargauge id='defaultContainer' style='display:block;'  style='display:block;' orientation='Horizontal' [annotations]='Annotation' [axes]='Axes'>

</ejs-lineargauge>

 

  1. Now, serve the application using the following command.

 

ng serve --open

 

After all the files have been compiled successfully, it will serve the site at localhost:4200

The following screenshot illustrates this.

LinearGauge

Summary

 

To know more about the Linear gauge, check our Angular Linear Gauge features from this pageIf you have any queries or require clarifications. Please let us know in comments below. You can also contact us through our Support forum or Direct-Trac. We are happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied