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

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.

主站蜘蛛池模板: 阿坝县| 云梦县| 广水市| 宁晋县| 林芝县| 平昌县| 潍坊市| 临西县| 济宁市| 濮阳县| 滦平县| 宣汉县| 凤城市| 武平县| 聂拉木县| 枞阳县| 拜城县| 太湖县| 巫溪县| 保定市| 嘉义县| 疏勒县| 于田县| 西安市| 朔州市| 齐齐哈尔市| 封开县| 米易县| 龙井市| 义乌市| 遂川县| 宝鸡市| 余庆县| 桂东县| 西林县| 阳江市| 涞水县| 南江县| 庆元县| 金昌市| 卫辉市|