This section explains you the steps required to create a simple circular gauge and demonstrate the basic usage of circular gauge control.
Following is the list of minimum dependencies required to use the Circular Gauge.
|-- @syncfusion/ej2-react-circulargauge
|-- @syncfusion/ej2-react-base
|-- @syncfusion/ej2-circulargauge
|-- @syncfusion/ej2-base
|-- @syncfusion/ej2-svg-base
|-- @syncfusion/ej2-paf-export
To get started with the React application, create-react-app can be used to setup the application. To install create-react-app run the following command.
npm install -g create-react-app
To create basic React application, run the following command.
create-react-app quickstart
Now, the application is created in the quickstart folder. Run the following command one-by-one to navigate to the quickstart folder, and install the required npm packages.
cd quickstart
npm install
In the quickstart application, the Syncfusion component is added in the JavaScript file.
To create React application with TypeScript, use the following command.
create-react-app quickstart --template typescript
Now, the application is created in the quickstart folder. Run the following command one-by-one to navigate to the quickstart folder, and install the required npm packages.
cd quickstart
npm install
All the available Essential JS 2 packages are published in npmjs.com public registry. To install Circular Gauge package, use the following command.
npm install @syncfusion/ej2-react-circulargauge --save
Now, the Circular Gauge component can be added in the application. To initialize the Circular Gauge control in the React application, import the Circular Gauge control in the src/App.js or src/App.tsx as per the application. Please use the below code to include the Circular Gauge component in the application.
import React from 'react';
import * as ReactDOM from "react-dom";
import { CircularGaugeComponent } from '@syncfusion/ej2-react-circulargauge';
export function App() {
return (<CircularGaugeComponent id="circulargauge"></CircularGaugeComponent>);
}
const root = ReactDOM.createRoot(document.getElementById('container'));
root.render(<App />);
The Circular Gauge control is now included in the quickstart application. Use the following command to run the application.
npm start
The below example shows the basic Circular Gauge.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { CircularGaugeComponent } from '@syncfusion/ej2-react-circulargauge';
export function App() {
return (<CircularGaugeComponent></CircularGaugeComponent>);
}
const root = ReactDOM.createRoot(document.getElementById('container'));
root.render(<App />);
import * as React from "react";
import * as ReactDOM from "react-dom";
import { CircularGaugeComponent } from '@syncfusion/ej2-react-circulargauge';
export function App(){
return(<CircularGaugeComponent ></CircularGaugeComponent>);
}
const root = ReactDOM.createRoot(document.getElementById('container'));
root.render(<App />);
You can change the pointer value in the above sample using value
property in pointers
.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { CircularGaugeComponent, AxesDirective, AxisDirective, PointersDirective, PointerDirective } from '@syncfusion/ej2-react-circulargauge';
export function App() {
return (<CircularGaugeComponent>
<AxesDirective>
<AxisDirective>
<PointersDirective>
<PointerDirective value={35}></PointerDirective>
</PointersDirective>
</AxisDirective>
</AxesDirective>
</CircularGaugeComponent>);
}
const root = ReactDOM.createRoot(document.getElementById('container'));
root.render(<App />);
import * as React from "react";
import * as ReactDOM from "react-dom";
import { CircularGaugeComponent, AxesDirective, AxisDirective, PointersDirective, PointerDirective } from '@syncfusion/ej2-react-circulargauge';
export function App() {
return(
<CircularGaugeComponent >
<AxesDirective>
<AxisDirective>
<PointersDirective>
<PointerDirective value={35}></PointerDirective>
</PointersDirective>
</AxisDirective>
</AxesDirective>
</CircularGaugeComponent>);
}
const root = ReactDOM.createRoot(document.getElementById('container'));
root.render(<App />);