From the course: D3.js Essential Training for Data Scientists
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Filtering data - D3.js Tutorial
From the course: D3.js Essential Training for Data Scientists
Filtering data
- [Narrator] There are times when you don't want to show an element for every data point you have. In this version three block, a data set's been used to generate a line and the same data set has been used to add some circles to the line. But only the most recent data points have been added as dots. In cases like this, d3.filter can be just what you need. So we're going to go back to our select.js example, closing data handlers, and opening Select there. We can refresh the page like so and we can comment out those logs to the console there. So we've got line 58. We'll delete that one and we can delete this one as well. Now the circles here are showing the numbers 1 to 18 from the array. We're going to use d3.filter to show circles only where the data point is above 10. So what we do is we find relevant block of code, which in this case is circles, and after the append statement we type .filter. Within the filter we have a function. So what the filter does is it goes through and checks…
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.