7 May 20256 minutes to read
This section briefly explains how to create a simpleCircular gauge component, and configure its available functionalities in TypeScript using Essential® JS 2quickstart seed repository.
This application is integrated with the
webpack.config.js
configuration and uses the latest version of thewebpack-cli. It requires nodev14.15.0
or higher. For more information about webpack and its features, refer to thewebpack documentation.
Below is the list of minimum dependencies required to use the circular gauge.
|--@syncfusion/ej2-circulargauge|--@syncfusion/ej2-base|--@syncfusion/ej2-svg-base|--@syncfusion/ej2-pdf-export
Open the command prompt from the required directory, and run the following command to clone the Syncfusion® JavaScript (Essential® JS 2) quickstart project fromGitHub.
git clone https://github.com/SyncfusionExamples/ej2-quickstart-webpack- ej2-quickstart
After cloning the application in theej2-quickstart
folder, run the following command line to navigate to theej2-quickstart
folder.
cd ej2-quickstart
Syncfusion® JavaScript (Essential® JS 2) packages are available on thenpmjs.com public registry. You can install all Syncfusion® JavaScript (Essential® JS 2) controls in a single@syncfusion/ej2 package or individual packages for each control.
The quickstart application is preconfigured with the dependent@syncfusion/ej2 package in the~/package.json
file. Use the following command to install the dependent npm packages from the command prompt.
npm install
The Essential® JS2 Circular Gauge control can be added to the application. To get started, add the Circular Gauge control to theapp.ts andindex.html files using the following code.
Add an HTML div element to act as the Circular Gauge element in theindex.html file using the following code.
<!DOCTYPE html><htmllang="en"><head><title>EJ2 Circular Gauge</title><metacharset="utf-8"/><metaname="viewport"content="width=device-width, initial-scale=1.0"/><metaname="description"content="Typescript UI Controls"/><metaname="author"content="Syncfusion"/></head><body><!--container which is going to render the Circular gauge--><divid='container'></div></body></html>
Import the Circular Gauge control in theapp.ts to initialize the Circular Gauge and append the Circular Gauge instance to the#container
.
import{CircularGauge}from'@syncfusion/ej2-circulargauge';// initialize CircularGauge componentletgauge:CircularGauge=newCircularGauge();// render initialized CircularGaugegauge.appendTo('#container');
The quickstart project is configured to compile and run the application in the browser. Use the following command to run the application.
npm start
The below example shows a basic Circular Gauge control.
import{CircularGauge}from'@syncfusion/ej2-circulargauge';letgauge:CircularGauge=newCircularGauge();gauge.appendTo('#element');
<!DOCTYPE html><htmllang="en"><head><title>EJ2 Animation</title><metacharset="utf-8"/><metaname="viewport"content="width=device-width, initial-scale=1.0"/><metaname="description"content="Typescript UI Controls"/><metaname="author"content="Syncfusion"/><linkhref="index.css"rel="stylesheet"/><linkhref="https://cdn.syncfusion.com/ej2/30.1.37/ej2-popups/styles/material.css"rel="stylesheet"/><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script><scriptsrc="systemjs.config.js"></script><scriptsrc="https://cdn.syncfusion.com/ej2/syncfusion-helper.js"type="text/javascript"></script></head><body><divid='loader'>Loading....</div><divid='container'><divid='element'></div></div></body></html>
You can change the pointer value in the above sample usingvalue
property inpointers
.
import{CircularGauge}from'@syncfusion/ej2-circulargauge';letgauge:CircularGauge=newCircularGauge({axes:[{pointers:[{value:35}],}]},'#element');
<!DOCTYPE html><htmllang="en"><head><title>EJ2 Animation</title><metacharset="utf-8"/><metaname="viewport"content="width=device-width, initial-scale=1.0"/><metaname="description"content="Typescript UI Controls"/><metaname="author"content="Syncfusion"/><linkhref="index.css"rel="stylesheet"/><linkhref="https://cdn.syncfusion.com/ej2/30.1.37/ej2-popups/styles/material.css"rel="stylesheet"/><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script><scriptsrc="systemjs.config.js"></script><scriptsrc="https://cdn.syncfusion.com/ej2/syncfusion-helper.js"type="text/javascript"></script></head><body><divid='loader'>Loading....</div><divid='container'><divid='element'></div></div></body></html>