Loading...
Loading...
Implement Syncfusion Angular Sparkline component for compact data visualization. Use this skill whenever the user needs to create sparkline charts, visualize small datasets inline, add markers or data labels, implement different sparkline types (Line, Column, Area, Pie, Win-Loss), or handle sparkline customization like tooltips, axis settings, and theme styling. Covers installation, basic rendering, type selection, marker configuration, data label formatting, advanced features, accessibility, and migration from EJ1.
npx skill4agent add syncfusion/angular-ui-components-skills syncfusion-angular-sparkline⚠️ CRITICAL: Multiple Sparklines Require Unique IDsWhen using more than one sparkline component on the same page, you MUST provide a uniqueattribute to each sparkline to ensure proper rendering.idhtml<!-- ✓ CORRECT - Unique IDs for multiple sparklines --> <ejs-sparkline id="sparkline1" [dataSource]="data1"></ejs-sparkline> <ejs-sparkline id="sparkline2" [dataSource]="data2"></ejs-sparkline> <ejs-sparkline id="sparkline3" [dataSource]="data3"></ejs-sparkline> <!-- ✗ WRONG - No IDs or duplicate IDs causes rendering issues --> <ejs-sparkline [dataSource]="data1"></ejs-sparkline> <ejs-sparkline [dataSource]="data2"></ejs-sparkline>Without unique IDs, sparklines may:
- Not render at all
- Render with incorrect data
- Overlap or conflict with each other
- Display inconsistent styles
import { SparklineModule } from '@syncfusion/ej2-angular-charts'
import { Component } from '@angular/core';
@Component({
imports: [SparklineModule],
standalone: true,
selector: 'app-container',
template: `<ejs-sparkline
id='sparkline-container'
[dataSource]="data"
xName="x"
yName="y"
type="Line">
</ejs-sparkline>`
})
export class AppComponent {
data = [
{ x: 'Jan', y: 2 },
{ x: 'Feb', y: 6 },
{ x: 'Mar', y: 4 },
{ x: 'Apr', y: 8 },
{ x: 'May', y: 5 }
]
}<table>
<tr>
<td>Product A</td>
<td><ejs-sparkline [dataSource]="salesA" type="Column" height="50px" width="150px"></ejs-sparkline></td>
</tr>
<tr>
<td>Product B</td>
<td><ejs-sparkline [dataSource]="salesB" type="Column" height="50px" width="150px"></ejs-sparkline></td>
</tr>
</table>@Component({
template: `<ejs-sparkline
[dataSource]="data"
type="Line"
[markerSettings]="markerSettings">
</ejs-sparkline>`
})
export class HighlightComponent {
data = [10, 25, 15, 35, 20, 30]
markerSettings = {
visible: ['High', 'Low'],
fill: '#FF5733',
size: 8,
opacity: 1
}
}import { SparklineModule, SparklineTooltipService } from '@syncfusion/ej2-angular-charts'
@Component({
imports: [SparklineModule],
standalone: true,
providers: [SparklineTooltipService],
template: `<ejs-sparkline
[dataSource]="data"
xName="month"
yName="sales"
[tooltipSettings]="tooltipSettings">
</ejs-sparkline>`
})
export class TooltipComponent {
data = [
{ month: 'Jan', sales: 10000 },
{ month: 'Feb', sales: 15000 }
]
tooltipSettings = {
visible: true,
format: '${month}: ${sales} units'
}
}@Component({
template: `<ejs-sparkline
[dataSource]="data"
type="Area"
[rangeBandSettings]="rangeBandSettings">
</ejs-sparkline>`
})
export class RangeBandComponent {
data = [20, 30, 25, 35, 28, 32, 40]
rangeBandSettings = [
{ startRange: 25, endRange: 35, color: '#90EE90', opacity: 0.3 }, // Good range
{ startRange: 15, endRange: 25, color: '#FFD700', opacity: 0.3 } // Warning range
]
}@Component({
template: `<ejs-sparkline
[dataSource]="data"
(pointRegionMouseClick)="onPointClick($event)"
(sparklineMouseClick)="onSparklineClick($event)">
</ejs-sparkline>`
})
export class EventComponent {
data = [10, 25, 15, 35, 20]
onPointClick(args: any) {
console.log('Point clicked:', args.pointIndex, args.value)
}
onSparklineClick(args: any) {
console.log('Sparkline clicked')
}
}| Property | Type | Default | Purpose |
|---|---|---|---|
| Array | | Data array (primitives or objects) - binds data to sparkline |
| string | - | Object property name for X values (e.g., 'month', 'date') |
| string | - | Object property name for Y values (e.g., 'sales', 'count') |
| string | | Sparkline type: Line, Column, Area, Pie, WinLoss |
| object | - | Configure marker display and style (High, Low, Start, End, Negative, All) with fill, border, size, opacity properties |
| object | - | Configure data label display with visible array, format string, fill color, border, textStyle, and edgeLabelMode |
| object | - | Tooltip configuration (visible, format with ${x}/${y} tokens, fill, border, textStyle, trackLineSettings) |
| string/number | | Container height in px (e.g., '150px') or percentage (e.g., '100%') |
| string/number | | Container width in px (e.g., '300px') or percentage (e.g., '100%') |
| object/array | - | Configure background shading regions (startRange, endRange, color, opacity) - supports single object or array for multiple bands |
| object | - | Axis configuration (minX, maxX, minY, maxY, intervalX, intervalY, valueType: Numeric/Category/DateTime) |
| string | - | Color for highest point in data series (hex or named color) |
| string | - | Color for lowest point in data series (hex or named color) |
| string | - | Color for first/start point in the series |
| string | - | Color for last/end point in the series |
| string | - | Color for negative data values (below zero) |
| string | - | Fill color for the sparkline area/column/bars (primary series color) |
| number | 1 | Thickness of line type sparkline (1-10 range recommended) |
| number | 1 | Opacity of the sparkline series (0-1 range) |
| boolean | false | Enable Right-to-Left layout for RTL languages (Arabic, Hebrew) |
| string | 'Numeric' | Data type for axis values: Numeric, Category, DateTime |
| string | - | Number format for axis values (e.g., 'n2' for 2 decimals, 'c' for currency) |
| boolean | false | Enable thousand separator formatting (e.g., 1,000) |
| string | 'Material' | Visual theme: Material, Fabric, Bootstrap, HighContrast, etc. |
| object | - | Border configuration (color, width) for sparkline container |
| object | - | Container customization (background color, border settings) |
| object | - | Padding for sparkline (left, right, top, bottom in pixels) |
Sparklinereferences