Localization in Angular Sparkline component
20 Sep 20224 minutes to read
The sparkline control supports localization. The default culture for localization is en-US
. You can change the culture using the setCulture
method.
Tooltip format
Sparkline tooltip supports localization. The following code sample shows tooltip text with currency format based on culture.
[app.component.ts
]
import { Component } from '@angular/core';
import { TooltipSettingsModel } from '@syncfusion/ej2-sparkline';
@Component({
selector: 'app-container',
template: `<ejs-sparkline id='container' width='350px' height='200px' [containerArea]= 'containerArea' lineWidth= 3 format= 'c0' useGroupingSeparator= 'true' [padding]='padding' [dataSource]="data" fill= '#b2cfff' type="Area"
[tooltipSettings]="tooltipSettings">
</ejs-sparkline>`
})
export class AppComponent {
public data: object[] = [30000, 60000, 40000, 10000, 30000, 20000, 50000];
public containerArea: object= {
border: { color: '#033e96', width: 2 }
};
public tooltipSettings: object= {
visible: true
};
public padding: object = { left: 20, right: 20, bottom: 20, top: 20};
public border: object = { color: '#033e96', width: 2 };
}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { SparklineModule, SparklineTooltipService } from '@syncfusion/ej2-angular-charts';
/**
* Module
*/
@NgModule({
imports: [
BrowserModule, SparklineModule
],
declarations: [AppComponent],
bootstrap: [AppComponent],
providers: [SparklineTooltipService]
})
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);
Rtl
If you set the enableRtl
property to true, then the sparkline will be rendered from rigt-to-left direction.
The following example shows the sparkline is render from “Right-to-left”.
import { Component } from '@angular/core';
import { TooltipSettingsModel } from '@syncfusion/ej2-sparkline';
@Component({
selector: 'app-container',
template: `<ejs-sparkline id='container' width='150px' height='150px' [dataSource]="data" enableRtl= true
>
</ejs-sparkline>`
})
export class AppComponent {
public data: object[] = [0, 6, 4, 1, 3, 2, 5];
}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { SparklineModule, SparklineTooltipService } from '@syncfusion/ej2-angular-charts';
/**
* Module
*/
@NgModule({
imports: [
BrowserModule, SparklineModule
],
declarations: [AppComponent],
bootstrap: [AppComponent],
providers: [SparklineTooltipService]
})
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);