How can I help you?
Localization in Angular Chart component
13 Mar 20265 minutes to read
Localization enables the chart component to adapt its text content to different languages and regions. The chart’s default text content, such as zoom toolbar labels and other static text elements, can be localized by providing locale-specific translation objects.
| Locale key | Text to display |
| Zoom | Zoom |
| ZoomIn | ZoomIn |
| ZoomOut | ZoomOut |
| Reset | Reset |
| Pan | Pan |
| ResetZoom | Reset Zoom |
To load translations in an application, use the L10n.load() function.
For more information about localization, see the localization guide: localization
import { ChartModule } from '@syncfusion/ej2-angular-charts'
import { DateTimeService, AreaSeriesService } from '@syncfusion/ej2-angular-charts'
import { LegendService, ZoomService } from '@syncfusion/ej2-angular-charts'
import { Component, OnInit } from '@angular/core';
import { L10n } from '@syncfusion/ej2-base';
L10n.load({
'ar-AR': {
'chart': {
ZoomIn: 'تكبير',
ZoomOut: 'تصغير',
Zoom: 'زوم',
Pan: 'مقلاة',
Reset: 'إعادة تعيين',
},
}
});
@Component({
imports: [
ChartModule
],
providers: [ DateTimeService, AreaSeriesService, LegendService, ZoomService],
standalone: true,
selector: 'app-container',
template: `<ejs-chart id="chart-container" [primaryXAxis]='primaryXAxis' [primaryYAxis]='primaryYAxis' [title]='title' locale='ar-AR' [zoomSettings]='zoom'>
<e-series-collection>
<e-series [dataSource]='chartData' type='Area' xName='x' yName='y' name='Product X' ></e-series>
<e-series [dataSource]='chartData' type='Area' xName='x' yName='y1' name='Product Y'></e-series>
</e-series-collection>
</ejs-chart>`
})
export class AppComponent implements OnInit {
public primaryXAxis?: Object;
public chartData?: Object[];
public title?: string;
public marker?: Object;
public primaryYAxis?: Object;
public zoom?: Object;
ngOnInit(): void {
this.chartData = [
{ x: 1900, y: 4, y1: 2.6, y2: 2.8 }, { x: 1920, y: 3.0, y1: 2.8, y2: 2.5 },
{ x: 1940, y: 3.8, y1: 2.6, y2: 2.8 }, { x: 1960, y: 3.4, y1: 3, y2: 3.2 },
{ x: 1980, y: 3.2, y1: 3.6, y2: 2.9 }, { x: 2000, y: 3.9, y1: 3, y2: 2 }
];
this.primaryXAxis = {
title: 'Year',
edgeLabelPlacement: 'Shift'
};
this.primaryYAxis = {
title: 'Sales Amount in Millions',
};
this.zoom = {
enableMouseWheelZooming: true,
enableDeferredZooming: true,
enablePinchZooming: true,
enableSelectionZooming: true,
toolbarItems: ['Zoom', 'ZoomIn', 'ZoomOut', 'Pan', 'Reset']
};
this.title = 'Average Sales Comparison';
}
}import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));