This source did not publish a separate summary. Review SKILL.md before using the skill.
SKILL.md
D3.js Visualization Guide
Overview
D3.js (Data-Driven Documents) is the most powerful and flexible JavaScript library for producing dynamic, interactive data visualizations in web browsers. With over 112K stars on GitHub, D3 has become the de facto standard for custom data visualization on the web. It uses HTML, SVG, and CSS to bring data to life, giving researchers full control over the final visual output.
Unlike higher-level charting libraries, D3 operates at the level of individual SVG elements and data bindings, which means researchers can create entirely bespoke visualizations tailored to their specific datasets and publication requirements. This makes it particularly valuable for academic work where standard chart types may not adequately represent complex research findings.
D3 provides a comprehensive ecosystem of modules covering everything from scales and axes to geographic projections, force-directed layouts, and hierarchical data structures. The library follows a functional, composable design that allows researchers to combine modules as needed for their specific visualization tasks.
Core Concepts for Research Visualizations
D3 revolves around the concept of binding data to DOM elements and applying data-driven transformations. The key patterns every researcher should understand are selections, data joins, scales, and axes.
Data Binding and Selections
// Load research data from CSV
const data = await d3.csv("experiment_results.csv", d => ({
condition: d.condition,
measurement: +d.measurement,
error: +d.standard_error
}));
// Create an SVG container
const svg = d3.select("#chart")
.append("svg")
.attr("width", 800)
.attr("height", 500);
// Binddata to elements using the enter-update-exit pattern
svg.selectAll("circle")
.data(data)
.join("circle")
.attr("cx", d => xScale(d.condition))
.attr("cy", d => yScale(d.measurement))
.attr("r", 5)
.attr("fill", "#3B82F6");
Scales and Axes
// Linear scale for continuous measurements
const yScale = d3.scaleLinear()
.domain([0, d3.max(data, d => d.measurement)])
.range([height - margin.bottom, margin.top]);
// Band scale for categorical conditions
const xScale = d3.scaleBand()
.domain(data.map(d => d.condition))
.range([margin.left, width - margin.right])
.padding(0.3);
// Add axes with proper formatting
svg.append("g")
.attr("transform", `translate(0,${height - margin.bottom})`)
.call(d3.axisBottom(xScale));
svg.append("g")
.attr("transform", `translate(${margin.left},0)`)
.call(d3.axisLeft(yScale).tickFormat(d3.format(".2f")));
D3 excels at adding interactivity to visualizations, which is valuable for research presentations, supplementary materials, and data exploration during analysis.