官术网_书友最值得收藏!

What's new in D3 v4?

One of the key changes to D3 since the last edition of this book is the release of version 4.

Among its many changes, the most significant one is a complete overhaul of the D3 namespace. This means that none of the examples in this book will work with D3 3.x, and the examples from Learning D3.js Data Visualization, Second Edition will not work with D3 4.x. This is quite possibly the cruelest thing Mr. Bostock could ever do to educational authors such as myself (I am joking here!). Kidding aside, it also means many of the block examples in the D3 community are out of date and may appear rather odd if this book is your first encounter with the library. For this reason, it is very important to note the version of D3 an example uses -- if it uses 3.x, it might be worth searching for a 4.x example just to prevent this cognitive dissonance.

You can usually find the version of D3 in an example block online by looking at the script tags near the top of the code. If it resembles: 
<script src="https://d3js.org/d3.v3.min.js"></script>
...You're looking at a D3 v3 example. If it says:
<script src="https://d3js.org/d3.v4.min.js"></script>
...You're looking at a modern, v4 example and are good to go.

Related to this is how D3 has been broken up from a single library into many smaller libraries (or micro-libraries). There are two approaches you can take:

  • You can use D3 as a single library (a monolib) in much the same way as version 3
  • You can selectively use inpidual (microlib) components of D3 in your project

This book takes the former route. While learning D3, using micro-libraries takes a lot more effort, even if it helps reduce the size of the final bundle that people who view your graphics will have to download. That said, I will try to signpost which package a particular piece of functionality resides in; so, once you become more comfortable with D3, you can start using the microlibs instead of including everything and the kitchen sink.

主站蜘蛛池模板: 新巴尔虎左旗| 偃师市| 龙口市| 交口县| 衡水市| 宜君县| 玉溪市| 慈利县| 九龙县| 民县| 通许县| 乐东| 思茅市| 驻马店市| 陇川县| 延津县| 长海县| 宜兰县| 应城市| 淮南市| 上思县| 漳浦县| 深州市| 廉江市| 台东市| 阿图什市| 神农架林区| 盐城市| 广宁县| 长治县| 信阳市| 克什克腾旗| 西峡县| 婺源县| 麟游县| 岳池县| 衡山县| 灵川县| 瑞金市| 浮梁县| 宁夏|