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