Interactive D3.js Visualization

VerifiedSafe

Create interactive data visualizations using D3.js. Use this when creating charts, graphs, network diagrams, geographic visualizations, or custom SVG-based data visualization.

Sby Skills Guide Bot
Data & AIIntermediate
7/28/2026
Claude CodeCursorCodex
#d3js#data-visualization#svg#interactive-charts#javascript

Recommended for

Automated summary

A practical guide for building interactive D3.js data visualizations, with code examples for common charts, tooltips, zoom and transitions.

Strengths

  • Provides a complete, reusable workflow: dimensions, margins, scales, axes and data joining
  • Includes ready-to-use snippets for bar, line and pie charts
  • Covers interactivity (tooltips, zoom/pan) and transitions, including staggered animations
  • Explicitly states when to prefer another library (Three.js for 3D, Chart.js/Recharts for simple charts)

Limitations

  • Claims support for network and geographic visualizations but gives no examples for either
  • Does not cover data loading (CSV, fetch), accessibility, or responsive rendering
  • The content is written in Korean, which may hinder some readers
When to use it

Use it when you need a custom, interactive SVG chart or visualization that goes beyond what a turnkey charting library can produce.

When not to use it

Avoid it for very simple standard charts where Chart.js or Recharts suffice, or for 3D visualization that belongs to Three.js.

Security analysis

Safe
Quality score76/100

The skill contains only D3.js instructional snippets and declares ordinary file-editing tools; it does not instruct destructive commands, credential access, network exfiltration, obfuscated payloads, or safety bypasses. The only minor concern is an educational tooltip pattern that could lead to XSS if used with untrusted data.

Findings
  • •Tooltip example uses .html(`Value: ${d.value}`) with unescaped data, which could introduce XSS if copied into an app handling untrusted input; prefer textContent or sanitize.
How this analysis is made

Examples

Bar chart with tooltips
Using D3.js, build a bar chart of monthly sales from this JSON array, with a hover tooltip showing the exact value and an animated transition when the data updates.
Zoomable line chart
Create a D3 line chart of daily temperatures with a time scale on the x-axis, and add pan and zoom limited to a 0.5x–10x range.
Custom animated chart
I need a custom SVG visualization that Recharts can't do: a scatter plot with staggered entrance animations and a log-scaled y-axis, written in D3 v7.

name: d3-viz description: Create interactive data visualizations using D3.js. Use this when creating charts, graphs, network diagrams, geographic visualizations, or custom SVG-based data visualization. allowed-tools: Read, Glob, Grep, Edit, Write license: MIT metadata: author: chrisvoncsefalvay version: "1.0"

D3.js Visualization

D3.js를 사용한 인터랙티브 데이터 시각화 가이드입니다.

When to Use D3.js

적합한 경우:

  • 커스텀 차트 (표준 라이브러리에 없는)
  • 인터랙티브 탐색 (pan, zoom, brush)
  • 네트워크/그래프 시각화
  • 지리 시각화 (커스텀 projection)
  • 애니메이션 transition
  • 출판 품질 그래픽

대안 고려:

  • 3D 시각화 → Three.js
  • 간단한 차트 → Chart.js, Recharts

Setup

// npm
import * as d3 from 'd3';

// CDN
<script src="https://d3js.org/d3.v7.min.js"></script>

Core Workflow

function drawVisualization(data) {
  if (!data || data.length === 0) return;

  const svg = d3.select('#chart');
  svg.selectAll("*").remove(); // Clear previous

  // 1. Dimensions
  const width = 800;
  const height = 400;
  const margin = { top: 20, right: 30, bottom: 40, left: 50 };
  const innerWidth = width - margin.left - margin.right;
  const innerHeight = height - margin.top - margin.bottom;

  // 2. Main group with margins
  const g = svg.append("g")
    .attr("transform", `translate(${margin.left},${margin.top})`);

  // 3. Scales
  const xScale = d3.scaleLinear()
    .domain([0, d3.max(data, d => d.x)])
    .range([0, innerWidth]);

  const yScale = d3.scaleLinear()
    .domain([0, d3.max(data, d => d.y)])
    .range([innerHeight, 0]);

  // 4. Axes
  g.append("g")
    .attr("transform", `translate(0,${innerHeight})`)
    .call(d3.axisBottom(xScale));

  g.append("g")
    .call(d3.axisLeft(yScale));

  // 5. Data binding
  g.selectAll("circle")
    .data(data)
    .join("circle")
    .attr("cx", d => xScale(d.x))
    .attr("cy", d => yScale(d.y))
    .attr("r", 5)
    .attr("fill", "steelblue");
}

Common Patterns

Bar Chart

