Internationalization in Angular Circular Gauge component
27 Apr 20248 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 component that works in different cultures/locales.
Internationalization library is used to globalize number in Circular Gauge using format property in labelStyle.
Numeric Format
In the below example, axis labels are globalized to EUR.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { CircularGaugeModule } from '@syncfusion/ej2-angular-circulargauge'
import { loadCldr, L10n, setCulture, setCurrencyCode } from '@syncfusion/ej2-base'
import { Component, OnInit } from '@angular/core';
@Component({
imports: [
CircularGaugeModule
],
standalone: true,
selector: 'app-container',
template:
`<ejs-circulargauge id="circular-container">
<e-axes>
<e-axis [labelStyle]="labelStyle"></e-axis>
</e-axes>
</ejs-circulargauge>`
})
export class AppComponent implements OnInit {
public labelStyle?: Object;
ngOnInit(): void {
// Initialize objects.
this.labelStyle= {
// Label format set as currency.
format: 'c'
};
}
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
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 { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { CircularGaugeModule } from '@syncfusion/ej2-angular-circulargauge'
import { LegendService, GaugeTooltipService } from '@syncfusion/ej2-angular-circulargauge'
import { Component, OnInit } from '@angular/core';
@Component({
imports: [
CircularGaugeModule
],
providers: [LegendService, GaugeTooltipService],
standalone: true,
selector: 'app-container',
template:
`<ejs-circulargauge id="circular-container" [enableRtl]="true" [tooltip]="tooltip" [legendSettings]='legendSettings'>
<e-axes>
<e-axis direction='AntiClockWise' startAngle=210 endAngle=150 minimum=0 maximum=120 radius='80%' [majorTicks]="majorTicks" [minorTicks]="minorTicks" [lineStyle]="lineStyle" [labelStyle]="labelStyle">
<e-pointers>
<e-pointer value=65 radius='60%' color='#757575' pointerWidth=8 [cap]="cap" [needleTail]="needleTail">
</e-pointer>
</e-pointers>
<e-ranges>
<e-range start=0 end=40 color='#30B32D'></e-range>
<e-range start=40 end=80 color='#FFDD00'></e-range>
<e-range start=80 end=120 color='#F03E3E'></e-range>
</e-ranges>
</e-axis>
</e-axes>
</ejs-circulargauge>`
})
export class AppComponent implements OnInit {
public labelStyle?: Object;
public tooltip?: Object;
public legendSettings?: object;
public lineStyle?: Object;
public majorTicks?: Object;
public minorTicks?: Object;
public cap?: Object;
public needleTail?: Object;
ngOnInit(): void {
// Initialize objects.
this.cap= {
radius: 7,
color: '#757575'
};
this.needleTail= {
length: '18%'
};
this.lineStyle = {
width: 10,
color: 'transparent'
};
this.majorTicks = {
height: 10,
offset: 5,
color: '#9E9E9E'
};
this.minorTicks = {
height: 0
};
this.labelStyle= {
position: 'Inside', useRangeColor: false,
font: {
size: '12px',
color: '#424242',
fontFamily: 'Roboto',
fontStyle: 'Regular'
}
};
this.tooltip = {
type:['Pointer', 'Range'],
format:'Pointer : {value} ',
enable: true,
enableAnimation: false
};
this.legendSettings= {
visible: true
};
}
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));