Building beautiful, performant, and reactive data visualizations by combining the declarative power of Svelte with the mathematical precision of D3.js.
This repository serves as a comprehensive learning resource and a collection of production-ready patterns for modern web-based data storytelling.
Traditional D3 manipulation often fights against modern framework reactivity. This project demonstrates the "Hybrid Approach":
<svg>, <rect>, <path>), lifecycle transitions, state management, and user interactions.d3-scale), shape generation (d3-shape), geographic projections (d3-geo), and complex data parsing.| Visualization | Key Concepts | Features |
|---|---|---|
| Animated Bar Chart | d3-scaleLinear, Svelte tweened |
Racing animations, sorted updates, and rank transitions. |
| Global Choropleth | d3-geo, GeoJSON, d3-scaleThreshold |
Interactive tooltips, zoom-to-country, and color choropleths. |
| Reactive Scatter Plot | d3-extent, Axis components |
Dynamic resizing, color encoding, and Voronoi overlays. |
| Real-time Line Graph | d3-line, d3-time-scale |
Streaming data visualization with smooth path transitions. |
Instead of manual updates, we use Svelte's reactive declarations ($:) to update scales automatically whenever data or container dimensions change.
// Scale remains reactive to both data updates and chart resizing
$: xScale = d3.scaleLinear()
.domain([0, d3.max(data, d => d.value)])
.range([0, width]);
<script>
export let xScale;
$: ticks = xScale.ticks();
</script>
{#each ticks as tick}
<g transform="translate({xScale(tick)}, 0)">
<line y2="6" stroke="currentColor" />
<text y="20" text-anchor="middle">{tick}</text>
</g>
{/each}
src/
āāā components/
ā āāā charts/ # Core chart components (BarChart.svelte, LineChart.svelte)
ā āāā elements/ # Reusable SVG parts (Axis.svelte, Tooltip.svelte)
ā āāā layout/ # Chart containers and responsive wrappers
āāā data/ # Sample datasets (CSV, JSON, GeoJSON)
āāā utils/ # D3 formatters, color schemes, and data parsers
Clone the repository:
git clone [https://github.com/raymondoyondi/Interactive-Data-Visualization.git](https://github.com/raymondoyondi/Interactive-Data-Visualization.git)
Install dependencies:
npm install
Run the development server:
npm run dev
Contributions make the open-source community an amazing place to learn and create.
git checkout -b feature/AmazingFeature).git commit -m 'Add some AmazingFeature).git push origin feature/AmazingFeature).