- Sparkline border
- Sparkline padding
- Sparkline area customization
- Sparkline theme
Contact Support
Appearance in Angular Sparkline component
27 Apr 20248 minutes to read
The appearance of the sparkline can be customized using margin, container Area border, and container Area background.
Sparkline border
The containerArea border
of the sparkline is used to render border to cover sparkline area.
The following code example shows the sparkline with overall border.
[app.component.ts
]
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { SparklineModule, SparklineTooltipService } from '@syncfusion/ej2-angular-charts'
import { Component } from '@angular/core';
import { TooltipSettingsModel } from '@syncfusion/ej2-angular-charts';
@Component({
imports: [
SparklineModule
],
providers: [SparklineTooltipService],
standalone: true,
selector: 'app-container',
template: `<ejs-sparkline id='container' width='350px' height='200px' [border]= 'border' [containerArea]='containerArea' [dataSource]="data" fill= '#b2cfff' type="Area">
</ejs-sparkline>`
})
export class AppComponent {
public data: object[] = [3, 6, 4, 1, 3, 2, 5] as any;
public containerArea: object= {
border: { color: '#033e96', width: 2 }
};
public border: object= { color: '#033e96', width: 1 };
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
Sparkline padding
Padding is used to specify padding value between container and sparkline. By default, padding value of the sparkline is 5. Sparkline padding
values are specified by the left, right, top, and bottom.
The following code example shows the sparkline with overall padding is set to 20.
[app.component.ts
]
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { SparklineModule, SparklineTooltipService } from '@syncfusion/ej2-angular-charts'
import { Component } from '@angular/core';
@Component({
imports: [
SparklineModule
],
providers: [SparklineTooltipService],
standalone: true,
selector: 'app-container',
template: `<ejs-sparkline id='container' width='350px' height='200px' [padding] = 'padding' [border]= 'border' [containerArea]='containerArea' [dataSource]="data" fill= '#b2cfff' type="Area">
</ejs-sparkline>`
})
export class AppComponent {
public data: object[] = [3, 6, 4, 1, 3, 2, 5] as any;
public containerArea: object= {
border: { color: '#033e96', width: 2 }
};
public padding: object= { left: 20, right: 20, bottom: 20, top: 20};
public border: object= { color: '#033e96', width: 1 };
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
Sparkline area customization
The background color of the sparkline area can be customized using the containerArea background
color. By default, the sparkline background color is transparent
.
[app.component.ts
]
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { SparklineModule, SparklineTooltipService } from '@syncfusion/ej2-angular-charts'
import { Component } from '@angular/core';
@Component({
imports: [
SparklineModule
],
providers: [SparklineTooltipService],
standalone: true,
selector: 'app-container',
template: `<ejs-sparkline id='container' width='350px' height='200px' [padding]= 'padding' [border]= 'border' [containerArea]='containerArea' [dataSource]="data" fill= '#b2cfff' type="Area">
</ejs-sparkline>`
})
export class AppComponent {
public data: object[] = [3, 6, 4, 1, 3, 2, 5] as any;
public containerArea: object= {
border: { color: '#033e96', width: 2 },
background: '#eff1f4',
};
public padding: object= { left: 20, right: 20, bottom: 20, top: 20};
public border: object= { color: '#033e96', width: 1 };
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
Sparkline theme
Datalabel and track line colors of the sparkline will be changed based on theme. For example, for dark theme, the color of datalabel and track line should be white; for light theme, their value should be black. The possible values for sparkline theme are Material
, Fabric
, Bootstrap
, and Highcontrast
.
The following code example shows the color for datalabel and track line is set to white for dark theme.
[app.component.ts
]
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { SparklineModule, SparklineTooltipService } from '@syncfusion/ej2-angular-charts'
import { Component } from '@angular/core';
import { TooltipSettingsModel } from '@syncfusion/ej2-angular-charts';
@Component({
imports: [
SparklineModule
],
providers: [SparklineTooltipService],
standalone: true,
selector: 'app-container',
template: `<ejs-sparkline id='container' width='350px' height='200px' [axisSettings]= 'axisSettings' theme= 'Highcontrast' [dataLabelSettings]= 'dataLabelSettings' [tooltipSettings]= 'tooltipSettings' [border]= 'border' [dataSource]="data" fill= '#007dd1' type="Line">
</ejs-sparkline>`
})
export class AppComponent {
public data: object[] = [3, 6, 4, 1, 3, 2, 5] as any;
public dataLabelSettings: object= { visible: ['All']};
public tooltipSettings: object= {
trackLineSettings: { visible: true }
};
public axisSettings: object= {
minX: -1, maxX: 7
};
public border: object = { color: 'transparent', width: 2 };
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));