Make D3.js visualizations accessible through sound
ā¶ Live Demo Ā· Why? Ā· Blog Post
sound3fy adds sonification to D3.js visualizations, making charts accessible to blind and low-vision users. Data values become musical notesāhigher values play higher pitches.
- šµ Musical Scales - Pentatonic, major, minor, blues, chromatic
- š Chart Support - Bar, line (continuous sweep), scatter (2D mapping)
- āØļø Keyboard Navigation - Full control without mouse
- š Screen Reader - ARIA live regions announce values
- šÆ Hover to Hear - Mouse over any data point
// One line to add sonification
d3.selectAll(".bar").sonify({ pitch: "value" });npm install sound3fyconst sonify = d3.selectAll(".bar")
.data(data)
.sonify({
pitch: {
field: "value",
range: [220, 880],
scale: "pentatonic"
},
duration: 200,
gap: 50
});
// Control playback
sonify.play();
sonify.pause();
sonify.stop();
sonify.next();
sonify.previous();
sonify.setSpeed(1.5);d3.selectAll(".dot").sonify({
pitch: "value",
mode: "continuous" // Smooth frequency sweep
});d3.selectAll(".dot").sonify({
chartType: "scatter",
x: "area", // X ā stereo pan
pitch: { field: "pop" } // Y ā pitch
});| Key | Action |
|---|---|
Space |
Play/Pause |
ā ā |
Navigate |
Home End |
First/Last |
+ - |
Speed |
M |
Toggle mode |
Esc |
Stop |
{
pitch: { field: "value", range: [220, 880], scale: "pentatonic" },
volume: { field: null, range: [0.4, 0.7] },
pan: { range: [-0.7, 0.7] },
duration: 200,
gap: 50,
mode: "discrete", // or "continuous"
accessibility: { keyboard: true, announce: true, focus: true, hover: true }
}| Scale | Notes |
|---|---|
pentatonic |
Pleasant, no dissonance (default) |
major |
Bright |
minor |
Serious |
blues |
Bluesy |
chromatic |
All 12 notes |
continuous |
Direct frequency |
Built for WCAG 2.2 compliance:
- ARIA:
role="graphics-symbol",aria-label,aria-live="polite" - Keyboard: Full navigation
- Focus: Visual indicators with high contrast support
- Reduced Motion: Respects user preferences
git clone https://github.com/IsmaelMartinez/sound3fy.git
cd sound3fy
npm install
npm run dev
npm test- Architecture Decisions - Key design decisions
Are you blind or low-vision? Your feedback is invaluable! Please share your experience ā does the sonification work for you?
MIT
Making data accessible, one sound at a time. šµ