D3.js
저수준 코드Low-level code스케일, 도형, 레이아웃 같은 기본 요소를 조합해 맞춤형 데이터 기반 웹 시각화를 만드는 기초 JavaScript 툴킷입니다.The foundational JavaScript toolkit for building custom, data-driven web visualizations from scales, shapes and layouts.
현재 버전Current version: 7.9.0, 정보 확인일 2026-10-24facts checked 2026-10-24
개요Overview
D3.js(Data-Driven Documents)는 웹 시각화에서 가장 영향력 있는 라이브러리 가운데 하나입니다. 스탠퍼드 대학교에서 마이크 보스톡(Mike Bostock), 바딤 오기에베츠키(Vadim Ogievetsky), 제프리 히어(Jeffrey Heer)가 발표한 연구에서 출발했습니다. D3는 완성된 차트를 내주지 않고 스케일, 축, 도형 생성기, 레이아웃, 지도 투영법, 포스 시뮬레이션, 계층 구조 같은 원시 요소를 제공합니다. 학습자는 이 요소들을 조합해 원하는 시각화를 직접 조립합니다.
D3.js (Data-Driven Documents) is one of the most influential libraries for web visualization. It grew out of research published at Stanford by Mike Bostock, Vadim Ogievetsky and Jeffrey Heer. D3 does not hand you finished charts. It provides primitives such as scales, axes, shape generators, layouts, map projections, force simulations and hierarchies, and you assemble the visualization you want from them.
"막대 차트" 함수는 D3에 없습니다. 요소를 선택하고, 데이터를 바인딩하고, 스케일로 위치를 계산해 사각형과 축을 그립니다. 이 방식 덕분에 D3로 만들 수 없는 2D 시각화는 사실상 없고, 데이터 저널리즘과 맞춤형 인터랙티브 그래픽에서 오랫동안 표준 도구로 쓰여 왔습니다. 대가로 코드 양과 학습 부담이 큽니다.
D3 has no "bar chart" function. You select elements, bind data, compute positions with scales, and draw the rectangles and axes yourself. That approach leaves almost no 2D visualization out of reach, which is why D3 has long been a standard tool in data journalism and bespoke interactive graphics. The price is more code and a steeper learning curve.
D3의 현재 버전은 7.9.0(2024년 3월)이며, 이후 새 릴리스는 없습니다. 모듈로 나뉘어 있어 d3-scale, d3-shape, d3-geo, d3-hierarchy, d3-force 등 필요한 부분만 가져올 수 있습니다. 표준 차트가 목적이라면 D3 위에서 동작하는 Observable Plot이 훨씬 짧은 코드로 같은 결과를 냅니다.
The current version is 7.9.0 (March 2024), and there has been no newer release since. The library is split into modules such as d3-scale, d3-shape, d3-geo, d3-hierarchy and d3-force, so you can import only what you need. For standard charts, Observable Plot, which is built on D3, reaches the same result with far less code.
2026년 현재What's new in 2026
- D3 7.9.0이 npm의 최신 버전입니다. 2024년 3월에 나왔고 2026년 10월 현재 7.x가 현행 메이저 버전입니다.
- D3 7.9.0 is the latest version on npm. It was released in March 2024, and 7.x is still the current major version as of October 2026.
- 7.9.0은 10색 범주형 색 구성표 schemeObservable10을 추가했습니다.
- Version 7.9.0 added the schemeObservable10 color scheme, a 10-color categorical palette.
- 새 기능보다 안정성이 중심인 라이브러리입니다. 예제 코드가 수년 전 것이어도 대부분 그대로 동작합니다.
- The library favors stability over new features, so example code written years ago mostly still runs unchanged.
- D3 자체에 AI 기능은 없습니다. 다만 AI 어시스턴트가 맞춤 차트를 만들 때 D3 코드를 출력하는 경우가 많아서, 처음부터 쓰기보다 AI가 쓴 D3 코드를 읽고 고치는 일이 늘었습니다.
- D3 itself has no AI features. AI assistants often output D3 code when asked for a custom chart, so reading and editing AI-written D3 has become as common as writing it from scratch.
강점Strengths
- 만들 수 있는 시각화에 한계가 없습니다. 어떤 2D 그래픽이든 가능합니다.
- No ceiling on what you can create: any 2D graphic is possible.
- 모든 요소와 인터랙션을 세밀하게 제어합니다.
- Fine-grained control over every element and interaction.
- 데이터 변경에 맞춰 부드럽게 바뀌는 전환과 애니메이션 기능이 있습니다.
- Transitions and animation let a chart update smoothly when the data changes.
- d3-geo는 다양한 지도 투영법을 제공합니다.
- d3-geo supports a wide range of map projections.
- 포스 레이아웃, 트리맵, 선버스트, 원 패킹, 덴드로그램 같은 레이아웃을 내장합니다.
- Built-in layouts include force-directed graphs, treemaps, sunbursts, circle packing and dendrograms.
- 모듈형 구조라서 필요한 부분만 번들에 넣을 수 있습니다.
- A modular design lets you bundle only the parts you use.
- SVG, Canvas, WebGL 어느 쪽에서도 쓸 수 있습니다. 데이터가 많으면 Canvas로 그릴 수 있습니다.
- Works with SVG, Canvas or WebGL, and you can draw to Canvas when the data is large.
- 예제와 자료가 매우 풍부해서 AI 어시스턴트에게 D3 코드를 요청하기 쉽습니다. 결과는 직접 실행해 확인해야 합니다.
- Examples and documentation are abundant, so it is easy to ask an AI assistant for D3 code. Run the result yourself to check it.
한계Limitations
- 학습 곡선이 가파릅니다. JavaScript, DOM, SVG에 대한 기초가 필요합니다.
- Steep learning curve: it requires a solid grounding in JavaScript, the DOM and SVG.
- 코드가 장황합니다. 단순한 막대 차트에도 수십 줄이 필요합니다.
- Verbose: even a simple bar chart takes dozens of lines.
- 완성된 차트 유형이 없어서 모든 것을 원시 요소로 조립해야 합니다.
- There are no ready-made chart types, so everything is assembled from primitives.
- 범례, 툴팁, 주석 같은 도우미가 없습니다.
- No built-in legend, tooltip or annotation helpers.
- 반응형 처리가 수동입니다. 크기 변화에 맞춰 직접 다시 그려야 합니다.
- Responsive behavior is manual: you handle resizing and redrawing yourself.
- React, Vue, Svelte와 함께 쓸 때는 누가 DOM을 소유하는지 신중히 정해야 합니다.
- With React, Vue or Svelte you must decide carefully who owns the DOM.
- 접근성(스크린 리더, 키보드 탐색)을 직접 구현해야 합니다.
- Accessibility (screen readers, keyboard navigation) must be built by hand.
이런 용도에 최적Best For
기존 라이브러리로는 만들 수 없는 시각화가 필요할 때 D3가 맞습니다. 데이터 저널리즘의 맞춤 그래픽, 새로운 차트 유형, 모든 시각 요소를 픽셀 단위로 통제해야 하는 작업에 적합합니다. 코드를 직접 작성하고 유지할 수 있는 개발자나 시각화 전공자가 주 사용자입니다.
D3 is the right tool when no existing library can produce the visualization you need. It suits custom graphics for data journalism, new chart types, and work that needs pixel-level control over every visual element. Its main users are developers and visualization specialists who can write and maintain the code.
표준 막대, 선, 산점도 차트라면 Observable Plot이나 ECharts, Vega-Lite가 더 빠릅니다. 학습 목적이라면 D3의 스케일, 셀렉션, 데이터 조인 개념을 익혀 두면 다른 시각화 도구를 이해하는 데도 도움이 됩니다.
For standard bar, line and scatter charts, Observable Plot, ECharts or Vega-Lite are faster. As a learning goal, the D3 concepts of scales, selections and data joins also help you understand other visualization tools.
시작하기Getting Started
- 프로젝트에 D3를 설치하거나(
npm install d3) HTML에서 CDN으로 불러옵니다. - Install D3 in your project (
npm install d3) or load it from a CDN in your HTML. - 차트를 그릴
div를 HTML에 만듭니다. - Add a
divto your HTML for the chart. - 아래 코드를 모듈 스크립트로 실행합니다. 번들러를 쓰지 않는다면
d3@7을 ES 모듈로 불러옵니다. - Run the code below as a module script. Without a bundler, import
d3@7as an ES module. - 스케일, 축, 도형의 역할을 하나씩 바꿔 가며 결과를 확인합니다. AI 어시스턴트에게 이미 작성된 코드를 설명해 달라고 요청하는 것도 좋은 학습 방법입니다.
- Change the role of the scale, axes and shapes one at a time and watch the result. Asking an AI assistant to explain finished code line by line is also a good way to learn.
<div id="chart"></div>
<script type="module">
import * as d3 from "https://cdn.jsdelivr.net/npm/d3@7/+esm";
const data = [
{ name: "A", value: 30 },
{ name: "B", value: 80 },
{ name: "C", value: 45 },
{ name: "D", value: 60 }
];
const width = 600, height = 400;
const margin = { top: 20, right: 20, bottom: 30, left: 40 };
const svg = d3.select("#chart")
.append("svg")
.attr("viewBox", [0, 0, width, height])
.attr("width", width)
.attr("height", height);
const x = d3.scaleBand()
.domain(data.map(d => d.name))
.range([margin.left, width - margin.right])
.padding(0.2);
const y = d3.scaleLinear()
.domain([0, d3.max(data, d => d.value)])
.nice()
.range([height - margin.bottom, margin.top]);
svg.append("g")
.selectAll("rect")
.data(data)
.join("rect")
.attr("x", d => x(d.name))
.attr("y", d => y(d.value))
.attr("width", x.bandwidth())
.attr("height", d => y(0) - y(d.value))
.attr("fill", "steelblue");
svg.append("g")
.attr("transform", `translate(0,${height - margin.bottom})`)
.call(d3.axisBottom(x));
svg.append("g")
.attr("transform", `translate(${margin.left},0)`)
.call(d3.axisLeft(y));
</script>
지원 차트 유형Supported Chart Types
D3는 거의 모든 2D 시각화를 만들 수 있습니다. 도형 생성기와 레이아웃이 직접 지원하는 유형은 막대, 누적 막대, 선, 영역, 파이, 도넛, 산점도, 버블, 히스토그램, 히트맵, 트리맵, 선버스트, 원 패킹, 덴드로그램, 코드 다이어그램, 포스 기반 네트워크 다이어그램, 코로플레스 지도, 헥스빈, 등고선, 박스 플롯, 바이올린 플롯, 평행 좌표, 레이더 차트입니다.
D3 can build almost any 2D visualization. The types its shape generators and layouts support directly are bar, stacked bar, line, area, pie, donut, scatterplot, bubble, histogram, heatmap, treemap, sunburst, circle packing, dendrogram, chord diagram, force-directed network diagram, choropleth map, hexbin, contour, box plot, violin plot, parallel coordinates and radar charts.
샌키 다이어그램은 d3-sankey, 워드 클라우드는 d3-cloud 같은 별도 플러그인을 함께 씁니다. 목록에 없는 차트도 기본 요소로 새로 만들 수 있다는 점이 D3의 가장 큰 특징입니다.
Sankey diagrams use the separate d3-sankey plugin and word clouds use d3-cloud. A chart that is not on the list can still be built from the primitives, which is the defining feature of D3.