Skip to Main Content
Data Visualization with D3 and AngularJS
book

Data Visualization with D3 and AngularJS

by Christoph Körner
April 2015
Intermediate to advanced content levelIntermediate to advanced
278 pages
5h 38m
English
Packt Publishing
Content preview from Data Visualization with D3 and AngularJS

Interactive filters

Let's switch back to AngularJS for a section. To be precise, let's take a look at filters. Let's implement two filters that compare Date objects and returns the elements of an array that are greater than or equal to a specific date (gte_date) and less than or equal to a specific date (lte_d). First, we need to add a filter via the .filter(name, filter_func) function to the AngularJS chart component. The filter_func argument needs to return a function in the shape of function(arg1, arg2, …), where arg1 is usually the input array that finally returns the filtered array. Okay, let's implement this:

/* src/chart.js */ .filter('gte_date', function(){ return function(input, raw_date){ var date = new Date(raw_date); return isNaN(date.getTime()) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

D3.js: Cutting-edge Data Visualization

D3.js: Cutting-edge Data Visualization

Ændrew H. Rininsland, Michael Heydt, Pablo Navarro Castillo
D3.js 4.x Data Visualization - Third Edition

D3.js 4.x Data Visualization - Third Edition

Aendrew Rininsland, Swizec Teller
Intermediate D3.js

Intermediate D3.js

Scott Murray

Publisher Resources

ISBN: 9781784398484Supplemental Content