const xScale = d3.scaleBand()
  .domain(data.map(d => d.category))
  .range([0, innerWidth])
  .padding(0.1);

g.selectAll("rect")
  .data(data)
  .join("rect")
  .attr("x", d => xScale(d.category))
  .attr("y", d => yScale(d.value))
  .attr("width", xScale.bandwidth())
  .attr("height", d => innerHeight - yScale(d.value))
  .attr("fill", "steelblue");

Line Chart

const line = d3.line()
  .x(d => xScale(d.date))
  .y(d => yScale(d.value))
  .curve(d3.curveMonotoneX);

g.append("path")
  .datum(data)
  .attr("fill", "none")
  .attr("stroke", "steelblue")
  .attr("stroke-width", 2)
  .attr("d", line);

Pie Chart

const pie = d3.pie().value(d => d.value);
const arc = d3.arc()
  .innerRadius(0)
  .outerRadius(Math.min(width, height) / 2 - 20);

g.selectAll("path")
  .data(pie(data))
  .join("path")
  .attr("d", arc)
  .attr("fill", (d, i) => d3.schemeCategory10[i]);

Interactivity

Tooltips

const tooltip = d3.select("body").append("div")
  .attr("class", "tooltip")
  .style("visibility", "hidden");

circles
  .on("mouseover", (event, d) => {
    tooltip.style("visibility", "visible")
      .html(`Value: ${d.value}`);
  })
  .on("mousemove", (event) => {
    tooltip
      .style("top", (event.pageY - 10) + "px")
      .style("left", (event.pageX + 10) + "px");
  })
  .on("mouseout", () => {
    tooltip.style("visibility", "hidden");
  });

Zoom & Pan

const zoom = d3.zoom()
  .scaleExtent([0.5, 10])
  .on("zoom", (event) => {
    g.attr("transform", event.transform);
  });

svg.call(zoom);

Transitions

// Basic
circles.transition()
  .duration(750)
  .attr("r", 10);

// Staggered
circles.transition()
  .delay((d, i) => i * 50)
  .duration(500)
  .attr("cy", d => yScale(d.value));

Scales Reference

| Scale Type | Use Case | |------------|----------| | scaleLinear | 연속 수치 | | scaleLog | 지수 데이터 | | scaleTime | 시간/날짜 | | scaleBand | Bar chart 카테고리 | | scaleOrdinal | 색상 매핑 | | scaleSequential | 연속 색상 |

Color Schemes

// Categorical
d3.schemeCategory10  // 10 colors
d3.schemeTableau10   // Tableau 10

// Sequential
d3.interpolateBlues
d3.interpolateYlOrRd

// Diverging
d3.interpolateRdBu

Best Practices

  1. Data Validation: null/NaN 체크
  2. Responsive: ResizeObserver 사용
  3. Performance: 1000+ 요소 시 Canvas 고려
  4. Accessibility: ARIA labels 추가
  5. Clean Up: 이전 렌더링 제거

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/interactive-d3-js-visualization-ms47vopr/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/interactive-d3-js-visualization-ms47vopr' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/interactive-d3-js-visualization-ms47vopr/download' --output '.skill-downloads/interactive-d3-js-visualization-ms47vopr/SKILL.md.part' && mv '.skill-downloads/interactive-d3-js-visualization-ms47vopr/SKILL.md.part' '.skill-downloads/interactive-d3-js-visualization-ms47vopr/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

Tools declared by the author (check availability in your agent): Read, Glob, Grep, Edit, Write

Original excerpt: Setup
// npm
import * as d3 from 'd3';

// CDN
<script src="https://d3js.org/d3.v7.min.js"></script>

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/interactive-d3-js-visualization-ms47vopr/SKILL.md' && test -s '.skill-downloads/interactive-d3-js-visualization-ms47vopr/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/d3-viz' && cp -R '.skill-downloads/interactive-d3-js-visualization-ms47vopr' '.claude/skills/d3-viz'

Cursor
test -f '.skill-downloads/interactive-d3-js-visualization-ms47vopr/SKILL.md' && test -s '.skill-downloads/interactive-d3-js-visualization-ms47vopr/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/d3-viz' && cp -R '.skill-downloads/interactive-d3-js-visualization-ms47vopr' '.cursor/skills/d3-viz'

Codex
test -f '.skill-downloads/interactive-d3-js-visualization-ms47vopr/SKILL.md' && test -s '.skill-downloads/interactive-d3-js-visualization-ms47vopr/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/d3-viz' && cp -R '.skill-downloads/interactive-d3-js-visualization-ms47vopr' '.agents/skills/d3-viz'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/interactive-d3-js-visualization-ms47vopr'

openskills read 'interactive-d3-js-visualization-ms47vopr'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/interactive-d3-js-visualization-ms47vopr/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills