Gauge user interaction in React Circular gauge component
24 Jan 202321 minutes to read
Tooltip for pointers
Circular gauge will displays the pointer details through tooltip, when the mouse is moved over the pointer.
Tooltip for ranges
Circular gauge displays the information about the ranges through tooltip when hovering the mouse over the ranges. You can enable this feature by setting the type property of tooltip to ‘Range’ in the array collection.
Tooltip customization for ranges
To customize the range tooltip, use the rangeSettings
property in tooltip. The following options are available to customize the range tooltip:
-
fill - Specifies the range tooltip fill color.
-
textStyle - Specifies the range tooltip text style.
-
format - Specifies the range content format.
-
template - Specifies the custom template for tooltip.
-
enableAnimation - Animates as it moves from one point to another.
-
border - Specifies the tooltip border.
-
showMouseAtPosition - Displays the position of the tooltip on the cursor position.
Tooltip for annotation
Circular gauge displays the information about the annotations through tooltip when hovering the mouse over the annotation. You can enable this feature by setting the type property of tooltip to ‘Annotation’ in the array collection.
Tooltip customization for annotation
To customize the annotation tooltip, use the annotationSettings
property in tooltip. The following options are available to customize the annotation tooltip:
-
fill - Specifies the annotation tooltip fill color.
-
textStyle - Specifies the annotation tooltip text style.
-
format - Specifies the annotation content format.
-
template - Specifies the tooltip content with custom template.
-
enableAnimation - Animates as it moves from one point to another.
-
border - Specifies the tooltip border.
The following code example shows the tooltip for the pointers, ranges and annotation.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { CircularGaugeComponent, RangesDirective, Annotations, AnnotationsDirective, AnnotationDirective, RangeDirective, AxesDirective, AxisDirective, PointersDirective, PointerDirective, Inject, GaugeTooltip } from '@syncfusion/ej2-react-circulargauge';
export function App() {
return ( <CircularGaugeComponent tooltip={{
type:['Pointer', 'Range', 'Annotation'],
enable: true,
enableAnimation: false,
annotationSettings: { template:'<div>CircularGauge</div>' },
rangeSettings: { fill:'red' }
}}
>
<Inject services={[ GaugeTooltip, Annotations ]}/>
<AxesDirective>
<AxisDirective startAngle={240} endAngle={120} radius='90%' minimum={0} maximum={120}
majorTicks={{
color: 'white', offset: -5, height: 12
}}
lineStyle={{ width: 0 }}
minorTicks={{
width: 0
}} labelStyle={{
useRangeColor: true, font: { color: '#424242', size: '13px', fontFamily: 'Roboto' }
}}>
<AnnotationsDirective>
<AnnotationDirective content='Circular Gauge' angle= {180} zIndex= '1' radius = '40%'/>
</AnnotationsDirective>
<PointersDirective>
<PointerDirective value={70} radius='60%'
cap={{
radius: 10, border: { color: '#33BCBD', width: 5 }
}}
animation={{
enable: true, duration: 1500
}} color='#33BCBD' />
</PointersDirective>
<RangesDirective>
<RangeDirective start={0} end={50} radius='102%' color='#3A5DC8' startWidth={10} endWidth={10} />
<RangeDirective start={50} end={120} radius='102%' color='#33BCBD' startWidth={10} endWidth={10} />
</RangesDirective>
</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, RangesDirective, Annotations, AnnotationsDirective, AnnotationDirective, RangeDirective, AxesDirective, AxisDirective, PointersDirective, PointerDirective, Inject, GaugeTooltip } from '@syncfusion/ej2-react-circulargauge';
export function App() {
return ( <CircularGaugeComponent tooltip={{
type:['Pointer', 'Range', 'Annotation'],
enable: true,
enableAnimation: false,
annotationSettings: { template:'<div>CircularGauge</div>' },
rangeSettings: { fill:'red' }
}}
>
<Inject services={[ GaugeTooltip, Annotations ]}/>
<AxesDirective>
<AxisDirective startAngle={240} endAngle={120} radius='90%' minimum={0} maximum={120}
majorTicks={{
color: 'white', offset: -5, height: 12
}}
lineStyle={{ width: 0 }}
minorTicks={{
width: 0
}} labelStyle={{
useRangeColor: true, font: { color: '#424242', size: '13px', fontFamily: 'Roboto' }
}}>
<AnnotationsDirective>
<AnnotationDirective content='Circular Gauge' angle= {180} zIndex= '1' radius = '40%'/>
</AnnotationsDirective>
<PointersDirective>
<PointerDirective value={70} radius='60%'
cap={{
radius: 10, border: { color: '#33BCBD', width: 5 }
}}
animation={{
enable: true, duration: 1500
}} color='#33BCBD' />
</PointersDirective>
<RangesDirective>
<RangeDirective start={0} end={50} radius='102%' color='#3A5DC8' startWidth={10} endWidth={10} />
<RangeDirective start={50} end={120} radius='102%' color='#33BCBD' startWidth={10} endWidth={10} />
</RangesDirective>
</AxisDirective>
</AxesDirective>
</CircularGaugeComponent>);
}
const root = ReactDOM.createRoot(document.getElementById('container'));
root.render(<App />);
Template
Any HTML elements can be displayed in the tooltip by using the template
property of the tooltip.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { CircularGaugeComponent, AxesDirective, AxisDirective, PointersDirective, PointerDirective, Inject, GaugeTooltip } from '@syncfusion/ej2-react-circulargauge';
export function App() {
return(
<CircularGaugeComponent tooltip= {{
enable: true,
template: '<div id="templateWrap"><div style="float: right; padding-left:10px; line-height:30px;"><span>Pointer : ${value}</span></div></div>'
}}>
<Inject services={[ GaugeTooltip ]}/>
<AxesDirective>
<AxisDirective>
<PointersDirective>
<PointerDirective value = {70}></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, Inject, GaugeTooltip } from '@syncfusion/ej2-react-circulargauge';
export function App() {
return(
<CircularGaugeComponent tooltip= {{
enable: true,
template: '<div id="templateWrap"><div style="float: right; padding-left:10px; line-height:30px;"><span>Pointer : ${value}</span></div></div>'
}}>
<Inject services={[ GaugeTooltip ]}/>
<AxesDirective>
<AxisDirective>
<PointersDirective>
<PointerDirective value = {70}></PointerDirective>
</PointersDirective>
</AxisDirective>
</AxesDirective>
</CircularGaugeComponent>);
}
const root = ReactDOM.createRoot(document.getElementById('container'));
root.render(<App />);
Pointer Drag
Pointers can be dragged over the axis value. This can be achieved by clicking and dragging the pointer. To enable or disable the pointer drag, you can use enablePointerDrag
property.
import * as React from "react";
import * as ReactDOM from "react-dom";
import { CircularGaugeComponent, AxesDirective, AxisDirective, PointersDirective, PointerDirective, Inject, GaugeTooltip } from '@syncfusion/ej2-react-circulargauge';
export function App() {
return(
<CircularGaugeComponent enablePointerDrag = {true} tooltip= {{
enable: true,
template: '<div id="templateWrap"><div style="float: right; padding-left:10px; line-height:30px;"><span>Pointer : ${value}</span></div></div>'
}}>
<Inject services={[ GaugeTooltip ]}/>
<AxesDirective>
<AxisDirective>
<PointersDirective>
<PointerDirective value = {70}></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, Inject, GaugeTooltip } from '@syncfusion/ej2-react-circulargauge';
export function App() {
return(
<CircularGaugeComponent enablePointerDrag = {true} tooltip= {{
enable: true,
template: '<div id="templateWrap"><div style="float: right; padding-left:10px; line-height:30px;"><span>Pointer : ${value}</span></div></div>'
}}>
<Inject services={[ GaugeTooltip ]}/>
<AxesDirective>
<AxisDirective>
<PointersDirective>
<PointerDirective value = {70}></PointerDirective>
</PointersDirective>
</AxisDirective>
</AxesDirective>
</CircularGaugeComponent>);
}
const root = ReactDOM.createRoot(document.getElementById('container'));
root.render(<App />);