Implementing Syncfusion Sparkline
When to Use This Skill
Use this skill when you need to:
- Create compact data visualizations - Sparklines are very small charts that visualize data in a condensed format without axes or coordinates
- Integrate with ASP.NET Core applications - Setting up Syncfusion Sparkline control in Razor pages or MVC applications
- Display temporal data trends - Showing data patterns over time in minimal space (perfect for dashboards and grids)
- Highlight specific data points - Using markers to show high, low, start, end, or negative values
- Support interactive data exploration - Adding tooltips and track lines for user interactivity
- Meet accessibility requirements - Ensuring WCAG 2.2 compliance and keyboard navigation support
Component Overview
The Syncfusion Sparkline is a lightweight chart component that presents common data shapes in a highly condensed format. Key characteristics:
- Consumes minimal space - Perfect for dashboards and grid integrations
- Five chart types - Line, Column, Area, Win-Loss, and Pie
- Visual enhancements - Markers, data labels, range bands
- Interactive features - Tooltips and track lines
- Customizable appearance - Themes, colors, borders, padding
- Accessibility ready - WCAG 2.2 AA compliant with keyboard shortcuts
Documentation and Navigation Guide
API Reference
📄 Read: references/api-reference.md
- Complete Sparkline class API documentation (40+ properties)
- SparklineAxisSettings, ContainerArea, Padding, Border configuration
- MarkerSettings for point highlighting (All, Start, End, High, Low, Negative)
- DataLabelSettings for label configuration and positioning
- TooltipSettings for interactive tooltips with custom templates
- RangeBandSettings for highlighting value ranges
- TrackLineSettings for mouse tracking lines
- Five SparklineType options (Line, Column, Area, Win-Loss, Pie)
- SparklineValueType options (Numeric, Category, DateTime)
- Theme support (Material, Fabric, Bootstrap, HighContrast)
- RangePadding options (None, Normal, Additional, Round)
- Comprehensive events reference (Load, Loaded, AxisRendering, SeriesRendering, etc.)
- User interaction events (SparklineMouseClick, PointRegionMouseMove, etc.)
- Data rendering events (PointRendering, MarkerRendering, DataLabelRendering, TooltipInitialize)
- Usage patterns for all sparkline types with code examples
- Official Syncfusion API reference links
Getting Started
📄 Read: references/getting-started.md
- ASP.NET Core project setup requirements
- NuGet package installation (Syncfusion.EJ2.AspNet.Core)
- TagHelper configuration and script manager registration
- Creating your first sparkline
- Data source binding and initialization
- Changing sparkline types
- Enabling tooltips
Sparkline Types & Configuration
📄 Read: references/sparkline-types.md
- Five chart type options (Line, Column, Area, Win-Loss, Pie)
- When to use each type for different data scenarios
- Implementation patterns for each sparkline type
- Code examples for all type variations
Data Features & Customization
📄 Read: references/data-features.md
- Data binding approaches and data source preparation
- Adding markers (All, Start, End, High, Low, Negative)
- Customizing marker appearance (fill, border, size, opacity)
- Data labels configuration and point selection
- Range bands for highlighting value ranges
- Data label customization (fill, border, text style)
- Formatting data label text
Appearance & Theming
📄 Read: references/appearance-theming.md
- Container area border and padding configuration
- Background color customization
- Theme selection (Material, Fabric, Bootstrap, Highcontrast)
- Text color and data label appearance by theme
- Size and spacing adjustments
- CSS customization approaches
User Interaction & Tooltips
📄 Read: references/user-interaction.md
- Tooltip implementation and module injection
- Tooltip customization (fill, text style, format, border)
- Tooltip templates with custom HTML
- Track line configuration and behavior
- Mouse-based point tracking
- Tooltip formatting options
Accessibility & Deployment
📄 Read: references/accessibility-deployment.md
- WCAG 2.2 AA compliance and standards adherence
- Section 508 support and screen reader compatibility
- Keyboard navigation shortcuts (Ctrl+P for printing)
- WAI-ARIA attributes and patterns
- Right-to-left (RTL) language support
- Color contrast and mobile device considerations
- Accessibility validation tools and checklist
Quick Start Example
Here's a minimal sparkline implementation:
// Controller: Index.cs
public class DataSource
{
public int x { get; set; }
public string xval { get; set; }
public double yval { get; set; }
public static List<DataSource> GetData()
{
List<DataSource> data = new List<DataSource>();
data.Add(new DataSource() { x = 0, xval = "2020", yval = 2000 });
data.Add(new DataSource() { x = 1, xval = "2021", yval = 3000 });
data.Add(new DataSource() { x = 2, xval = "2022", yval = 2500 });
data.Add(new DataSource() { x = 3, xval = "2023", yval = 4000 });
return data;
}
}
<!-- View: Index.cshtml -->
<ejs-sparkline id="sparkline"
type="Line"
dataSource="ViewBag.DataPoints">
<e-sparkline-tooltipsettings visible="true"></e-sparkline-tooltipsettings>
</ejs-sparkline>
Common Patterns
Pattern 1: Dashboard Summary Sparklines
Use compact Line sparklines in dashboard summary cards to show key metric trends at a glance.
Pattern 2: Grid Integration
Embed sparklines within grid columns to visualize data distribution across rows without excessive space consumption.
Pattern 3: Status Indicators with Win-Loss
Use Win-Loss sparklines to show success/failure patterns or positive/negative outcomes in historical data.
Pattern 4: Financial Charts
Use Column sparklines for revenue/expense comparisons, and Area sparklines for cumulative financial trends.
Pattern 5: Data Point Highlighting
Combine markers and range bands to emphasize exceptional values (high/low points) and target ranges.
Key Properties
| Property |
Purpose |
Example |
type |
Sets sparkline chart type |
type="Line" |
dataSource |
Binds data to sparkline |
dataSource="@ViewBag.Data" |
xName |
X-axis data field |
xName="xval" |
yName |
Y-axis data field |
yName="yval" |
theme |
Sets color theme |
theme="Material" |
markerSettings.visible |
Shows markers at points |
visible="All" |
dataLabelSettings.visible |
Displays data labels |
visible="All" |
tooltipSettings.visible |
Enables tooltips |
visible="true" |
trackLineSettings.visible |
Shows track line on hover |
visible="true" |
Common Use Cases
- Financial Dashboards: Show revenue trends using Area sparklines in summary widgets
- KPI Monitoring: Display performance metrics with Line sparklines and highlighted range bands
- Data Tables: Add sparklines to grid columns showing sales history or performance over time
- Status Reports: Use Win-Loss sparklines to visualize project outcomes or test results
- Mobile Dashboards: Utilize compact Pie sparklines for portfolio allocation or category distribution
1---2name: syncfusion-aspnetcore-sparkline3description: When user needs to create sparklines (compact data visualizations) in ASP.NET Core applications, always use this skill to implement sparkline components, configure chart types (line, column, area, win-loss, pie), bind data, customize appearance, add markers and data labels, enable user interactions (tooltips, track lines), and ensure accessibility compliance immediately.4---56# Implementing Syncfusion Sparkline78## When to Use This Skill910Use this skill when you need to:1112- **Create compact data visualizations** - Sparklines are very small charts that visualize data in a condensed format without axes or coordinates13- **Integrate with ASP.NET Core applications** - Setting up Syncfusion Sparkline control in Razor pages or MVC applications14- **Display temporal data trends** - Showing data patterns over time in minimal space (perfect for dashboards and grids)15- **Highlight specific data points** - Using markers to show high, low, start, end, or negative values16- **Support interactive data exploration** - Adding tooltips and track lines for user interactivity17- **Meet accessibility requirements** - Ensuring WCAG 2.2 compliance and keyboard navigation support1819## Component Overview2021The Syncfusion Sparkline is a lightweight chart component that presents common data shapes in a highly condensed format. Key characteristics:2223- **Consumes minimal space** - Perfect for dashboards and grid integrations24- **Five chart types** - Line, Column, Area, Win-Loss, and Pie25- **Visual enhancements** - Markers, data labels, range bands26- **Interactive features** - Tooltips and track lines27- **Customizable appearance** - Themes, colors, borders, padding28- **Accessibility ready** - WCAG 2.2 AA compliant with keyboard shortcuts2930## Documentation and Navigation Guide3132### API Reference33📄 **Read:** [references/api-reference.md](references/api-reference.md)34- Complete Sparkline class API documentation (40+ properties)35- SparklineAxisSettings, ContainerArea, Padding, Border configuration36- MarkerSettings for point highlighting (All, Start, End, High, Low, Negative)37- DataLabelSettings for label configuration and positioning38- TooltipSettings for interactive tooltips with custom templates39- RangeBandSettings for highlighting value ranges40- TrackLineSettings for mouse tracking lines41- Five SparklineType options (Line, Column, Area, Win-Loss, Pie)42- SparklineValueType options (Numeric, Category, DateTime)43- Theme support (Material, Fabric, Bootstrap, HighContrast)44- RangePadding options (None, Normal, Additional, Round)45- Comprehensive events reference (Load, Loaded, AxisRendering, SeriesRendering, etc.)46- User interaction events (SparklineMouseClick, PointRegionMouseMove, etc.)47- Data rendering events (PointRendering, MarkerRendering, DataLabelRendering, TooltipInitialize)48- Usage patterns for all sparkline types with code examples49- Official Syncfusion API reference links5051### Getting Started52📄 **Read:** [references/getting-started.md](references/getting-started.md)53- ASP.NET Core project setup requirements54- NuGet package installation (Syncfusion.EJ2.AspNet.Core)55- TagHelper configuration and script manager registration56- Creating your first sparkline57- Data source binding and initialization58- Changing sparkline types59- Enabling tooltips6061### Sparkline Types & Configuration62📄 **Read:** [references/sparkline-types.md](references/sparkline-types.md)63- Five chart type options (Line, Column, Area, Win-Loss, Pie)64- When to use each type for different data scenarios65- Implementation patterns for each sparkline type66- Code examples for all type variations6768### Data Features & Customization69📄 **Read:** [references/data-features.md](references/data-features.md)70- Data binding approaches and data source preparation71- Adding markers (All, Start, End, High, Low, Negative)72- Customizing marker appearance (fill, border, size, opacity)73- Data labels configuration and point selection74- Range bands for highlighting value ranges75- Data label customization (fill, border, text style)76- Formatting data label text7778### Appearance & Theming79📄 **Read:** [references/appearance-theming.md](references/appearance-theming.md)80- Container area border and padding configuration81- Background color customization82- Theme selection (Material, Fabric, Bootstrap, Highcontrast)83- Text color and data label appearance by theme84- Size and spacing adjustments85- CSS customization approaches8687### User Interaction & Tooltips88📄 **Read:** [references/user-interaction.md](references/user-interaction.md)89- Tooltip implementation and module injection90- Tooltip customization (fill, text style, format, border)91- Tooltip templates with custom HTML92- Track line configuration and behavior93- Mouse-based point tracking94- Tooltip formatting options9596### Accessibility & Deployment97📄 **Read:** [references/accessibility-deployment.md](references/accessibility-deployment.md)98- WCAG 2.2 AA compliance and standards adherence99- Section 508 support and screen reader compatibility100- Keyboard navigation shortcuts (Ctrl+P for printing)101- WAI-ARIA attributes and patterns102- Right-to-left (RTL) language support103- Color contrast and mobile device considerations104- Accessibility validation tools and checklist105106## Quick Start Example107108Here's a minimal sparkline implementation:109110```csharp111// Controller: Index.cs112public class DataSource113{114 public int x { get; set; }115 public string xval { get; set; }116 public double yval { get; set; }117 118 public static List<DataSource> GetData()119 {120 List<DataSource> data = new List<DataSource>();121 data.Add(new DataSource() { x = 0, xval = "2020", yval = 2000 });122 data.Add(new DataSource() { x = 1, xval = "2021", yval = 3000 });123 data.Add(new DataSource() { x = 2, xval = "2022", yval = 2500 });124 data.Add(new DataSource() { x = 3, xval = "2023", yval = 4000 });125 return data;126 }127}128```129130```cshtml131<!-- View: Index.cshtml -->132<ejs-sparkline id="sparkline" 133 type="Line" 134 dataSource="ViewBag.DataPoints">135 <e-sparkline-tooltipsettings visible="true"></e-sparkline-tooltipsettings>136</ejs-sparkline>137```138139## Common Patterns140141### Pattern 1: Dashboard Summary Sparklines142Use compact Line sparklines in dashboard summary cards to show key metric trends at a glance.143144### Pattern 2: Grid Integration145Embed sparklines within grid columns to visualize data distribution across rows without excessive space consumption.146147### Pattern 3: Status Indicators with Win-Loss148Use Win-Loss sparklines to show success/failure patterns or positive/negative outcomes in historical data.149150### Pattern 4: Financial Charts151Use Column sparklines for revenue/expense comparisons, and Area sparklines for cumulative financial trends.152153### Pattern 5: Data Point Highlighting154Combine markers and range bands to emphasize exceptional values (high/low points) and target ranges.155156## Key Properties157158| Property | Purpose | Example |159|----------|---------|---------|160| `type` | Sets sparkline chart type | `type="Line"` |161| `dataSource` | Binds data to sparkline | `dataSource="@ViewBag.Data"` |162| `xName` | X-axis data field | `xName="xval"` |163| `yName` | Y-axis data field | `yName="yval"` |164| `theme` | Sets color theme | `theme="Material"` |165| `markerSettings.visible` | Shows markers at points | `visible="All"` |166| `dataLabelSettings.visible` | Displays data labels | `visible="All"` |167| `tooltipSettings.visible` | Enables tooltips | `visible="true"` |168| `trackLineSettings.visible` | Shows track line on hover | `visible="true"` |169170## Common Use Cases1711721. **Financial Dashboards**: Show revenue trends using Area sparklines in summary widgets1732. **KPI Monitoring**: Display performance metrics with Line sparklines and highlighted range bands1743. **Data Tables**: Add sparklines to grid columns showing sales history or performance over time1754. **Status Reports**: Use Win-Loss sparklines to visualize project outcomes or test results1765. **Mobile Dashboards**: Utilize compact Pie sparklines for portfolio allocation or category distribution