From the course: D3.js Essential Training
Unlock this course with a free trial
Join today to access over 25,600 courses taught by industry experts.
Dealing with NaNs using defined() - D3.js Tutorial
From the course: D3.js Essential Training
Dealing with NaNs using defined()
- [Instructor] Have you ever had a single dodgy data point throw out all your code? One misformatted date, for example, or one null in thousands of numbers? It's frustrating, isn't it? Well, in this video, we're going to see how we can handle it gracefully in D3. So first of all, we have to break our data and we're going to put in a null and a string null just for fun, and refresh, and you see that we are not left with what we would hope to have. We don't have meaningful area charts representing our data. Without using defined, D3 tries to plot every point, even the broken ones, which can crush your chart or worse, make your output quite misleading. But it offers us a way round and we use it on the generator. So, this could be a d3.area generator or a line generator, and we say .defined like so. And within it, we pass the data and we say it counts as defined data if it is not throwing us a not a number error. You can write other things in here, it doesn't have to be this statement…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Introducing path11m 37s
-
(Locked)
Using line and area generators6m 23s
-
(Locked)
Using group elements to organize your elements9m 16s
-
(Locked)
Dealing with NaNs using defined()2m 29s
-
(Locked)
Challenge: Line chart with missing data1m 28s
-
(Locked)
Solution: Line chart with missing data4m 41s
-
(Locked)
-
-
-
-
-
-