Internationalization in EJ2 JavaScript Circular gauge control

29 Aug 20239 minutes to read

Circular Gauge provides internationalization support for below elements.

  • Axis Labels
  • Tooltip

For more information about number formatter, you can refer internationalization.

Globalization

Globalization is the process of designing and developing a control that works in different cultures/locales.

Internationalization library is used to globalize number in the Circular Gauge using format property in labelStyle.

Numeric Format

In the below example, axis labels are globalized to EUR.

var circulargauge = new ej.circulargauge.CircularGauge({
    axes: [{
        labelStyle: {
            position: 'Inside',
            //Label format as currency.
            format: 'c'
        }
    }]
}, '#element');
<!DOCTYPE html><html lang="en"><head>
    <title>EJ2 Animation</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Typescript UI Controls">
    <meta name="author" content="Syncfusion">
    <link href="index.css" rel="stylesheet">
    <link href="https://cdn.syncfusion.com/ej2/25.1.35/ej2-popups/styles/material.css" rel="stylesheet">
    
    
<script src="https://cdn.syncfusion.com/ej2/25.1.35/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>

<body>
    
    <div id="container">
        <div id="element"></div>
    </div>


<script>
var ele = document.getElementById('container');
if(ele) {
  ele.style.visibility = "visible";
}   
      </script>
<script src="index.js" type="text/javascript"></script>
</body></html>

Right-to-left

Circular Gauge can render its elements from right to left, which improves the user experience for certain language users. To do so, set the enableRtl property to true. When this property is enabled, elements such as the tooltip and legend will be rendered from right to left. Meanwhile, the axis can be rendered from right to left by setting the direction property to AntiClockWise. For more information on axis, click here.

The following example illustrates the right to left rendering of the Circular Gauge.

var circulargauge = new ej.circulargauge.CircularGauge({
    enableRtl:true,
    tooltip: {
        type:['Pointer', 'Range'],
        format:'Pointer : {value} ',
         enable: true,
        enableAnimation: false
    },
    legendSettings:{
        visible:true
    },
    axes: [{
        direction: 'AntiClockWise',
        lineStyle: { width: 10, color: 'transparent' },
        labelStyle: {
            position: 'Inside', useRangeColor: false,
            font: { 
                size: '12px', 
                color: '#424242', 
                fontFamily: 'Roboto', 
                fontStyle: 'Regular' 
            }
        }, 
        majorTicks: { 
            height: 10, 
            offset: 5, 
            color: '#9E9E9E' 
        }, 
        minorTicks: { height: 0 },
        startAngle: 210, 
        endAngle: 150, 
        minimum: 0, 
        maximum: 120, 
        radius: '80%',
        ranges: [{ 
            start: 0, 
            end: 40, 
            color: '#30B32D' 
        }, 
        { 
            start: 40, 
            end: 80, 
            color: '#FFDD00' 
        },
        { 
            start: 80, 
            end: 120, 
            color: '#F03E3E' 
        }],
        pointers: [{
            animation: { enable: false },
            value: 65, 
            radius: '60%', 
            color: '#757575', 
            pointerWidth: 8,
            cap: { 
                radius: 7, 
                color: '#757575' 
            }, 
            needleTail: { 
                length: '18%' 
            }
        }]
    }]
}, '#element');
<!DOCTYPE html><html lang="en"><head>
    <title>EJ2 Animation</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Typescript UI Controls">
    <meta name="author" content="Syncfusion">
    <link href="index.css" rel="stylesheet">
    <link href="https://cdn.syncfusion.com/ej2/25.1.35/ej2-popups/styles/material.css" rel="stylesheet">
    
    
<script src="https://cdn.syncfusion.com/ej2/25.1.35/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>

<body>
    
    <div id="container">
        <div id="element"></div>
    </div>


<script>
var ele = document.getElementById('container');
if(ele) {
  ele.style.visibility = "visible";
}   
      </script>
<script src="index.js" type="text/javascript"></script>
</body></html>