Internationalization in EJ2 TypeScript Circular gauge control

29 Aug 20238 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.

import { CircularGauge } from '@syncfusion/ej2-circulargauge';
import { loadCldr, L10n, setCulture, setCurrencyCode } from '@syncfusion/ej2-base';
setCulture('de');
setCurrencyCode('EUR');
let gauge: CircularGauge = new CircularGauge({
    axes: [{
        labelStyle: {
            position: 'Inside',
            //Label format set 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://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>

<body>
    <div id='loader'>Loading....</div>
    <div id='container'>
        <div id='element'></div>
    </div>
</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.

import { CircularGauge, GaugeTooltip, Legend } from '@syncfusion/ej2-circulargauge';
CircularGauge.Inject(GaugeTooltip, Legend);
let gauge: CircularGauge = new 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://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>

<body>
    <div id='loader'>Loading....</div>
    <div id='container'>
        <div id='element'></div>
    </div>
</body>

</html>