CHANGES.md 8.35 KB
Newer Older
Mike Bostock's avatar
Mike Bostock committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# Changes In D3 4.0

N.B.: This document is a work-in-progress. It does not yet cover all API changes.

## Modularity

D3 3.x was a monolithic library: the core functionality resided in a single [repository](https://github.com/d3/d3) and was published in a single file, [d3.v3.js](https://d3js.org/d3.v3.js). It was possible to create a custom build using a nonstandard tool ([SMASH](https://github.com/mbostock/smash)), but not easy. (There were also [plugins](https://github.com/d3/d3-plugins), but these could only add features and had their own monolithic repository.)

D3 4.0 is modular. Instead of one library, D3 now consists of many [small libraries](https://github.com/d3) that are designed to work together, but don’t have to; you can pick and choose which parts to use as you see fit. Each library is maintained in a separate repository, allowing decentralized ownership and independent release cycles.

The default bundle of D3, [d3.v4.js](https://d3js.org/d3.v4.0.0-alpha.45.js), aggregates about thirty of these small libraries. However, you don’t have to use the default bundle; it is merely provided for convenience. You can load D3 modules separately using vanilla script tags or RequireJS (great for HTTP/2!); you can `cat` them into a custom bundle; you can use an advanced bundler such as Webpack or Rollup to create optimized custom bundles. I recommend Rollup: the D3 microlibraries are written as [ES6 modules](http://www.2ality.com/2014/09/es6-modules-final.html), and Rollup lets you pick at the *symbol* level to produce the smallest bundles! Custom bundles are especially useful for charting libraries that use only a subset of D3’s features; for example, a React charting library might use D3’s scales and shapes, but use React for DOM manipulation instead of selections.

But modularity is less about optimizing custom bundles, and more about making D3 *fun* again. Small, standalone modules are easier to understand and test, and make it easier for new people to get involved and contribute. I want to reduce the distinction between a “core module” and a “plugin”, and increase the pace of development in D3 features.

If you don’t care about modularity, you can mostly ignore this change and continue to use the default bundle. However, there’s an unavoidable consequence: every symbol in D3 4.0 now shares a flat namespace rather than the somewhat haphazard grouping employed in D3 3.x. For example, d3.scale.linear is now d3.scaleLinear, and d3.layout.treemap is now just d3.treemap. There have also been significant changes (hopefully improvements!) to D3’s functionality. So rather than list all of the renamed symbols, I’ll cover the changes in the corresponding section below.

## d3-timer

* d3.timer.flush -> d3.timerFlush

## d3-random

* d3.random.normal -> d3.randomNormal
* d3.random.logNormal -> d3.randomLogNormal
* d3.random.bates -> d3.randomBates
* d3.random.irwinHall -> d3.randomIrwinHall

## d3-dsv

* d3.csv.parse -> d3.csvParse
* d3.csv.parseRows -> d3.csvParseRows
* d3.csv.format -> d3.csvFormat
* d3.csv.formatRows -> d3.csvFormatRows
* d3.tsv.parse -> d3.tsvParse
* d3.tsv.parseRows -> d3.tsvParseRows
* d3.tsv.format -> d3.tsvFormat
* d3.tsv.formatRows -> d3.tsvFormatRows

## d3-scale

* d3.scale.linear -> d3.scaleLinear
* d3.scale.sqrt -> d3.scaleSqrt
* d3.scale.pow -> d3.scalePow
* d3.scale.log -> d3.scaleLog
* d3.scale.quantize -> d3.scaleQuantize
* d3.scale.threshold -> d3.scaleThreshold
* d3.scale.quantile -> d3.scaleQuantile
* d3.scale.identity -> d3.scaleIdentity
* d3.scale.ordinal -> d3.scaleOrdinal
* d3.scale.category10 -> d3.schemeCategory10
* d3.scale.category20 -> d3.schemeCategory20
* d3.scale.category20b -> d3.schemeCategory20b
* d3.scale.category20c -> d3.schemeCategory20c
* d3.time.scale -> d3.scaleTime

## d3-shape

* d3.svg.line -> d3.line
* d3.svg.line.radial -> d3.radialLine
* d3.svg.area -> d3.area
* d3.svg.area.radial -> d3.radialArea
* d3.svg.arc -> d3.arc
* d3.svg.symbol -> d3.symbol
* d3.svg.symbolTypes -> d3.symbolTypes
* d3.svg.diagonal -> REMOVED
* d3.svg.diagonal.radial -> REMOVED
* d3.layout.bundle -> d3.curveBundle
* d3.layout.stack -> d3.stack

## d3-axis

* d3.svg.axis -> d3.axisTop, d3.axisRight, d3.axisBottom, d3.axisLeft

## d3-brush

* d3.svg.brush -> d3.brush

## d3-time-format

* d3.time.format -> d3.timeFormat
* d3.time.format.multi -> REMOVED
* d3.time.format.utc -> d3.utcFormat
* d3.time.format.iso -> d3.isoFormat

## d3-time

* d3.time.interval -> d3.timeInterval
* d3.time.day -> d3.timeDay
* d3.time.days -> d3.timeDays
* d3.time.dayOfYear -> d3.timeDay.count
* d3.time.hour -> d3.timeHour
* d3.time.hours -> d3.timeHours
* d3.time.minute -> d3.timeMinute
* d3.time.minutes -> d3.timeMinutes
* d3.time.month -> d3.timeMonth
* d3.time.months -> d3.timeMonths
* d3.time.second -> d3.timeSecond
* d3.time.seconds -> d3.timeSeconds
* d3.time.sunday -> d3.timeSunday
* d3.time.sundays -> d3.timeSundays
* d3.time.sundayOfYear -> d3.timeSunday.count
* d3.time.monday -> d3.timeMonday
* d3.time.mondays -> d3.timeMondays
* d3.time.mondayOfYear -> d3.timeMonday.count
* d3.time.tuesday -> d3.timeTuesday
* d3.time.tuesdays -> d3.timeTuesdays
* d3.time.tuesdayOfYear -> d3.timeTuesday.count
* d3.time.wednesday -> d3.timeWednesday
* d3.time.wednesdays -> d3.timeWednesdays
* d3.time.wednesdayOfYear -> d3.timeWednesday.count
* d3.time.thursday -> d3.timeThursday
* d3.time.thursdays -> d3.timeThursdays
* d3.time.thursdayOfYear -> d3.timeThursday.count
* d3.time.friday -> d3.timeFriday
* d3.time.fridays -> d3.timeFridays
* d3.time.fridayOfYear -> d3.timeFriday.count
* d3.time.saturday -> d3.timeSaturday
* d3.time.saturdays -> d3.timeSaturdays
* d3.time.saturdayOfYear -> d3.timeSaturday.count
* d3.time.week -> d3.timeWeek
* d3.time.weeks -> d3.timeWeeks
* d3.time.weekOfYear -> d3.timeWeek.count
* d3.time.year -> d3.timeYear
* d3.time.years -> d3.timeYears
* d3.time.day.utc -> d3.utcDay
* d3.time.days.utc -> d3.utcDays
* d3.time.dayOfYear.utc -> d3.utcDay.count
* d3.time.hour.utc -> d3.utcHour
* d3.time.hours.utc -> d3.utcHours
* d3.time.minute.utc -> d3.utcMinute
* d3.time.minutes.utc -> d3.utcMinutes
* d3.time.month.utc -> d3.utcMonth
* d3.time.months.utc -> d3.utcMonths
* d3.time.second.utc -> d3.utcSecond
* d3.time.seconds.utc -> d3.utcSeconds
* d3.time.sunday.utc -> d3.utcSunday
* d3.time.sundays.utc -> d3.utcSundays
* d3.time.sundayOfYear.utc -> d3.utcSunday.count
* d3.time.monday.utc -> d3.utcMonday
* d3.time.mondays.utc -> d3.utcMondays
* d3.time.mondayOfYear.utc -> d3.utcMonday.count
* d3.time.tuesday.utc -> d3.utcTuesday
* d3.time.tuesdays.utc -> d3.utcTuesdays
* d3.time.tuesdayOfYear.utc -> d3.utcTuesday.count
* d3.time.wednesday.utc -> d3.utcWednesday
* d3.time.wednesdays.utc -> d3.utcWednesdays
* d3.time.wednesdayOfYear.utc -> d3.utcWednesday.count
* d3.time.thursday.utc -> d3.utcThursday
* d3.time.thursdays.utc -> d3.utcThursdays
* d3.time.thursdayOfYear.utc -> d3.utcThursday.count
* d3.time.friday.utc -> d3.utcFriday
* d3.time.fridays.utc -> d3.utcFridays
* d3.time.fridayOfYear.utc -> d3.utcFriday.count
* d3.time.saturday.utc -> d3.utcSaturday
* d3.time.saturdays.utc -> d3.utcSaturdays
* d3.time.saturdayOfYear.utc -> d3.utcSaturday.count
* d3.time.week.utc -> d3.utcWeek
* d3.time.weeks.utc -> d3.utcWeeks
* d3.time.weekOfYear.utc -> d3.utcWeek.count
* d3.time.year.utc -> d3.utcYear
* d3.time.years.utc -> d3.utcYears

## d3-chord

* d3.svg.chord -> d3.ribbon (TODO)
* d3.layout.chord -> d3.chord (TODO)

## d3-hierarchy

* d3.layout.cluster -> d3.cluster
* d3.layout.hierarchy -> d3.hierarchy
* d3.layout.pack -> d3.pack
* d3.layout.partition -> d3.partition
* d3.layout.tree -> d3.tree
* d3.layout.treemap -> d3.treemap

## d3-force

* d3.layout.force -> d3.forceSimulation

## d3-array

* d3.layout.histogram -> d3.histogram

## d3-geo

* d3.geo.graticule -> d3.geoGraticule
* d3.geo.circle -> d3.geoCircle
* d3.geo.area -> d3.geoArea
* d3.geo.bounds -> d3.geoBounds
* d3.geo.centroid -> d3.geoCentroid
* d3.geo.distance -> d3.geoDistance
* d3.geo.interpolate -> d3.geoInterpolate
* d3.geo.length -> d3.geoLength
* d3.geo.rotation -> d3.geoRotation
* d3.geo.stream -> d3.geoStream

## d3-voronoi

* d3.geom.voronoi -> d3.voronoi

## d3-quadtree

* d3.geom.quadtree -> d3.quadtree

## d3-polygon

* d3.geom.polygon.area -> d3.polygonArea
* d3.geom.polygon.centroid -> d3.polygonCentroid
* d3.geom.hull -> d3.polygonHull

## d3-drag

* d3.behavior.drag -> d3.drag

## d3-zoom

* d3.behavior.zoom -> d3.zoom

## d3-geo-projection

* d3.geo.path -> d3.geoPath