
D3.js 5.0 is out - tolien
https://github.com/d3/d3/blob/master/CHANGES.md#changes-in-d3-50
======
omarforgotpwd
Wow, didn't even know about the Fetch API. XMLHTTPRequest, the API that
changed software forever by igniting a wave of more powerful browser
applications, is finally going to be replaced. Funny that the last 20 years of
the web were all built on this ridiculous API that Microsoft came up with to
try and make Outlook work in a browser. Good riddance, but you will be missed.
Not that any of us has used that disgusting API directly in the last 10 years.

~~~
realandreskytt
We used to do that stuff using frames back in the day. You’d have a hidden
frame, change its url and look at what that dom contains. At scale, too. I was
amazed at all the hoo-haa around that “new” xmlhttp API

~~~
dustinmoorenet
We did the same thing, and to dynamically pull in content into the parent
context, we created our own script block tag. <div type="javascript">...</div>
so that we could extract the JS and eval it in the parent context. The clunky
thing was that you had to hand escape reserved html characters (&, <, etc) in
your JS code. So many bugs...

------
jake-low
Shout out to Philippe Rivière for the awesome work on d3-geo-polygon[1]
(mentioned in the release notes), which enables tons of new map projections
like these[2].

Philippe, if you're reading this, thank you. I'm really excited about d3-geo-
polygon and I know a lot of others in the community are too.

[1]: [https://github.com/d3/d3-geo-polygon](https://github.com/d3/d3-geo-
polygon)

[2]: [https://beta.observablehq.com/@fil/polyhedral-projections-
wi...](https://beta.observablehq.com/@fil/polyhedral-projections-with-d3-geo-
polygon)

~~~
aeriklawson
What are the use cases for this functionality? Genuinely curious.

~~~
jake-low
Unusual map projections like these are often curiosities, but the can also be
useful for certain topics, like mapping migrations[1][2][3] or showing airline
routes[4][5].

[1]: [https://commons.wikimedia.org/wiki/File:Map-of-human-
migrati...](https://commons.wikimedia.org/wiki/File:Map-of-human-
migrations.jpg)

