Implementing Syncfusion React Sparklines
A comprehensive guide for implementing Syncfusion React Sparkline components - lightweight, compact charts designed to visualize data trends in minimal space without axes or coordinates.
When to Use This Skill
Use this skill when you need to:
- Create compact data visualizations in dashboards or grids
- Display trend indicators inline with data
- Implement mini charts that consume minimal space
- Show data patterns in table cells or small containers
- Create any of the 5 sparkline types: Line, Column, Area, Win-Loss, or Pie
- Add tooltips, markers, or data labels to sparklines
- Customize sparkline appearance with themes and colors
- Implement accessible, responsive sparkline visualizations
- Integrate sparklines with grids or other components
- Highlight specific data ranges with range bands
Component Overview
The Syncfusion React Sparkline is a highly condensed chart component that presents data in a simple, compact format. Key features include:
- 5 Sparkline Types: Line, Column, Area, Win-Loss, and Pie
- Interactive Features: Tooltips with customization and templates, track lines
- Visual Markers: Highlight start, end, high, low, and negative points
- Data Labels: Display values at specific points with formatting
- Range Bands: Highlight specific value ranges along the y-axis
- Axis Customization: Support for Numeric, Category, and DateTime value types
- Themes: Material, Fabric, Bootstrap, and Highcontrast themes
- Accessibility: WCAG 2.2, Section 508 compliance with WAI-ARIA support
- Grid Integration: Designed to work seamlessly within grid cells
- Localization: Support for internationalization
Documentation and Navigation Guide
Getting Started
📄 Read: references/getting-started.md
- Dependencies and package installation (
@syncfusion/ej2-react-charts)
- Creating React application with Vite
- Adding SparklineComponent to project
- Module injection for tooltip feature
- Binding data source with dataSource property
- Changing sparkline type (Line, Column, Area, Win-Loss, Pie)
- Basic tooltip configuration
- First working example
Sparkline Types
📄 Read: references/sparkline-types.md
- Overview of all 5 sparkline types
- Line type: Continuous trend visualization
- Column type: Discrete value comparison
- Area type: Filled trend visualization
- Win-Loss type: Binary outcome representation
- Pie type: Proportional data display
- Type selection guide based on data and use case
- Complete examples for each type
Appearance Customization
📄 Read: references/appearance-customization.md
- Sparkline border configuration with containerArea
- Padding customization (left, right, top, bottom)
- Container background color
- Theme selection (Material, Fabric, Bootstrap, Highcontrast)
- Color and styling best practices
- Visual design guidelines
Data Labels
📄 Read: references/data-labels.md
- Enabling data labels for specific points
- Visibility options: All, Start, End, High, Low, Negative
- Customizing fill color, border, opacity, and text styles
- Formatting data label text with format property
- Displaying x and y values together
- Data label positioning and readability
Markers
📄 Read: references/markers.md
- Adding markers to sparkline points
- Marker visibility options: All, Start, End, High, Low, Negative
- Special point marker configuration
- Customizing marker fill, border, size, and opacity
- Combining markers with other features
- Best practices for marker usage
User Interaction
📄 Read: references/user-interaction.md
- Tooltip configuration and SparklineTooltip injection
- Tooltip customization (fill, text styles, format, border)
- Creating custom tooltip templates with HTML
- Track line feature for mouse tracking
- Track line color and styling
- Interactive feature best practices
Advanced Features
📄 Read: references/advanced-features.md
- Axis customization with valueType (Numeric, Category, DateTime)
- Setting min/max values (minX, maxX, minY, maxY)
- Axis line customization (color, width, opacity, dashArray)
- Range bands for highlighting value ranges
- Multiple range band configuration
- Special points customization (start, end, positive, negative, low)
- Tie point color for Win-Loss sparklines
- Sparkline dimensions (container, pixel, percentage sizing)
- Localization and culture support
Accessibility
📄 Read: references/accessibility.md
- WCAG 2.2 and Section 508 compliance
- WAI-ARIA attributes (img role, aria-label, aria-hidden)
- Keyboard interaction (Ctrl + P for printing)
- Screen reader support
- Right-to-left (RTL) support
- Color contrast guidelines
- Mobile device support
- Accessibility testing tools
API Reference
📄 Read: references/api-reference.md
- Complete API reference for
SparklineComponent: props, events, methods, child directives, and a usage example (based on the official Syncfusion React Sparkline API).
Quick Start
Installation
npm install @syncfusion/ej2-react-charts --save
Basic Sparkline
import { SparklineComponent } from '@syncfusion/ej2-react-charts';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
const data = [0, 6, 4, 1, 3, 2, 5];
return (
<SparklineComponent
dataSource={data}
type="Line"
height="150px"
width="300px"
/>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('charts'));
Sparkline with Tooltip
import { SparklineComponent, Inject, SparklineTooltip } from '@syncfusion/ej2-react-charts';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
const data = [0, 6, 4, 1, 3, 2, 5];
return (
<SparklineComponent
dataSource={data}
type="Area"
height="150px"
width="300px"
tooltipSettings={{ visible: true, format: '${x} : ${y}' }}
>
<Inject services={[SparklineTooltip]} />
</SparklineComponent>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('charts'));
Common Patterns
Column Sparkline with Markers
import { SparklineComponent } from '@syncfusion/ej2-react-charts';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function ColumnSparkline() {
const data = [3, 6, 4, 1, 3, 2, 5];
return (
<SparklineComponent
dataSource={data}
type="Column"
height="150px"
width="300px"
markerSettings={{ visible: ['High', 'Low'] }}
highPointColor="green"
lowPointColor="red"
/>
);
}
export default ColumnSparkline;
ReactDOM.render(<ColumnSparkline />, document.getElementById('charts'));
Win-Loss Sparkline
import { SparklineComponent } from '@syncfusion/ej2-react-charts';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function WinLossSparkline() {
const data = [12, 15, -10, 13, 15, 6, -12, 17, 13, 0, 8, -10];
return (
<SparklineComponent
dataSource={data}
type="WinLoss"
height="150px"
width="300px"
tiePointColor="blue"
/>
);
}
export default WinLossSparkline;
ReactDOM.render(<WinLossSparkline />, document.getElementById('charts'));
Sparkline with Data Labels
import { SparklineComponent } from '@syncfusion/ej2-react-charts';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function SparklineWithLabels() {
const data = [0, 6, 4, 1, 3, 2, 5];
return (
<SparklineComponent
dataSource={data}
type="Line"
height="150px"
width="300px"
dataLabelSettings={{
visible: ['Start', 'End'],
border: { color: 'blue', width: 1 },
fill: 'blue',
opacity: 0.4,
textStyle: { color: 'white' }
}}
/>
);
}
export default SparklineWithLabels;
ReactDOM.render(<SparklineWithLabels />, document.getElementById('charts'));
Sparkline with Range Band
import { SparklineComponent } from '@syncfusion/ej2-react-charts';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function SparklineWithRangeBand() {
const data = [0, 6, 4, 1, 3, 2, 5];
return (
<SparklineComponent
dataSource={data}
type="Area"
height="150px"
width="300px"
rangeBandSettings={[
{ startRange: 1, endRange: 3, color: '#bfd4fc', opacity: 0.4 }
]}
/>
);
}
export default SparklineWithRangeBand;
ReactDOM.render(<SparklineWithRangeBand />, document.getElementById('charts'));
Key Props Reference
| Property |
Type |
Description |
dataSource |
object[] |
Data for the sparkline |
type |
string |
Sparkline type: 'Line', 'Column', 'Area', 'WinLoss', 'Pie' |
xName |
string |
Property name for x-axis from dataSource |
yName |
string |
Property name for y-axis from dataSource |
height |
string |
Height of the sparkline |
width |
string |
Width of the sparkline |
fill |
string |
Color of the sparkline |
valueType |
string |
Axis value type: 'Numeric', 'Category', 'DateTime' |
markerSettings |
object |
Configuration for markers |
dataLabelSettings |
object |
Configuration for data labels |
tooltipSettings |
object |
Configuration for tooltips |
axisSettings |
object |
Axis min/max and line customization |
rangeBandSettings |
object[] |
Range band configurations |
theme |
string |
Theme: 'Material', 'Fabric', 'Bootstrap', 'Highcontrast' |
padding |
object |
Padding around sparkline (left, right, top, bottom) |
containerArea |
object |
Border and background for sparkline area |
Common Use Cases
- Dashboard Trend Indicators: Display KPI trends inline with metrics
- Grid Integration: Show mini charts in table cells
- Financial Data: Win-Loss sparklines for stock market gains/losses
- Performance Monitoring: Quick visualization of server metrics or response times
- Comparison Views: Multiple sparklines side-by-side for data comparison
- Mobile Dashboards: Compact visualizations for small screens
- Email Reports: Lightweight charts that render quickly
- Real-time Monitoring: Simple, fast-updating visualizations
Next Steps
- Start with Getting Started: Read
references/getting-started.md for installation and basic setup
- Choose Your Type: Read
references/sparkline-types.md to select the right sparkline type
- Customize Appearance: Read
references/appearance-customization.md for styling
- Add Interactivity: Read
references/user-interaction.md for tooltips and track lines
- Advanced Configuration: Read
references/advanced-features.md for axis, range bands, and more
1---
2name: syncfusion-react-sparkline
3description: Implement Syncfusion React Sparkline components for compact, inline data visualization. Use this when working with sparklines, mini charts, or trend indicators in constrained spaces. This skill covers all 5 sparkline types (line, column, area, win-loss, pie), tooltips, markers, data labels, range bands, axis customization, and themes. Ideal for displaying data trends within grids, dashboards, or tables without full-sized charts.
4metadata:
5 author: "Syncfusion Inc"
6 version: "34.1.29"
7 category: "Data Visualization"
8---
9
10# Implementing Syncfusion React Sparklines
11
12A comprehensive guide for implementing Syncfusion React Sparkline components - lightweight, compact charts designed to visualize data trends in minimal space without axes or coordinates.
13
14## When to Use This Skill
15
16Use this skill when you need to:
17- Create compact data visualizations in dashboards or grids
18- Display trend indicators inline with data
19- Implement mini charts that consume minimal space
20- Show data patterns in table cells or small containers
21- Create any of the 5 sparkline types: Line, Column, Area, Win-Loss, or Pie
22- Add tooltips, markers, or data labels to sparklines
23- Customize sparkline appearance with themes and colors
24- Implement accessible, responsive sparkline visualizations
25- Integrate sparklines with grids or other components
26- Highlight specific data ranges with range bands
27
28## Component Overview
29
30The Syncfusion React Sparkline is a highly condensed chart component that presents data in a simple, compact format. Key features include:
31
32- **5 Sparkline Types:** Line, Column, Area, Win-Loss, and Pie
33- **Interactive Features:** Tooltips with customization and templates, track lines
34- **Visual Markers:** Highlight start, end, high, low, and negative points
35- **Data Labels:** Display values at specific points with formatting
36- **Range Bands:** Highlight specific value ranges along the y-axis
37- **Axis Customization:** Support for Numeric, Category, and DateTime value types
38- **Themes:** Material, Fabric, Bootstrap, and Highcontrast themes
39- **Accessibility:** WCAG 2.2, Section 508 compliance with WAI-ARIA support
40- **Grid Integration:** Designed to work seamlessly within grid cells
41- **Localization:** Support for internationalization
42
43## Documentation and Navigation Guide
44
45### Getting Started
46📄 **Read:** [references/getting-started.md](references/getting-started.md)
47- Dependencies and package installation (`@syncfusion/ej2-react-charts`)
48- Creating React application with Vite
49- Adding SparklineComponent to project
50- Module injection for tooltip feature
51- Binding data source with dataSource property
52- Changing sparkline type (Line, Column, Area, Win-Loss, Pie)
53- Basic tooltip configuration
54- First working example
55
56### Sparkline Types
57📄 **Read:** [references/sparkline-types.md](references/sparkline-types.md)
58- Overview of all 5 sparkline types
59- Line type: Continuous trend visualization
60- Column type: Discrete value comparison
61- Area type: Filled trend visualization
62- Win-Loss type: Binary outcome representation
63- Pie type: Proportional data display
64- Type selection guide based on data and use case
65- Complete examples for each type
66
67### Appearance Customization
68📄 **Read:** [references/appearance-customization.md](references/appearance-customization.md)
69- Sparkline border configuration with containerArea
70- Padding customization (left, right, top, bottom)
71- Container background color
72- Theme selection (Material, Fabric, Bootstrap, Highcontrast)
73- Color and styling best practices
74- Visual design guidelines
75
76### Data Labels
77📄 **Read:** [references/data-labels.md](references/data-labels.md)
78- Enabling data labels for specific points
79- Visibility options: All, Start, End, High, Low, Negative
80- Customizing fill color, border, opacity, and text styles
81- Formatting data label text with format property
82- Displaying x and y values together
83- Data label positioning and readability
84
85### Markers
86📄 **Read:** [references/markers.md](references/markers.md)
87- Adding markers to sparkline points
88- Marker visibility options: All, Start, End, High, Low, Negative
89- Special point marker configuration
90- Customizing marker fill, border, size, and opacity
91- Combining markers with other features
92- Best practices for marker usage
93
94### User Interaction
95📄 **Read:** [references/user-interaction.md](references/user-interaction.md)
96- Tooltip configuration and SparklineTooltip injection
97- Tooltip customization (fill, text styles, format, border)
98- Creating custom tooltip templates with HTML
99- Track line feature for mouse tracking
100- Track line color and styling
101- Interactive feature best practices
102
103### Advanced Features
104📄 **Read:** [references/advanced-features.md](references/advanced-features.md)
105- Axis customization with valueType (Numeric, Category, DateTime)
106- Setting min/max values (minX, maxX, minY, maxY)
107- Axis line customization (color, width, opacity, dashArray)
108- Range bands for highlighting value ranges
109- Multiple range band configuration
110- Special points customization (start, end, positive, negative, low)
111- Tie point color for Win-Loss sparklines
112- Sparkline dimensions (container, pixel, percentage sizing)
113- Localization and culture support
114
115### Accessibility
116📄 **Read:** [references/accessibility.md](references/accessibility.md)
117- WCAG 2.2 and Section 508 compliance
118- WAI-ARIA attributes (img role, aria-label, aria-hidden)
119- Keyboard interaction (Ctrl + P for printing)
120- Screen reader support
121- Right-to-left (RTL) support
122- Color contrast guidelines
123- Mobile device support
124- Accessibility testing tools
125
126### API Reference
127📄 **Read:** [references/api-reference.md](references/api-reference.md)
128- Complete API reference for `SparklineComponent`: props, events, methods, child directives, and a usage example (based on the official Syncfusion React Sparkline API).
129
130## Quick Start
131
132### Installation
133
134```bash
135npm install @syncfusion/ej2-react-charts --save
136```
137
138### Basic Sparkline
139
140```javascript
141import { SparklineComponent } from '@syncfusion/ej2-react-charts';
142import * as React from 'react';
143import * as ReactDOM from 'react-dom';
144
145function App() {
146 const data = [0, 6, 4, 1, 3, 2, 5];
147
148 return (
149 <SparklineComponent
150 dataSource={data}
151 type="Line"
152 height="150px"
153 width="300px"
154 />
155 );
156}
157
158export default App;
159ReactDOM.render(<App />, document.getElementById('charts'));
160```
161
162### Sparkline with Tooltip
163
164```javascript
165import { SparklineComponent, Inject, SparklineTooltip } from '@syncfusion/ej2-react-charts';
166import * as React from 'react';
167import * as ReactDOM from 'react-dom';
168
169function App() {
170 const data = [0, 6, 4, 1, 3, 2, 5];
171
172 return (
173 <SparklineComponent
174 dataSource={data}
175 type="Area"
176 height="150px"
177 width="300px"
178 tooltipSettings={{ visible: true, format: '${x} : ${y}' }}
179 >
180 <Inject services={[SparklineTooltip]} />
181 </SparklineComponent>
182 );
183}
184
185export default App;
186ReactDOM.render(<App />, document.getElementById('charts'));
187```
188
189## Common Patterns
190
191### Column Sparkline with Markers
192
193```javascript
194import { SparklineComponent } from '@syncfusion/ej2-react-charts';
195import * as React from 'react';
196import * as ReactDOM from 'react-dom';
197
198function ColumnSparkline() {
199 const data = [3, 6, 4, 1, 3, 2, 5];
200
201 return (
202 <SparklineComponent
203 dataSource={data}
204 type="Column"
205 height="150px"
206 width="300px"
207 markerSettings={{ visible: ['High', 'Low'] }}
208 highPointColor="green"
209 lowPointColor="red"
210 />
211 );
212}
213
214export default ColumnSparkline;
215ReactDOM.render(<ColumnSparkline />, document.getElementById('charts'));
216```
217
218### Win-Loss Sparkline
219
220```javascript
221import { SparklineComponent } from '@syncfusion/ej2-react-charts';
222import * as React from 'react';
223import * as ReactDOM from 'react-dom';
224
225function WinLossSparkline() {
226 const data = [12, 15, -10, 13, 15, 6, -12, 17, 13, 0, 8, -10];
227
228 return (
229 <SparklineComponent
230 dataSource={data}
231 type="WinLoss"
232 height="150px"
233 width="300px"
234 tiePointColor="blue"
235 />
236 );
237}
238
239export default WinLossSparkline;
240ReactDOM.render(<WinLossSparkline />, document.getElementById('charts'));
241```
242
243### Sparkline with Data Labels
244
245```javascript
246import { SparklineComponent } from '@syncfusion/ej2-react-charts';
247import * as React from 'react';
248import * as ReactDOM from 'react-dom';
249
250function SparklineWithLabels() {
251 const data = [0, 6, 4, 1, 3, 2, 5];
252
253 return (
254 <SparklineComponent
255 dataSource={data}
256 type="Line"
257 height="150px"
258 width="300px"
259 dataLabelSettings={{
260 visible: ['Start', 'End'],
261 border: { color: 'blue', width: 1 },
262 fill: 'blue',
263 opacity: 0.4,
264 textStyle: { color: 'white' }
265 }}
266 />
267 );
268}
269
270export default SparklineWithLabels;
271ReactDOM.render(<SparklineWithLabels />, document.getElementById('charts'));
272```
273
274### Sparkline with Range Band
275
276```javascript
277import { SparklineComponent } from '@syncfusion/ej2-react-charts';
278import * as React from 'react';
279import * as ReactDOM from 'react-dom';
280
281function SparklineWithRangeBand() {
282 const data = [0, 6, 4, 1, 3, 2, 5];
283
284 return (
285 <SparklineComponent
286 dataSource={data}
287 type="Area"
288 height="150px"
289 width="300px"
290 rangeBandSettings={[
291 { startRange: 1, endRange: 3, color: '#bfd4fc', opacity: 0.4 }
292 ]}
293 />
294 );
295}
296
297export default SparklineWithRangeBand;
298ReactDOM.render(<SparklineWithRangeBand />, document.getElementById('charts'));
299```
300
301## Key Props Reference
302
303| Property | Type | Description |
304|----------|------|-------------|
305| `dataSource` | object[] | Data for the sparkline |
306| `type` | string | Sparkline type: 'Line', 'Column', 'Area', 'WinLoss', 'Pie' |
307| `xName` | string | Property name for x-axis from dataSource |
308| `yName` | string | Property name for y-axis from dataSource |
309| `height` | string | Height of the sparkline |
310| `width` | string | Width of the sparkline |
311| `fill` | string | Color of the sparkline |
312| `valueType` | string | Axis value type: 'Numeric', 'Category', 'DateTime' |
313| `markerSettings` | object | Configuration for markers |
314| `dataLabelSettings` | object | Configuration for data labels |
315| `tooltipSettings` | object | Configuration for tooltips |
316| `axisSettings` | object | Axis min/max and line customization |
317| `rangeBandSettings` | object[] | Range band configurations |
318| `theme` | string | Theme: 'Material', 'Fabric', 'Bootstrap', 'Highcontrast' |
319| `padding` | object | Padding around sparkline (left, right, top, bottom) |
320| `containerArea` | object | Border and background for sparkline area |
321
322## Common Use Cases
323
3241. **Dashboard Trend Indicators:** Display KPI trends inline with metrics
3252. **Grid Integration:** Show mini charts in table cells
3263. **Financial Data:** Win-Loss sparklines for stock market gains/losses
3274. **Performance Monitoring:** Quick visualization of server metrics or response times
3285. **Comparison Views:** Multiple sparklines side-by-side for data comparison
3296. **Mobile Dashboards:** Compact visualizations for small screens
3307. **Email Reports:** Lightweight charts that render quickly
3318. **Real-time Monitoring:** Simple, fast-updating visualizations
332
333## Next Steps
334
3351. **Start with Getting Started:** Read `references/getting-started.md` for installation and basic setup
3362. **Choose Your Type:** Read `references/sparkline-types.md` to select the right sparkline type
3373. **Customize Appearance:** Read `references/appearance-customization.md` for styling
3384. **Add Interactivity:** Read `references/user-interaction.md` for tooltips and track lines
3395. **Advanced Configuration:** Read `references/advanced-features.md` for axis, range bands, and more