[2]:
[https://nordpil.com/static/images/redknot_migration.png](https://nordpil.com/static/images/redknot_migration.png)

[3]:
[http://ngm.nationalgeographic.com/ngm/0603/feature2/map.html](http://ngm.nationalgeographic.com/ngm/0603/feature2/map.html)

[4]: [https://imgur.com/5TFPcDa](https://imgur.com/5TFPcDa)

[5]: [https://imgur.com/6X91323](https://imgur.com/6X91323)

Additionally, this project is a generalization of a feature that already
existed in D3 (clipping spherical polygons to map boundaries -- previously you
could only do this if the boundary in question was the antimeridian or a small
circle centered at the origin). That generalization will make it easier to use
some more common map projections that were already supported in d3-geo-
projection[5] like as Goode's interrupted homolosine and Mollweide
projections. These are useful projections for showing things like population
density[6] where you care about preventing distortion in the landmasses but
don't care about the oceans. While these projections were possible before,
they required the use of SVG clip-paths and other tricks to prevent drawing
outside the map bounds. In theory they could now be simplified using the
polygon clipping implemented in d3-geo-polygon.

[5]: [https://github.com/d3/d3-geo-projection](https://github.com/d3/d3-geo-
projection)

[6]: [http://www.jakelow.com/essays/mapping-the-world-
population](http://www.jakelow.com/essays/mapping-the-world-population)

~~~
aeriklawson
Awesome. Thanks for the informative reply!

------
drej
The sad state of affairs is that while D3 is brilliant in terms of API design,
it is fairly low level, so few people use it directly. I've been using tools
based on D3.js (like C3, NVD3) and it's been a joy.

However, last time I checked (~mid 2017), most of these hadn't migrated to D3
v4, so I'm not sure how fast v5 adoption will be. Maybe some will skip v4
altogether and go directly to v5?

At this point, I'm not sure which wrapper to use, because I don't want to get
stuck with v3.

~~~
ehayes
I've been using Billboard.js as a drop-in replacement for C3. It's a fork made
specifically to work on D3 v4+.

[https://naver.github.io/billboard.js/](https://naver.github.io/billboard.js/)

~~~
drej
Amazing, thanks. C3.js has been a real pleasure to use, so I'm glad this fork
exists. Cheers.

------
yiransheng
Finally, `d3.create`[1] - it has been a minor pain pointer in d3 to create a
detached selection for quite some time :)

[1]
[https://github.com/d3/d3-selection/blob/master/README.md#cre...](https://github.com/d3/d3-selection/blob/master/README.md#create)

------
pwthornton
I'm looking to get my team into using D3 more as we begin to do more graphing
and data visualization. Do any of you have recommendations on tutorials,
classes and other learning aids?

------
mcochrane
Promises instead of archaic callbacks. That's a feature I'm excited about!

~~~
jordache
promise is callback. When used in the context of the simple data loading
scenario typical of D3, there is no difference.

~~~
always_good
Promises compose, bubble errors, lift sync errors, can be awaited, have
combinators like Promise.all(), they're where the ecosystem headed, and more.

Thinking that promises are callbacks because .then() takes a function suggests
misunderstanding.

------
kamac
That seems like a small update compared to v4. Wouldn't it be better to brand
it as a minor version and provide backwards compatibility with deprecation
warning where Promises were added?

~~~
travellingprog
Regularly occurring major versions, with only a small amount of changes, has
actually kind of become seen as best practice in the JavaScript community.
React, Node, Angular and a ton of other popular tools now release a major
version update every year or 6 months. The reasoning is that by taking small,
backward-incompatible steps, then developers are more likely to make the
effort to install the latest update.

To understand the problems the community is trying to avoid, one only needs to
go back to 2015-2016, when Angular 2 was released. At the time, AngularJS (aka
Angular 1) was extremely hot; it had in record time become THE framework for
any front-end developer to learn, and it looked set to dominate the landscape
for years. And then, Angular 2 came out and it had a TON of changes. The
learning curve of some elements of Angular 2 was very high for the average
developer (TypeScript, reactive programming). And worst of all, the "migration
path" from AngularJS to Angular 2 essentially amounted to a rewrite of your
front-end application. Most never bothered updating their app, and most devs
moved away from Angular, especially when React was released. All of that
AngularJS experience that we accumulated became "outdated" in the span of
about a year.

~~~
stupidcar
Sorry, but this is a rewriting of history and the present facts, and I can't
let it go unchallenged.

React was first released in 2013, whereas Angular (2) was first released in
2016. React was already a very popular and rapidly growing framework by that
point, so the idea that people adopted it simply because of Angular 2 is
clearly false.

And while the migration process from Angular 1 to 2 was painful, it's simply
untrue to say that nobody bothered, or that every AngularJS developer moved
away. If you look at a source like
[https://hotframeworks.com/](https://hotframeworks.com/), which sources
framework popularity data from GitHub and Stack Overflow, you can see that
Angular has achieved a significant amount of adoption, and there are plenty of
examples of people migrating successfully from 1 to 2+.

~~~
cbaleanu
Sorry but your facts are just wrong. Angular2 was announced in late 2014, just
about the time when angular 1 was becoming mainstream used by big banks and
the like. Look at Microsoft's blog from early 2015 announcing the use of
typescript in Angular2. Linking some generic website does not make your
comment less toxic and I would strongly suggest you get your facts right
before posting stuff like that here.

------
johnhenry
> D3 now uses Promises

Thank the lord!

~~~
runarberg
Its funny, when I landed my first job as a software developer, in a
statistical startup, I learned about promises using d3.queue[1]. This was
before javascript had native promises, and around the javascript community was
settling on A+ promises. But d3 was how I learned to write asynchronous code
without relying solely on callbacks.

[1]: [https://github.com/d3/d3-queue](https://github.com/d3/d3-queue)

~~~
Cthulhu_
Likewise, but in jQuery, which in one version introduced a feature where you
could add listeners to an ajax request and it'd get called after the response
returned - I was like what? how? whoa!?

------
cuchoi
Any good introductory tutorials for D3.js?

~~~
et-al
Mike Bostock (creator of D3) has a bunch of great code examples on
bl.ocks.org.

I would start with his General Update Pattern (the link below goes through
1-3), which is key to understanding D3 as binding data to SVG elements (hence
the name Data-Driven Documents) and animating any transitions.

General Update Pattern:
[https://bl.ocks.org/mbostock/3808218](https://bl.ocks.org/mbostock/3808218)

Also the documentation is great, so check out the intro here:

[https://d3js.org/#introduction](https://d3js.org/#introduction)

btw, if you're using D3 purely for charting, expect a lot of work to get
something that looks decent. There charting libraries that have taken care of
the styling and add functions on top of D3 to make your life easier.

~~~
newbear
Are there d3 only jobs? Aside from NYTimes, who is using d3? Thanks

~~~
asanwal
We do at CB Insights (and we are hiring)

~~~
davidjankoski
open for applications from europe as well?

------
tunesmith
Is the best way to accomplish sugiyama still to use dagre-d3?

~~~
chrisweekly
sugiyama?

~~~
expiredtofu
See [1], looks like a method for drawing digraphs.

[1][https://github.com/d3/d3/issues/349](https://github.com/d3/d3/issues/349)

------
stareatgoats
Looks cool - would love to implement some things using D3! Would be
interesting to know how people plan to handle browser incompatibility, or is
it even a concern when approaching ~90% of browser usage support? [0] (for
fetch, promises but mainly async/await in this case, if I understand it
correctly)

[0] [https://caniuse.com/#feat=async-
functions](https://caniuse.com/#feat=async-functions)

~~~
codenberg
You'll have to manually include polyfills for both Promise and Fetch to
support things like IE 11 or iOS 10.2.

------
jackweirdy
Streaming responses is very cool

------
jlukic
Incredible work, by an incredible programmer.

------
ktpsns
I love d3js, but I had the feeling it never got so widespread as jQuery.
Similarly, from my feeling, it never had such a revolutionary impact. Maybe I
am wrong because the data-driven approach (ie. data binding) inspired a whole
generation of frameworks. But is there a showcase of famours sites using d3js
for anything beyond visualizations (say in a similar manner how jQuery is used
across all web page client logic)?

~~~
Vinnl
The entire purpose of D3 is to be used for visualisations, so no, it's not
really used for anything like that and doesn't have as wide a scope as jQuery.

